2
0
mirror of https://github.com/frappe/books.git synced 2024-12-24 11:55:46 +00:00
books/reports/TrialBalance/TrialBalance.js
18alantom 1a8a23d2a2 build(electron): bump electron to 15.3.0
- refactor Common Js imports to ES6
2021-11-05 14:31:35 +05:30

24 lines
656 B
JavaScript

import frappe from 'frappejs';
import { getTrialBalance } from '../FinancialStatements/FinancialStatements';
export default class TrialBalance {
async run({ fromDate, toDate }) {
if (!fromDate && !toDate) {
return { rows: [] };
}
const promises = ['Asset', 'Expense', 'Income', 'Liability', 'Equity'].map(
rootType => {
return getTrialBalance({ rootType, fromDate, toDate });
}
);
const values = await Promise.all(promises);
let rows = values.reduce((acc, curr) => {
return [...acc, ...curr];
}, []);
rows = rows.filter(r => r.debit !== 0 || r.credit !== 0);
return { rows };
}
};