draft: AR and AP aging summary report.

This commit is contained in:
a.bouhuolia
2021-01-07 13:48:45 +02:00
parent 7fa6822905
commit 22b2fd5918
17 changed files with 639 additions and 590 deletions

View File

@@ -30,8 +30,8 @@ export default class ARAgingSummaryReportController extends BaseController {
get validationSchema() {
return [
query('as_date').optional().isISO8601(),
query('aging_days_before').optional().isNumeric().toInt(),
query('aging_periods').optional().isNumeric().toInt(),
query('aging_days_before').optional().isInt({ max: 500 }).toInt(),
query('aging_periods').optional().isInt({ max: 12 }).toInt(),
query('number_format.no_cents').optional().isBoolean().toBoolean(),
query('number_format.1000_divide').optional().isBoolean().toBoolean(),
oneOf(
@@ -49,18 +49,31 @@ export default class ARAgingSummaryReportController extends BaseController {
* Retrieve receivable aging summary report.
*/
async receivableAgingSummary(req: Request, res: Response) {
const { tenantId } = req;
const { tenantId, settings } = req;
const filter = this.matchedQueryData(req);
const organizationName = settings.get({
group: 'organization',
key: 'name',
});
const baseCurrency = settings.get({
group: 'organization',
key: 'base_currency',
});
try {
const {
data,
columns
columns,
query,
} = await this.ARAgingSummaryService.ARAgingSummary(tenantId, filter);
return res.status(200).send({
organization_name: organizationName,
base_currency: baseCurrency,
data: this.transfromToResponse(data),
columns: this.transfromToResponse(columns),
query: this.transfromToResponse(query),
});
} catch (error) {
console.log(error);