diff --git a/e2e/paths/claim-module/03_detail.spec.js b/e2e/paths/claim-module/03_detail.spec.js index 1a7112ff8..55e12fc52 100644 --- a/e2e/paths/claim-module/03_detail.spec.js +++ b/e2e/paths/claim-module/03_detail.spec.js @@ -44,7 +44,7 @@ describe('Claim detail', () => { .waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText'); expect(claimedQuantity).toEqual('10'); - expect(totalClaimed).toEqual('29.50 €'); + expect(totalClaimed).toContain('29.50'); }); it('should delete the second item from the claim', async() => { diff --git a/e2e/paths/client-module/14_risk.spec.js b/e2e/paths/client-module/14_risk.spec.js index 9faea512c..964c0d9b1 100644 --- a/e2e/paths/client-module/14_risk.spec.js +++ b/e2e/paths/client-module/14_risk.spec.js @@ -65,7 +65,7 @@ describe('Client risk path', () => { expect(company).toEqual('VNL'); - expect(firstRiskLineBalance).toEqual('0.00 €'); + expect(firstRiskLineBalance).toContain('0.00'); }); it('should now click the new payment button', async() => { @@ -91,7 +91,7 @@ describe('Client risk path', () => { let result = await nightmare .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); - expect(result).toEqual('100.00 €'); + expect(result).toContain('100.00'); }); it('should again click the new payment button', async() => { @@ -117,7 +117,7 @@ describe('Client risk path', () => { let result = await nightmare .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); - expect(result).toEqual('-50.00 €'); + expect(result).toContain('-€50.00'); }); it('should now click on the Clients button of the top bar menu', async() => { diff --git a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js index a23363675..d48b67c81 100644 --- a/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js +++ b/e2e/paths/ticket-module/06_edit_basic_data_steps.spec.js @@ -73,7 +73,7 @@ describe('Ticket Edit basic data path', () => { .wait(1900) .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); - expect(result).toContain('-187.75 €'); + expect(result).toContain('-€187.75'); }); it(`should then click next to move on to step three`, async() => { diff --git a/front/core/filters/currency.js b/front/core/filters/currency.js index 874305f08..d44457813 100644 --- a/front/core/filters/currency.js +++ b/front/core/filters/currency.js @@ -5,15 +5,29 @@ import ngModule from '../module'; * * @return {String} The formated number */ -export default function currency() { - return function(input, symbol, fractionSize) { - if (!fractionSize) - fractionSize = 2; - if (typeof input == 'number' && fractionSize) { - input = input.toFixed(fractionSize); - return `${input} ${symbol}`; + +export default function currency($translate) { + function currency(input, symbol = 'EUR', fractionSize = 2) { + let options = { + style: 'currency', + currency: symbol, + minimumFractionDigits: fractionSize, + maximumFractionDigits: fractionSize + }; + + if (typeof input == 'number') { + return new Intl.NumberFormat($translate.use(), options) + .format(input); } + return undefined; - }; + } + + currency.$stateful = true; + + return currency; } + +currency.$inject = ['$translate']; + ngModule.filter('currency', currency); diff --git a/front/core/filters/specs/currency.spec.js b/front/core/filters/specs/currency.spec.js index db5a0c163..28a4a3640 100644 --- a/front/core/filters/specs/currency.spec.js +++ b/front/core/filters/specs/currency.spec.js @@ -12,28 +12,28 @@ describe('Currency filter', () => { }; it('should return a ONE decimal number as per the argument', () => { - let html = `
{{200 | currency: '€': 1}}
`; + let html = `
{{200 | currency: 'EUR': 1}}
`; compile(html); - expect($element[0].innerHTML).toEqual('200.0 €'); + expect($element[0].innerHTML).toContain('200.0'); }); it('should return a TWO decimals number as per the argument', () => { - let html = `
{{200 | currency: '€': 2}}
`; + let html = `
{{200 | currency: 'EUR': 2}}
`; compile(html); - expect($element[0].innerHTML).toEqual('200.00 €'); + expect($element[0].innerHTML).toContain('200.00'); }); it('should return a TEN decimals number as per the argument', () => { - let html = `
{{200 | currency: '€': 10}}
`; + let html = `
{{200 | currency: 'EUR': 10}}
`; compile(html); - expect($element[0].innerHTML).toEqual('200.0000000000 €'); + expect($element[0].innerHTML).toContain('200.0000000000'); }); it('sould return nothing when the value is not set', () => { - let html = `
{{null | currency: '€': 2}}
`; + let html = `
{{null | currency: 'EUR': 2}}
`; compile(html); expect($element[0].innerHTML).toEqual(''); diff --git a/gulpfile.js b/gulpfile.js index fce5555ce..831ae6dde 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -50,6 +50,7 @@ function backWatch(done) { nodemon({ exec: commands.join(' && '), + ext: 'js html css', args: ['backOnly'], watch: backSources, done: done diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 06060fe67..b94e67a0c 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -30,5 +30,6 @@ "You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client", "Worker cannot be blank": "Worker cannot be blank", "You must delete the claim id %d first": "You must delete the claim id %d first", - "You don't have enough privileges": "You don't have enough privileges" + "You don't have enough privileges": "You don't have enough privileges", + "Tag value cannot be blank": "Tag value cannot be blank" } \ No newline at end of file diff --git a/modules/agency/front/descriptor/index.html b/modules/agency/front/descriptor/index.html index 27042bdfc..e3a42f346 100644 --- a/modules/agency/front/descriptor/index.html +++ b/modules/agency/front/descriptor/index.html @@ -35,10 +35,10 @@ value="{{$ctrl.zone.travelingDays}}"> + value="{{$ctrl.zone.price | currency: 'EUR': 2}}"> + value="{{$ctrl.zone.price | currency: 'EUR': 2}}"> diff --git a/modules/agency/front/index/index.html b/modules/agency/front/index/index.html index 17b978b70..9ee708672 100644 --- a/modules/agency/front/index/index.html +++ b/modules/agency/front/index/index.html @@ -37,7 +37,7 @@ {{::zone.agencyMode.name}} {{::zone.warehouse.name}} {{::zone.hour | date: 'HH:mm'}} - {{::zone.price | currency:'€':2}} + {{::zone.price | currency: 'EUR':2}} + value="{{::$ctrl.summary.price | currency: 'EUR': 2}}"> + value="{{::$ctrl.summary.price | currency: 'EUR': 2}}"> diff --git a/modules/claim/front/action/index.html b/modules/claim/front/action/index.html index ff979c4be..f86b9650b 100644 --- a/modules/claim/front/action/index.html +++ b/modules/claim/front/action/index.html @@ -10,7 +10,7 @@
+ value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
@@ -75,12 +75,12 @@ {{saleClaimed.sale.ticket.landed | dateTime: 'dd/MM/yyyy'}} {{saleClaimed.sale.quantity}} {{saleClaimed.sale.concept}} - {{saleClaimed.sale.price | currency:'€':2}} + {{saleClaimed.sale.price | currency: 'EUR':2}} {{saleClaimed.sale.discount}} % {{(saleClaimed.sale.quantity * saleClaimed.sale.price) - ((saleClaimed.sale.discount * - (saleClaimed.sale.quantity * saleClaimed.sale.price))/100) | currency:'€':2 + (saleClaimed.sale.quantity * saleClaimed.sale.price))/100) | currency: 'EUR':2 }} @@ -138,10 +138,10 @@ {{sale.landed | dateTime: 'dd/MM/yyyy'}} {{sale.quantity}} {{sale.concept}} - {{sale.price | currency:'€':2}} + {{sale.price | currency: 'EUR':2}} {{sale.discount}} % - {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2}} + {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency: 'EUR':2}} diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html index c9f6a0f38..0c0fe1140 100644 --- a/modules/claim/front/detail/index.html +++ b/modules/claim/front/detail/index.html @@ -12,10 +12,10 @@
+ value="{{$ctrl.paidTotal | currency: 'EUR':2}}"> + value="{{$ctrl.claimedTotal | currency: 'EUR':2}}">
@@ -52,10 +52,10 @@
{{::saleClaimed.sale.concept}} - {{::saleClaimed.sale.price | currency:'€':2}} + {{::saleClaimed.sale.price | currency: 'EUR':2}} {{::saleClaimed.sale.discount}} % - {{::$ctrl.getSaleTotal(saleClaimed.sale) | currency:'€':2}} + {{::$ctrl.getSaleTotal(saleClaimed.sale) | currency: 'EUR':2}} {{sale.landed | dateTime: 'dd/MM/yyyy'}} {{sale.quantity}} {{sale.concept}} - {{sale.price | currency:'€':2}} + {{sale.price | currency: 'EUR':2}} {{sale.discount}} % - {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency:'€':2}} + {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency: 'EUR':2}} diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 3966c6d5e..e624d7434 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -63,12 +63,12 @@ {{saleClaimed.sale.quantity}} {{saleClaimed.quantity}} {{saleClaimed.sale.concept}} - {{saleClaimed.sale.price | currency:'€':2}} + {{saleClaimed.sale.price | currency: 'EUR':2}} {{saleClaimed.sale.discount}} % {{(saleClaimed.sale.quantity * saleClaimed.sale.price) - ((saleClaimed.sale.discount * - (saleClaimed.sale.quantity * saleClaimed.sale.price))/100) | currency:'€':2 + (saleClaimed.sale.quantity * saleClaimed.sale.price))/100) | currency: 'EUR':2 }} @@ -138,7 +138,7 @@ {{(action.sale.quantity * action.sale.price) - ((action.sale.discount * - (action.sale.quantity * action.sale.price))/100) | currency:'€':2 + (action.sale.quantity * action.sale.price))/100) | currency: 'EUR':2 }} diff --git a/modules/client/front/credit-insurance/insurance/index/index.html b/modules/client/front/credit-insurance/insurance/index/index.html index fc58eaa29..6d74d01ea 100644 --- a/modules/client/front/credit-insurance/insurance/index/index.html +++ b/modules/client/front/credit-insurance/insurance/index/index.html @@ -18,7 +18,7 @@ - {{::insurance.credit | currency: ' €': 2}} + {{::insurance.credit | currency: 'EUR': 2}} {{::insurance.grade}} {{::insurance.created | date: 'dd/MM/yyyy'}} diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index 3c088add6..35df1f929 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -27,10 +27,10 @@ value="{{$ctrl.client.phone | phone}}"> + value="{{$ctrl.client.credit | currency: 'EUR': 2}}"> + value="{{$ctrl.client.creditInsurance | currency: 'EUR': 2}}"> diff --git a/modules/client/front/greuge/index/index.html b/modules/client/front/greuge/index/index.html index 213ccab53..3e3866b8f 100644 --- a/modules/client/front/greuge/index/index.html +++ b/modules/client/front/greuge/index/index.html @@ -15,7 +15,7 @@
+ value="{{edit.model.sumAmount | currency: 'EUR': 2}}">
@@ -33,7 +33,7 @@ {{::greuge.shipped | date:'dd/MM/yyyy HH:mm' }} {{::greuge.description}} - {{::greuge.amount | currency: ' €': 2}} + {{::greuge.amount | currency: 'EUR': 2}} {{::greuge.greugeType.name}}
diff --git a/modules/client/front/recovery/index/index.html b/modules/client/front/recovery/index/index.html index 35bf0ea25..b130d73c2 100644 --- a/modules/client/front/recovery/index/index.html +++ b/modules/client/front/recovery/index/index.html @@ -32,7 +32,7 @@
{{::recovery.started | date:'dd/MM/yyyy' }} {{recovery.finished | date:'dd/MM/yyyy' }} - {{::recovery.amount | currency:' €': 0}} + {{::recovery.amount | currency: 'EUR': 0}} {{::recovery.period}} diff --git a/modules/client/front/risk/index/index.html b/modules/client/front/risk/index/index.html index a11e01724..8313a12f2 100644 --- a/modules/client/front/risk/index/index.html +++ b/modules/client/front/risk/index/index.html @@ -34,7 +34,7 @@ + value="{{riskByCompany.amount | currency: 'EUR':2}}"> @@ -65,9 +65,9 @@ BILL {{::risk.ref}} {{::risk.bankFk}} - {{::risk.debit | currency:'€':2}} - {{::risk.credit | currency:'€':2}} - {{risk.balance | currency:'€':2}} + {{::risk.debit | currency: 'EUR':2}} + {{::risk.credit | currency: 'EUR':2}} + {{risk.balance | currency: 'EUR':2}}

Business data

+ value="{{$ctrl.summary.totalGreuge | currency: 'EUR':2}}"> + value="{{$ctrl.summary.mana.mana | currency: 'EUR':2}}"> + value="{{$ctrl.summary.averageInvoiced.invoiced | currency: 'EUR':2}}"> @@ -167,26 +167,26 @@

Financial information

diff --git a/modules/client/front/web-payment/index.html b/modules/client/front/web-payment/index.html index c148a2b52..94da3f9a5 100644 --- a/modules/client/front/web-payment/index.html +++ b/modules/client/front/web-payment/index.html @@ -33,7 +33,7 @@
{{::transaction.id}} - {{::transaction.amount | currency: '€':2}} + {{::transaction.amount | currency: 'EUR':2}} {{::transaction.created | dateTime:'dd/MM/yyyy'}} { require('../methods/item-tag/filterItemTags')(Self); - Self.validatesPresenceOf('value', {message: 'Tag value cannot be blank'}); + Self.rewriteDbError(function(err) { + if (err.code === 'ER_BAD_NULL_ERROR') + return new UserError(`Tag value cannot be blank`); + return err; + }); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') diff --git a/modules/order/front/catalog/index.html b/modules/order/front/catalog/index.html index c4ba3e49a..26389c7b6 100644 --- a/modules/order/front/catalog/index.html +++ b/modules/order/front/catalog/index.html @@ -74,7 +74,7 @@ {{::item.available}} from - {{::item.price | currency: ' €': 2}} + {{::item.price | currency: 'EUR': 2}} diff --git a/modules/order/front/descriptor/index.html b/modules/order/front/descriptor/index.html index 51776be31..03b5f1f3f 100644 --- a/modules/order/front/descriptor/index.html +++ b/modules/order/front/descriptor/index.html @@ -35,7 +35,7 @@ value="{{$ctrl.order.rows.length || 0}}"> + value="{{$ctrl.order.total | currency: 'EUR': 2}}"> \ No newline at end of file diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 32dcc9afe..0d8f21e1f 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -116,10 +116,10 @@ ng-click="$ctrl.showEditPricePopover($event, sale)" pointer vn-tooltip="Edit price"> - {{sale.price | currency:'€':2}} + {{sale.price | currency: 'EUR':2}} - {{sale.price | currency:'€':2}} + {{sale.price | currency: 'EUR':2}} - {{$ctrl.getSaleTotal(sale) | currency:'€':2}} + {{$ctrl.getSaleTotal(sale) | currency: 'EUR':2}} @@ -146,15 +146,15 @@ ng-if="$ctrl.sales.length > 0">

Subtotal - {{$ctrl.subTotal | currency:'€':2}} + {{$ctrl.subTotal | currency: 'EUR':2}}

VAT - {{$ctrl.VAT | currency:'€':2}} + {{$ctrl.VAT | currency: 'EUR':2}}

Total - {{$ctrl.total | currency:'€':2}} + {{$ctrl.total | currency: 'EUR':2}}

@@ -169,7 +169,7 @@ vn-id="editPricePopover" on-open="$ctrl.getManaSalespersonMana()"> -
MANÁ: {{$ctrl.mana | currency:'€':0}}
+
MANÁ: {{$ctrl.mana | currency: 'EUR':0}}
New price

{{($ctrl.sale.quantity * $ctrl.editedPrice) - (($ctrl.sale.discount * ($ctrl.sale.quantity * $ctrl.editedPrice))/100) - | currency:'€':2}}

+ | currency: 'EUR':2}}

diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 508cb8928..c8535d5ec 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -46,9 +46,9 @@ -

Subtotal {{$ctrl.summary.subTotal | currency:' €':2}}

-

VAT {{$ctrl.summary.VAT | currency:' €':2}}

-

Total {{$ctrl.summary.total | currency:' €':2}}

+

Subtotal {{$ctrl.summary.subTotal | currency: 'EUR':2}}

+

VAT {{$ctrl.summary.VAT | currency: 'EUR':2}}

+

Total {{$ctrl.summary.total | currency: 'EUR':2}}

Sale

@@ -92,9 +92,9 @@
{{::sale.quantity}} - {{::sale.price | currency:'€':2}} + {{::sale.price | currency: 'EUR':2}} {{::sale.discount}} % - {{::sale.quantity * sale.price | currency:'€':2}} + {{::sale.quantity * sale.price | currency: 'EUR':2}} No results diff --git a/print/common/css/layout.css b/print/common/css/layout.css index 294593142..2f2a4f7c9 100644 --- a/print/common/css/layout.css +++ b/print/common/css/layout.css @@ -34,8 +34,8 @@ } .row { - margin-bottom: 15px; - overflow: hidden + white-space: nowrap; + margin-bottom: 15px } .row.small { @@ -52,10 +52,6 @@ box-sizing: border-box } -.row .text, .row .control { - overflow: hidden -} - .row .description { position: relative; padding-top: 2px; @@ -87,17 +83,18 @@ } .row.inline .text { + display: inline-block; margin-bottom: 0; width: 40%; - float: left + } .row.inline .control { + display: inline-block; font-weight: bold; padding-left: 20px; color: #000; - width: 60%; - float: left + width: 60% } .row.inline .description { @@ -105,36 +102,29 @@ overflow: visible } -.grid { - border-bottom: 3px solid #888888 -} - -.grid .row { - padding: 5px; - margin-bottom: 0 -} - -.grid .header { - border-bottom: 1px solid #808080; - border-top: 1px solid #808080; - font-weight: bold -} - -.grid .row.inline > section { - float: left; -} - .panel { - border: 1px solid #DDD; - margin-bottom: 10px; - position: relative; - padding:20px + position: relative } .panel .header { background-color: #FFF; + position:absolute; + left: 17.5px; + top: -12px; + padding: 2.5px 5px; + font-weight: bold; - margin-top: -20px +} + +.panel .body { + border: 1px solid #CCC; + margin-top: 10px; + overflow: hidden; + padding: 20px +} + +.panel .body h3 { + margin-top: 0 } .box { @@ -161,4 +151,55 @@ .pull-right { float: right -} \ No newline at end of file +} + +.verticalText { + -moz-transform: rotate(90deg); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); + position: absolute; + text-align: center; + font-size: .65em; + width: 200px; + border: 2px solid #000; + right: -110px; + top: 50% +} + +vn-table { + border-collapse: collapse; + margin: 20px 0; + display: table; + width: 100%; +} + +vn-thead { + border-bottom: 1px solid #808080; + border-top: 1px solid #808080; + display: table-header-group +} + +vn-tbody { + border-top: 3px solid #888888; + display: table-row-group +} + +vn-tfoot { + border-top: 1px solid #808080; + display: table-footer-group +} + +vn-tr { + display: table-row +} + +vn-th { + font-weight: bold +} + +vn-td, vn-th { + vertical-align: middle; + display: table-cell; + text-align: left; + padding: 5px 0 +} diff --git a/print/config/routes.json b/print/config/routes.json index added704e..242557e51 100644 --- a/print/config/routes.json +++ b/print/config/routes.json @@ -8,6 +8,8 @@ {"type": "report", "name": "delivery-note"}, {"type": "report", "name": "invoice"}, {"type": "report", "name": "rpt-claim-pickup-order"}, + {"type": "report", "name": "rpt-letter-debtor"}, + {"type": "report", "name": "rpt-sepa-core"}, {"type": "static", "name": "email-header"}, {"type": "static", "name": "email-footer"}, {"type": "static", "name": "report-header"}, diff --git a/print/lib/reportEngine.js b/print/lib/reportEngine.js index b77d88267..899893b7f 100644 --- a/print/lib/reportEngine.js +++ b/print/lib/reportEngine.js @@ -95,9 +95,10 @@ module.exports = { const template = await fs.readFile(templatePath, 'utf8'); const css = require(stylePath); + const cssOptions = {inlinePseudoElements: true}; component.i18n = require(localePath); - component.template = juice.inlineContent(template, css); + component.template = juice.inlineContent(template, css, cssOptions); }, async toPdf(name, ctx) { diff --git a/print/lib/router.js b/print/lib/router.js index 69b02b702..21aeabe6f 100644 --- a/print/lib/router.js +++ b/print/lib/router.js @@ -16,8 +16,8 @@ module.exports = app => { app.get(`/api/report/${name}`, (request, response, next) => { reportEngine.toPdf(name, request).then(stream => { - response.setHeader('Content-Disposition', `attachment; filename="${name}.pdf"`); - response.setHeader('Content-type', 'application/pdf'); + // response.setHeader('Content-Disposition', `attachment; filename="${name}.pdf"`); + // response.setHeader('Content-type', 'application/pdf'); stream.pipe(response); }).catch(e => { next(e); diff --git a/print/report/client-welcome/index.js b/print/report/client-welcome/index.js index d3ac31205..aeca24a06 100755 --- a/print/report/client-welcome/index.js +++ b/print/report/client-welcome/index.js @@ -1,6 +1,4 @@ const database = require(`${appPath}/lib/database`); -const emailHeader = require('../email-header'); -const emailFooter = require('../email-footer'); const UserException = require(`${appPath}/lib/exceptions/userException`); module.exports = { @@ -42,7 +40,7 @@ module.exports = { }, }, components: { - 'email-header': emailHeader, - 'email-footer': emailFooter, + 'email-header': require('../email-header'), + 'email-footer': require('../email-footer'), }, }; diff --git a/print/report/letter-debtor-nd/assets/css/index.js b/print/report/letter-debtor-nd/assets/css/index.js new file mode 100644 index 000000000..c1943eee1 --- /dev/null +++ b/print/report/letter-debtor-nd/assets/css/index.js @@ -0,0 +1,6 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/letter-debtor-nd/index.js b/print/report/letter-debtor-nd/index.js index 77eec9351..49aa46bbf 100755 --- a/print/report/letter-debtor-nd/index.js +++ b/print/report/letter-debtor-nd/index.js @@ -1,11 +1,11 @@ const database = require(`${appPath}/lib/database`); -const emailHeader = require('../email-header'); -const emailFooter = require('../email-footer'); +const reportEngine = require(`${appPath}/lib/reportEngine.js`); const UserException = require(`${appPath}/lib/exceptions/userException`); module.exports = { name: 'letter-debtor-nd', async asyncData(ctx, params) { + const promises = []; const data = { isPreview: ctx.method === 'GET', }; @@ -16,21 +16,24 @@ module.exports = { if (!params.companyFk) throw new UserException('No company id specified'); - return this.methods.fetchClientData(params.clientFk, params.companyFk) - .then(([result]) => { - return Object.assign(data, result[0]); - }); + promises.push(reportEngine.toPdf('rpt-letter-debtor', ctx)); + promises.push(this.methods.fetchClient(params.clientFk, params.companyFk)); + + return Promise.all(promises).then(result => { + const stream = result[0]; + const [[client]] = result[1]; + + Object.assign(data, client); + Object.assign(data, {attachments: [{filename: 'rpt-letter-debtor.pdf', content: stream}]}); + + return data; + }); }, created() { this.$i18n.locale = this.locale; }, - data() { - return { - attachments: ['http://localhost:8080/report/delivery-note'], - }; - }, methods: { - fetchClientData(clientFk, companyFk) { + fetchClient(clientFk, companyFk) { return database.pool.query(` SELECT u.lang locale, @@ -47,13 +50,8 @@ module.exports = { WHERE c.id = ? AND cny.id = ?`, [clientFk, companyFk]); }, }, - computed: { - accountAddress: function() { - return this.iban.slice(-4); - }, - }, components: { - 'email-header': emailHeader, - 'email-footer': emailFooter, + 'email-header': require('../email-header'), + 'email-footer': require('../email-footer'), }, }; diff --git a/print/report/letter-debtor-nd/locale.js b/print/report/letter-debtor-nd/locale.js index 07b81099f..f15437a72 100644 --- a/print/report/letter-debtor-nd/locale.js +++ b/print/report/letter-debtor-nd/locale.js @@ -6,12 +6,12 @@ module.exports = { sections: { introduction: { title: 'Estimado cliente', - description: `Nos dirigimos a Vd. nuevamente para informarle que sigue - pendiente su deuda con nuestra empresa, tal y como puede comprobar en el extracto adjunto.`, + description: `Nos dirigimos a ti nuevamente para informarte que sigue + pendiente tu deuda con nuestra empresa, tal y como puedes comprobar en el extracto adjunto.`, terms: `Dado que los plazos de pago acordados están ampliamente superados, no procede mayor dilación en la liquidación del importe adeudado.`, }, payMethod: { - description: 'Para ello dispone de las siguientes formas de pago', + description: 'Para ello dispones de las siguientes formas de pago', options: [ 'Pago online desde nuestra web.', 'Ingreso o transferencia al número de cuenta que detallamos al pie de esta carta, indicando el número de cliente.', @@ -27,11 +27,9 @@ module.exports = { ], }, }, - contactPhone: 'Para consultas, puede ponerse en contacto con nosotros en el 96 324 21 00.', - conclusion: 'En espera de sus noticias.
Gracias por su atención.', + contactPhone: 'Para consultas, puedes ponerte en contacto con nosotros en el 96 324 21 00.', + conclusion: 'En espera de tus noticias.
Gracias por tu atención.', transferAccount: 'Datos para transferencia bancaria', }, }, }; - - diff --git a/print/report/letter-debtor-st/assets/css/index.js b/print/report/letter-debtor-st/assets/css/index.js new file mode 100644 index 000000000..c1943eee1 --- /dev/null +++ b/print/report/letter-debtor-st/assets/css/index.js @@ -0,0 +1,6 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/letter-debtor-st/index.js b/print/report/letter-debtor-st/index.js index 8fb51e408..a1a4d8833 100755 --- a/print/report/letter-debtor-st/index.js +++ b/print/report/letter-debtor-st/index.js @@ -1,7 +1,5 @@ const database = require(`${appPath}/lib/database`); const reportEngine = require(`${appPath}/lib/reportEngine.js`); -const emailHeader = require('../email-header'); -const emailFooter = require('../email-footer'); const UserException = require(`${appPath}/lib/exceptions/userException`); @@ -19,7 +17,7 @@ module.exports = { if (!params.companyFk) throw new UserException('No company id specified'); - promises.push(reportEngine.toPdf('delivery-note', ctx)); + promises.push(reportEngine.toPdf('rpt-letter-debtor', ctx)); promises.push(this.methods.fetchClient(params.clientFk, params.companyFk)); return Promise.all(promises).then(result => { @@ -27,7 +25,7 @@ module.exports = { const [[client]] = result[1]; Object.assign(data, client); - Object.assign(data, {attachments: [{filename: 'delivery-note.pdf', content: stream}]}); + Object.assign(data, {attachments: [{filename: 'rpt-letter-debtor.pdf', content: stream}]}); return data; }); @@ -53,13 +51,8 @@ module.exports = { WHERE c.id = ? AND cny.id = ?`, [clientFk, companyFk]); } }, - computed: { - accountAddress: function() { - return this.iban.slice(-4); - }, - }, components: { - 'email-header': emailHeader, - 'email-footer': emailFooter, + 'email-header': require('../email-header'), + 'email-footer': require('../email-footer'), }, }; diff --git a/print/report/letter-debtor-st/locale.js b/print/report/letter-debtor-st/locale.js index 60387e13b..afee35288 100644 --- a/print/report/letter-debtor-st/locale.js +++ b/print/report/letter-debtor-st/locale.js @@ -10,9 +10,9 @@ module.exports = { datos contables, tu cuenta tiene un saldo pendiente de liquidar.`, }, }, - checkExtract: `Te solicitamos compruebes que el extracto adjunto corresponde con los datos de que Vd. dispone. - Nuestro departamento de administración le aclarará gustosamente cualquier duda que pueda tener, - e igualmente le facilitará cualquier documento que solicite.`, + checkExtract: `Te solicitamos compruebes que el extracto adjunto corresponde con los datos de que dispones. + Nuestro departamento de administración te aclarará gustosamente cualquier duda que puedas tener, + e igualmente te facilitará cualquier documento que solicites.`, checkValidData: `Si al comprobar los datos aportados resultaran correctos, te rogamos procedas a regularizar tu situación.`, payMethod: `Si no deseas desplazarte personalmente hasta nuestras oficinas, diff --git a/print/report/report-footer/assets/css/style.css b/print/report/report-footer/assets/css/style.css index cd0f75570..5c44d3a6d 100644 --- a/print/report/report-footer/assets/css/style.css +++ b/print/report/report-footer/assets/css/style.css @@ -1,6 +1,5 @@ footer { font-family: verdana, sans-serif; - margin-top: 30px; font-size: 12px; color: #555; zoom: 0.55 diff --git a/print/report/rpt-claim-pickup-order/assets/css/style.css b/print/report/rpt-claim-pickup-order/assets/css/style.css index 53965a625..dcf1a56ae 100644 --- a/print/report/rpt-claim-pickup-order/assets/css/style.css +++ b/print/report/rpt-claim-pickup-order/assets/css/style.css @@ -7,4 +7,17 @@ margin-top: 0; margin-bottom: 20px; font-size: 2em +} + +vn-table { + margin-top: 50px !important +} + +.sign { + margin: 150px auto; + width: 300px +} + +.sign .body { + height: 150px } \ No newline at end of file diff --git a/print/report/rpt-claim-pickup-order/index.html b/print/report/rpt-claim-pickup-order/index.html index 8d607f537..9862260f2 100644 --- a/print/report/rpt-claim-pickup-order/index.html +++ b/print/report/rpt-claim-pickup-order/index.html @@ -7,7 +7,7 @@
-

{{$t('title')}}

+

{{$t('title')}}

{{$t('claimId')}}:
{{claimId}}
@@ -25,48 +25,47 @@
{{$t('clientData')}}
-

- {{clientName}} -

-
- {{street}} -
-
- {{postcode}}, {{city}} ({{province}}) -
-
- {{country}} +
+

{{clientName}}

+
+ {{street}} +
+
+ {{postcode}}, {{city}} ({{province}}) +
+
+ {{country}} +
-
-
-
{{$t('quantity')}}
-
{{$t('claims')}}
-
{{$t('reference')}}
-
{{$t('concept')}}
-
-
-
{{sale.quantity}} 
-
{{sale.claimQuantity}} 
-
{{sale.id}} 
-
{{sale.concept}} 
+ + + + {{$t('reference')}} + {{$t('quantity')}} + {{$t('claims')}} + {{$t('concept')}} + + + + + {{sale.id}} + {{sale.quantity}} + {{sale.claimQuantity}} + {{sale.concept}} + + + + +
+
+

{{clientName}}

-
-
 
-
-
-
-

{{clientName}}

-
-
-
-
 
-

diff --git a/print/report/rpt-claim-pickup-order/locale.js b/print/report/rpt-claim-pickup-order/locale.js index 9ba80b456..6aefd199e 100644 --- a/print/report/rpt-claim-pickup-order/locale.js +++ b/print/report/rpt-claim-pickup-order/locale.js @@ -1,7 +1,7 @@ module.exports = { messages: { es: { - title: 'ORD. RECOGIDA', + title: 'Ord. recogida', claimId: 'Reclamación', clientId: 'Cliente', date: 'Fecha', diff --git a/print/report/rpt-letter-debtor/assets/css/index.js b/print/report/rpt-letter-debtor/assets/css/index.js new file mode 100644 index 000000000..d40ab4984 --- /dev/null +++ b/print/report/rpt-letter-debtor/assets/css/index.js @@ -0,0 +1,7 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/misc.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/rpt-letter-debtor/assets/css/style.css b/print/report/rpt-letter-debtor/assets/css/style.css new file mode 100644 index 000000000..ae9b314c0 --- /dev/null +++ b/print/report/rpt-letter-debtor/assets/css/style.css @@ -0,0 +1,14 @@ +.container { + color: #000 +} + +.title { + font-weight: 100; + margin-top: 0; + margin-bottom: 20px; + font-size: 2em +} + +vn-table { + margin-top: 50px !important +} \ No newline at end of file diff --git a/print/report/rpt-letter-debtor/index.html b/print/report/rpt-letter-debtor/index.html new file mode 100644 index 000000000..e2458f223 --- /dev/null +++ b/print/report/rpt-letter-debtor/index.html @@ -0,0 +1,77 @@ + + + +
+ +
+
+
+
+

{{$t('title')}}

+
+
{{$t('clientId')}}:
+
{{clientId}}
+
+
+
{{$t('date')}}:
+
{{dated()}}
+
+
+
+
+
+
{{$t('clientData')}}
+
+

{{clientName}}

+
+ {{street}} +
+
+ {{postcode}}, {{city}} ({{province}}) +
+
+ {{country}} +
+
+
+
+
+ + + + + {{$t('date')}} + {{$t('concept')}} + {{$t('invoiced')}} + {{$t('payed')}} + {{$t('balance')}} + + + + + {{toISOString(sale.issued)}} + {{sale.ref}} + {{sale.debtOut}} + {{sale.debtIn}} + {{getBalance(sale)}} + + + + + + Total + {{getTotalDebtOut()}} + {{getTotalDebtIn()}} + {{totalBalance}} + + + +
+ + + +
+ + \ No newline at end of file diff --git a/print/report/rpt-letter-debtor/index.js b/print/report/rpt-letter-debtor/index.js new file mode 100755 index 000000000..2b72b6242 --- /dev/null +++ b/print/report/rpt-letter-debtor/index.js @@ -0,0 +1,98 @@ +const strftime = require('strftime'); +const database = require(`${appPath}/lib/database`); +const UserException = require(`${appPath}/lib/exceptions/userException`); + +module.exports = { + name: 'rpt-letter-debtor', + async asyncData(ctx, params) { + const promises = []; + const data = {}; + + if (!params.clientFk) + throw new UserException('No client id specified'); + + if (!params.companyFk) + throw new UserException('No company id specified'); + + promises.push(this.methods.fetchClient(params.clientFk)); + promises.push(this.methods.fetchSales(params.clientFk, params.companyFk)); + + return Promise.all(promises).then(result => { + const [[client]] = result[0]; + const [[sales]] = result[1]; + + if (!client) + throw new UserException('No client data found'); + + Object.assign(data, client, {sales}); + + return data; + }); + }, + created() { + this.$i18n.locale = this.locale; + }, + data() { + return {totalBalance: 0.00}; + }, + methods: { + fetchClient(clientFk) { + return database.pool.query( + `SELECT + c.id clientId, + u.lang locale, + c.email AS recipient, + c.socialName AS clientName, + c.street, + c.postcode, + c.city, + c.fi, + p.name AS province, + ct.country + FROM client c + JOIN account.user u ON u.id = c.id + JOIN country ct ON ct.id = c.countryFk + LEFT JOIN province p ON p.id = c.provinceFk + WHERE c.id = ?`, [clientFk]); + }, + fetchSales(clientFk, companyFk) { + return database.pool.query( + `CALL vn.clientGetDebtDiary(?, ?)`, [clientFk, companyFk]); + }, + dated: () => { + return strftime('%d-%m-%Y', new Date()); + }, + toISOString: date => { + return strftime('%d-%m-%Y', date); + }, + getBalance(sale) { + if (sale.debtOut) + this.totalBalance += parseFloat(sale.debtOut); + + if (sale.debtIn) + this.totalBalance -= parseFloat(sale.debtIn); + + return parseFloat(this.totalBalance.toFixed(2)); + }, + getTotalDebtOut() { + let debtOut = 0.00; + this.sales.forEach(sale => { + debtOut += sale.debtOut ? parseFloat(sale.debtOut) : 0; + }); + + return debtOut.toFixed(2); + }, + getTotalDebtIn() { + let debtIn = 0.00; + this.sales.forEach(sale => { + debtIn += sale.debtIn ? parseFloat(sale.debtIn) : 0; + }); + + return debtIn.toFixed(2); + }, + }, + components: { + 'report-header': require('../report-header'), + 'report-footer': require('../report-footer'), + }, +}; diff --git a/print/report/rpt-letter-debtor/locale.js b/print/report/rpt-letter-debtor/locale.js new file mode 100644 index 000000000..8ace81596 --- /dev/null +++ b/print/report/rpt-letter-debtor/locale.js @@ -0,0 +1,16 @@ +module.exports = { + messages: { + es: { + title: 'Extracto', + claimId: 'Reclamación', + clientId: 'Cliente', + clientData: 'Datos del cliente', + date: 'Fecha', + concept: 'Concepto', + invoiced: 'Facturado', + payed: 'Pagado', + balance: 'Saldo', + client: 'Cliente {0}' + }, + }, +}; diff --git a/print/report/rpt-sepa-core/assets/css/index.js b/print/report/rpt-sepa-core/assets/css/index.js new file mode 100644 index 000000000..d40ab4984 --- /dev/null +++ b/print/report/rpt-sepa-core/assets/css/index.js @@ -0,0 +1,7 @@ +const CssReader = require(`${appPath}/lib/cssReader`); + +module.exports = new CssReader([ + `${appPath}/common/css/layout.css`, + `${appPath}/common/css/misc.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/report/rpt-sepa-core/assets/css/style.css b/print/report/rpt-sepa-core/assets/css/style.css new file mode 100644 index 000000000..ae9b314c0 --- /dev/null +++ b/print/report/rpt-sepa-core/assets/css/style.css @@ -0,0 +1,14 @@ +.container { + color: #000 +} + +.title { + font-weight: 100; + margin-top: 0; + margin-bottom: 20px; + font-size: 2em +} + +vn-table { + margin-top: 50px !important +} \ No newline at end of file diff --git a/print/report/rpt-sepa-core/index.html b/print/report/rpt-sepa-core/index.html new file mode 100644 index 000000000..3ae44673f --- /dev/null +++ b/print/report/rpt-sepa-core/index.html @@ -0,0 +1,270 @@ + + + +
+ +
+
+
+
{{$t('supplier.toCompleteBySupplier')}}
+
+
{{$t('supplier.orderReference')}}
+
{{mandateCode}}
+
+
+
{{$t('supplier.identifier')}}
+
ES89000B97367486
+
+
+
{{$t('supplier.name')}}
+
{{supplierName}}
+
+
+
{{$t('supplier.street')}}
+
{{supplierStreet}}
+
+
+
{{$t('supplier.location')}}
+
{{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}})
+
+
+
{{$t('supplier.country')}}
+
{{supplierCountry}}
+
+
+
+ +
+
+
{{$t('supplier.toCompleteBySupplier')}}
+
+
{{$t('supplier.orderReference')}}
+
{{mandateCode}}
+
+
+
{{$t('supplier.identifier')}}
+
ES89000B97367486
+
+
+
{{$t('supplier.name')}}
+
{{supplierName}}
+
+
+
{{$t('supplier.street')}}
+
{{supplierStreet}}
+
+
+
{{$t('supplier.location')}}
+
{{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}})
+
+
+
{{$t('supplier.country')}}
+
{{supplierCountry}}
+
+
+
+ +
+
+
{{$t('supplier.toCompleteBySupplier')}}
+
+
{{$t('supplier.orderReference')}}
+
{{mandateCode}}
+
+
+
{{$t('supplier.identifier')}}
+
ES89000B97367486
+
+
+
{{$t('supplier.name')}}
+
{{supplierName}}
+
+
+
{{$t('supplier.street')}}
+
{{supplierStreet}}
+
+
+
{{$t('supplier.location')}}
+
{{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}})
+
+
+
{{$t('supplier.country')}}
+
{{supplierCountry}}
+
+
+
+ + +
+
+
{{$t('supplier.toCompleteBySupplier')}}
+
+
{{$t('supplier.orderReference')}}
+
{{mandateCode}}
+
+
+
{{$t('supplier.identifier')}}
+
ES89000B97367486
+
+
+
{{$t('supplier.name')}}
+
{{supplierName}}
+
+
+
{{$t('supplier.street')}}
+
{{supplierStreet}}
+
+
+
{{$t('supplier.location')}}
+
{{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}})
+
+
+
{{$t('supplier.country')}}
+
{{supplierCountry}}
+
+
+
+ +
+
+
{{$t('supplier.toCompleteBySupplier')}}
+
+
{{$t('supplier.orderReference')}}
+
{{mandateCode}}
+
+
+
{{$t('supplier.identifier')}}
+
ES89000B97367486
+
+
+
{{$t('supplier.name')}}
+
{{supplierName}}
+
+
+
{{$t('supplier.street')}}
+
{{supplierStreet}}
+
+
+
{{$t('supplier.location')}}
+
{{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}})
+
+
+
{{$t('supplier.country')}}
+
{{supplierCountry}}
+
+
+
+ + +
+
+
{{$t('supplier.toCompleteBySupplier')}}
+
+
{{$t('supplier.orderReference')}}
+
{{mandateCode}}
+
+
+
{{$t('supplier.identifier')}}
+
ES89000B97367486
+
+
+
{{$t('supplier.name')}}
+
{{supplierName}}
+
+
+
{{$t('supplier.street')}}
+
{{supplierStreet}}
+
+
+
{{$t('supplier.location')}}
+
{{supplierPostCode}}, {{supplierCity}} ({{supplierProvince}})
+
+
+
{{$t('supplier.country')}}
+
{{supplierCountry}}
+
+
+
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/print/report/rpt-sepa-core/index.js b/print/report/rpt-sepa-core/index.js new file mode 100755 index 000000000..9c4ee6ac6 --- /dev/null +++ b/print/report/rpt-sepa-core/index.js @@ -0,0 +1,67 @@ +const strftime = require('strftime'); +const database = require(`${appPath}/lib/database`); +const UserException = require(`${appPath}/lib/exceptions/userException`); + +module.exports = { + name: 'rpt-sepa-core', + async asyncData(ctx, params) { + if (!params.clientFk) + throw new UserException('No client id specified'); + + if (!params.companyFk) + throw new UserException('No company id specified'); + + return this.methods.fetchClient(params.clientFk) + .then(([[client]]) => { + if (!client) + throw new UserException('No client data found'); + + return client; + }); + }, + created() { + if (this.locale) + this.$i18n.locale = this.locale; + }, + methods: { + fetchClient(clientFk) { + return database.pool.query( + `SELECT + c.id clientId, + u.lang locale, + m.code mandateCode, + c.email AS recipient, + c.socialName AS clientName, + c.street AS clientStreet, + c.postcode AS clientPostCode, + c.city AS clientCity, + p.name AS clientProvince, + ct.country AS clientCountry, + s.name AS supplierName, + s.street AS supplierStreet, + sc.country AS supplierCountry, + s.postCode AS supplierPostCode, + s.city AS supplierCity, + sp.name AS supplierProvince + FROM client c + JOIN account.user u ON u.id = c.id + JOIN country ct ON ct.id = c.countryFk + LEFT JOIN province p ON p.id = c.provinceFk + LEFT JOIN mandate m ON m.clientFk = c.id AND m.finished IS NULL + LEFT JOIN supplier s ON s.id = m.companyFk + LEFT JOIN country sc ON sc.id = s.countryFk + LEFT JOIN province sp ON sp.id = s.provinceFk + WHERE c.id = ?`, [clientFk]); + }, + dated: () => { + return strftime('%d-%m-%Y', new Date()); + }, + toISOString: date => { + return strftime('%d-%m-%Y', date); + }, + }, + components: { + 'report-header': require('../report-header'), + 'report-footer': require('../report-footer'), + }, +}; diff --git a/print/report/rpt-sepa-core/locale.js b/print/report/rpt-sepa-core/locale.js new file mode 100644 index 000000000..e95265a26 --- /dev/null +++ b/print/report/rpt-sepa-core/locale.js @@ -0,0 +1,19 @@ +module.exports = { + messages: { + es: { + title: 'Orden de domiciliación de adeudo SEPA CORE', + supplier: { + toCompleteBySupplier: 'A cumplimentar por el acreedor', + orderReference: 'Referencia de la orden de domiciliación', + identifier: 'Identificador del acreedor', + name: 'Nombre del acreedor', + street: 'Dirección', + location: 'CP - Población - Provincia', + country: 'País', + }, + client: { + toCompleteByClient: 'A cumplimentar por el deudor', + }, + }, + }, +};