Compare commits

...

1 Commits

Author SHA1 Message Date
giovanni f64839dfe1 add delete snapshoot if change chickin date 2026-06-04 23:46:25 +07:00
@@ -2127,7 +2127,7 @@ func (s chickinService) UpdateChickInDate(ctx *fiber.Ctx, req *validation.Update
return fiber.NewError(fiber.StatusNotFound, "Project flock kandang tidak ditemukan") return fiber.NewError(fiber.StatusNotFound, "Project flock kandang tidak ditemukan")
} }
return s.Repository.DB().WithContext(ctx.Context()).Transaction(func(tx *gorm.DB) error { if err := s.Repository.DB().WithContext(ctx.Context()).Transaction(func(tx *gorm.DB) error {
if err := s.Repository.UpdateChickInDateByProjectFlockKandangID(ctx.Context(), tx, req.ProjectFlockKandangId, newDate); err != nil { if err := s.Repository.UpdateChickInDateByProjectFlockKandangID(ctx.Context(), tx, req.ProjectFlockKandangId, newDate); err != nil {
return err return err
} }
@@ -2139,5 +2139,10 @@ func (s chickinService) UpdateChickInDate(ctx *fiber.Ctx, req *validation.Update
WHERE project_flock_kandangs_id = ? WHERE project_flock_kandangs_id = ?
AND deleted_at IS NULL AND deleted_at IS NULL
`, req.ChickInDate, req.ProjectFlockKandangId).Error `, req.ChickInDate, req.ProjectFlockKandangId).Error
}) }); err != nil {
return err
}
s.invalidateDepreciationSnapshots(ctx.Context(), nil, []uint{req.ProjectFlockKandangId}, newDate)
return nil
} }