mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
adjust api hpp per kandang and implement common service hpp
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user