From d58a5eb1ff66e4e12aab515f3f6d44bf12e50883 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 3 Mar 2023 08:54:55 +0100 Subject: [PATCH 1/6] hotfix itemWaste --- modules/item/front/waste/index/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/item/front/waste/index/index.html b/modules/item/front/waste/index/index.html index 5da5acbf1..f1475c1b3 100644 --- a/modules/item/front/waste/index/index.html +++ b/modules/item/front/waste/index/index.html @@ -33,16 +33,16 @@ - + ng-show="$ctrl.wasteConfig[detail.buyer].hidden"> {{::waste.family}} {{::(waste.percentage / 100) | percentage: 2}} {{::waste.dwindle | currency: 'EUR'}} {{::waste.total | currency: 'EUR'}} - + From 6eaf4bdd1bdbf0320a9ecd08570e1c0a0f004592 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 3 Mar 2023 10:57:57 +0100 Subject: [PATCH 2/6] =?UTF-8?q?refs=20#5174=20tpvTransaction:=20A=C3=B1adi?= =?UTF-8?q?das=20columnas=20para=20depuraci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/tpv-transaction/confirm.js | 69 ++++++++++++------- .../client/back/models/tpv-transaction.json | 13 +++- 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/modules/client/back/methods/tpv-transaction/confirm.js b/modules/client/back/methods/tpv-transaction/confirm.js index a26e0bad6..36ee13206 100644 --- a/modules/client/back/methods/tpv-transaction/confirm.js +++ b/modules/client/back/methods/tpv-transaction/confirm.js @@ -41,36 +41,57 @@ module.exports = Self => { params[param] = decodeURIComponent(decodedParams[param]); const orderId = params['Ds_Order']; - const merchantId = parseInt(params['Ds_MerchantCode']); - if (!orderId) - throw new UserError('Order id not found'); - if (!merchantId) - throw new UserError('Mechant id not found'); + throw new UserError('Order id not provided'); - const merchant = await $.TpvMerchant.findById(merchantId, { - fields: ['id', 'secretKey'] - }); + const transaction = await Self.findById(orderId, {fields: ['id']}); + if (!transaction) + throw new UserError('Order not found'); - const base64hmac = Self.createSignature( - orderId, - merchant.secretKey, - merchantParameters - ); + try { + await transaction.updateAttributes({ + merchantParameters, + signature, + signatureVersion, + }); - if (base64hmac !== base64url.toBase64(signature)) - throw new UserError('Invalid signature'); + const merchantId = parseInt(params['Ds_MerchantCode']); + if (!merchantId) + throw new UserError('Merchant id not provided'); - await Self.rawSql( - 'CALL hedera.tpvTransaction_confirm(?, ?, ?, ?, ?, ?)', [ - params['Ds_Amount'], + const merchant = await $.TpvMerchant.findById(merchantId, { + fields: ['id', 'secretKey'] + }); + if (!merchant) + throw new UserError('Merchant not found'); + + const base64hmac = Self.createSignature( orderId, - merchantId, - params['Ds_Currency'], - params['Ds_Response'], - params['Ds_ErrorCode'] - ]); + merchant.secretKey, + merchantParameters + ); - return true; + if (base64hmac !== base64url.toBase64(signature)) + throw new UserError('Invalid signature'); + + await Self.rawSql( + 'CALL hedera.tpvTransaction_confirm(?, ?, ?, ?, ?, ?)', [ + params['Ds_Amount'], + orderId, + merchantId, + params['Ds_Currency'], + params['Ds_Response'], + params['Ds_ErrorCode'] + ]); + + return true; + } catch (err) { + try { + await transaction.updateAttribute('responseError', err.message); + } catch (e) { + console.error(e); + } + throw err; + } }; }; diff --git a/modules/client/back/models/tpv-transaction.json b/modules/client/back/models/tpv-transaction.json index 2d926cc40..878b1f41a 100644 --- a/modules/client/back/models/tpv-transaction.json +++ b/modules/client/back/models/tpv-transaction.json @@ -35,6 +35,18 @@ }, "created": { "type": "date" + }, + "merchantParameters": { + "type": "string" + }, + "signature": { + "type": "string" + }, + "signatureVersion": { + "type": "string" + }, + "responseError": { + "type": "string" } }, "relations": { @@ -45,4 +57,3 @@ } } } - \ No newline at end of file From 8ac575419a195374eccc85490e1ac369ab76ecb8 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 3 Mar 2023 12:31:20 +0100 Subject: [PATCH 3/6] fix: no mostraba la factura rectificada correcta --- modules/invoiceOut/front/descriptor/index.html | 15 +++++++++------ print/templates/reports/invoice/sql/rectified.sql | 11 ++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/modules/invoiceOut/front/descriptor/index.html b/modules/invoiceOut/front/descriptor/index.html index 92f0b9de5..e1dc579ab 100644 --- a/modules/invoiceOut/front/descriptor/index.html +++ b/modules/invoiceOut/front/descriptor/index.html @@ -3,7 +3,7 @@ description="$ctrl.invoiceOut.ref" summary="$ctrl.$.summary"> - @@ -11,23 +11,23 @@
- {{$ctrl.invoiceOut.client.name}}
@@ -53,4 +53,7 @@ - \ No newline at end of file + + + diff --git a/print/templates/reports/invoice/sql/rectified.sql b/print/templates/reports/invoice/sql/rectified.sql index 49db8f68b..79ce733e3 100644 --- a/print/templates/reports/invoice/sql/rectified.sql +++ b/print/templates/reports/invoice/sql/rectified.sql @@ -1,10 +1,11 @@ SELECT - io.amount, - io.ref, - io.issued, + io2.amount, + io2.ref, + io2.issued, ict.description FROM invoiceOut io JOIN invoiceCorrection ic ON ic.correctingFk = io.id - JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk + JOIN invoiceOut io2 ON io2.id = ic.correctedFk LEFT JOIN ticket t ON t.refFk = io.ref -WHERE io.ref = ? \ No newline at end of file + JOIN invoiceCorrectionType ict ON ict.id = ic.invoiceCorrectionTypeFk +WHERE io.ref = ? From 99f8bc6bac00467ab7c5333092bc6ff8648a2ba7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 3 Mar 2023 18:55:58 +0100 Subject: [PATCH 4/6] refs #5174 TpvTransaction.confirm code refator to improve debugging --- .../back/methods/tpv-transaction/confirm.js | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/client/back/methods/tpv-transaction/confirm.js b/modules/client/back/methods/tpv-transaction/confirm.js index 36ee13206..41229a1fd 100644 --- a/modules/client/back/methods/tpv-transaction/confirm.js +++ b/modules/client/back/methods/tpv-transaction/confirm.js @@ -32,23 +32,24 @@ module.exports = Self => { Self.confirm = async(signatureVersion, merchantParameters, signature) => { const $ = Self.app.models; - - const decodedParams = JSON.parse( - base64url.decode(merchantParameters, 'utf8')); - const params = {}; - - for (const param in decodedParams) - params[param] = decodeURIComponent(decodedParams[param]); - - const orderId = params['Ds_Order']; - if (!orderId) - throw new UserError('Order id not provided'); - - const transaction = await Self.findById(orderId, {fields: ['id']}); - if (!transaction) - throw new UserError('Order not found'); + let transaction; try { + const decodedParams = JSON.parse( + base64url.decode(merchantParameters, 'utf8')); + const params = {}; + + for (const param in decodedParams) + params[param] = decodeURIComponent(decodedParams[param]); + + const orderId = params['Ds_Order']; + if (!orderId) + throw new UserError('Order id not provided'); + + transaction = await Self.findById(orderId, {fields: ['id']}); + if (!transaction) + throw new UserError('Order not found'); + await transaction.updateAttributes({ merchantParameters, signature, @@ -86,11 +87,10 @@ module.exports = Self => { return true; } catch (err) { - try { + if (transaction) await transaction.updateAttribute('responseError', err.message); - } catch (e) { - console.error(e); - } + else + console.error(err); throw err; } }; From e83b5184700713b73553460097a6118645826e5a Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 6 Mar 2023 09:23:24 +0100 Subject: [PATCH 5/6] refs #3723 Set docker memory limit --- docker-compose.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 4fc5dc811..13a7bc751 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,9 @@ services: placement: constraints: - node.role == worker + resources: + limits: + memory: 1G back: image: registry.verdnatura.es/salix-back:${BRANCH_NAME:?} build: . @@ -38,6 +41,9 @@ services: placement: constraints: - node.role == worker + resources: + limits: + memory: 4G configs: datasources: external: true From aeb50b2c19b05c4b3dc3c16814651680f23f267f Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 8 Mar 2023 10:19:02 +0100 Subject: [PATCH 6/6] Removed callback syntax --- .../methods/item-image-queue/downloadImages.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index 08e5df050..c4d7f4b98 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -59,17 +59,10 @@ module.exports = Self => { } const writeStream = fs.createWriteStream(filePath); - writeStream.on('open', () => { - response.pipe(writeStream); - }); - - writeStream.on('error', async error => { - await errorHandler(image.itemFk, error, filePath); - }); - - writeStream.on('finish', async function() { - writeStream.end(); - }); + writeStream.on('open', () => response.pipe(writeStream)); + writeStream.on('error', async error => + await errorHandler(image.itemFk, error, filePath)); + writeStream.on('finish', writeStream.end()); writeStream.on('close', async function() { try {