From 33c1c450e0d4172586f37975ad2c87371d3f4281 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sat, 15 Jun 2024 07:51:05 +0200 Subject: [PATCH] store items --- internal/booking/service.go | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/internal/booking/service.go b/internal/booking/service.go index c5b5454..77f1eb1 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -8,7 +8,6 @@ import ( "strings" "time" - "github.com/labstack/gommon/log" u "github.com/rjNemo/underscore" "gorm.io/gorm" "gorm.io/gorm/clause" @@ -247,21 +246,11 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) { item := extractString(`Maison 1 Chambre \((T2|T3) -`, content) standardRate := extractFloat(`Standard Rate\n\s+€ (\d+)`, content) - result := map[string]any{ - "from": formatDate(arrivalDate), - "to": formatDate(departureDate), - "stay_length": stayLength, - "total_amount": totalAmount, - "customer_name": customerName, - "email": customerEmail, - "customer_number": customerNumber, - "commission_amount": commissionAmount, - "item": item, - "price": standardRate, - } - log.Info(result) + taxQty := (totalAmount - standardRate*float64(stayLength)) / 1.5 b := bs.Create(*formatDate(arrivalDate), *formatDate(departureDate), customerName, "", customerEmail, "Booking", customerNumber, commissionAmount) + bs.CreateItem(b.Id, item, stayLength, standardRate, "Card") + bs.CreateItem(b.Id, "Taxes", int(taxQty), 1.5, "Cash") return b, nil }