mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
fix: Cache singles and currencySymbols in postStart
This commit is contained in:
parent
049432dbf1
commit
c282844685
@ -4,6 +4,7 @@ module.exports = {
|
||||
doctype: 'DocType',
|
||||
isSingle: 0,
|
||||
keywordFields: ['name', 'symbol'],
|
||||
quickEditFields: ['name', 'symbol'],
|
||||
fields: [
|
||||
{
|
||||
fieldname: 'name',
|
||||
|
@ -26,5 +26,28 @@ module.exports = async function postStart() {
|
||||
await naming.createNumberSeries('PO-', 'PurchaseOrderSettings');
|
||||
await naming.createNumberSeries('PREC-', 'PurchaseReceiptSettings');
|
||||
|
||||
// fetch singles
|
||||
// these will be available as
|
||||
// frappe.SystemSettings and frappe.AccountingSettings
|
||||
await frappe.getSingle('SystemSettings');
|
||||
await frappe.getSingle('AccountingSettings');
|
||||
|
||||
// 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;
|
||||
}, {});
|
||||
});
|
||||
}
|
||||
|
@ -203,9 +203,8 @@ import router from './router';
|
||||
dbPath: filepath
|
||||
});
|
||||
await frappe.db.connect();
|
||||
await frappe.db.migrate();
|
||||
frappe.getSingle('SystemSettings');
|
||||
await postStart();
|
||||
await frappe.db.migrate();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user