2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 03:19:01 +00:00
books/reports/index.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-04-19 14:31:35 +00:00
const frappe = require('frappejs');
const GeneralLedger = require('./GeneralLedger/GeneralLedger');
const ProfitAndLoss = require('./ProfitAndLoss/ProfitAndLoss');
const BalanceSheet = require('./BalanceSheet/BalanceSheet');
2018-04-27 11:33:36 +00:00
const TrialBalance = require('./TrialBalance/TrialBalance');
const SalesRegister = require('./SalesRegister/SalesRegister');
const PurchaseRegister = require('./PurchaseRegister/PurchaseRegister');
2018-04-29 09:07:59 +00:00
const AccountsReceivablePayable = require('./AccountsReceivablePayable/AccountsReceivablePayable');
2018-04-19 14:31:35 +00:00
// called on server side
function registerReportMethods() {
2018-04-29 09:07:59 +00:00
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 11:20:34 +00:00
}
2018-04-29 09:07:59 +00:00
];
reports.forEach(report => {
frappe.registerMethod({
method: report.method,
handler: getReportData(report.class)
});
2018-04-27 11:33:36 +00:00
});
frappe.registerMethod({
2018-04-29 09:07:59 +00:00
method: 'accounts-receivable',
handler: args => new AccountsReceivablePayable().run('Receivable', args)
});
frappe.registerMethod({
2018-04-29 09:07:59 +00:00
method: 'accounts-payable',
handler: args => new AccountsReceivablePayable().run('Payable', args)
});
2018-04-19 14:31:35 +00:00
}
function getReportData(ReportClass) {
return args => new ReportClass().run(args);
2018-04-19 14:31:35 +00:00
}
module.exports = registerReportMethods