From d8159487954243c1595447f5beb14a588c7f0e75 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Fri, 3 Jan 2020 13:52:42 +0100 Subject: [PATCH 1/4] Added buyer week-waste email #1972 --- .../buyer-week-waste/assets/css/import.js | 8 +++ .../buyer-week-waste/buyer-week-waste.html | 69 +++++++++++++++++++ .../buyer-week-waste/buyer-week-waste.js | 31 +++++++++ .../email/buyer-week-waste/locale/es.yml | 8 +++ 4 files changed, 116 insertions(+) create mode 100644 print/templates/email/buyer-week-waste/assets/css/import.js create mode 100644 print/templates/email/buyer-week-waste/buyer-week-waste.html create mode 100755 print/templates/email/buyer-week-waste/buyer-week-waste.js create mode 100644 print/templates/email/buyer-week-waste/locale/es.yml diff --git a/print/templates/email/buyer-week-waste/assets/css/import.js b/print/templates/email/buyer-week-waste/assets/css/import.js new file mode 100644 index 000000000..b44d6bd37 --- /dev/null +++ b/print/templates/email/buyer-week-waste/assets/css/import.js @@ -0,0 +1,8 @@ +const Stylesheet = require(`${appPath}/core/stylesheet`); + +module.exports = new Stylesheet([ + `${appPath}/common/css/spacing.css`, + `${appPath}/common/css/misc.css`, + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/email.css`]) + .mergeStyles(); diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.html b/print/templates/email/buyer-week-waste/buyer-week-waste.html new file mode 100644 index 000000000..a0405e5f2 --- /dev/null +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.html @@ -0,0 +1,69 @@ + + + + + + {{ $t('subject') }} + + + + + + + + +
+ +
+
+
+ +
+
+ +
+
+ +
+
+

{{ $t('title') }}

+

{{$t('dear')}},

+

