feat: general ledger sub-accounts

This commit is contained in:
Ahmed Bouhuolia
2024-06-05 21:45:01 +02:00
parent 6afe1a09c6
commit 044f11ff74
5 changed files with 249 additions and 78 deletions

View File

@@ -51,7 +51,7 @@ export default class Ledger implements ILedger {
/**
* Filters entries by the given accounts ids then returns a new ledger.
* @param {number[]} accountIds
* @param {number[]} accountIds
* @returns {ILedger}
*/
public whereAccountsIds(accountIds: number[]): ILedger {
@@ -274,4 +274,14 @@ export default class Ledger implements ILedger {
const entries = Ledger.mappingTransactions(transactions);
return new Ledger(entries);
}
/**
* Retrieve the transaction amount.
* @param {number} credit - Credit amount.
* @param {number} debit - Debit amount.
* @param {string} normal - Credit or debit.
*/
static getAmount(credit: number, debit: number, normal: string) {
return normal === 'credit' ? credit - debit : debit - credit;
}
}