mirror of
https://github.com/frappe/books.git
synced 2025-01-11 10:38:14 +00:00
refactor: shift currency to books, change iP to 11, update
This commit is contained in:
parent
7698af67e6
commit
0bad10e1be
35
index.js
35
index.js
@ -12,17 +12,28 @@ module.exports = {
|
||||
this.registerModels(customModels);
|
||||
},
|
||||
|
||||
async initializeMoneyMaker() {
|
||||
async initializeMoneyMaker(currency) {
|
||||
currency ??= 'XXX';
|
||||
|
||||
// to be called after db initialization
|
||||
const { currency, internalPrecision: precision } = (
|
||||
await frappe.db.getSingleValues(
|
||||
{ fieldname: 'currency', parent: 'AccountingSettings' },
|
||||
{ fieldname: 'internalPrecision', parent: 'SystemSettings' }
|
||||
)
|
||||
).reduce((acc, { fieldname, value }) => {
|
||||
acc[fieldname] = value;
|
||||
return acc;
|
||||
}, {});
|
||||
let values;
|
||||
try {
|
||||
// error thrown if migration hasn't taken place
|
||||
values = await frappe.db.getSingleValues({
|
||||
fieldname: 'internalPrecision',
|
||||
parent: 'SystemSettings',
|
||||
});
|
||||
} catch {
|
||||
values = [];
|
||||
}
|
||||
|
||||
let { internalPrecision: precision } = values.reduce(
|
||||
(acc, { fieldname, value }) => {
|
||||
acc[fieldname] = value;
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
|
||||
if (typeof precision === 'undefined') {
|
||||
precision = this.getMeta('SystemSettings').fields.find(
|
||||
@ -31,9 +42,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (typeof precision === 'undefined') {
|
||||
throw new frappe.errors.NotFoundError(
|
||||
'SystemSettings internalPrecision value is undefined'
|
||||
);
|
||||
precision = 11;
|
||||
}
|
||||
|
||||
if (typeof precision.value === 'string') {
|
||||
|
@ -52,7 +52,7 @@ module.exports = {
|
||||
fieldname: 'internalPrecision',
|
||||
label: 'Internal Precision',
|
||||
fieldtype: 'Int',
|
||||
default: 12,
|
||||
default: 11,
|
||||
description: _(
|
||||
'Sets the internal precision used for monetary calculations. Above 6 should be sufficient for most currencies.'
|
||||
),
|
||||
|
@ -32,7 +32,7 @@
|
||||
"multer": "^1.4.3",
|
||||
"node-fetch": "^3.0.0",
|
||||
"nunjucks": "^3.2.3",
|
||||
"pesa": "^1.0.3",
|
||||
"pesa": "^1.0.4",
|
||||
"postcss": "^8.3.11",
|
||||
"postcss-loader": "^6.2.0",
|
||||
"sass-loader": "^12.3.0",
|
||||
|
@ -3417,10 +3417,10 @@ performance-now@^2.1.0:
|
||||
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
|
||||
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
|
||||
|
||||
pesa@^1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/pesa/-/pesa-1.0.3.tgz#e0eab7a13a6a8d0cfd1cbc0214aece6befd63a74"
|
||||
integrity sha512-UGw3TPnQKAcM0EhPzQO17cXtibBcJCCqlB/hjfYtVPFAgDOIJ2kv6az9Fwq5Gflp2R7hODZlJy1cG+eL70od/g==
|
||||
pesa@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/pesa/-/pesa-1.0.4.tgz#aaed9760b319d1435ea663bdb96c0a99f88cbd53"
|
||||
integrity sha512-SuXEyavfSv1GGk625Mgdmw8ZJvNaMQ6C5e413zxTpkdLmDdTwWidhlQDDbFuI+Drj1GBHu/L20NVsoRUjUjU5w==
|
||||
|
||||
pg-connection-string@2.5.0:
|
||||
version "2.5.0"
|
||||
|
Loading…
Reference in New Issue
Block a user