add counting hpp-expedition by project

This commit is contained in:
ragilap
2025-12-14 23:15:30 +07:00
parent e98d0a9fa1
commit fc49cef781
5 changed files with 143 additions and 0 deletions
@@ -188,3 +188,35 @@ func (u *ClosingController) GetClosingSapronak(c *fiber.Ctx) error {
Data: result,
})
}
func (u *ClosingController) GetExpeditionHPP(c *fiber.Ctx) error {
param := c.Params("project_flock_id")
projectFlockID, err := strconv.Atoi(param)
if err != nil || projectFlockID <= 0 {
return fiber.NewError(fiber.StatusBadRequest, "Invalid Project Flock Id")
}
var projectFlockKandangID *uint
if raw := c.Query("project_flock_kandang_id"); raw != "" {
idInt, convErr := strconv.Atoi(raw)
if convErr != nil || idInt <= 0 {
return fiber.NewError(fiber.StatusBadRequest, "Invalid project_flock_kandang_id")
}
idUint := uint(idInt)
projectFlockKandangID = &idUint
}
result, err := u.ClosingService.GetExpeditionHPP(c, uint(projectFlockID), projectFlockKandangID)
if err != nil {
return err
}
return c.Status(fiber.StatusOK).
JSON(response.Success{
Code: fiber.StatusOK,
Status: "success",
Message: "Get expedition HPP successfully",
Data: result,
})
}