From 703c224e91e2e5d0ab668fc68224be3363723f6a Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 12 Jun 2023 10:26:50 +0200 Subject: [PATCH 1/2] refs #5513 modified-entry email --- db/dump/fixtures.sql | 3 ++- modules/entry/back/methods/entry/addFromBuy.js | 2 +- .../back/methods/supplier/getItemsPackaging.js | 4 ++-- .../email/modified-entry/assets/css/import.js | 11 +++++++++++ .../templates/email/modified-entry/locale/en.yml | 3 +++ .../templates/email/modified-entry/locale/es.yml | 3 +++ .../email/modified-entry/modified-entry.html | 11 +++++++++++ .../email/modified-entry/modified-entry.js | 16 ++++++++++++++++ 8 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 print/templates/email/modified-entry/assets/css/import.js create mode 100644 print/templates/email/modified-entry/locale/en.yml create mode 100644 print/templates/email/modified-entry/locale/es.yml create mode 100644 print/templates/email/modified-entry/modified-entry.html create mode 100755 print/templates/email/modified-entry/modified-entry.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 4441ec19c..5e3efd1de 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2732,7 +2732,8 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) (1, 'print-email', 'notification fixture one'), (2, 'invoice-electronic', 'A electronic invoice has been generated'), (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), - (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'); + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), + (5, 'modified-entry', 'An entry has been modified'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index f7e1b637e..bfbd1b416 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -46,7 +46,7 @@ module.exports = Self => { } try { - let buy = await models.Buy.findOne({where: {entryFk: args.id}}, myOptions); + let buy = await models.Buy.findOne({where: {entryFk: args.id, itemFk: args.item}}, myOptions); if (buy) await buy.updateAttribute('printedStickers', args.printedStickers, myOptions); else { diff --git a/modules/supplier/back/methods/supplier/getItemsPackaging.js b/modules/supplier/back/methods/supplier/getItemsPackaging.js index 8ef80529b..c06195a55 100644 --- a/modules/supplier/back/methods/supplier/getItemsPackaging.js +++ b/modules/supplier/back/methods/supplier/getItemsPackaging.js @@ -26,14 +26,14 @@ module.exports = Self => { Self.getItemsPackaging = async(id, entry) => { return Self.rawSql(` WITH entryTmp AS ( - SELECT i.id, SUM(b.quantity) quantity + SELECT i.id, SUM(b.quantity) quantity, SUM(b.printedStickers) printedStickers FROM vn.entry e JOIN vn.buy b ON b.entryFk = e.id JOIN vn.supplier s ON s.id = e.supplierFk JOIN vn.item i ON i.id = b.itemFk WHERE e.id = ? AND e.supplierFk = ? GROUP BY i.id - ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal + ) SELECT i.id, i.name, et.quantity, SUM(b.quantity) quantityTotal, et.printedStickers FROM vn.buy b JOIN vn.item i ON i.id = b.itemFk JOIN vn.entry e ON e.id = b.entryFk diff --git a/print/templates/email/modified-entry/assets/css/import.js b/print/templates/email/modified-entry/assets/css/import.js new file mode 100644 index 000000000..4b4bb7086 --- /dev/null +++ b/print/templates/email/modified-entry/assets/css/import.js @@ -0,0 +1,11 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/modified-entry/locale/en.yml b/print/templates/email/modified-entry/locale/en.yml new file mode 100644 index 000000000..c70cfe5cc --- /dev/null +++ b/print/templates/email/modified-entry/locale/en.yml @@ -0,0 +1,3 @@ +subject: Modified entry +title: Modified entry +description: 'From Warehouse the following packaging entry has been created/modified: ' diff --git a/print/templates/email/modified-entry/locale/es.yml b/print/templates/email/modified-entry/locale/es.yml new file mode 100644 index 000000000..72ddb5ca5 --- /dev/null +++ b/print/templates/email/modified-entry/locale/es.yml @@ -0,0 +1,3 @@ +subject: Entrada modificada +title: Entrada modificada +description: 'Desde Almacén se ha creado/modificado la siguiente entrada de embalajes: ' diff --git a/print/templates/email/modified-entry/modified-entry.html b/print/templates/email/modified-entry/modified-entry.html new file mode 100644 index 000000000..a0f297354 --- /dev/null +++ b/print/templates/email/modified-entry/modified-entry.html @@ -0,0 +1,11 @@ + +
+
+

{{ $t('title') }}

+

+ {{ $t('description') }} + {{ url }} +

+
+
+
diff --git a/print/templates/email/modified-entry/modified-entry.js b/print/templates/email/modified-entry/modified-entry.js new file mode 100755 index 000000000..35474a12f --- /dev/null +++ b/print/templates/email/modified-entry/modified-entry.js @@ -0,0 +1,16 @@ +const Component = require(`vn-print/core/component`); +const emailBody = new Component('email-body'); + +module.exports = { + name: 'modified-entry', + components: { + 'email-body': emailBody.build(), + }, + props: { + url: { + type: String, + required: true + } + } +}; + From 2a34abac611ba522648bba05a85890b21d714384 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 15 Jun 2023 12:06:42 +0200 Subject: [PATCH 2/2] refs #5513 minor fixes --- print/templates/email/modified-entry/locale/en.yml | 2 +- print/templates/email/modified-entry/locale/es.yml | 2 +- print/templates/email/modified-entry/modified-entry.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/print/templates/email/modified-entry/locale/en.yml b/print/templates/email/modified-entry/locale/en.yml index c70cfe5cc..7bdfa15ff 100644 --- a/print/templates/email/modified-entry/locale/en.yml +++ b/print/templates/email/modified-entry/locale/en.yml @@ -1,3 +1,3 @@ subject: Modified entry title: Modified entry -description: 'From Warehouse the following packaging entry has been created/modified: ' +description: From Warehouse the following packaging entry has been created/modified diff --git a/print/templates/email/modified-entry/locale/es.yml b/print/templates/email/modified-entry/locale/es.yml index 72ddb5ca5..5a00307f9 100644 --- a/print/templates/email/modified-entry/locale/es.yml +++ b/print/templates/email/modified-entry/locale/es.yml @@ -1,3 +1,3 @@ subject: Entrada modificada title: Entrada modificada -description: 'Desde Almacén se ha creado/modificado la siguiente entrada de embalajes: ' +description: Desde Almacén se ha creado/modificado la siguiente entrada de embalajes diff --git a/print/templates/email/modified-entry/modified-entry.html b/print/templates/email/modified-entry/modified-entry.html index a0f297354..869d019a4 100644 --- a/print/templates/email/modified-entry/modified-entry.html +++ b/print/templates/email/modified-entry/modified-entry.html @@ -3,7 +3,7 @@

{{ $t('title') }}

- {{ $t('description') }} + {{ $t('description') }}: {{ url }}