diff --git a/internal/config/host.go b/internal/config/host.go index 44f82c1..0f9915b 100644 --- a/internal/config/host.go +++ b/internal/config/host.go @@ -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, diff --git a/internal/server/handle_bookings.go b/internal/server/handle_bookings.go index f7073f3..541bf11 100644 --- a/internal/server/handle_bookings.go +++ b/internal/server/handle_bookings.go @@ -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( diff --git a/internal/service/booking/item.go b/internal/service/booking/item.go index 0c301e0..8149bae 100644 --- a/internal/service/booking/item.go +++ b/internal/service/booking/item.go @@ -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", diff --git a/internal/service/booking/sync.go b/internal/service/booking/sync.go index 6f29cd3..8cf7858 100644 --- a/internal/service/booking/sync.go +++ b/internal/service/booking/sync.go @@ -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