2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/reports/TrialBalance/TrialBalance.js
thefalconx33 e4c2bd3dda * New Account defaults & filters based on rootType
* Trial Balance: Parent accounts assumes child data
* Trial Balance: Tree View
2019-07-18 16:15:44 +05:30

23 lines
605 B
JavaScript

const frappe = require('frappejs');
const {
getTrialBalance
} = require('../FinancialStatements/FinancialStatements');
module.exports = class TrialBalance {
async run({ fromDate, toDate }) {
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 };
}
};