2
0
mirror of https://github.com/frappe/books.git synced 2025-01-22 22:58:28 +00:00
books/reports/TrialBalance/TrialBalance.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
616 B
JavaScript
Raw Normal View History

import { getTrialBalance } from '../helpers/financialStatements';
2018-04-27 17:03:36 +05:30
export default class TrialBalance {
async run({ fromDate, toDate }) {
2019-08-14 13:13:49 +05:30
if (!fromDate && !toDate) {
return { rows: [] };
}
const promises = ['Asset', 'Expense', 'Income', 'Liability', 'Equity'].map(
(rootType) => {
return getTrialBalance({ rootType, fromDate, toDate });
}
);
2018-04-27 17:03:36 +05:30
const values = await Promise.all(promises);
let rows = values.reduce((acc, curr) => {
return [...acc, ...curr];
}, []);
2018-04-27 17:03:36 +05:30
rows = rows.filter((r) => r.debit !== 0 || r.credit !== 0);
return { rows };
}
}