store items

This commit is contained in:
Ruidy 2024-06-15 07:51:05 +02:00
parent 0b5c12716c
commit 33c1c450e0
No known key found for this signature in database
GPG key ID: E00F51288CB857CC

View file

@ -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
}