2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00
books/reports/TrialBalance/TrialBalance.js

24 lines
656 B
JavaScript
Raw Normal View History

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