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
@@ -347,6 +347,7 @@ func (s *repportService) GetExpenseDepreciationManualInputs(ctx *fiber.Ctx) ([]d
ProjectFlockID: int64(row.ProjectFlockID),
FarmName: row.FarmName,
TotalCost: row.TotalCost,
CutoverDate: row.CutoverDate.Format("2006-01-02"),
Note: row.Note,
})
}
@@ -397,10 +398,19 @@ func (s *repportService) UpsertExpenseDepreciationManualInput(ctx *fiber.Ctx, re
if s.ExpenseDepreciationRepo == nil {
return nil, fiber.NewError(fiber.StatusInternalServerError, "expense depreciation repository is not configured")
}
location, err := time.LoadLocation("Asia/Jakarta")
if err != nil {
return nil, fiber.NewError(fiber.StatusInternalServerError, "failed to load timezone configuration")
}
cutoverDate, err := time.ParseInLocation("2006-01-02", req.CutoverDate, location)
if err != nil {
return nil, fiber.NewError(fiber.StatusBadRequest, "cutover_date must follow format YYYY-MM-DD")
}
row := entity.FarmDepreciationManualInput{
ProjectFlockId: req.ProjectFlockID,
TotalCost: req.TotalCost,
CutoverDate: cutoverDate,
Note: req.Note,
}
if err := s.ExpenseDepreciationRepo.UpsertManualInput(ctx.Context(), &row); err != nil {
@@ -411,6 +421,7 @@ func (s *repportService) UpsertExpenseDepreciationManualInput(ctx *fiber.Ctx, re
ID: int64(row.Id),
ProjectFlockID: int64(row.ProjectFlockId),
TotalCost: row.TotalCost,
CutoverDate: row.CutoverDate.Format("2006-01-02"),
Note: row.Note,
}