Skip to content

Commit

Permalink
Merge pull request #485 from bigcapitalhq/BIG-186
Browse files Browse the repository at this point in the history
fix: Closing balance in general ledger report does not sum the negative figures
  • Loading branch information
abouolia authored Jun 10, 2024
2 parents 4d4ef54 + 1cbc1c0 commit e4f6182
Show file tree
Hide file tree
Showing 10 changed files with 549 additions and 196 deletions.
2 changes: 2 additions & 0 deletions packages/server/src/interfaces/GeneralLedgerSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface IGeneralLedgerSheetAccount {
transactions: IGeneralLedgerSheetAccountTransaction[];
openingBalance: IGeneralLedgerSheetAccountBalance;
closingBalance: IGeneralLedgerSheetAccountBalance;
closingBalanceSubaccounts?: IGeneralLedgerSheetAccountBalance;
children?: IGeneralLedgerSheetAccount[];
}

export type IGeneralLedgerSheetData = IGeneralLedgerSheetAccount[];
Expand Down
12 changes: 11 additions & 1 deletion packages/server/src/services/Accounting/Ledger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as R from 'ramda';
import { FinancialPreviousPeriod } from '../FinancialPreviousPeriod';
import { FinancialHorizTotals } from '../FinancialHorizTotals';
import { FinancialSheetStructure } from '../FinancialSheetStructure';
import {
BALANCE_SHEET_SCHEMA_NODE_TYPE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as R from 'ramda';
import { Knex } from 'knex';
import { isEmpty } from 'lodash';
import {
IAccount,
IAccountTransactionsGroupBy,
IBalanceSheetQuery,
ILedger,
Expand All @@ -12,7 +11,6 @@ import { transformToMapBy } from 'utils';
import Ledger from '@/services/Accounting/Ledger';
import { BalanceSheetQuery } from './BalanceSheetQuery';
import { FinancialDatePeriods } from '../FinancialDatePeriods';
import { ACCOUNT_PARENT_TYPE, ACCOUNT_TYPE } from '@/data/AccountTypes';
import { BalanceSheetRepositoryNetIncome } from './BalanceSheetRepositoryNetIncome';

@Service()
Expand Down
Loading

0 comments on commit e4f6182

Please sign in to comment.