mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 15:25:43 +00:00
fix[BE]Reset chickin pending usage and skip zero entries
This commit is contained in:
@@ -572,6 +572,7 @@ func (s *chickinService) convertChickinsToTarget(ctx *fiber.Ctx, chickins []enti
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectFlockPopulationRepotx := s.ProjectflockPopulationRepo.WithTx(dbTransaction)
|
ProjectFlockPopulationRepotx := s.ProjectflockPopulationRepo.WithTx(dbTransaction)
|
||||||
|
chickinRepoTx := s.Repository.WithTx(dbTransaction)
|
||||||
|
|
||||||
var totalQuantityAdded float64
|
var totalQuantityAdded float64
|
||||||
|
|
||||||
@@ -601,6 +602,13 @@ func (s *chickinService) convertChickinsToTarget(ctx *fiber.Ctx, chickins []enti
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset PendingUsageQty to 0 since population has been created
|
||||||
|
if err := chickinRepoTx.PatchOne(ctx.Context(), chickin.Id, map[string]any{
|
||||||
|
"pending_usage_qty": 0,
|
||||||
|
}, nil); err != nil {
|
||||||
|
return fmt.Errorf("failed to reset pending usage qty for chickin %d: %w", chickin.Id, err)
|
||||||
|
}
|
||||||
|
|
||||||
totalQuantityAdded += quantityToConvert
|
totalQuantityAdded += quantityToConvert
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -204,6 +204,11 @@ func toAvailableQtyDTOsFromMap(chickins []entity.ProjectChickin, availableQtyMap
|
|||||||
|
|
||||||
result := make([]AvailableQtyDTO, 0, len(availableQtyMap))
|
result := make([]AvailableQtyDTO, 0, len(availableQtyMap))
|
||||||
for pwId, availableQty := range availableQtyMap {
|
for pwId, availableQty := range availableQtyMap {
|
||||||
|
// Skip jika available qty = 0
|
||||||
|
if availableQty <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
pw, exists := pwMap[pwId]
|
pw, exists := pwMap[pwId]
|
||||||
if !exists || pw == nil {
|
if !exists || pw == nil {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user