feat: format amount rows of financial statemnets.

This commit is contained in:
a.bouhuolia
2021-01-12 11:45:36 +02:00
parent 463c748717
commit 7680150a31
27 changed files with 392 additions and 208 deletions

View File

@@ -73,7 +73,7 @@ export default class BalanceSheetStatement extends FinancialSheet {
sections: IBalanceSheetSection[]
): IBalanceSheetAccountTotal {
const amount = sumBy(sections, 'total.amount');
const formattedAmount = this.formatNumber(amount);
const formattedAmount = this.formatTotalNumber(amount);
const currencyCode = this.baseCurrency;
return { amount, formattedAmount, currencyCode };
@@ -89,7 +89,25 @@ export default class BalanceSheetStatement extends FinancialSheet {
): IBalanceSheetAccountTotal[] {
return this.dateRangeSet.map((date, index) => {
const amount = sumBy(sections, `totalPeriods[${index}].amount`);
const formattedAmount = this.formatNumber(amount);
const formattedAmount = this.formatTotalNumber(amount);
const currencyCode = this.baseCurrency;
return { date, amount, formattedAmount, currencyCode };
});
}
/**
* Retrieve accounts total periods.
* @param {Array<IBalanceSheetAccount>} accounts -
* @return {IBalanceSheetAccountTotal[]}
*/
private getAccountsTotalPeriods(
accounts: Array<IBalanceSheetAccount>
): IBalanceSheetAccountTotal[] {
return this.dateRangeSet.map((date, index) => {
const amount = sumBy(accounts, `totalPeriods[${index}].amount`);
const formattedAmount = this.formatNumber(amount)
const currencyCode = this.baseCurrency;
return { date, amount, formattedAmount, currencyCode };
@@ -190,12 +208,12 @@ export default class BalanceSheetStatement extends FinancialSheet {
}),
total: {
amount: totalAmount,
formattedAmount: this.formatNumber(totalAmount),
formattedAmount: this.formatTotalNumber(totalAmount),
currencyCode: this.baseCurrency,
},
...(this.query.displayColumnsType === 'date_periods'
? {
totalPeriods: this.getSectionTotalPeriods(filteredAccounts),
totalPeriods: this.getAccountsTotalPeriods(filteredAccounts),
}
: {}),
};
@@ -232,7 +250,7 @@ export default class BalanceSheetStatement extends FinancialSheet {
*/
private balanceSheetStructureMapper(
structure: IBalanceSheetStructureSection,
accounts: IAccount & { type: IAccountType }[]
accounts: IAccount & { type: IAccountType }[],
): IBalanceSheetSection {
const result = {
name: structure.name,
@@ -276,14 +294,9 @@ export default class BalanceSheetStatement extends FinancialSheet {
}
)
// Mappes the balance sheet scetions only
.map(
([sheetSection, structure]: [
IBalanceSheetSection,
IBalanceSheetStructureSection
]) => {
return sheetSection;
}
)
.map(([sheetSection]: [IBalanceSheetSection]) => {
return sheetSection;
})
);
}

View File

@@ -29,8 +29,11 @@ export default class BalanceSheetStatementService
fromDate: moment().startOf('year').format('YYYY-MM-DD'),
toDate: moment().endOf('year').format('YYYY-MM-DD'),
numberFormat: {
noCents: false,
precision: 2,
divideOn1000: false,
showZero: false,
formatMoney: 'total',
negativeFormat: 'mines'
},
noneZero: false,
noneTransactions: false,