UNPKG

@accounter/server

Version:
13 lines 669 B
import { LedgerError } from './utils.helper.js'; export function conversionFeeCalculator(base, quote, officialRate, defaultLocalCurrency) { if (base.currency === quote.currency) { throw new LedgerError('Conversion records must have different currencies'); } if (quote.currency === defaultLocalCurrency) { const baseAmount = (base.creditAmount1 ?? 0) / officialRate; const feeAmountByQuoteCurrency = quote.localCurrencyCreditAmount1 - baseAmount; return feeAmountByQuoteCurrency; } return quote.localCurrencyCreditAmount1 - base.localCurrencyCreditAmount1; } //# sourceMappingURL=conversion-charge-ledger.helper.js.map