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');
|
|
|
|
|
2018-04-24 07:58:57 +00:00
|
|
|
const BalanceSheet = require('./BalanceSheet/BalanceSheet');
|
|
|
|
const BalanceSheetView = require('./BalanceSheet/BalanceSheetView');
|
|
|
|
|
2018-04-26 10:23:27 +00:00
|
|
|
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',
|
2018-04-26 10:23:27 +00:00
|
|
|
handler: getReportData(GeneralLedger)
|
2018-04-19 14:31:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
frappe.registerMethod({
|
|
|
|
method: 'profit-and-loss',
|
2018-04-26 10:23:27 +00:00
|
|
|
handler: getReportData(ProfitAndLoss)
|
2018-04-19 14:31:35 +00:00
|
|
|
});
|
2018-04-24 07:58:57 +00:00
|
|
|
|
|
|
|
frappe.registerMethod({
|
|
|
|
method: 'balance-sheet',
|
2018-04-26 10:23:27 +00:00
|
|
|
handler: getReportData(BalanceSheet)
|
|
|
|
});
|
|
|
|
|
|
|
|
frappe.registerMethod({
|
|
|
|
method: 'sales-register',
|
|
|
|
handler: getReportData(SalesRegister)
|
|
|
|
});
|
|
|
|
|
|
|
|
frappe.registerMethod({
|
|
|
|
method: 'purchase-register',
|
|
|
|
handler: getReportData(PurchaseRegister)
|
2018-04-24 07:58:57 +00:00
|
|
|
});
|
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);
|
|
|
|
});
|
2018-04-24 07:58:57 +00:00
|
|
|
|
|
|
|
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-26 10:23:27 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|