mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-24 07:15:43 +00:00
add approval projectflockkandang closed,expense must be done,stock must empty by flag unfinished:need info approval fix
This commit is contained in:
+23
-1
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -219,6 +220,27 @@ func (s projectFlockKandangService) Closing(c *fiber.Ctx, id uint, req *validati
|
||||
return nil, fiber.NewError(fiber.StatusBadRequest, "Masih ada expense belum selesai untuk kandang ini")
|
||||
}
|
||||
}
|
||||
|
||||
if s.WarehouseRepo != nil && s.ProductWarehouseRepo != nil {
|
||||
warehouse, werr := s.WarehouseRepo.GetByKandangID(c.Context(), pfk.KandangId)
|
||||
if werr != nil {
|
||||
return nil, werr
|
||||
}
|
||||
|
||||
for _, flagName := range []utils.FlagType{utils.FlagPakan, utils.FlagOVK} {
|
||||
productWarehouses, pwErr := s.ProductWarehouseRepo.GetByFlagAndWarehouseID(c.Context(), string(flagName), warehouse.Id)
|
||||
if pwErr != nil {
|
||||
return nil, pwErr
|
||||
}
|
||||
|
||||
for _, pw := range productWarehouses {
|
||||
if pw.Quantity > 0 {
|
||||
return nil, fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("Stok %s masih tersedia (product warehouse %d: %.2f)", flagName, pw.Id, pw.Quantity))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeTime := now
|
||||
if req.ClosedDate != nil {
|
||||
parsed, perr := utils.ParseDateString(strings.TrimSpace(*req.ClosedDate))
|
||||
@@ -236,7 +258,7 @@ func (s projectFlockKandangService) Closing(c *fiber.Ctx, id uint, req *validati
|
||||
c.Context(),
|
||||
utils.ApprovalWorkflowProjectFlockKandang,
|
||||
id,
|
||||
utils.ProjectFlockKandangStepDisetujui,
|
||||
utils.ProjectFlockKandangStepClosed,
|
||||
&closeAction,
|
||||
actorID,
|
||||
nil,
|
||||
|
||||
Reference in New Issue
Block a user