mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
Merge branch 'fix/hppv2-egg-production-double-count' into 'development'
Fix/hppv2 egg production double count See merge request mbugroup/lti-api!463
This commit is contained in:
@@ -878,6 +878,25 @@ func (r *HppV2RepositoryImpl) GetEggProduksiPiecesAndWeightKgByProjectFlockKanda
|
|||||||
return 0, 0, err
|
return 0, 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var adjustmentTotals struct {
|
||||||
|
TotalQty float64
|
||||||
|
TotalWeight float64
|
||||||
|
}
|
||||||
|
err = r.db.WithContext(ctx).
|
||||||
|
Table("adjustment_stocks AS ast").
|
||||||
|
Select("COALESCE(SUM(ast.total_qty), 0) AS total_qty, COALESCE(SUM(ast.price), 0) AS total_weight").
|
||||||
|
Joins("JOIN product_warehouses AS pw ON pw.id = ast.product_warehouse_id").
|
||||||
|
Where("pw.project_flock_kandang_id IN (?)", projectFlockKandangIDs).
|
||||||
|
Where("ast.function_code = ?", string(utils.AdjustmentTransactionSubtypeRecordingEggIn)).
|
||||||
|
Where("ast.created_at <= ?", *date).
|
||||||
|
Scan(&adjustmentTotals).Error
|
||||||
|
if err != nil {
|
||||||
|
return 0, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
totals.TotalPieces += adjustmentTotals.TotalQty
|
||||||
|
totals.TotalWeightKg += adjustmentTotals.TotalWeight
|
||||||
|
|
||||||
return totals.TotalPieces, totals.TotalWeightKg, nil
|
return totals.TotalPieces, totals.TotalWeightKg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user