diff --git a/internal/booking/models.go b/internal/booking/models.go index 2bc33b9..dcbbed2 100644 --- a/internal/booking/models.go +++ b/internal/booking/models.go @@ -5,8 +5,9 @@ import ( "strconv" "time" - "github.com/rjNemo/rentease/config" "gorm.io/gorm" + + "github.com/rjNemo/rentease/config" ) type Booking struct { @@ -21,6 +22,7 @@ type Booking struct { Id int CustomerNumber int `gorm:"column:customers"` PlatformFees float64 `gorm:"type:decimal(10,2)"` + Canceled bool `gorm:"default:false"` } func (b Booking) InvoiceNumber(hc *config.Host) string { diff --git a/internal/booking/service.go b/internal/booking/service.go index 2ee113b..6998ae8 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -128,6 +128,7 @@ type Line struct { Id int Total float64 PlatformFees float64 + Canceled bool } func (l Line) InvoiceNumber(hc *config.Host) string { diff --git a/internal/server/handle_bookings.go b/internal/server/handle_bookings.go index 250b4cb..2a34013 100644 --- a/internal/server/handle_bookings.go +++ b/internal/server/handle_bookings.go @@ -31,6 +31,7 @@ func handleListBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFun Platform: b.Platform, Name: b.CustomerName, Total: strconv.FormatFloat(b.Total, 'f', 2, 64), + Canceled: b.Canceled, } }) @@ -93,6 +94,7 @@ func handleBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc { From: b.From.Format(time.DateOnly), To: b.To.Format(time.DateOnly), Platform: b.Platform, + Canceled: b.Canceled, PlatformFees: strconv.FormatFloat(b.PlatformFees, 'f', 2, 64), Url: templ.EscapeString(fmt.Sprintf("%s/%d", constant.RouteBooking, b.Id)), PdfUrl: templ.SafeURL(fmt.Sprintf("%s/pdf/%d", constant.RouteBooking, b.Id)), @@ -155,6 +157,7 @@ func handleUpdateBooking(bs *booking.Service, hc *config.Host) echo.HandlerFunc Email: b.Email, From: b.From.Format(time.DateOnly), To: b.To.Format(time.DateOnly), + Canceled: b.Canceled, Platform: b.Platform, Platforms: hc.Platforms, PlatformFees: strconv.FormatFloat(b.PlatformFees, 'f', 2, 64), diff --git a/internal/view/booking_by_id.templ b/internal/view/booking_by_id.templ index 84cd259..c0e6363 100644 --- a/internal/view/booking_by_id.templ +++ b/internal/view/booking_by_id.templ @@ -11,6 +11,7 @@ type BookingViewModel struct { PhoneNumber string CustomerNumber string Email string + Canceled bool From string To string Platform string @@ -43,9 +44,14 @@ templ BookingById(booking *BookingViewModel) {