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