From bec6a93152b654360ae81731bb469d3ed1218c66 Mon Sep 17 00:00:00 2001 From: aguhh18 Date: Wed, 31 Dec 2025 11:43:03 +0700 Subject: [PATCH] FIX[BE]Stop adjusting target product warehouse quantity Avoid double counting: population entries and ConsumeChickinStocks already update inventory. Pullet/layer for the flock will be added via other flows (purchase, transfer, etc.) --- .../chickins/services/chickin.service.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/modules/production/chickins/services/chickin.service.go b/internal/modules/production/chickins/services/chickin.service.go index 9784ef8a..e071f3be 100644 --- a/internal/modules/production/chickins/services/chickin.service.go +++ b/internal/modules/production/chickins/services/chickin.service.go @@ -612,15 +612,12 @@ func (s *chickinService) convertChickinsToTarget(ctx *fiber.Ctx, chickins []enti totalQuantityAdded += quantityToConvert } - if totalQuantityAdded > 0 { - if err := s.ProductWarehouseRepo.AdjustQuantities(ctx.Context(), map[uint]float64{ - targetPW.Id: totalQuantityAdded, - }, func(db *gorm.DB) *gorm.DB { - return dbTransaction - }); err != nil { - return fmt.Errorf("failed to update target product warehouse quantity: %w", err) - } - } + // NOTE: Tidak menambah target ProductWarehouse quantity karena: + // 1. Ayam sudah dipakai (masuk population) + // 2. ProductWarehouse source sudah berkurang saat create chickin (ConsumeChickinStocks) + // 3. Menambah quantity disini akan menyebabkan double count + // + // PULLET/LAYER untuk flock ini akan di-add lewat mekanisme lain (misal: purchase, transfer, dll) return nil }