feat: manual pullet cost

This commit is contained in:
Adnan Zahir
2026-04-19 15:10:53 +07:00
parent a2ae139fae
commit 69d6fc165a
13 changed files with 857 additions and 33 deletions
@@ -33,6 +33,7 @@ type FarmDepreciationManualInputRow struct {
ProjectFlockID uint
FarmName string
TotalCost float64
CutoverDate time.Time
Note *string
}
@@ -271,6 +272,7 @@ func (r *expenseDepreciationRepository) GetLatestManualInputsByFarms(
fdmi.project_flock_id AS project_flock_id,
pf.flock_name AS farm_name,
fdmi.total_cost AS total_cost,
fdmi.cutover_date AS cutover_date,
fdmi.note AS note
`).
Joins("JOIN project_flocks AS pf ON pf.id = fdmi.project_flock_id").
@@ -308,9 +310,10 @@ func (r *expenseDepreciationRepository) UpsertManualInput(ctx context.Context, r
{Name: "project_flock_id"},
},
DoUpdates: clause.Assignments(map[string]any{
"total_cost": row.TotalCost,
"note": row.Note,
"updated_at": now,
"total_cost": row.TotalCost,
"cutover_date": row.CutoverDate,
"note": row.Note,
"updated_at": now,
}),
}).
Create(row).Error
@@ -320,7 +323,7 @@ func (r *expenseDepreciationRepository) UpsertManualInput(ctx context.Context, r
return r.db.WithContext(ctx).
Table("farm_depreciation_manual_inputs").
Select("id, project_flock_id, total_cost, note").
Select("id, project_flock_id, total_cost, cutover_date, note").
Where("project_flock_id = ?", row.ProjectFlockId).
Take(row).Error
}