2
0
mirror of https://github.com/frappe/books.git synced 2025-01-24 15:48:25 +00:00
books/reports/index.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-04-19 20:01:35 +05:30
const frappe = require('frappejs');
const GeneralLedger = require('./GeneralLedger/GeneralLedger');
const ProfitAndLoss = require('./ProfitAndLoss/ProfitAndLoss');
const BalanceSheet = require('./BalanceSheet/BalanceSheet');
2018-04-27 17:03:36 +05:30
const TrialBalance = require('./TrialBalance/TrialBalance');
const SalesRegister = require('./SalesRegister/SalesRegister');
const PurchaseRegister = require('./PurchaseRegister/PurchaseRegister');
2018-04-29 14:37:59 +05:30
const AccountsReceivablePayable = require('./AccountsReceivablePayable/AccountsReceivablePayable');
2018-04-19 20:01:35 +05:30
// called on server side
function registerReportMethods() {
2018-04-29 14:37:59 +05:30
const reports = [
{
method: 'general-ledger',
class: GeneralLedger
},
{
method: 'profit-and-loss',
class: ProfitAndLoss
},
{
method: 'balance-sheet',
class: BalanceSheet
},
{
method: 'trial-balance',
class: TrialBalance
},
{
method: 'sales-register',
class: SalesRegister
},
{
method: 'purchase-register',
class: PurchaseRegister
2018-06-11 16:50:34 +05:30
}
2018-04-29 14:37:59 +05:30
];
reports.forEach(report => {
frappe.registerMethod({
method: report.method,
handler: getReportData(report.class)
});
2018-04-27 17:03:36 +05:30
});
frappe.registerMethod({
2018-04-29 14:37:59 +05:30
method: 'accounts-receivable',
handler: args => new AccountsReceivablePayable().run('Receivable', args)
});
frappe.registerMethod({
2018-04-29 14:37:59 +05:30
method: 'accounts-payable',
handler: args => new AccountsReceivablePayable().run('Payable', args)
});
2018-04-19 20:01:35 +05:30
}
function getReportData(ReportClass) {
return args => new ReportClass().run(args);
2018-04-19 20:01:35 +05:30
}
module.exports = registerReportMethods