RE19 taxes only for booking (#24)

* create taxes only ofr booking platform

* also for sync

sync
This commit is contained in:
Ruidy 2024-11-14 23:29:20 +01:00 committed by GitHub
parent 42764ab6cc
commit 6376fbd234
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 4 deletions

View file

@ -58,14 +58,17 @@ func NewHost() *Host {
HasEndDate: true,
Taxes: 1.5,
},
"Airport": {
Name: "Airport",
Price: 25.0,
},
"Port": {
Name: "Port",
Price: 20.0,
},
"Transport": {
Name: "Transport",
Price: 20.0,

View file

@ -256,7 +256,7 @@ func handleCreateItem(bs *booking.Service, hc *config.Host) echo.HandlerFunc {
return fmt.Errorf("invalid item name %q", ni.Item)
}
newItems := bs.CreateItem(b.Id, itm, ni.Quantity, ni.Price, ni.PaymentMethod, b.CustomerNumber)
newItems := bs.CreateItem(b.Id, itm, ni.Quantity, ni.Price, ni.PaymentMethod, b.CustomerNumber, b.Platform)
// TODO: fix the calendar integration
// if err = cs.Create(

View file

@ -6,7 +6,7 @@ import (
"github.com/rjNemo/rentease/internal/config"
)
func (bs Service) CreateItem(bookingId int, item config.HostItem, quantity int, price float64, paymentMethod string, customerNumber int) (items []*Item) {
func (bs Service) CreateItem(bookingId int, item config.HostItem, quantity int, price float64, paymentMethod string, customerNumber int, platform string) (items []*Item) {
i := &Item{
BookingId: bookingId,
Item: item.Name,
@ -19,7 +19,7 @@ func (bs Service) CreateItem(bookingId int, item config.HostItem, quantity int,
}
items = append(items, i)
if item.Taxes != 0.0 {
if item.Taxes != 0.0 && platform == "Booking" {
ti := &Item{
BookingId: bookingId,
Item: "Taxes",

View file

@ -28,7 +28,7 @@ func (bs Service) ParseFromApi(rawContent string) (*Booking, error) {
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, standardRate, "Card", customerNumber)
bs.CreateItem(b.Id, item, stayLength, standardRate, "Card", customerNumber, b.Platform)
}
return b, nil