mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix: AR/AP aging summary report.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
ISaleInvoice,
|
||||
IARAgingSummaryData,
|
||||
IARAgingSummaryColumns,
|
||||
IARAgingSummaryTotal,
|
||||
} from 'interfaces';
|
||||
import AgingSummaryReport from './AgingSummary';
|
||||
import { Dictionary } from 'tsyringe/dist/typings/types';
|
||||
@@ -44,8 +45,14 @@ export default class ARAgingSummarySheet extends AgingSummaryReport {
|
||||
this.baseCurrency = baseCurrency;
|
||||
this.numberFormat = this.query.numberFormat;
|
||||
|
||||
this.overdueInvoicesByContactId = groupBy(overdueSaleInvoices, 'customerId');
|
||||
this.currentInvoicesByContactId = groupBy(currentSaleInvoices, 'customerId');
|
||||
this.overdueInvoicesByContactId = groupBy(
|
||||
overdueSaleInvoices,
|
||||
'customerId'
|
||||
);
|
||||
this.currentInvoicesByContactId = groupBy(
|
||||
currentSaleInvoices,
|
||||
'customerId'
|
||||
);
|
||||
|
||||
// Initializes the aging periods.
|
||||
this.agingPeriods = this.agingRangePeriods(
|
||||
@@ -84,27 +91,41 @@ export default class ARAgingSummarySheet extends AgingSummaryReport {
|
||||
.map((customer) => this.customerData(customer))
|
||||
.filter(
|
||||
(customer: IARAgingSummaryCustomer) =>
|
||||
!(customer.total.total === 0 && this.query.noneZero)
|
||||
!(customer.total.amount === 0 && this.query.noneZero)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the customers aging and current total.
|
||||
* @param {IARAgingSummaryCustomer} customersAgingPeriods
|
||||
*/
|
||||
private getCustomersTotal(
|
||||
customersAgingPeriods: IARAgingSummaryCustomer[]
|
||||
): IARAgingSummaryTotal {
|
||||
const totalAgingPeriods = this.getTotalAgingPeriods(customersAgingPeriods);
|
||||
const totalCurrent = this.getTotalCurrent(customersAgingPeriods);
|
||||
const totalCustomersTotal = this.getTotalContactsTotals(
|
||||
customersAgingPeriods
|
||||
);
|
||||
|
||||
return {
|
||||
current: this.formatTotalAmount(totalCurrent),
|
||||
aging: totalAgingPeriods,
|
||||
total: this.formatTotalAmount(totalCustomersTotal),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve A/R aging summary report data.
|
||||
* @return {IARAgingSummaryData}
|
||||
*/
|
||||
public reportData(): IARAgingSummaryData {
|
||||
const customersAgingPeriods = this.customersWalker(this.contacts);
|
||||
const totalAgingPeriods = this.getTotalAgingPeriods(customersAgingPeriods);
|
||||
const totalCurrent = this.getTotalCurrent(customersAgingPeriods);
|
||||
const totalCustomersTotal = this.getTotalContactsTotals(customersAgingPeriods);
|
||||
const customersTotal = this.getCustomersTotal(customersAgingPeriods);
|
||||
|
||||
return {
|
||||
customers: customersAgingPeriods,
|
||||
total: {
|
||||
current: this.formatTotalAmount(totalCurrent),
|
||||
aging: totalAgingPeriods,
|
||||
total: this.formatTotalAmount(totalCustomersTotal),
|
||||
}
|
||||
total: customersTotal,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user