From 97d02c3537ba6dc1fa8e39812ed73695fc17a43b Mon Sep 17 00:00:00 2001 From: "aditya.siregar" Date: Sat, 24 Aug 2024 14:25:58 +0700 Subject: [PATCH] Update Product POS --- internal/entity/order.go | 1 + internal/entity/product.go | 5 +++-- internal/handlers/http/order/order.go | 13 +++++++------ internal/handlers/response/order.go | 11 ++++++----- internal/repository/orders/order.go | 3 ++- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/internal/entity/order.go b/internal/entity/order.go index fab2f1d..a8f2749 100644 --- a/internal/entity/order.go +++ b/internal/entity/order.go @@ -230,6 +230,7 @@ type OrderPrintDetail struct { ID int64 `gorm:"column:id"` Logo string `gorm:"logo"` PartnerName string `gorm:"column:partner_name"` + SiteName string `gorm:"column:site_name"` OrderID string `gorm:"column:order_id"` VisitDate time.Time `gorm:"column:visit_date"` PaymentType string `gorm:"column:payment_type"` diff --git a/internal/entity/product.go b/internal/entity/product.go index e36e487..39e6062 100644 --- a/internal/entity/product.go +++ b/internal/entity/product.go @@ -21,7 +21,7 @@ type Product struct { DeletedAt *time.Time `gorm:"column:deleted_at"` CreatedBy int64 `gorm:"type:int;column:created_by"` UpdatedBy int64 `gorm:"type:int;column:updated_by"` - Stock int64 `gorm:"type:int;column:stock"` + Stock int64 `gorm:"type:int;column:stock"` } func (Product) TableName() string { @@ -94,7 +94,8 @@ func (b *ProductList) ToProductList() []*Product { func (b *ProductList) ToProductListPOS() []*Product { var Products []*Product - today := time.Now().Weekday() + location, _ := time.LoadLocation("Asia/Jakarta") + today := time.Now().In(location).Weekday() isWeekend := today == time.Saturday || today == time.Sunday for _, p := range *b { diff --git a/internal/handlers/http/order/order.go b/internal/handlers/http/order/order.go index 5114add..b189c9a 100644 --- a/internal/handlers/http/order/order.go +++ b/internal/handlers/http/order/order.go @@ -446,11 +446,12 @@ func MapOrderToPrintDetailResponse(order *entity.OrderPrintDetail, casherName st orderItems := make([]response.CreateOrderItemResponse, len(order.OrderItems)) for i, item := range order.OrderItems { orderItems[i] = response.CreateOrderItemResponse{ - ID: item.ID, - ItemID: item.ItemID, - Quantity: item.Quantity, - Price: item.Price, - Name: item.Product.Name, + ID: item.ID, + ItemID: item.ItemID, + Quantity: item.Quantity, + Price: item.Price, + Name: item.Product.Name, + IsSeasonTicket: item.Product.IsSeasonTicket, } } @@ -465,7 +466,7 @@ func MapOrderToPrintDetailResponse(order *entity.OrderPrintDetail, casherName st VisitTime: time.Now().Format("15:04:05"), OrderItems: orderItems, CasheerName: casherName, - PartnerName: order.PartnerName, + PartnerName: order.SiteName, Logo: order.Logo, } } diff --git a/internal/handlers/response/order.go b/internal/handlers/response/order.go index 777d805..b8627a4 100644 --- a/internal/handlers/response/order.go +++ b/internal/handlers/response/order.go @@ -146,11 +146,12 @@ type CheckingInquiryResponse struct { } type CreateOrderItemResponse struct { - ID int64 `json:"id"` - ItemID int64 `json:"item_id"` - Quantity int64 `json:"quantity"` - Price float64 `json:"price"` - Name string `json:"name"` + ID int64 `json:"id"` + ItemID int64 `json:"item_id"` + Quantity int64 `json:"quantity"` + Price float64 `json:"price"` + Name string `json:"name"` + IsSeasonTicket bool `json:"is_season_ticket"` } type ProductDailySales struct { diff --git a/internal/repository/orders/order.go b/internal/repository/orders/order.go index 4f5823d..4d12a4c 100644 --- a/internal/repository/orders/order.go +++ b/internal/repository/orders/order.go @@ -70,10 +70,11 @@ func (r *OrderRepository) FindPrintDetailByID(ctx context.Context, id int64) (*e err := r.db.WithContext(ctx). Table("orders"). - Select("orders.id, partners.name as partner_name, partners.logo as logo, orders.ref_id as order_id, "+ + Select("orders.id, partners.name as partner_name, sites.name as site_name, partners.logo as logo, orders.ref_id as order_id, "+ "orders.visit_date, orders.payment_type, orders.source, "+ "orders.ticket_status, orders.total, orders.fee"). Joins("JOIN partners ON partners.id = orders.partner_id"). + Joins("JOIN sites ON sites.id = orders.site_id"). Where("orders.id = ?", id). Scan(&printDetail).Error