mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 05:21:57 +00:00
fix status marketing when edit sales order and edit marketing delivery
This commit is contained in:
@@ -542,9 +542,15 @@ func (s deliveryOrdersService) UpdateOne(c *fiber.Ctx, req *validation.DeliveryO
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
latestApproval, err := s.ApprovalSvc.LatestByTarget(c.Context(), utils.ApprovalWorkflowMarketing, id, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fiber.NewError(fiber.StatusInternalServerError, "Failed to check approval status")
|
||||||
|
}
|
||||||
|
|
||||||
err = s.MarketingRepo.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
err = s.MarketingRepo.DB().WithContext(c.Context()).Transaction(func(dbTransaction *gorm.DB) error {
|
||||||
marketingProductRepositoryTx := marketingRepo.NewMarketingProductRepository(dbTransaction)
|
marketingProductRepositoryTx := marketingRepo.NewMarketingProductRepository(dbTransaction)
|
||||||
marketingDeliveryProductRepositoryTx := marketingRepo.NewMarketingDeliveryProductRepository(dbTransaction)
|
marketingDeliveryProductRepositoryTx := marketingRepo.NewMarketingDeliveryProductRepository(dbTransaction)
|
||||||
|
approvalSvcTx := commonSvc.NewApprovalService(commonRepo.NewApprovalRepository(dbTransaction))
|
||||||
marketingRepoTx := marketingRepo.NewMarketingRepository(dbTransaction)
|
marketingRepoTx := marketingRepo.NewMarketingRepository(dbTransaction)
|
||||||
|
|
||||||
marketing, err := marketingRepoTx.GetByID(c.Context(), id, nil)
|
marketing, err := marketingRepoTx.GetByID(c.Context(), id, nil)
|
||||||
@@ -630,6 +636,23 @@ func (s deliveryOrdersService) UpdateOne(c *fiber.Ctx, req *validation.DeliveryO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if latestApproval != nil && latestApproval.StepNumber == uint16(utils.MarketingDeliveryOrder) {
|
||||||
|
action := entity.ApprovalActionUpdated
|
||||||
|
_, err := approvalSvcTx.CreateApproval(
|
||||||
|
c.Context(),
|
||||||
|
utils.ApprovalWorkflowMarketing,
|
||||||
|
id,
|
||||||
|
utils.MarketingStepSalesOrder,
|
||||||
|
&action,
|
||||||
|
actorID,
|
||||||
|
nil)
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, gorm.ErrDuplicatedKey) {
|
||||||
|
return fiber.NewError(fiber.StatusInternalServerError, "Failed to reset approval to Sales Order")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ func (s salesOrdersService) UpdateOne(c *fiber.Ctx, req *validation.Update, id u
|
|||||||
c.Context(),
|
c.Context(),
|
||||||
utils.ApprovalWorkflowMarketing,
|
utils.ApprovalWorkflowMarketing,
|
||||||
id,
|
id,
|
||||||
approvalutils.ApprovalStep(latestApproval.StepNumber),
|
utils.MarketingStepPengajuan,
|
||||||
&action,
|
&action,
|
||||||
actorID,
|
actorID,
|
||||||
nil)
|
nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user