From 4578482aa6427112a665805523f3a8d7d9af6db4 Mon Sep 17 00:00:00 2001 From: Seddik Date: Tue, 3 Sep 2024 19:10:53 +0200 Subject: [PATCH 1/4] new: add reconversion feature to reclaim national currencies from local currency --- package-lock.json | 36 ++--- public/config.sample.json | 3 +- src/components/BankAccountItem.vue | 2 +- src/components/ConfirmPaymentModal.vue | 68 +++++---- src/components/MoneyTransaction.vue | 8 +- src/components/MoneyTransferModal.vue | 14 +- src/components/TransactionItem.vue | 31 +++- src/components/TransactionListModal.vue | 6 +- src/components/TransactionListRecent.vue | 5 +- src/i18n/fr-FR/app.po | 181 ++++++++++++----------- src/services/lokapiService.ts | 21 ++- 11 files changed, 224 insertions(+), 151 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3ea9a9e..b612bfa7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2051,9 +2051,9 @@ } }, "node_modules/@com-chain/jsc3l": { - "version": "2.0.1-rc.16", - "resolved": "https://registry.npmjs.org/@com-chain/jsc3l/-/jsc3l-2.0.1-rc.16.tgz", - "integrity": "sha512-f6XOvfXTn0lPI/Lv+TFsZG15wz+d2KCJzv7UgwVqsn4j8N2QZ823W+134o3ajUM8ZI9ZnDG2oBf0/yQN9NsPfQ==", + "version": "2.0.1-rc.17", + "resolved": "https://registry.npmjs.org/@com-chain/jsc3l/-/jsc3l-2.0.1-rc.17.tgz", + "integrity": "sha512-eeHO3MalJOe/GoP+ulCbfyKZlXV8yf2/8vd1rrcgqU7NNs9i5cokiU8fkjdh2qgb9nFuyH4v2xpbWCYWV5LQLg==", "dependencies": { "bignumber.js": "^2.4.0", "ethereumjs-tx": "^1.3.7", @@ -2588,18 +2588,18 @@ } }, "node_modules/@lokavaluto/lokapi": { - "version": "0.1.1-alpha.202312211720", - "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi/-/lokapi-0.1.1-alpha.202312211720.tgz", - "integrity": "sha512-d4aeL5T8NSXhnn7lvVVGxa29lyAOFrZ3dPGG9cmeTBRvZUYcPW9UHdM1GHavgu6VIn1yXjzdgazKysbQ2Vlw4A==", + "version": "0.1.1-alpha.202409111621", + "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi/-/lokapi-0.1.1-alpha.202409111621.tgz", + "integrity": "sha512-BDxH4GWSHdcpRHW9QheaCTMyL3cGOmhKwIlycX8gl9ltU/gqISh/uNfdsDA/WcdqmycyQaenqgFsqeC4LyMTfw==", "dependencies": { "@0k/types-request": "^1.0.0", "qs": "^6.10.1" } }, "node_modules/@lokavaluto/lokapi-backend-comchain": { - "version": "0.1.1-alpha.202405151629", - "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi-backend-comchain/-/lokapi-backend-comchain-0.1.1-alpha.202405151629.tgz", - "integrity": "sha512-ALzJEEa7DZST1k9/aLBS814QbjIqgioA6TomU+GMNzWSZComvtpx0gVlR6NU+VbD1j0wVhVqAYrPZIm2ahNjqg==", + "version": "0.1.1-alpha.202409111135", + "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi-backend-comchain/-/lokapi-backend-comchain-0.1.1-alpha.202409111135.tgz", + "integrity": "sha512-MtRFbjB3F+PBTZG9RlBAHV+u67Isq3lEB8JlDF0ZUXBoSq1WvwmoXcZIrq3NP9i4nsFFqSPDIxq5hi/xmuP9PQ==", "dependencies": { "@com-chain/jsc3l": ">=2.0.1-rc", "@lokavaluto/lokapi": "0.1.0 || >=0.1.1-alpha" @@ -19834,9 +19834,9 @@ "optional": true }, "@com-chain/jsc3l": { - "version": "2.0.1-rc.16", - "resolved": "https://registry.npmjs.org/@com-chain/jsc3l/-/jsc3l-2.0.1-rc.16.tgz", - "integrity": "sha512-f6XOvfXTn0lPI/Lv+TFsZG15wz+d2KCJzv7UgwVqsn4j8N2QZ823W+134o3ajUM8ZI9ZnDG2oBf0/yQN9NsPfQ==", + "version": "2.0.1-rc.17", + "resolved": "https://registry.npmjs.org/@com-chain/jsc3l/-/jsc3l-2.0.1-rc.17.tgz", + "integrity": "sha512-eeHO3MalJOe/GoP+ulCbfyKZlXV8yf2/8vd1rrcgqU7NNs9i5cokiU8fkjdh2qgb9nFuyH4v2xpbWCYWV5LQLg==", "requires": { "bignumber.js": "^2.4.0", "ethereumjs-tx": "^1.3.7", @@ -20264,18 +20264,18 @@ } }, "@lokavaluto/lokapi": { - "version": "0.1.1-alpha.202312211720", - "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi/-/lokapi-0.1.1-alpha.202312211720.tgz", - "integrity": "sha512-d4aeL5T8NSXhnn7lvVVGxa29lyAOFrZ3dPGG9cmeTBRvZUYcPW9UHdM1GHavgu6VIn1yXjzdgazKysbQ2Vlw4A==", + "version": "0.1.1-alpha.202409111621", + "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi/-/lokapi-0.1.1-alpha.202409111621.tgz", + "integrity": "sha512-BDxH4GWSHdcpRHW9QheaCTMyL3cGOmhKwIlycX8gl9ltU/gqISh/uNfdsDA/WcdqmycyQaenqgFsqeC4LyMTfw==", "requires": { "@0k/types-request": "^1.0.0", "qs": "^6.10.1" } }, "@lokavaluto/lokapi-backend-comchain": { - "version": "0.1.1-alpha.202405151629", - "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi-backend-comchain/-/lokapi-backend-comchain-0.1.1-alpha.202405151629.tgz", - "integrity": "sha512-ALzJEEa7DZST1k9/aLBS814QbjIqgioA6TomU+GMNzWSZComvtpx0gVlR6NU+VbD1j0wVhVqAYrPZIm2ahNjqg==", + "version": "0.1.1-alpha.202409111135", + "resolved": "https://registry.npmjs.org/@lokavaluto/lokapi-backend-comchain/-/lokapi-backend-comchain-0.1.1-alpha.202409111135.tgz", + "integrity": "sha512-MtRFbjB3F+PBTZG9RlBAHV+u67Isq3lEB8JlDF0ZUXBoSq1WvwmoXcZIrq3NP9i4nsFFqSPDIxq5hi/xmuP9PQ==", "requires": { "@com-chain/jsc3l": ">=2.0.1-rc", "@lokavaluto/lokapi": "0.1.0 || >=0.1.1-alpha" diff --git a/public/config.sample.json b/public/config.sample.json index 9cc4649c..3cc1212f 100644 --- a/public/config.sample.json +++ b/public/config.sample.json @@ -75,5 +75,6 @@ }, "css": ".nav-item {color: red !important} .refresh {background-color: #009688;}", "accountsRefreshInterval": 90, - "transactionsRefreshInterval": 47 + "transactionsRefreshInterval": 47, + "disableReconversion": true } diff --git a/src/components/BankAccountItem.vue b/src/components/BankAccountItem.vue index 1a5e3397..adcc3edf 100644 --- a/src/components/BankAccountItem.vue +++ b/src/components/BankAccountItem.vue @@ -59,7 +59,7 @@ @@ -39,6 +40,9 @@ : $gettext("Transaction processed"), paymentConfirmation: $gettext("Payment sent"), topup: $gettext("Top-up requested"), + reconversion: $modal.args?.value[0].transaction.pending + ? $gettext("Reconversion sent") + : $gettext("Reconversion processed"), }[$modal.args?.value[0].type] }}

