From f64839dfe1c2dca42ccb330583b1b80b95724b4b Mon Sep 17 00:00:00 2001 From: giovanni Date: Thu, 4 Jun 2026 23:46:25 +0700 Subject: [PATCH] add delete snapshoot if change chickin date --- .../production/chickins/services/chickin.service.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/modules/production/chickins/services/chickin.service.go b/internal/modules/production/chickins/services/chickin.service.go index d8c9f18f..0978fd9d 100644 --- a/internal/modules/production/chickins/services/chickin.service.go +++ b/internal/modules/production/chickins/services/chickin.service.go @@ -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 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 { return err } @@ -2139,5 +2139,10 @@ func (s chickinService) UpdateChickInDate(ctx *fiber.Ctx, req *validation.Update WHERE project_flock_kandangs_id = ? AND deleted_at IS NULL `, req.ChickInDate, req.ProjectFlockKandangId).Error - }) + }); err != nil { + return err + } + + s.invalidateDepreciationSnapshots(ctx.Context(), nil, []uint{req.ProjectFlockKandangId}, newDate) + return nil }