2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 23:00:56 +00:00

incr: save version in the db

This commit is contained in:
18alantom 2022-05-06 12:30:32 +05:30
parent 58dce76d10
commit 6dfad44ba3
2 changed files with 29 additions and 1 deletions

View File

@ -88,7 +88,19 @@
"label": "Currency",
"fieldtype": "AutoComplete",
"required": true
},
{
"fieldname": "version",
"label": "Version",
"fieldtype": "Data",
"readOnly": true
}
],
"quickEditFields": ["locale", "dateFormat", "currency", "displayPrecision", "hideGetStarted"]
"quickEditFields": [
"locale",
"dateFormat",
"currency",
"displayPrecision",
"hideGetStarted"
]
}

View File

@ -31,6 +31,7 @@ export async function initializeInstance(
await setSingles(fyo);
await setCreds(fyo);
await setVersion(fyo);
await setCurrencySymbols(fyo);
}
@ -48,6 +49,21 @@ async function setCreds(fyo: Fyo) {
fyo.auth.user = email ?? user;
}
async function setVersion(fyo: Fyo) {
const version = (await fyo.getValue(
ModelNameEnum.SystemSettings,
'version'
)) as string | undefined;
const { appVersion } = fyo.store;
if (version !== appVersion) {
const systemSettings = await fyo.doc.getSingle(
ModelNameEnum.SystemSettings
);
await systemSettings?.setAndSync('version', appVersion);
}
}
async function setCurrencySymbols(fyo: Fyo) {
const currencies = (await fyo.db.getAll(ModelNameEnum.Currency, {
fields: ['name', 'symbol'],