From d226d5f7f3365432d25ef859e2fb8d86a0fcd12f Mon Sep 17 00:00:00 2001 From: ragilap Date: Wed, 25 Mar 2026 12:42:05 +0700 Subject: [PATCH] fix asof chickin adjustment --- .../production/chickins/services/chickin.service.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/modules/production/chickins/services/chickin.service.go b/internal/modules/production/chickins/services/chickin.service.go index 3a342646..33651482 100644 --- a/internal/modules/production/chickins/services/chickin.service.go +++ b/internal/modules/production/chickins/services/chickin.service.go @@ -37,6 +37,7 @@ import ( const ( chickinDeletePopulationGuardMessage = "Chickin tidak dapat dihapus karena masih memiliki population aktif" chickinDeleteDownstreamGuardMessage = "Chickin tidak bisa dihapus karena masih dipakai oleh transaksi turunan. Hapus/unexecute Marketing, Recording, Transfer, Adjustment, dan Transfer to Laying terlebih dahulu." + chickinAdjustmentSourceTable = "adjustment_stocks" ) type ChickinService interface { @@ -577,7 +578,7 @@ func (s *chickinService) resolveLayingSourceAvailableQty(ctx context.Context, tx Lane: commonSvc.FifoStockV2Lane("STOCKABLE"), AllocationPurpose: entity.StockAllocationPurposeConsume, ProductWarehouseID: productWarehouseID, - AsOf: asOf, + AsOf: nil, Limit: 10000, Tx: tx, }) @@ -586,10 +587,16 @@ func (s *chickinService) resolveLayingSourceAvailableQty(ctx context.Context, tx } available := 0.0 + hasAsOf := asOf != nil && !asOf.IsZero() for _, row := range gatherRows { if row.AvailableQuantity <= 0 { continue } + if hasAsOf && + !strings.EqualFold(strings.TrimSpace(row.SourceTable), chickinAdjustmentSourceTable) && + row.SortAt.After(*asOf) { + continue + } available += row.AvailableQuantity } return available, nil