@@ -88,37 +92,39 @@ }))($modal.args?.value[0].transaction) }}

-

- {{ - $modal.args?.value[0].transaction.paid - ? $gettext( - "This top-up request is waiting for an administrator of your local currency to validate it" - ) - : $gettext( - "This top-up request is waiting for you to pay it or delete it" - ) - }} -

-

- {{ - $modal.args?.value[0].transaction.amount < 0 - ? $gettext("to") - : $gettext("from") - }} -

-

- {{ $modal.args?.value[0].transaction.related }} -

+
+

+ {{ + $modal.args?.value[0].transaction.paid + ? $gettext( + "This top-up request is waiting for an administrator of your local currency to validate it" + ) + : $gettext( + "This top-up request is waiting for you to pay it or delete it" + ) + }} +

+

+ {{ + $modal.args?.value[0].transaction.amount < 0 + ? $gettext("to") + : $gettext("from") + }} +

+

+ {{ $modal.args?.value[0].transaction.related }} +

+

{{ dateFormat }} diff --git a/src/components/MoneyTransaction.vue b/src/components/MoneyTransaction.vue index 53ed859d..9d04c7e5 100644 --- a/src/components/MoneyTransaction.vue +++ b/src/components/MoneyTransaction.vue @@ -16,7 +16,7 @@ -

+

{{ $gettext("To") }}

@@ -51,6 +51,7 @@ {{ parentErrors }}
-
+
{{ errors.message }}
diff --git a/src/components/MoneyTransferModal.vue b/src/components/MoneyTransferModal.vue index b4a4af9d..327a3a63 100644 --- a/src/components/MoneyTransferModal.vue +++ b/src/components/MoneyTransferModal.vue @@ -330,15 +330,11 @@ return } this.transferOngoing = true - this.errors = false - - if (this.ownSelectedAccount._obj.getGlobalBalance) { + if (this.ownSelectedAccount._obj.getBalance) { let realBal try { - realBal = await this.ownSelectedAccount._obj.getGlobalBalance( - "latest" - ) + realBal = await this.ownSelectedAccount._obj.getBalance("latest") } catch (err) { this.$msg.error( this.$gettext( @@ -351,21 +347,21 @@ "please contact your administrator." ) ) - console.error("getGlobalBalance failed:", err) + console.error("getBalance failed:", err) this.transferOngoing = false return } // ensure realBal is the correct format if (!(realBal.includes(".") && realBal.split(".")[1].length === 2)) { throw new Error( - "Invalid amount returned by getGlobalBalance", + "Invalid amount returned by getBalance", realBal ) } const amount_cents = parseInt(this.amount.replace(".", "")) const realBal_cents = parseInt(realBal.replace(".", "")) const bal_cents = parseInt( - this.ownSelectedAccount.bal.toFixed(2).replace(".", "") + this.ownSelectedAccount.bal.replace(".", "") ) // ensure we are in safe limits (we could use BigInt if needed) Object.entries({ amount_cents, realBal_cents, bal_cents }).forEach( diff --git a/src/components/TransactionItem.vue b/src/components/TransactionItem.vue index 01db3fde..3cb09a69 100644 --- a/src/components/TransactionItem.vue +++ b/src/components/TransactionItem.vue @@ -1,5 +1,8 @@