mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
fix: accounts types with new design.
This commit is contained in:
@@ -184,7 +184,7 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
||||
const filteredAccounts = accounts
|
||||
// Filter accounts that associated to the section accounts types.
|
||||
.filter(
|
||||
(account) => sectionAccountsTypes.indexOf(account.type.key) !== -1
|
||||
(account) => sectionAccountsTypes.indexOf(account.accountType) !== -1
|
||||
)
|
||||
.map((account) => this.balanceSheetAccountMapper(account))
|
||||
// Filter accounts that have no transaction when `noneTransactions` is on.
|
||||
|
||||
@@ -70,7 +70,7 @@ export default class BalanceSheetStatementService
|
||||
this.logger.info('[balance_sheet] trying to calculate the report.', { filter, tenantId });
|
||||
|
||||
// Retrieve all accounts on the storage.
|
||||
const accounts = await accountRepository.all('type');
|
||||
const accounts = await accountRepository.all();
|
||||
const accountsGraph = await accountRepository.getDependencyGraph();
|
||||
|
||||
// Retrieve all journal transactions based on the given query.
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
IGeneralLedgerSheetAccountTransaction,
|
||||
IAccount,
|
||||
IJournalPoster,
|
||||
IAccountType,
|
||||
IJournalEntry,
|
||||
IContact,
|
||||
} from 'interfaces';
|
||||
@@ -130,7 +129,7 @@ export default class GeneralLedgerSheet extends FinancialSheet {
|
||||
* @return {IGeneralLedgerSheetAccountTransaction[]}
|
||||
*/
|
||||
private accountTransactionsMapper(
|
||||
account: IAccount & { type: IAccountType },
|
||||
account: IAccount,
|
||||
openingBalance: number
|
||||
): IGeneralLedgerSheetAccountTransaction[] {
|
||||
const entries = this.transactions.getAccountEntries(account.id);
|
||||
@@ -184,7 +183,7 @@ export default class GeneralLedgerSheet extends FinancialSheet {
|
||||
* @return {IGeneralLedgerSheetAccount}
|
||||
*/
|
||||
private accountMapper(
|
||||
account: IAccount & { type: IAccountType }
|
||||
account: IAccount
|
||||
): IGeneralLedgerSheetAccount {
|
||||
const openingBalance = this.accountOpeningBalance(account);
|
||||
const closingBalance = this.accountClosingBalance(account);
|
||||
@@ -210,11 +209,11 @@ export default class GeneralLedgerSheet extends FinancialSheet {
|
||||
* @return {IGeneralLedgerSheetAccount[]}
|
||||
*/
|
||||
private accountsWalker(
|
||||
accounts: IAccount & { type: IAccountType }[]
|
||||
accounts: IAccount[]
|
||||
): IGeneralLedgerSheetAccount[] {
|
||||
return (
|
||||
accounts
|
||||
.map((account: IAccount & { type: IAccountType }) =>
|
||||
.map((account: IAccount) =>
|
||||
this.accountMapper(account)
|
||||
)
|
||||
// Filter general ledger accounts that have no transactions
|
||||
|
||||
@@ -89,7 +89,7 @@ export default class GeneralLedgerService {
|
||||
key: 'base_currency',
|
||||
});
|
||||
// Retrieve all accounts with associated type from the storage.
|
||||
const accounts = await accountRepository.all('type');
|
||||
const accounts = await accountRepository.all();
|
||||
const accountsGraph = await accountRepository.getDependencyGraph();
|
||||
|
||||
// Retrieve all contacts on the storage.
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
IProfitLossSheetTotalSection,
|
||||
} from 'interfaces';
|
||||
import { flatToNestedArray, dateRangeCollection } from 'utils';
|
||||
import { ACCOUNT_TYPE } from 'data/AccountTypes';
|
||||
|
||||
export default class ProfitLossSheet extends FinancialSheet {
|
||||
tenantId: number;
|
||||
@@ -51,7 +52,7 @@ export default class ProfitLossSheet extends FinancialSheet {
|
||||
}
|
||||
|
||||
get otherIncomeAccounts() {
|
||||
return this.accounts.filter((a) => a.type.key === 'other_income');
|
||||
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.OTHER_INCOME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +60,7 @@ export default class ProfitLossSheet extends FinancialSheet {
|
||||
* @return {IAccount & { type: IAccountType }[]}
|
||||
*/
|
||||
get incomeAccounts() {
|
||||
return this.accounts.filter((a) => a.type.key === 'income');
|
||||
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.INCOME);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,7 @@ export default class ProfitLossSheet extends FinancialSheet {
|
||||
* @return {IAccount & { type: IAccountType }[]}
|
||||
*/
|
||||
get expensesAccounts() {
|
||||
return this.accounts.filter((a) => a.type.key === 'expense');
|
||||
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.EXPENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ export default class ProfitLossSheet extends FinancialSheet {
|
||||
* @return {IAccount & { type: IAccountType }[]}}
|
||||
*/
|
||||
get otherExpensesAccounts() {
|
||||
return this.accounts.filter((a) => a.type.key === 'other_expense');
|
||||
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.OTHER_EXPENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +84,7 @@ export default class ProfitLossSheet extends FinancialSheet {
|
||||
* @return {IAccount & { type: IAccountType }[]}
|
||||
*/
|
||||
get costOfSalesAccounts() {
|
||||
return this.accounts.filter((a) => a.type.key === 'cost_of_goods_sold');
|
||||
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.COST_OF_GOODS_SOLD);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -77,7 +77,7 @@ export default class ProfitLossSheetService {
|
||||
key: 'base_currency',
|
||||
});
|
||||
// Retrieve all accounts on the storage.
|
||||
const accounts = await accountRepository.all('type');
|
||||
const accounts = await accountRepository.all();
|
||||
const accountsGraph = await accountRepository.getDependencyGraph();
|
||||
|
||||
// Retrieve all journal transactions based on the given query.
|
||||
|
||||
@@ -65,7 +65,7 @@ export default class TrialBalanceSheet extends FinancialSheet {
|
||||
parentAccountId: account.parentAccountId,
|
||||
name: account.name,
|
||||
code: account.code,
|
||||
accountNormal: account.type.normal,
|
||||
accountNormal: account.accountNormal,
|
||||
hasTransactions: entries.length > 0,
|
||||
|
||||
credit: trial.credit,
|
||||
|
||||
@@ -69,7 +69,7 @@ export default class TrialBalanceSheetService extends FinancialSheet {
|
||||
filter,
|
||||
});
|
||||
// Retrieve all accounts on the storage.
|
||||
const accounts = await accountRepository.all('type');
|
||||
const accounts = await accountRepository.all();
|
||||
const accountsGraph = await accountRepository.getDependencyGraph();
|
||||
|
||||
// Retrieve all journal transactions based on the given query.
|
||||
|
||||
Reference in New Issue
Block a user