Skip to content

Commit e4f6182

Browse files
authored
Merge pull request #485 from bigcapitalhq/BIG-186
fix: Closing balance in general ledger report does not sum the negative figures
2 parents 4d4ef54 + 1cbc1c0 commit e4f6182

File tree

10 files changed

+549
-196
lines changed

10 files changed

+549
-196
lines changed

packages/server/src/interfaces/GeneralLedgerSheet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export interface IGeneralLedgerSheetAccount {
5656
transactions: IGeneralLedgerSheetAccountTransaction[];
5757
openingBalance: IGeneralLedgerSheetAccountBalance;
5858
closingBalance: IGeneralLedgerSheetAccountBalance;
59+
closingBalanceSubaccounts?: IGeneralLedgerSheetAccountBalance;
60+
children?: IGeneralLedgerSheetAccount[];
5961
}
6062

6163
export type IGeneralLedgerSheetData = IGeneralLedgerSheetAccount[];

packages/server/src/services/Accounting/Ledger.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class Ledger implements ILedger {
5151

5252
/**
5353
* Filters entries by the given accounts ids then returns a new ledger.
54-
* @param {number[]} accountIds
54+
* @param {number[]} accountIds
5555
* @returns {ILedger}
5656
*/
5757
public whereAccountsIds(accountIds: number[]): ILedger {
@@ -274,4 +274,14 @@ export default class Ledger implements ILedger {
274274
const entries = Ledger.mappingTransactions(transactions);
275275
return new Ledger(entries);
276276
}
277+
278+
/**
279+
* Retrieve the transaction amount.
280+
* @param {number} credit - Credit amount.
281+
* @param {number} debit - Debit amount.
282+
* @param {string} normal - Credit or debit.
283+
*/
284+
static getAmount(credit: number, debit: number, normal: string) {
285+
return normal === 'credit' ? credit - debit : debit - credit;
286+
}
277287
}

packages/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetAggregators.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import * as R from 'ramda';
2-
import { FinancialPreviousPeriod } from '../FinancialPreviousPeriod';
3-
import { FinancialHorizTotals } from '../FinancialHorizTotals';
42
import { FinancialSheetStructure } from '../FinancialSheetStructure';
53
import {
64
BALANCE_SHEET_SCHEMA_NODE_TYPE,

packages/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetRepository.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as R from 'ramda';
33
import { Knex } from 'knex';
44
import { isEmpty } from 'lodash';
55
import {
6-
IAccount,
76
IAccountTransactionsGroupBy,
87
IBalanceSheetQuery,
98
ILedger,
@@ -12,7 +11,6 @@ import { transformToMapBy } from 'utils';
1211
import Ledger from '@/services/Accounting/Ledger';
1312
import { BalanceSheetQuery } from './BalanceSheetQuery';
1413
import { FinancialDatePeriods } from '../FinancialDatePeriods';
15-
import { ACCOUNT_PARENT_TYPE, ACCOUNT_TYPE } from '@/data/AccountTypes';
1614
import { BalanceSheetRepositoryNetIncome } from './BalanceSheetRepositoryNetIncome';
1715

1816
@Service()

0 commit comments

Comments
 (0)