mirror of
https://github.com/frappe/books.git
synced 2025-02-08 23:18:31 +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',
|
doctype: 'DocType',
|
||||||
isSingle: 0,
|
isSingle: 0,
|
||||||
keywordFields: ['name', 'symbol'],
|
keywordFields: ['name', 'symbol'],
|
||||||
|
quickEditFields: ['name', 'symbol'],
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
fieldname: 'name',
|
fieldname: 'name',
|
||||||
|
@ -26,5 +26,28 @@ module.exports = async function postStart() {
|
|||||||
await naming.createNumberSeries('PO-', 'PurchaseOrderSettings');
|
await naming.createNumberSeries('PO-', 'PurchaseOrderSettings');
|
||||||
await naming.createNumberSeries('PREC-', 'PurchaseReceiptSettings');
|
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();
|
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
|
dbPath: filepath
|
||||||
});
|
});
|
||||||
await frappe.db.connect();
|
await frappe.db.connect();
|
||||||
await frappe.db.migrate();
|
|
||||||
frappe.getSingle('SystemSettings');
|
|
||||||
await postStart();
|
await postStart();
|
||||||
|
await frappe.db.migrate();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user