mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-12 13:46:51 +00:00
use the price from the form
This commit is contained in:
parent
0a0e819133
commit
6451bd5926
2 changed files with 6 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue