For transactions such as Bill Credit, Credit Memo, Customer Deposit, and Payment, we utilize the “transaction.amountremainingbasecurrency” attribute. However, for all other transaction types, we rely on the “transaction.foreignamountunpaid” attribute to determine the remaining balance.