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

incr: deprecate frappe.call

This commit is contained in:
18alantom 2022-03-22 13:51:00 +05:30
parent 82709165a4
commit 2afec6a74b
7 changed files with 25 additions and 96 deletions

View File

@ -3,14 +3,7 @@ import GSTR3B from './GSTR3BDocument';
export default class GSTR3BServer extends GSTR3B {
async validate() {
if (this.month.length === 0 || this.year.length != 4) {
frappe.call({
method: 'show-dialog',
args: {
title: 'Invalid Entry',
message: `Month or Year is not valid`
}
});
throw new Error();
throw new Error('Month or Year is not valid');
}
}
async beforeInsert() {

View File

@ -4,14 +4,7 @@ import Document from 'frappe/model/document';
export default class PartyServer extends Document {
beforeInsert() {
if (this.customer && this.supplier) {
frappe.call({
method: 'show-dialog',
args: {
title: 'Invalid Entry',
message: 'Select a single party type.',
},
});
throw new Error();
throw new Error('Select a single party type.');
}
if (!this.customer && !this.supplier) {

View File

@ -84,12 +84,6 @@ export const findMatchingReferences = async (json, report) => {
},
});
} else {
frappe.call({
method: 'show-dialog',
args: {
title: 'Message',
message: 'No entries found with matching Ref / Cheque ID',
},
});
// 'No entries found with matching Ref / Cheque ID'
}
};

View File

@ -1,4 +1,3 @@
import frappe from 'frappe';
import AccountsReceivablePayable from './AccountsReceivablePayable/AccountsReceivablePayable';
import BalanceSheet from './BalanceSheet/BalanceSheet';
import BankReconciliation from './BankReconciliation/BankReconciliation';
@ -10,67 +9,27 @@ import PurchaseRegister from './PurchaseRegister/PurchaseRegister';
import SalesRegister from './SalesRegister/SalesRegister';
import TrialBalance from './TrialBalance/TrialBalance';
// called on server side
function registerReportMethods() {
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,
},
{
method: 'bank-reconciliation',
class: BankReconciliation,
},
{
method: 'gstr-1',
class: GSTR1,
},
{
method: 'gstr-2',
class: GSTR2,
},
];
export function getReportData(method, filters) {
const reports = {
'general-ledger': GeneralLedger,
'profit-and-loss': ProfitAndLoss,
'balance-sheet': BalanceSheet,
'trial-balance': TrialBalance,
'gstr-1': GSTR1,
'gstr-2': GSTR2,
'sales-register': SalesRegister,
'purchase-register': PurchaseRegister,
'bank-reconciliation': BankReconciliation,
};
reports.forEach((report) => {
frappe.registerMethod({
method: report.method,
handler: getReportData(report.class),
});
});
if (method === 'accounts-receivable') {
return new AccountsReceivablePayable().run('Receivable', filters);
}
frappe.registerMethod({
method: 'accounts-receivable',
handler: (args) => new AccountsReceivablePayable().run('Receivable', args),
});
if (method === 'accounts-payable') {
return new AccountsReceivablePayable().run('Payable', filters);
}
frappe.registerMethod({
method: 'accounts-payable',
handler: (args) => new AccountsReceivablePayable().run('Payable', args),
});
const ReportClass = reports[method];
return new ReportClass().run(filters);
}
function getReportData(ReportClass) {
return (args) => new ReportClass().run(args);
}
export default registerReportMethods;

View File

@ -6,7 +6,6 @@ import PartyServer from '../models/doctype/Party/PartyServer.js';
import PaymentServer from '../models/doctype/Payment/PaymentServer.js';
import PurchaseInvoiceServer from '../models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js';
import SalesInvoiceServer from '../models/doctype/SalesInvoice/SalesInvoiceServer.js';
import registerServerMethods from './registerServerMethods';
export default async function postStart() {
// set server-side modules
@ -38,8 +37,6 @@ export default async function postStart() {
// cache currency symbols for frappe.format
await setCurrencySymbols();
registerServerMethods();
}
export async function setCurrencySymbols() {

View File

@ -1,5 +0,0 @@
import registerReportMethods from '../reports';
export default function registerServerMethods() {
registerReportMethods();
}

View File

@ -146,6 +146,7 @@ import SearchBar from '@/components/SearchBar';
import WithScroll from '@/components/WithScroll';
import frappe from 'frappe';
import { h, markRaw } from 'vue';
import { getReportData } from '../../reports/index';
import DropdownWithActions from '../components/DropdownWithActions.vue';
export default {
@ -195,10 +196,7 @@ export default {
});
},
async fetchReportData() {
let data = await frappe.call({
method: this.report.method,
args: this.filters,
});
let data = await getReportData(this.report.method, this.filters)
let rows;
if (data.rows) {