This commit is contained in:
elforjani3
2021-03-24 16:14:23 +02:00
6 changed files with 50 additions and 14 deletions

View File

@@ -140,6 +140,14 @@ export const profitLossSheetReducer = (profitLoss) => {
], ],
}); });
} }
if (profitLoss.net_other_income) {
results.push({
name: 'Net other income',
total: profitLoss.net_other_income.total,
total_periods: profitLoss.net_other_income.total_periods,
rowTypes: ['net_other_income', 'section_total', 'total'],
});
}
if (profitLoss.net_income) { if (profitLoss.net_income) {
results.push({ results.push({
name: 'Net Income', name: 'Net Income',
@@ -209,6 +217,7 @@ export const generalLedgerTableRowsReducer = (accounts) => {
...account.opening_balance, ...account.opening_balance,
name: 'Opening balance', name: 'Opening balance',
rowType: 'OPENING_BALANCE', rowType: 'OPENING_BALANCE',
date: moment(account.opening_balance.date).format('DD MMM YYYY'),
}, },
...account.transactions.map((transaction) => ({ ...account.transactions.map((transaction) => ({
...transaction, ...transaction,
@@ -220,8 +229,11 @@ export const generalLedgerTableRowsReducer = (accounts) => {
...account.closing_balance, ...account.closing_balance,
name: 'Closing balance', name: 'Closing balance',
rowType: 'CLOSING_BALANCE', rowType: 'CLOSING_BALANCE',
date: moment(account.closing_balance.date).format('DD MMM YYYY'),
}, },
], ],
amount: account.closing_balance.amount,
formatted_amount: account.closing_balance.formatted_amount,
}; };
}) })
.value(); .value();

View File

@@ -36,7 +36,7 @@
.tr.is-expanded{ .tr.is-expanded{
.td.total, .td.total,
.td.total-period{ .td.total-period{
> span.cell-text{ .cell-text{
display: none; display: none;
} }
} }

View File

@@ -34,6 +34,18 @@
.tr:not(.no-results) .td{ .tr:not(.no-results) .td{
border-left: 1px solid #ececec; border-left: 1px solid #ececec;
} }
.tr{
&.is-expanded{
.td.amount{
.cell-inner{
display: none
}
}
}
}
.tr.row-type{ .tr.row-type{

View File

@@ -31,7 +31,7 @@
.tr.is-expanded{ .tr.is-expanded{
.td.total, .td.total,
.td.total-period{ .td.total-period{
> span{ .cell-text{
display: none; display: none;
} }
} }

View File

@@ -53,6 +53,7 @@ export interface IProfitLossSheetStatement {
otherIncome: IProfitLossSheetAccountsSection, otherIncome: IProfitLossSheetAccountsSection,
netIncome: IProfitLossSheetTotalSection; netIncome: IProfitLossSheetTotalSection;
operatingProfit: IProfitLossSheetTotalSection; operatingProfit: IProfitLossSheetTotalSection;
netOtherIncome: IProfitLossSheetTotalSection,
grossProfit: IProfitLossSheetTotalSection; grossProfit: IProfitLossSheetTotalSection;
}; };

View File

@@ -52,7 +52,9 @@ export default class ProfitLossSheet extends FinancialSheet {
} }
get otherIncomeAccounts() { get otherIncomeAccounts() {
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.OTHER_INCOME); return this.accounts.filter(
(a) => a.accountType === ACCOUNT_TYPE.OTHER_INCOME
);
} }
/** /**
@@ -76,7 +78,9 @@ export default class ProfitLossSheet extends FinancialSheet {
* @return {IAccount & { type: IAccountType }[]}} * @return {IAccount & { type: IAccountType }[]}}
*/ */
get otherExpensesAccounts() { get otherExpensesAccounts() {
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.OTHER_EXPENSE); return this.accounts.filter(
(a) => a.accountType === ACCOUNT_TYPE.OTHER_EXPENSE
);
} }
/** /**
@@ -84,7 +88,9 @@ export default class ProfitLossSheet extends FinancialSheet {
* @return {IAccount & { type: IAccountType }[]} * @return {IAccount & { type: IAccountType }[]}
*/ */
get costOfSalesAccounts() { get costOfSalesAccounts() {
return this.accounts.filter((a) => a.accountType === ACCOUNT_TYPE.COST_OF_GOODS_SOLD); return this.accounts.filter(
(a) => a.accountType === ACCOUNT_TYPE.COST_OF_GOODS_SOLD
);
} }
/** /**
@@ -244,8 +250,8 @@ export default class ProfitLossSheet extends FinancialSheet {
return { return {
name: 'Other Income', name: 'Other Income',
entryNormal: 'credit', entryNormal: 'credit',
...this.sectionMapper(this.otherIncomeAccounts) ...this.sectionMapper(this.otherIncomeAccounts),
} };
} }
/** /**
@@ -369,12 +375,16 @@ export default class ProfitLossSheet extends FinancialSheet {
const grossProfit = this.getSummarySection(income, costOfSales); const grossProfit = this.getSummarySection(income, costOfSales);
// - Operating profit = Gross profit - Expenses. // - Operating profit = Gross profit - Expenses.
const operatingProfit = this.getSummarySection(grossProfit, [ const operatingProfit = this.getSummarySection(grossProfit, expenses);
expenses,
costOfSales, // Net other income = Other income - other expenses.
]); const netOtherIncome = this.getSummarySection(otherIncome, otherExpenses);
// - Net income = Operating profit - Other expenses.
const netIncome = this.getSummarySection(operatingProfit, otherExpenses); // - Net income = (Operating profit + other income) - Other expenses.
const netIncome = this.getSummarySection(
[operatingProfit, netOtherIncome],
[],
);
return { return {
income, income,
@@ -383,8 +393,9 @@ export default class ProfitLossSheet extends FinancialSheet {
expenses, expenses,
otherIncome, otherIncome,
otherExpenses, otherExpenses,
netIncome,
operatingProfit, operatingProfit,
netOtherIncome,
netIncome,
}; };
} }