adjust validation select phase

This commit is contained in:
giovanni
2026-01-28 09:46:34 +07:00
parent 095080320c
commit 3d39d6d31e
4 changed files with 7 additions and 4 deletions
@@ -10,6 +10,7 @@ BEGIN
'daily_checklist_activity_tasks', 'daily_checklist_activity_tasks',
'daily_checklist_phases', 'daily_checklist_phases',
'daily_checklist_tasks', 'daily_checklist_tasks',
'daily_checklists',
'employee_kandangs', 'employee_kandangs',
'employees', 'employees',
'phase_activities', 'phase_activities',
@@ -11,6 +11,7 @@ BEGIN
'daily_checklist_activity_tasks', 'daily_checklist_activity_tasks',
'daily_checklist_phases', 'daily_checklist_phases',
'daily_checklist_tasks', 'daily_checklist_tasks',
'daily_checklists',
'employee_kandangs', 'employee_kandangs',
'employees', 'employees',
'phase_activities', 'phase_activities',
@@ -355,9 +355,10 @@ func (r *ClosingRepositoryImpl) SumMarketingWeightAndQtyByProjectFlockKandangIDs
Joins("JOIN product_warehouses pw ON pw.id = mp.product_warehouse_id"). Joins("JOIN product_warehouses pw ON pw.id = mp.product_warehouse_id").
Joins("JOIN products prod ON prod.id = pw.product_id"). Joins("JOIN products prod ON prod.id = pw.product_id").
Joins("JOIN flags f ON f.flagable_id = prod.id AND f.flagable_type = ?", "products"). Joins("JOIN flags f ON f.flagable_id = prod.id AND f.flagable_type = ?", "products").
Joins("JOIN marketing_delivery_products mdp ON mdp.marketing_product_id = mp.id").
Where("pw.project_flock_kandang_id IN ?", projectFlockKandangIDs). Where("pw.project_flock_kandang_id IN ?", projectFlockKandangIDs).
Where("f.name IN ?", flagNames). Where("f.name IN ?", flagNames).
Select("COALESCE(SUM(mp.total_weight), 0) AS total_weight, COALESCE(SUM(mp.qty), 0) AS total_qty, COALESCE(SUM(mp.total_price), 0) AS total_price"). Select("COALESCE(SUM(mdp.total_weight), 0) AS total_weight, COALESCE(SUM(mdp.usage_qty), 0) AS total_qty, COALESCE(SUM(mp.total_price), 0) AS total_price").
Scan(&agg).Error Scan(&agg).Error
if err != nil { if err != nil {
return 0, 0, 0, err return 0, 0, 0, err
@@ -797,7 +798,7 @@ func (r *ClosingRepositoryImpl) detailQuery(
) *gorm.DB { ) *gorm.DB {
db := r.withCtx(ctx). db := r.withCtx(ctx).
Table(table). Table(table).
Joins("JOIN product_warehouses pw ON "+pwJoinCond). Joins("JOIN product_warehouses pw ON " + pwJoinCond).
Joins("JOIN products p ON p.id = pw.product_id") Joins("JOIN products p ON p.id = pw.product_id")
db = applyJoins(db, joins...) db = applyJoins(db, joins...)
@@ -1034,7 +1035,7 @@ func (r *ClosingRepositoryImpl) fetchStockLogs(ctx context.Context, kandangID ui
COALESCE(sl.increase,0) AS increase, COALESCE(sl.increase,0) AS increase,
COALESCE(sl.decrease,0) AS decrease, COALESCE(sl.decrease,0) AS decrease,
COALESCE(p.product_price,0) AS price, COALESCE(p.product_price,0) AS price,
`+movementSelect+` ` + movementSelect + `
`). `).
Joins("JOIN product_warehouses pw ON pw.id = sl.product_warehouse_id"). Joins("JOIN product_warehouses pw ON pw.id = sl.product_warehouse_id").
Joins("JOIN products p ON p.id = pw.product_id"). Joins("JOIN products p ON p.id = pw.product_id").
@@ -29,7 +29,7 @@ type Query struct {
} }
type AssignPhases struct { type AssignPhases struct {
PhaseIDs string `json:"phase_ids" validate:"required"` PhaseIDs string `json:"phase_ids" validate:"omitempty"`
} }
type AssignTask struct { type AssignTask struct {