2018-03-26 12:14:27 +00:00
|
|
|
const frappe = require('frappejs');
|
|
|
|
|
2018-03-27 13:52:59 +00:00
|
|
|
class GeneralLedger {
|
2018-07-14 14:28:41 +00:00
|
|
|
async run(params) {
|
|
|
|
const filters = {};
|
|
|
|
if (params.account) filters.account = params.account;
|
|
|
|
if (params.party) filters.party = params.party;
|
|
|
|
if (params.referenceType) filters.referenceType = params.referenceType;
|
|
|
|
if (params.referenceName) filters.referenceName = params.referenceName;
|
|
|
|
if (params.toDate || params.fromDate) {
|
|
|
|
filters.date = [];
|
|
|
|
if (params.toDate) filters.date.push('<=', params.toDate);
|
|
|
|
if (params.fromDate) filters.date.push('>=', params.fromDate);
|
|
|
|
}
|
|
|
|
let data = await frappe.db.getAll({
|
|
|
|
doctype: 'AccountingLedgerEntry',
|
|
|
|
fields: ['date', 'account', 'party', 'referenceType', 'referenceName', 'debit', 'credit'],
|
|
|
|
filters: filters
|
|
|
|
});
|
2018-03-26 12:14:27 +00:00
|
|
|
|
2018-07-14 14:28:41 +00:00
|
|
|
return data;
|
|
|
|
}
|
2018-04-18 09:02:05 +00:00
|
|
|
}
|
|
|
|
|
2018-04-26 10:23:27 +00:00
|
|
|
module.exports = GeneralLedger;
|