2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 23:00:56 +00:00

Separate client and server files for report

This commit is contained in:
Faris Ansari 2018-04-28 20:23:30 +05:30
parent 9fed2fbb19
commit a5b4b81051
5 changed files with 610 additions and 704 deletions

View File

@ -1,5 +1,5 @@
const frappe = require('frappejs');
const { registerReportRoutes } = require('../reports');
const registerReportRoutes = require('../reports/view');
module.exports = {
start() {

View File

@ -1,22 +1,10 @@
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');
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');
// called on server side
function registerReportMethods() {
@ -51,56 +39,8 @@ function registerReportMethods() {
});
}
// 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);
});
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);
}
module.exports = {
registerReportMethods,
registerReportRoutes
}
module.exports = registerReportMethods

54
reports/view.js Normal file
View File

@ -0,0 +1,54 @@
const frappe = require('frappejs');
const GeneralLedgerView = require('../reports/generalLedger/GeneralLedgerView');
const ProfitAndLossView = require('./ProfitAndLoss/ProfitAndLossView');
const BalanceSheetView = require('./BalanceSheet/BalanceSheetView');
const TrialBalanceView = require('./TrialBalance/TrialBalanceView');
const SalesRegisterView = require('./SalesRegister/SalesRegisterView');
const PurchaseRegisterView = require('./PurchaseRegister/PurchaseRegisterView');
// 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);
});
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);
});
}
module.exports = registerReportRoutes;

View File

@ -5,7 +5,7 @@ global.rootRequire = function(name) {
const server = require('frappejs/server');
const frappe = require('frappejs');
const naming = require('frappejs/model/naming');
const { registerReportMethods } = require('../reports');
const registerReportMethods = require('../reports');
module.exports = {
async start() {

1194
www/dist/js/bundle.js vendored

File diff suppressed because it is too large Load Diff