R31422-2 Payment Transaction - Convert Amounts

Code 31422-2
Entity Finance.Payments.PaymentTransactions Entity
Name ConvertAmounts
Attribute PaymentTransaction.TotalAmount,

PaymentTransactionLine.Amount
Layer Front-End
Events AttributeChanged(TotalAmountCurrency)
Priority Normal
Modify YES
Applicable Legislations ALL // no condition needed
Action if( oldTotalAmountCurrency != newTotalAmountCurrency AND CurrencyDirectory != null)

TotalAmount = new Amount(TotalAmount.Value, oldTotalAmountCurrency ).ConvertTo(newTotalAmountCurrency, CurrencyDirectory);

foreach (Lines) { line.Amount = new Amount(line.Amount.Value, oldTotalAmountCurrency).ConvertTo(newTotalAmountCurrency, CurrencyDirectory); }
Description When Total Amount Currency is changed, if the previous currency is different from the new currency, Total Amount should be converted from the old currency to the new currency and Amount in all lines should be converted, too.
Message
Version Introduced: 21



Revocable YES