add restrict for expense,purchase,adjustment transfer: unfinished

This commit is contained in:
ragilap
2025-12-09 15:16:01 +07:00
parent 7094d90034
commit 0fbf04fc1d
18 changed files with 681 additions and 395 deletions
@@ -222,6 +222,14 @@ func (s *deliveryOrdersService) CreateOne(c *fiber.Ctx, req *validation.Create)
return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("Marketing product %d not found for this marketing", requestedProduct.MarketingProductId))
}
if err := commonSvc.EnsureProjectFlockNotClosedForProductWarehouses(
c.Context(),
dbTransaction,
[]uint{foundMarketingProduct.ProductWarehouseId},
); err != nil {
return err
}
deliveryProduct, err := marketingDeliveryProductRepositoryTx.GetByMarketingProductID(c.Context(), foundMarketingProduct.Id)
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
@@ -319,6 +327,13 @@ func (s deliveryOrdersService) UpdateOne(c *fiber.Ctx, req *validation.Update, i
if foundMarketingProduct == nil {
return fiber.NewError(fiber.StatusNotFound, fmt.Sprintf("Marketing product %d not found for this marketing", requestedProduct.MarketingProductId))
}
if err := commonSvc.EnsureProjectFlockNotClosedForProductWarehouses(
c.Context(),
dbTransaction,
[]uint{foundMarketingProduct.ProductWarehouseId},
); err != nil {
return err
}
deliveryProduct, err := marketingDeliveryProductRepositoryTx.GetByMarketingProductID(c.Context(), foundMarketingProduct.Id)
if err != nil {