make external id nullable

This commit is contained in:
Ruidy 2024-07-14 23:02:06 +02:00
parent 18daf5d482
commit 1f55bf3556
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
3 changed files with 4 additions and 4 deletions

View file

@ -18,7 +18,7 @@ type Booking struct {
PhoneNumber string
Email string
Platform string
ExternalId string `gorm:"uniqueIndex:booking_external_id"`
ExternalId *string `gorm:"uniqueIndex:booking_external_id"`
Items []Item
Id int
CustomerNumber int `gorm:"column:customers"`

View file

@ -38,7 +38,7 @@ func (bs Service) All() []*Line {
}
func (bs Service) Create(From time.Time, To time.Time, Name string, PhoneNumber string, Email string, Platform string,
CustomerNumber int, PlatformFees float64, externalId string,
CustomerNumber int, PlatformFees float64, externalId *string,
) *Booking {
b := &Booking{
Name: Name,
@ -253,7 +253,7 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
standardRate := extractFloat(`Standard Rate\n\s+€ (\d+)`, content)
taxQty := (totalAmount - standardRate*float64(stayLength)) / 1.5
b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount, externalId)
b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount, &externalId)
bs.CreateItem(b.Id, item, stayLength, standardRate, "Card")
bs.CreateItem(b.Id, "Taxes", int(taxQty), 1.5, "Cash")

View file

@ -72,7 +72,7 @@ func handleCreateBooking(bs *booking.Service) echo.HandlerFunc {
ts, _ = myTime.ParseFromForm(c.FormValue("to"))
nb.To = ts
b := bs.Create(nb.From, nb.To, nb.Name, nb.PhoneNumber, nb.Email, nb.Platform, nb.CustomerNumber, nb.PlatformFees, "") // TODO: add field in the form
b := bs.Create(nb.From, nb.To, nb.Name, nb.PhoneNumber, nb.Email, nb.Platform, nb.CustomerNumber, nb.PlatformFees, nil) // TODO: add field in the form
return c.Redirect(http.StatusSeeOther, fmt.Sprintf("%s/%d", constant.RouteBooking, b.Id))
}
}