+
+
+ +
+
+ + + + + + + + + + + + + + + + + +
{{$t('buyer')}}{{$t('percentage')}}{{$t('dwindle')}}{{$t('total')}}
{{waste.buyer}}{{waste.porcentaje | percentage(2, 2, locale)}}{{waste.mermas | currency('EUR', locale)}}{{waste.total | currency('EUR', locale)}}
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.js b/print/templates/email/buyer-week-waste/buyer-week-waste.js new file mode 100755 index 000000000..4639e7d5b --- /dev/null +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.js @@ -0,0 +1,31 @@ +const Component = require(`${appPath}/core/component`); +const db = require(`${appPath}/core/database`); +const emailHeader = new Component('email-header'); +const emailFooter = new Component('email-footer'); + +module.exports = { + name: 'buyer-week-waste', + async serverPrefetch() { + this.wastes = await this.fetchWastes(); + + if (!this.wastes) + throw new Error('Something went wrong'); + }, + computed: { + dated: function() { + const filters = this.$options.filters; + + return filters.date(new Date(), '%d-%m-%Y'); + } + }, + methods: { + fetchWastes() { + return db.findOne(`CALL bs.weekWaste()`); + } + }, + components: { + 'email-header': emailHeader.build(), + 'email-footer': emailFooter.build() + }, + props: {} +}; diff --git a/print/templates/email/buyer-week-waste/locale/es.yml b/print/templates/email/buyer-week-waste/locale/es.yml new file mode 100644 index 000000000..1bf0e0938 --- /dev/null +++ b/print/templates/email/buyer-week-waste/locale/es.yml @@ -0,0 +1,8 @@ +subject: Resumen semanal +title: Resumen semanal +dear: Hola +description: A continuación se muestra el resumen semanal a fecha de {0}. +buyer: Comprador +percentage: Porcentaje +dwindle: Mermas +total: Total \ No newline at end of file From e7433fab2470ad30265d93c1c55b94ad4a699ef6 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 8 Jan 2020 08:53:07 +0100 Subject: [PATCH 2/4] some fixes --- .../templates/email/buyer-week-waste/buyer-week-waste.html | 2 +- print/templates/email/buyer-week-waste/locale/es.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.html b/print/templates/email/buyer-week-waste/buyer-week-waste.html index a0405e5f2..9cf3aeefb 100644 --- a/print/templates/email/buyer-week-waste/buyer-week-waste.html +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.html @@ -43,7 +43,7 @@ {{waste.buyer}} - {{waste.porcentaje | percentage(2, 2, locale)}} + {{(waste.porcentaje / 100) | percentage(4, 4, locale)}} {{waste.mermas | currency('EUR', locale)}} {{waste.total | currency('EUR', locale)}} diff --git a/print/templates/email/buyer-week-waste/locale/es.yml b/print/templates/email/buyer-week-waste/locale/es.yml index 1bf0e0938..b0595a1b4 100644 --- a/print/templates/email/buyer-week-waste/locale/es.yml +++ b/print/templates/email/buyer-week-waste/locale/es.yml @@ -1,7 +1,7 @@ -subject: Resumen semanal -title: Resumen semanal +subject: Merma semanal +title: Merma semanal dear: Hola -description: A continuación se muestra el resumen semanal a fecha de {0}. +description: A continuación se muestra la merma semanal a fecha de {0}. buyer: Comprador percentage: Porcentaje dwindle: Mermas From 6c9def9c6cfaa7fb5d1bd788d3fdb5df8384fb65 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Wed, 8 Jan 2020 09:06:19 +0100 Subject: [PATCH 3/4] changed translation --- .../templates/email/buyer-week-waste/buyer-week-waste.html | 6 +++--- print/templates/email/buyer-week-waste/locale/es.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.html b/print/templates/email/buyer-week-waste/buyer-week-waste.html index 9cf3aeefb..99dbd92af 100644 --- a/print/templates/email/buyer-week-waste/buyer-week-waste.html +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.html @@ -36,15 +36,15 @@ {{$t('buyer')}} {{$t('percentage')}} - {{$t('dwindle')}} + {{$t('weakening')}} {{$t('total')}} {{waste.buyer}} - {{(waste.porcentaje / 100) | percentage(4, 4, locale)}} - {{waste.mermas | currency('EUR', locale)}} + {{(waste.percentage / 100) | percentage(4, 4, locale)}} + {{waste.weakening | currency('EUR', locale)}} {{waste.total | currency('EUR', locale)}} diff --git a/print/templates/email/buyer-week-waste/locale/es.yml b/print/templates/email/buyer-week-waste/locale/es.yml index b0595a1b4..96e49d9eb 100644 --- a/print/templates/email/buyer-week-waste/locale/es.yml +++ b/print/templates/email/buyer-week-waste/locale/es.yml @@ -4,5 +4,5 @@ dear: Hola description: A continuación se muestra la merma semanal a fecha de {0}. buyer: Comprador percentage: Porcentaje -dwindle: Mermas +weakening: Mermas total: Total \ No newline at end of file From 0999c7e2ca90a10a310f70fbdd7d00ac3b8764ae Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 9 Jan 2020 07:54:34 +0100 Subject: [PATCH 4/4] renamed field --- print/templates/email/buyer-week-waste/buyer-week-waste.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.html b/print/templates/email/buyer-week-waste/buyer-week-waste.html index 99dbd92af..47d162a6f 100644 --- a/print/templates/email/buyer-week-waste/buyer-week-waste.html +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.html @@ -36,7 +36,7 @@ {{$t('buyer')}} {{$t('percentage')}} - {{$t('weakening')}} + {{$t('dwindle')}} {{$t('total')}} @@ -44,7 +44,7 @@ {{waste.buyer}} {{(waste.percentage / 100) | percentage(4, 4, locale)}} - {{waste.weakening | currency('EUR', locale)}} + {{waste.dwindle | currency('EUR', locale)}} {{waste.total | currency('EUR', locale)}}