fix: override is_transfer lookup for direct cut-over laying flocks

This commit is contained in:
Adnan Zahir
2026-03-17 18:41:51 +07:00
parent d76f72050e
commit 2713210bcc
2 changed files with 75 additions and 0 deletions
@@ -318,6 +318,7 @@ func (u *ProjectflockController) LookupProjectFlockKandang(c *fiber.Ctx) error {
dtoResult.IsTransition = isTransition
dtoResult.IsLaying = isLaying
}
applyCutOverLayingLookupOverride(&dtoResult)
if withPopulation {
population := dtoResult.AvailableQuantity
dtoResult.Population = &population
@@ -344,6 +345,20 @@ func (u *ProjectflockController) LookupProjectFlockKandang(c *fiber.Ctx) error {
Data: dtoResult})
}
func applyCutOverLayingLookupOverride(result *dto.ProjectFlockKandangDTO) {
if result == nil || result.ProjectFlock == nil || result.IsLaying || result.ChickInDate == nil {
return
}
category := strings.ToUpper(strings.TrimSpace(result.ProjectFlock.Category))
if category != strings.ToUpper(string(utils.ProjectFlockCategoryLaying)) {
return
}
result.IsTransition = false
result.IsLaying = true
}
func (u *ProjectflockController) Resubmit(c *fiber.Ctx) error {
param := c.Params("id")
req := new(validation.Resubmit)