Skip to content

Commit

Permalink
Update - Ajout de validation supplémentaire sur le processing des tra…
Browse files Browse the repository at this point in the history
…nsfert consommateur vers producteurs et sur les remboursements consommateurs
  • Loading branch information
noelmugnier committed Nov 7, 2020
1 parent cb0dcf0 commit 4bc100f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public async Task<Result<Guid>> Handle(CreatePayinRefundCommand request, Cancell
if (order.Payin.Status != TransactionStatus.Succeeded)
return BadRequest<Guid>(MessageKind.PayinRefund_CannotCreate_PurchaseOrderRefund_Payin_Invalid_Status);
if(order.Payin.Refunds.Any(c => c.PurchaseOrder.Id == purchaseOrder.Id && c.Status != TransactionStatus.Failed))
if (order.Payin.Refunds.Any(c => c.PurchaseOrder.Id == purchaseOrder.Id && c.Status == TransactionStatus.Succeeded))
return BadRequest<Guid>(MessageKind.PayinRefund_CannotCreate_PurchaseOrderRefund_PayinRefund_AlreadyProcessed);
if (order.Payin.Refunds.Any(c => c.PurchaseOrder.Id == purchaseOrder.Id && c.Status != TransactionStatus.Failed))
return BadRequest<Guid>(MessageKind.PayinRefund_CannotCreate_PurchaseOrderRefund_Pending_PayinRefund);
using (var transaction = await _context.BeginTransactionAsync(token))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ public async Task<Result<Guid>> Handle(CreateTransferCommand request, Cancellati
if (purchaseOrder.Status != PurchaseOrderStatus.Delivered)
return BadRequest<Guid>(MessageKind.Transfer_CannotCreate_PurchaseOrder_Invalid_Status);
if(purchaseOrder.Transfer != null && purchaseOrder.Transfer.Status != TransactionStatus.Failed)
if (purchaseOrder.Transfer != null && purchaseOrder.Transfer.Status == TransactionStatus.Succeeded)
return BadRequest<Guid>(MessageKind.Transfer_CannotCreate_AlreadyProcessed);
if (purchaseOrder.Transfer != null && purchaseOrder.Transfer.Status != TransactionStatus.Failed)
return BadRequest<Guid>(MessageKind.Transfer_CannotCreate_Pending_Transfer);
var checkResult = await _mediatr.Process(new CheckProducerConfigurationCommand(request.RequestUser) { ProducerId = purchaseOrder.Vendor.Id }, token);
Expand Down
2 changes: 2 additions & 0 deletions Sheaft.Exceptions/Enums/MessageKind.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public enum MessageKind
Transfer = 30000,
Transfer_CannotCreate_PurchaseOrder_Invalid_Status = 30101,
Transfer_CannotCreate_Pending_Transfer = 30102,
Transfer_CannotCreate_AlreadyProcessed = 30103,
Payout = 31000,
Ubo = 32000,
Wallet = 33000,
Expand All @@ -170,6 +171,7 @@ public enum MessageKind
PayinRefund_CannotCreate_Payin_PurchaseOrder_Invalid_Status = 35101,
PayinRefund_CannotCreate_PurchaseOrderRefund_Payin_Invalid_Status = 35102,
PayinRefund_CannotCreate_PurchaseOrderRefund_Pending_PayinRefund = 35103,
PayinRefund_CannotCreate_PurchaseOrderRefund_PayinRefund_AlreadyProcessed = 35104,
BankAccount = 36000,
Country = 37000,
Declaration = 38000,
Expand Down
18 changes: 18 additions & 0 deletions Sheaft.Localization/Resources/MessageResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Sheaft.Localization/Resources/MessageResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -864,4 +864,10 @@
<data name="Legal_Cannot_Unrequire_Declaration" xml:space="preserve">
<value>Il n'est pas possible de basculer la déclaration en non requise</value>
</data>
<data name="Transfer_CannotCreate_AlreadyProcessed" xml:space="preserve">
<value>Impossible de créer un transfert, un transfert a déjà été effectué</value>
</data>
<data name="PayinRefund_CannotCreate_PurchaseOrderRefund_PayinRefund_AlreadyProcessed" xml:space="preserve">
<value>Impossible de créer un remboursement pour la commande, un remboursement est a déjà été effectué</value>
</data>
</root>

0 comments on commit 4bc100f

Please sign in to comment.