@lucaapp/service-utils 1.58.1 → 1.58.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -131,7 +131,13 @@ const moneyfiedGet = (model, key) => {
131
131
  };
132
132
  exports.moneyfiedGet = moneyfiedGet;
133
133
  const moneyfiedSet = (model, key, value) => {
134
- model.setDataValue(key, value?.getAmount());
135
- model.setDataValue('currency', value?.currency);
134
+ const modelCurrency = model.getDataValue('currency');
135
+ if (value?.currency && modelCurrency && value.currency !== modelCurrency) {
136
+ throw new TypeError(`Currencies must match: ${value.currency}, ${modelCurrency}`);
137
+ }
138
+ else if (value?.currency && !modelCurrency) {
139
+ model.setDataValue('currency', value.currency);
140
+ }
141
+ model.setDataValue(key, value ? value?.getAmount() : value);
136
142
  };
137
143
  exports.moneyfiedSet = moneyfiedSet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.58.1",
3
+ "version": "1.58.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -66,6 +66,7 @@
66
66
  "prettier": "2.7.1",
67
67
  "semantic-release": "^19.0.3",
68
68
  "semantic-release-monorepo": "^7.0.5",
69
+ "sqlite3": "5.0.4",
69
70
  "supertest": "^6.3.3",
70
71
  "typescript": "5.5.3",
71
72
  "vite-tsconfig-paths": "4.3.2"