adjust api hpp per kandang and implement common service hpp

This commit is contained in:
giovanni
2026-01-22 17:37:28 +07:00
parent 58b29501c0
commit 0d585a99a6
4 changed files with 47 additions and 207 deletions
@@ -66,9 +66,9 @@ func (r *HppRepositoryImpl) GetDocCost(ctx context.Context, projectFlockKandangI
func (r *HppRepositoryImpl) GetBudgetCostByProjectFlockId(ctx context.Context, projectFlockId uint) (float64, error) {
var total float64
err := r.db.WithContext(ctx).
Table("project_chickin_details AS pcd").
Select("COALESCE(SUM(pcd.qty * pcd.price), 0)").
Where("pcd.project_flock_id = ?", projectFlockId).
Table("project_budgets AS pb").
Select("COALESCE(SUM(pb.qty * pb.price), 0)").
Where("pb.project_flock_id = ?", projectFlockId).
Scan(&total).Error
if err != nil {
return 0, err
@@ -269,6 +269,7 @@ func (r *HppRepositoryImpl) GetTransferSourceSummary(ctx context.Context, projec
Select("lt.from_project_flock_id AS project_flock_id, COALESCE(SUM(ltt.total_qty), 0) AS total_qty").
Joins("JOIN laying_transfers AS lt ON lt.id = ltt.laying_transfer_id").
Where("ltt.target_project_flock_kandang_id = ?", projectFlockKandangId).
Group("lt.from_project_flock_id").
Scan(&summary).Error
if err != nil {
return 0, 0, err