mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-06 02:36:49 +00:00
make external id nullable
This commit is contained in:
parent
18daf5d482
commit
1f55bf3556
3 changed files with 4 additions and 4 deletions
|
|
@ -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"`
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue