mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user