mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
feat: select customers/vendors in AR/AP summary aging report.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import moment from 'moment';
|
||||
import { Inject, Service } from 'typedi';
|
||||
import { IAPAgingSummaryQuery } from 'interfaces';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
import APAgingSummarySheet from './APAgingSummarySheet';
|
||||
|
||||
@@ -25,27 +26,26 @@ export default class PayableAgingSummaryService {
|
||||
},
|
||||
vendorsIds: [],
|
||||
noneZero: false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number} tenantId
|
||||
* @param query
|
||||
* Retrieve A/P aging summary report.
|
||||
* @param {number} tenantId -
|
||||
* @param {IAPAgingSummaryQuery} query -
|
||||
*/
|
||||
async APAgingSummary(tenantId: number, query) {
|
||||
const {
|
||||
vendorRepository,
|
||||
billRepository
|
||||
} = this.tenancy.repositories(tenantId);
|
||||
const { Bill } = this.tenancy.models(tenantId);
|
||||
async APAgingSummary(tenantId: number, query: IAPAgingSummaryQuery) {
|
||||
const { vendorRepository, billRepository } = this.tenancy.repositories(
|
||||
tenantId
|
||||
);
|
||||
|
||||
const filter = {
|
||||
...this.defaultQuery,
|
||||
...query,
|
||||
};
|
||||
this.logger.info('[AR_Aging_Summary] trying to prepairing the report.', {
|
||||
tenantId, filter,
|
||||
tenantId,
|
||||
filter,
|
||||
});
|
||||
// Settings tenant service.
|
||||
const settings = this.tenancy.settings(tenantId);
|
||||
@@ -54,12 +54,15 @@ export default class PayableAgingSummaryService {
|
||||
key: 'base_currency',
|
||||
});
|
||||
// Retrieve all vendors from the storage.
|
||||
const vendors = await vendorRepository.all();
|
||||
const vendors =
|
||||
filter.vendorsIds.length > 0
|
||||
? await vendorRepository.findWhereIn('id', filter.vendorsIds)
|
||||
: await vendorRepository.all();
|
||||
|
||||
// Retrieve all overdue vendors bills.
|
||||
const overdueBills = await billRepository.overdueBills(
|
||||
filter.asDate,
|
||||
);
|
||||
const overdueBills = await billRepository.overdueBills(filter.asDate);
|
||||
|
||||
// Retrieve all due vendors bills.
|
||||
const dueBills = await billRepository.dueBills(filter.asDate);
|
||||
|
||||
// A/P aging summary report instance.
|
||||
@@ -69,7 +72,7 @@ export default class PayableAgingSummaryService {
|
||||
vendors,
|
||||
overdueBills,
|
||||
dueBills,
|
||||
baseCurrency,
|
||||
baseCurrency
|
||||
);
|
||||
// A/P aging summary report data and columns.
|
||||
const data = APAgingSummaryReport.reportData();
|
||||
@@ -77,4 +80,4 @@ export default class PayableAgingSummaryService {
|
||||
|
||||
return { data, columns, query: filter };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Inject, Service } from 'typedi';
|
||||
import { IARAgingSummaryQuery } from 'interfaces';
|
||||
import TenancyService from 'services/Tenancy/TenancyService';
|
||||
import ARAgingSummarySheet from './ARAgingSummarySheet';
|
||||
import SaleInvoiceRepository from 'repositories/SaleInvoiceRepository';
|
||||
|
||||
@Service()
|
||||
export default class ARAgingSummaryService {
|
||||
@@ -31,9 +30,9 @@ export default class ARAgingSummaryService {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {number} tenantId
|
||||
* @param query
|
||||
* Retrieve A/R aging summary report.
|
||||
* @param {number} tenantId - Tenant id.
|
||||
* @param {IARAgingSummaryQuery} query -
|
||||
*/
|
||||
async ARAgingSummary(tenantId: number, query: IARAgingSummaryQuery) {
|
||||
const {
|
||||
@@ -56,7 +55,10 @@ export default class ARAgingSummaryService {
|
||||
key: 'base_currency',
|
||||
});
|
||||
// Retrieve all customers from the storage.
|
||||
const customers = await customerRepository.all();
|
||||
const customers =
|
||||
filter.customersIds.length > 0
|
||||
? await customerRepository.findWhereIn('id', filter.customersIds)
|
||||
: await customerRepository.all();
|
||||
|
||||
// Retrieve all overdue sale invoices.
|
||||
const overdueSaleInvoices = await saleInvoiceRepository.overdueInvoices(
|
||||
|
||||
Reference in New Issue
Block a user