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.)
This commit is contained in:
aguhh18
2025-12-31 11:43:03 +07:00
parent 42853aaac0
commit bec6a93152
@@ -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
}