use the price from the form

This commit is contained in:
Ruidy 2024-08-26 21:28:40 +02:00
parent 0a0e819133
commit 6451bd5926
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
2 changed files with 6 additions and 4 deletions

View file

@ -97,16 +97,17 @@ func (bs Service) Update(id int, From time.Time, To time.Time, Name string, Phon
return b
}
func (bs Service) CreateItem(bookingId int, item config.HostItem, quantity int, paymentMethod string, customerNumber int) (items []*Item) {
func (bs Service) CreateItem(bookingId int, item config.HostItem, quantity int, price float64, paymentMethod string, customerNumber int) (items []*Item) {
i := &Item{
BookingId: bookingId,
Item: item.Name,
Quantity: quantity,
Price: item.Price,
Price: price,
PaymentMethod: paymentMethod,
}
_ = bs.db.Create(i)
items = append(items, i)
if item.Taxes != 0.0 {
ti := &Item{
BookingId: bookingId,
@ -277,10 +278,11 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
commissionAmount := extractFloat(`Commission : € (\d+,\d+)`, content)
itemName := extractString(`Maison 1 Chambre \((T2|T3) -`, content)
externalId := extractString(`Numéro de réservation : \n\s+(\d+)`, content)
standardRate := extractFloat(`Standard Rate\n\s+€ (\d+)`, content)
b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount, &externalId)
if item, ok := config.NewHost().Items[itemName]; ok {
bs.CreateItem(b.Id, item, stayLength, "Card", customerNumber)
bs.CreateItem(b.Id, item, stayLength, standardRate, "Card", customerNumber)
}
return b, nil

View file

@ -257,7 +257,7 @@ func handleCreateItem(bs *booking.Service, cs *calendar.Service, hc *config.Host
return fmt.Errorf("invalid item name %q", ni.Item)
}
newItems := bs.CreateItem(b.Id, itm, ni.Quantity, ni.PaymentMethod, b.CustomerNumber)
newItems := bs.CreateItem(b.Id, itm, ni.Quantity, ni.Price, ni.PaymentMethod, b.CustomerNumber)
if err = cs.Create(
itm.CalendarId,