From 884b5f8475b0bfabec4990ca7084a6f4b869dfd2 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 31 May 2024 11:51:32 +0200 Subject: [PATCH 1/2] feat: refs #6404 add cero filler to counter --- back/methods/mrw-config/createShipment.ejs | 3 ++- back/methods/mrw-config/createShipment.js | 14 ++++++++++---- .../11080-maroonAnthurium/00-firstScript.sql | 9 +++++++++ package.json | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 db/versions/11080-maroonAnthurium/00-firstScript.sql diff --git a/back/methods/mrw-config/createShipment.ejs b/back/methods/mrw-config/createShipment.ejs index e29d3df7e..7468218f2 100644 --- a/back/methods/mrw-config/createShipment.ejs +++ b/back/methods/mrw-config/createShipment.ejs @@ -26,10 +26,11 @@ <%= expeditionData.fi %> <%= expeditionData.clientName %> <%= expeditionData.phone %> + <%= expeditionData.deliveryObservation %> <%= expeditionData.created %> - <%= expeditionData.expeditionId %> + <%= expeditionData.reference %> <%= expeditionData.serviceType %> 1 <%= expeditionData.weekDays %> diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 081a83382..1bbfeaab2 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -45,7 +45,7 @@ module.exports = Self => { `SELECT CASE co.code WHEN 'ES' THEN a.postalCode - WHEN 'PT' THEN LEFT(a.postalCode, 4) + WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim) WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00') END postalCode, a.city, @@ -56,9 +56,10 @@ module.exports = Self => { c.phone, DATE_FORMAT(t.shipped, '%d/%m/%Y') created, t.shipped, - e.id expeditionId, - LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType, - IF(mw.weekdays, 'S', 'N') weekDays + CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, + LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType, + IF(mw.weekdays, 'S', 'N') weekDays, + oa.description deliveryObservation FROM expedition e JOIN ticket t ON e.ticketFk = t.id JOIN agencyMode am ON am.id = t.agencyModeFk @@ -66,8 +67,12 @@ module.exports = Self => { LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a') JOIN client c ON t.clientFk = c.id JOIN address a ON t.addressFk = a.id + LEFT JOIN addressObservation oa ON oa.addressFk = a.id + LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk + AND ot.code = 'delivery' JOIN province p ON a.provinceFk = p.id JOIN country co ON co.id = p.countryFk + JOIN mrwConfig mc WHERE e.id = ? LIMIT 1`; @@ -92,6 +97,7 @@ module.exports = Self => { if (tx) await tx.commit(); + console.log('file: ', file); return {shipmentId, file}; }; diff --git a/db/versions/11080-maroonAnthurium/00-firstScript.sql b/db/versions/11080-maroonAnthurium/00-firstScript.sql new file mode 100644 index 000000000..651cd4c7c --- /dev/null +++ b/db/versions/11080-maroonAnthurium/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS counterWidth INT UNSIGNED NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS serviceTypeWidth INT UNSIGNED NULL + COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.'; + +ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS portugalPostCodeTrim INT UNSIGNED NULL + COMMENT 'It will trim the last characters of the postal code'; diff --git a/package.json b/package.json index 6872fee36..4df55c492 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.22.6", + "version": "24.22.7", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", -- 2.40.1 From 988b3cbbee67f94e10897f35c117bece50cd9c80 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 31 May 2024 11:53:55 +0200 Subject: [PATCH 2/2] fix: refs #6404 ref #6404 remove console.log --- back/methods/mrw-config/createShipment.js | 1 - 1 file changed, 1 deletion(-) diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 1bbfeaab2..dd2ed883a 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -97,7 +97,6 @@ module.exports = Self => { if (tx) await tx.commit(); - console.log('file: ', file); return {shipmentId, file}; }; -- 2.40.1