mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +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
|
totalQuantityAdded += quantityToConvert
|
||||||
}
|
}
|
||||||
|
|
||||||
if totalQuantityAdded > 0 {
|
// NOTE: Tidak menambah target ProductWarehouse quantity karena:
|
||||||
if err := s.ProductWarehouseRepo.AdjustQuantities(ctx.Context(), map[uint]float64{
|
// 1. Ayam sudah dipakai (masuk population)
|
||||||
targetPW.Id: totalQuantityAdded,
|
// 2. ProductWarehouse source sudah berkurang saat create chickin (ConsumeChickinStocks)
|
||||||
}, func(db *gorm.DB) *gorm.DB {
|
// 3. Menambah quantity disini akan menyebabkan double count
|
||||||
return dbTransaction
|
//
|
||||||
}); err != nil {
|
// PULLET/LAYER untuk flock ini akan di-add lewat mekanisme lain (misal: purchase, transfer, dll)
|
||||||
return fmt.Errorf("failed to update target product warehouse quantity: %w", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user