2
0
mirror of https://github.com/frappe/books.git synced 2025-01-24 23:58:27 +00:00
books/reports/generalLedger/GeneralLedger.js

25 lines
878 B
JavaScript
Raw Normal View History

2018-03-26 17:44:27 +05:30
const frappe = require('frappejs');
2018-03-27 19:22:59 +05:30
module.exports = function execute(params) {
return new GeneralLedger().run(params);
}
class GeneralLedger {
2018-03-26 17:44:27 +05:30
async run(params) {
const filters = {};
if (params.account) filters.account = params.account;
if (params.party) filters.party = params.party;
2018-03-27 19:22:59 +05:30
if (params.referenceType) filters.referenceType = params.referenceType;
if (params.referenceName) filters.referenceName = params.referenceName;
if (params.fromDate) filters.date = ['>=', params.fromDate];
if (params.toDate) filters.date = ['<=', params.toDate];
2018-03-26 17:44:27 +05:30
let data = await frappe.db.getAll({
doctype: 'AccountingLedgerEntry',
fields: ['date', 'account', 'party', 'referenceType', 'referenceName', 'debit', 'credit'],
filters: filters
});
return data;
}
}