2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/server/registerServerMethods.js
2019-08-01 18:30:52 +05:30

44 lines
1.2 KiB
JavaScript

const frappe = require('frappejs');
const registerReportMethods = require('../reports');
const sender = require('../email/sender');
module.exports = function registerServerMethods() {
registerReportMethods();
frappe.registerMethod({
method: 'send-mail',
handler: sender.sendMail
});
frappe.registerMethod({
method: 'import-coa',
async handler() {
const importCOA = require('../models/doctype/Account/importCOA');
await importCOA();
}
});
frappe.registerMethod({
method: 'print-pdf',
handler({ doctype, name, html }) {
if (frappe.isElectron) {
const path = require('path');
const { getPDFForElectron } = require('frappejs/server/pdf');
const { getSettings } = require('../electron/settings');
const destination = path.resolve('.');
getPDFForElectron(doctype, name, destination, html);
}
}
});
frappe.registerMethod({
method: 'show-dialog',
handler({ title, message }) {
frappe.showModal({
modalProps: { title, noFooter: true },
component: require('../src/components/MessageDialog').default,
props: { message }
});
}
});
};