2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/reports/index.js

107 lines
3.3 KiB
JavaScript
Raw Normal View History

2018-04-19 14:31:35 +00:00
const frappe = require('frappejs');
const GeneralLedger = require('./GeneralLedger/GeneralLedger');
const GeneralLedgerView = require('../reports/generalLedger/GeneralLedgerView');
const ProfitAndLoss = require('./ProfitAndLoss/ProfitAndLoss');
const ProfitAndLossView = require('./ProfitAndLoss/ProfitAndLossView');
const BalanceSheet = require('./BalanceSheet/BalanceSheet');
const BalanceSheetView = require('./BalanceSheet/BalanceSheetView');
2018-04-27 11:33:36 +00:00
const TrialBalance = require('./TrialBalance/TrialBalance');
const TrialBalanceView = require('./TrialBalance/TrialBalanceView');
const SalesRegister = require('./SalesRegister/SalesRegister');
const SalesRegisterView = require('./SalesRegister/SalesRegisterView');
const PurchaseRegister = require('./PurchaseRegister/PurchaseRegister');
const PurchaseRegisterView = require('./PurchaseRegister/PurchaseRegisterView');
2018-04-19 14:31:35 +00:00
// called on server side
function registerReportMethods() {
frappe.registerMethod({
method: 'general-ledger',
handler: getReportData(GeneralLedger)
2018-04-19 14:31:35 +00:00
});
frappe.registerMethod({
method: 'profit-and-loss',
handler: getReportData(ProfitAndLoss)
2018-04-19 14:31:35 +00:00
});
frappe.registerMethod({
method: 'balance-sheet',
handler: getReportData(BalanceSheet)
});
2018-04-27 11:33:36 +00:00
frappe.registerMethod({
method: 'trial-balance',
handler: getReportData(TrialBalance)
});
frappe.registerMethod({
method: 'sales-register',
handler: getReportData(SalesRegister)
});
frappe.registerMethod({
method: 'purchase-register',
handler: getReportData(PurchaseRegister)
});
2018-04-19 14:31:35 +00:00
}
// called on client side
function registerReportRoutes() {
frappe.router.add('report/general-ledger', async (params) => {
if (!frappe.views.GeneralLedger) {
frappe.views.GeneralLedger = new GeneralLedgerView();
}
await frappe.views.GeneralLedger.show(params);
});
frappe.router.add('report/profit-and-loss', async (params) => {
if (!frappe.views.ProfitAndLoss) {
frappe.views.ProfitAndLoss = new ProfitAndLossView();
}
await frappe.views.ProfitAndLoss.show(params);
});
frappe.router.add('report/balance-sheet', async (params) => {
if (!frappe.views.BalanceSheet) {
frappe.views.BalanceSheet = new BalanceSheetView();
}
await frappe.views.BalanceSheet.show(params);
});
2018-04-27 11:33:36 +00:00
frappe.router.add('report/trial-balance', async (params) => {
if (!frappe.views.TrialBalance) {
frappe.views.TrialBalance = new TrialBalanceView();
}
await frappe.views.TrialBalance.show(params);
});
frappe.router.add('report/sales-register', async (params) => {
if (!frappe.views.SalesRegister) {
frappe.views.SalesRegister = new SalesRegisterView();
}
await frappe.views.SalesRegister.show(params);
});
frappe.router.add('report/purchase-register', async (params) => {
if (!frappe.views.PurchaseRegister) {
frappe.views.PurchaseRegister = new PurchaseRegisterView();
}
await frappe.views.PurchaseRegister.show(params);
});
}
function getReportData(ReportClass) {
return args => new ReportClass().run(args);
2018-04-19 14:31:35 +00:00
}
module.exports = {
registerReportMethods,
registerReportRoutes
}