mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix(BalanceSheet): calculate the section total.
fix(MakeJournal): write transaction number and reference.
This commit is contained in:
@@ -7,6 +7,7 @@ export interface IManualJournal {
|
|||||||
date: Date | string;
|
date: Date | string;
|
||||||
journalNumber: number;
|
journalNumber: number;
|
||||||
journalType: string;
|
journalType: string;
|
||||||
|
reference: string;
|
||||||
amount: number;
|
amount: number;
|
||||||
publishedAt: Date | null;
|
publishedAt: Date | null;
|
||||||
description: string;
|
description: string;
|
||||||
|
|||||||
@@ -286,8 +286,13 @@ export default class JournalCommands {
|
|||||||
* @param {number} manualJournalId
|
* @param {number} manualJournalId
|
||||||
*/
|
*/
|
||||||
async manualJournal(manualJournalObj: IManualJournal) {
|
async manualJournal(manualJournalObj: IManualJournal) {
|
||||||
|
const commonEntry = {
|
||||||
|
transaction_number: manualJournalObj.journalNumber,
|
||||||
|
reference_number: manualJournalObj.reference,
|
||||||
|
};
|
||||||
manualJournalObj.entries.forEach((entry: IManualJournalEntry) => {
|
manualJournalObj.entries.forEach((entry: IManualJournalEntry) => {
|
||||||
const jouranlEntry = new JournalEntry({
|
const jouranlEntry = new JournalEntry({
|
||||||
|
...commonEntry,
|
||||||
debit: entry.debit,
|
debit: entry.debit,
|
||||||
credit: entry.credit,
|
credit: entry.credit,
|
||||||
account: entry.accountId,
|
account: entry.accountId,
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
|||||||
): IBalanceSheetAccountTotal[] {
|
): IBalanceSheetAccountTotal[] {
|
||||||
return this.dateRangeSet.map((date, index) => {
|
return this.dateRangeSet.map((date, index) => {
|
||||||
const amount = sumBy(accounts, `totalPeriods[${index}].amount`);
|
const amount = sumBy(accounts, `totalPeriods[${index}].amount`);
|
||||||
const formattedAmount = this.formatNumber(amount)
|
const formattedAmount = this.formatNumber(amount);
|
||||||
const currencyCode = this.baseCurrency;
|
const currencyCode = this.baseCurrency;
|
||||||
|
|
||||||
return { date, amount, formattedAmount, currencyCode };
|
return { date, amount, formattedAmount, currencyCode };
|
||||||
@@ -198,14 +198,15 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
|||||||
!(section.total.amount === 0 && this.query.noneZero)
|
!(section.total.amount === 0 && this.query.noneZero)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Gets total amount of the given accounts.
|
const children = flatToNestedArray(filteredAccounts, {
|
||||||
const totalAmount = sumBy(filteredAccounts, 'total.amount');
|
|
||||||
|
|
||||||
return {
|
|
||||||
children: flatToNestedArray(filteredAccounts, {
|
|
||||||
id: 'id',
|
id: 'id',
|
||||||
parentId: 'parentAccountId',
|
parentId: 'parentAccountId',
|
||||||
}),
|
});
|
||||||
|
// Gets total amount of the given accounts.
|
||||||
|
const totalAmount = sumBy(children, 'total.amount');
|
||||||
|
|
||||||
|
return {
|
||||||
|
children,
|
||||||
total: {
|
total: {
|
||||||
amount: totalAmount,
|
amount: totalAmount,
|
||||||
formattedAmount: this.formatTotalNumber(totalAmount),
|
formattedAmount: this.formatTotalNumber(totalAmount),
|
||||||
@@ -250,17 +251,14 @@ export default class BalanceSheetStatement extends FinancialSheet {
|
|||||||
*/
|
*/
|
||||||
private balanceSheetStructureMapper(
|
private balanceSheetStructureMapper(
|
||||||
structure: IBalanceSheetStructureSection,
|
structure: IBalanceSheetStructureSection,
|
||||||
accounts: IAccount & { type: IAccountType }[],
|
accounts: IAccount & { type: IAccountType }[]
|
||||||
): IBalanceSheetSection {
|
): IBalanceSheetSection {
|
||||||
const result = {
|
const result = {
|
||||||
name: structure.name,
|
name: structure.name,
|
||||||
sectionType: structure.sectionType,
|
sectionType: structure.sectionType,
|
||||||
type: structure.type,
|
type: structure.type,
|
||||||
...(structure.type === 'accounts_section'
|
...(structure.type === 'accounts_section'
|
||||||
? this.structureRelatedAccountsMapper(
|
? this.structureRelatedAccountsMapper(structure.accountsTypes, accounts)
|
||||||
structure.accountsTypes,
|
|
||||||
accounts
|
|
||||||
)
|
|
||||||
: this.structureSectionMapper(structure, accounts)),
|
: this.structureSectionMapper(structure, accounts)),
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user