Fix allocations (#101)

This commit is contained in:
ndiezel0 2023-10-26 11:36:41 +05:00 committed by GitHub
parent 2a869217ac
commit 30e14fec09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -994,13 +994,13 @@ capture(St, Reason, Cost, Cart, AllocationPrototype, Opts) ->
VS = collect_validation_varset(St, Opts),
MerchantTerms = get_merchant_payments_terms(Opts, Revision, Timestamp, VS),
CaptureCost = genlib:define(Cost, get_payment_cost(Payment)),
#domain_Invoice{allocation = Allocation} = get_invoice(Opts),
Allocation = genlib:define(maybe_allocation(AllocationPrototype, CaptureCost, MerchantTerms, Opts), Allocation),
#domain_Invoice{allocation = Allocation0} = get_invoice(Opts),
Allocation1 = genlib:define(maybe_allocation(AllocationPrototype, CaptureCost, MerchantTerms, Opts), Allocation0),
case check_equal_capture_cost_amount(Cost, Payment) of
true ->
total_capture(St, Reason, Cart, Allocation);
total_capture(St, Reason, Cart, Allocation1);
false ->
partial_capture(St, Reason, Cost, Cart, Opts, MerchantTerms, Timestamp, Allocation)
partial_capture(St, Reason, Cost, Cart, Opts, MerchantTerms, Timestamp, Allocation1)
end.
maybe_allocation(undefined, _Cost, _MerchantTerms, _Opts) ->