mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
86d841da7a
- GetStarted model to track progress
52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
const frappe = require('frappejs');
|
|
const naming = require('frappejs/model/naming');
|
|
const registerServerMethods = require('./registerServerMethods');
|
|
|
|
module.exports = async function postStart() {
|
|
// set server-side modules
|
|
frappe.models.SalesInvoice.documentClass = require('../models/doctype/SalesInvoice/SalesInvoiceServer.js');
|
|
frappe.models.Payment.documentClass = require('../models/doctype/Payment/PaymentServer.js');
|
|
frappe.models.Party.documentClass = require('../models/doctype/Party/PartyServer.js');
|
|
frappe.models.PurchaseInvoice.documentClass = require('../models/doctype/PurchaseInvoice/PurchaseInvoiceServer.js');
|
|
frappe.models.JournalEntry.documentClass = require('../models/doctype/JournalEntry/JournalEntryServer.js');
|
|
frappe.models.GSTR3B.documentClass = require('../models/doctype/GSTR3B/GSTR3BServer.js');
|
|
|
|
frappe.metaCache = {};
|
|
|
|
// init naming series if missing
|
|
await naming.createNumberSeries('SINV-', 'SalesInvoiceSettings');
|
|
await naming.createNumberSeries('PINV-', 'PurchaseInvoiceSettings');
|
|
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');
|
|
|
|
// fetch singles
|
|
// so that they are available synchronously
|
|
await frappe.getSingle('SystemSettings');
|
|
await frappe.getSingle('AccountingSettings');
|
|
await frappe.getSingle('GetStarted');
|
|
|
|
// cache currency symbols for frappe.format
|
|
frappe.currencySymbols = await getCurrencySymbols();
|
|
|
|
registerServerMethods();
|
|
};
|
|
|
|
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;
|
|
}, {});
|
|
});
|
|
}
|