@@ -1481,7 +1481,13 @@ create_cash_flow_adjustment(Timestamp, Params, DomainRevision, St, Opts) ->
14811481 revision => NewRevision ,
14821482 allocation => Allocation
14831483 },
1484- NewCashFlow = calculate_cashflow (Context , Opts ),
1484+ NewCashFlow =
1485+ case Payment of
1486+ # domain_InvoicePayment {status = {failed , _ }} ->
1487+ [];
1488+ _ ->
1489+ calculate_cashflow (Context , Opts )
1490+ end ,
14851491 AdjState =
14861492 {cash_flow , # domain_InvoicePaymentAdjustmentCashFlowState {
14871493 scenario = # domain_InvoicePaymentAdjustmentCashFlow {domain_revision = DomainRevision }
@@ -1605,17 +1611,26 @@ get_cash_flow_for_target_status({captured, Captured}, St0, Opts) ->
16051611 Route = get_route (St0 ),
16061612 Cost = get_captured_cost (Captured , Payment0 ),
16071613 Allocation = get_captured_allocation (Captured ),
1608- Payment = Payment0 # domain_InvoicePayment {
1614+ Payment1 = Payment0 # domain_InvoicePayment {
16091615 cost = Cost
16101616 },
1611- Timestamp = get_payment_created_at (Payment ),
1612- St = St0 # st {payment = Payment },
1613- Revision = Payment # domain_InvoicePayment .domain_revision ,
1617+ Payment2 =
1618+ case Payment1 of
1619+ # domain_InvoicePayment {changed_cost = ChangedCost } when ChangedCost =/= undefined ->
1620+ Payment1 # domain_InvoicePayment {
1621+ cost = ChangedCost
1622+ };
1623+ _ ->
1624+ Payment1
1625+ end ,
1626+ Timestamp = get_payment_created_at (Payment2 ),
1627+ St = St0 # st {payment = Payment2 },
1628+ Revision = Payment2 # domain_InvoicePayment .domain_revision ,
16141629 VS = collect_validation_varset (St , Opts ),
16151630 Context = #{
16161631 provision_terms => get_provider_terminal_terms (Route , VS , Revision ),
16171632 route => Route ,
1618- payment => Payment ,
1633+ payment => Payment2 ,
16191634 timestamp => Timestamp ,
16201635 varset => VS ,
16211636 revision => Revision ,
@@ -2982,6 +2997,8 @@ get_invoice_shop_id(#domain_Invoice{shop_id = ShopID}) ->
29822997get_payment_id (# domain_InvoicePayment {id = ID }) ->
29832998 ID .
29842999
3000+ get_payment_cost (# domain_InvoicePayment {changed_cost = Cost }) when Cost =/= undefined ->
3001+ Cost ;
29853002get_payment_cost (# domain_InvoicePayment {cost = Cost }) ->
29863003 Cost .
29873004
0 commit comments