2018-10-22 18:02:47 +00:00
|
|
|
const frappe = require('frappejs');
|
|
|
|
const naming = require('frappejs/model/naming');
|
|
|
|
const registerServerMethods = require('./registerServerMethods');
|
|
|
|
|
|
|
|
module.exports = async function postStart() {
|
|
|
|
// set server-side modules
|
2019-08-01 11:52:58 +00:00
|
|
|
frappe.models.SalesInvoice.documentClass = require('../models/doctype/SalesInvoice/SalesInvoiceServer.js');
|
2018-10-22 18:02:47 +00:00
|
|
|
frappe.models.Payment.documentClass = require('../models/doctype/Payment/PaymentServer.js');
|
2019-08-01 13:00:52 +00:00
|
|
|
frappe.models.Party.documentClass = require('../models/doctype/Party/PartyServer.js');
|
2019-08-01 11:52:58 +00:00
|
|
|
frappe.models.PurchaseInvoice.documentClass = require('../models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js');
|
2018-10-22 18:02:47 +00:00
|
|
|
frappe.models.JournalEntry.documentClass = require('../models/doctype/JournalEntry/JournalEntryServer.js');
|
2019-07-30 12:02:49 +00:00
|
|
|
frappe.models.GSTR3B.documentClass = require('../models/doctype/GSTR3B/GSTR3BServer.js');
|
2018-10-22 18:02:47 +00:00
|
|
|
|
|
|
|
frappe.metaCache = {};
|
|
|
|
|
|
|
|
// init naming series if missing
|
2019-08-01 11:52:58 +00:00
|
|
|
await naming.createNumberSeries('SINV-', 'SalesInvoiceSettings');
|
|
|
|
await naming.createNumberSeries('PINV-', 'PurchaseInvoiceSettings');
|
2018-10-22 18:02:47 +00:00
|
|
|
await naming.createNumberSeries('PAY-', 'PaymentSettings');
|
|
|
|
await naming.createNumberSeries('JV-', 'JournalEntrySettings');
|
|
|
|
await naming.createNumberSeries('QTN-', 'QuotationSettings');
|
|
|
|
await naming.createNumberSeries('SO-', 'SalesOrderSettings');
|
|
|
|
await naming.createNumberSeries('OF-', 'FulfillmentSettings');
|
|
|
|
await naming.createNumberSeries('PO-', 'PurchaseOrderSettings');
|
|
|
|
await naming.createNumberSeries('PREC-', 'PurchaseReceiptSettings');
|
|
|
|
|
2019-12-03 08:12:31 +00:00
|
|
|
// fetch singles
|
2019-12-21 14:46:50 +00:00
|
|
|
// so that they are available synchronously
|
2019-12-03 08:12:31 +00:00
|
|
|
await frappe.getSingle('SystemSettings');
|
|
|
|
await frappe.getSingle('AccountingSettings');
|
2019-12-21 14:46:50 +00:00
|
|
|
await frappe.getSingle('GetStarted');
|
2019-12-03 08:12:31 +00:00
|
|
|
|
|
|
|
// cache currency symbols for frappe.format
|
|
|
|
frappe.currencySymbols = await getCurrencySymbols();
|
|
|
|
|
2018-10-22 18:02:47 +00:00
|
|
|
registerServerMethods();
|
2019-07-30 12:02:49 +00:00
|
|
|
};
|
2019-12-03 08:12:31 +00:00
|
|
|
|
|
|
|
function getCurrencySymbols() {
|
|
|
|
return frappe.db
|
|
|
|
.getAll({
|
|
|
|
doctype: 'Currency',
|
|
|
|
fields: ['name', 'symbol']
|
|
|
|
})
|
|
|
|
.then(data => {
|
|
|
|
return data.reduce((obj, currency) => {
|
|
|
|
obj[currency.name] = currency.symbol;
|
|
|
|
return obj;
|
|
|
|
}, {});
|
|
|
|
});
|
|
|
|
}
|