2018-04-27 11:33:36 +00:00
|
|
|
const frappe = require('frappejs');
|
2019-07-18 10:45:44 +00:00
|
|
|
const {
|
|
|
|
getTrialBalance
|
|
|
|
} = require('../FinancialStatements/FinancialStatements');
|
2018-04-27 11:33:36 +00:00
|
|
|
|
|
|
|
module.exports = class TrialBalance {
|
2019-07-18 10:45:44 +00:00
|
|
|
async run({ fromDate, toDate }) {
|
|
|
|
const promises = ['Asset', 'Expense', 'Income', 'Liability', 'Equity'].map(
|
|
|
|
rootType => {
|
|
|
|
return getTrialBalance({ rootType, fromDate, toDate });
|
|
|
|
}
|
|
|
|
);
|
2018-04-27 11:33:36 +00:00
|
|
|
|
2019-07-18 10:45:44 +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
|
|
|
|
2019-07-18 10:45:44 +00:00
|
|
|
rows = rows.filter(r => r.debit !== 0 || r.credit !== 0);
|
|
|
|
return { rows };
|
|
|
|
}
|
|
|
|
};
|