From 5606b9c4a3118303142f27e030a4b5e4eb6a2254 Mon Sep 17 00:00:00 2001 From: aguhh18 Date: Thu, 8 Jan 2026 20:44:56 +0700 Subject: [PATCH] FIX(BE): fix closing marketing 500 --- .../modules/closings/dto/closingMarketing.dto.go | 9 +++++++-- .../modules/closings/services/closing.service.go | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/internal/modules/closings/dto/closingMarketing.dto.go b/internal/modules/closings/dto/closingMarketing.dto.go index 4c7b4d35..42d95be2 100644 --- a/internal/modules/closings/dto/closingMarketing.dto.go +++ b/internal/modules/closings/dto/closingMarketing.dto.go @@ -55,16 +55,21 @@ func ToSalesDTO(e entity.MarketingDeliveryProduct) SalesDTO { kandang = &mapped } + var realizationDate time.Time + if e.DeliveryDate != nil { + realizationDate = *e.DeliveryDate + } + doNumber := deliveryOrdersDTO.GenerateDeliveryOrderNumber(e.MarketingProduct.Marketing.SoNumber, e.DeliveryDate, e.MarketingProduct.ProductWarehouse.Warehouse.Id) return SalesDTO{ Id: e.Id, - RealizationDate: *e.DeliveryDate, + RealizationDate: realizationDate, Age: age, DoNumber: doNumber, Product: product, Customer: customer, - Qty: e.UsageQty, // Show allocated quantity from FIFO + Qty: e.UsageQty, Weight: e.TotalWeight, AvgWeight: e.AvgWeight, Price: e.UnitPrice, diff --git a/internal/modules/closings/services/closing.service.go b/internal/modules/closings/services/closing.service.go index 9659601e..c3e3108d 100644 --- a/internal/modules/closings/services/closing.service.go +++ b/internal/modules/closings/services/closing.service.go @@ -153,7 +153,17 @@ func (s closingService) GetPenjualan(c *fiber.Ctx, projectFlockID uint) ([]entit if len(realisasi) == 0 { return []entity.MarketingDeliveryProduct{}, nil } - return realisasi, nil + + filtered := make([]entity.MarketingDeliveryProduct, 0, len(realisasi)) + for _, item := range realisasi { + + if item.UsageQty != 0 || item.TotalWeight != 0 || item.AvgWeight != 0 || + item.UnitPrice != 0 || item.TotalPrice != 0 { + filtered = append(filtered, item) + } + } + + return filtered, nil } func (s closingService) GetClosingSummary(c *fiber.Ctx, projectFlockID uint) (*dto.ClosingSummaryDTO, error) {