mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
fix: Trial balance sheet adjusted balance (#273)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import moment from 'moment';
|
||||
import { defaultTo, uniqBy } from 'lodash';
|
||||
import { defaultTo, sumBy, uniqBy } from 'lodash';
|
||||
import { IAccountTransaction, ILedger, ILedgerEntry } from '@/interfaces';
|
||||
|
||||
export default class Ledger implements ILedger {
|
||||
@@ -49,6 +49,15 @@ export default class Ledger implements ILedger {
|
||||
return this.filter((entry) => entry.accountId === accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters entries by the given accounts ids then returns a new ledger.
|
||||
* @param {number[]} accountsIds - Accounts ids.
|
||||
* @returns {ILedger}
|
||||
*/
|
||||
public whereAccountsIds(accountsIds: number[]): ILedger {
|
||||
return this.filter((entry) => accountsIds.indexOf(entry.accountId) !== -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters entries that before or same the given date and returns a new ledger.
|
||||
* @param {Date|string} fromDate
|
||||
@@ -130,6 +139,22 @@ export default class Ledger implements ILedger {
|
||||
return closingBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the closing credit of the entries.
|
||||
* @returns {number}
|
||||
*/
|
||||
public getClosingCredit(): number {
|
||||
return sumBy(this.entries, 'credit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the closing debit of the entries.
|
||||
* @returns {number}
|
||||
*/
|
||||
public getClosingDebit(): number {
|
||||
return sumBy(this.entries, 'debit');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the closing balance of the entries.
|
||||
* @returns {number}
|
||||
|
||||
Reference in New Issue
Block a user