mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
FIX[BE]: fixing bug transfer to laying, delet biaya, nominal expesen e, chickin
This commit is contained in:
+23
-2
@@ -552,6 +552,7 @@ func (s projectFlockKandangService) Closing(c *fiber.Ctx, id uint, req *validati
|
||||
}
|
||||
|
||||
func (s projectFlockKandangService) calculateAvailableQuantityForProductWarehouse(c *fiber.Ctx, projectFlockKandang *entity.ProjectFlockKandang, productWarehouse *entity.ProductWarehouse) (float64, error) {
|
||||
|
||||
availableQty := productWarehouse.Quantity
|
||||
|
||||
if projectFlockKandang.ProjectFlock.Category == string(utils.ProjectFlockCategoryGrowing) {
|
||||
@@ -564,7 +565,17 @@ func (s projectFlockKandangService) calculateAvailableQuantityForProductWarehous
|
||||
}
|
||||
}
|
||||
|
||||
availableQty = productWarehouse.Quantity - totalPendingQty
|
||||
totalPopulationQty := 0.0
|
||||
if s.PopulationRepo != nil {
|
||||
popQty, err := s.PopulationRepo.GetTotalQtyByProductWarehouseID(c.Context(), productWarehouse.Id)
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to get population qty for PW %d: %+v", productWarehouse.Id, err)
|
||||
} else {
|
||||
totalPopulationQty = popQty
|
||||
}
|
||||
}
|
||||
|
||||
availableQty = productWarehouse.Quantity - totalPendingQty - totalPopulationQty
|
||||
if availableQty < 0 {
|
||||
availableQty = 0
|
||||
}
|
||||
@@ -578,7 +589,17 @@ func (s projectFlockKandangService) calculateAvailableQuantityForProductWarehous
|
||||
}
|
||||
}
|
||||
|
||||
availableQty = productWarehouse.Quantity - totalPendingQty
|
||||
totalPopulationQty := 0.0
|
||||
if s.PopulationRepo != nil {
|
||||
popQty, err := s.PopulationRepo.GetTotalQtyByProductWarehouseID(c.Context(), productWarehouse.Id)
|
||||
if err != nil {
|
||||
s.Log.Errorf("Failed to get population qty for PW %d: %+v", productWarehouse.Id, err)
|
||||
} else {
|
||||
totalPopulationQty = popQty
|
||||
}
|
||||
}
|
||||
|
||||
availableQty = productWarehouse.Quantity - totalPendingQty - totalPopulationQty
|
||||
if availableQty < 0 {
|
||||
availableQty = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user