diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 2f1c5d893..4eebe0d66 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -824,7 +824,7 @@ export default { travelThermograph: { add: 'vn-travel-thermograph-index vn-float-button[icon="add"]', thermographID: 'vn-travel-thermograph-create vn-autocomplete[ng-model="$ctrl.dms.thermographId"]', - uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="attach_file"]', + uploadIcon: 'vn-travel-thermograph-create vn-icon[icon="icon-attach"]', createdThermograph: 'vn-travel-thermograph-index vn-tbody > vn-tr', upload: 'vn-travel-thermograph-create button[type=submit]' }, diff --git a/front/core/directives/specs/http-click.spec.js b/front/core/directives/specs/http-click.spec.js index 70a79bcff..1b0979f13 100644 --- a/front/core/directives/specs/http-click.spec.js +++ b/front/core/directives/specs/http-click.spec.js @@ -60,7 +60,7 @@ describe('Directive http-click', () => { }).finally(() => { expect(finalValue).toEqual('called!'); }).catch(err => { - console.log(err); + throw err; }); }); }); diff --git a/front/core/services/modules.js b/front/core/services/modules.js index 1021bc4fa..6b4e9dfe1 100644 --- a/front/core/services/modules.js +++ b/front/core/services/modules.js @@ -2,10 +2,11 @@ import ngModule from '../module'; import getMainRoute from '../lib/get-main-route'; export default class Modules { - constructor(aclService, $window) { + constructor(aclService, $window, $translate) { Object.assign(this, { aclService, - $window + $window, + $translate }); } @@ -17,7 +18,7 @@ export default class Modules { if (this.modules) return this.modules; - this.modules = []; + const modules = []; for (let mod of this.$window.routes) { if (!mod || !mod.routes) continue; @@ -31,7 +32,7 @@ export default class Modules { if (res) keyBind = res.key.toUpperCase(); } - this.modules.push({ + modules.push({ name: mod.name || mod.module, icon: mod.icon || null, route, @@ -39,9 +40,15 @@ export default class Modules { }); } - return this.modules; + const sortedModules = modules.sort((a, b) => { + const translatedNameA = this.$translate.instant(a.name); + const translatedNameB = this.$translate.instant(b.name); + return translatedNameA.localeCompare(translatedNameB); + }); + + return sortedModules; } } -Modules.$inject = ['aclService', '$window']; +Modules.$inject = ['aclService', '$window', '$translate']; ngModule.service('vnModules', Modules); diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index c633dd3c1..6ea2d1892 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -16,7 +16,8 @@ class Controller extends Component { {name: 'Send Delivery Note', callback: this.confirmDeliveryNote}, {name: 'Delete ticket', callback: this.showDeleteTicketDialog}, {name: 'Change shipped hour', callback: this.showChangeShipped}, - {name: 'Send SMS', callback: this.showSMSDialog}, + {name: 'SMS Pending payment', callback: this.sendPaymentSms}, + {name: 'SMS Minimum import', callback: this.sendImportSms}, { name: 'Add stowaway', callback: this.showAddStowaway, @@ -240,17 +241,30 @@ class Controller extends Component { ); } + sendImportSms() { + const params = { + ticketId: this.ticket.id, + created: this.ticket.created + }; + const message = this.$params.message || this.$translate.instant('Minimum is needed', params); + this.newSMS = {message}; + this.showSMSDialog(); + } + + sendPaymentSms() { + const message = this.$params.message || this.$translate.instant('Make a payment'); + this.newSMS = {message}; + this.showSMSDialog(); + } + showSMSDialog() { const address = this.ticket.address; const client = this.ticket.client; const phone = this.$params.phone || address.mobile || address.phone || client.mobile || client.phone; - const message = this.$params.message || this.$translate.instant('SMSPayment'); - this.newSMS = { - destinationFk: this.ticket.clientFk, - destination: phone, - message: message - }; + + this.newSMS.destinationFk = this.ticket.clientFk; + this.newSMS.destination = phone; this.$.sms.open(); } diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index a43561833..3f4b87682 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -20,7 +20,13 @@ describe('Ticket Component vnTicketDescriptor', () => { $httpBackend = _$httpBackend_; $httpParamSerializer = _$httpParamSerializer_; controller = $componentController('vnTicketDescriptor', {$element}); - controller._ticket = {id: 2, invoiceOut: {id: 1}, client: {id: 101, email: 'client@email'}}; + controller._ticket = { + id: 2, + clientFk: 101, + invoiceOut: {id: 1}, + client: {id: 101, email: 'client@email'}, + address: {id: 101, mobile: 111111111, phone: 2222222222} + }; controller.cardReload = ()=> { return true; }; @@ -161,7 +167,6 @@ describe('Ticket Component vnTicketDescriptor', () => { }); }); - describe('showAddStowaway()', () => { it('should show a dialog with a list of tickets available for an stowaway', () => { controller.$.addStowaway = {}; @@ -223,4 +228,20 @@ describe('Ticket Component vnTicketDescriptor', () => { expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); + + describe('showSMSDialog()', () => { + it('should set the destionationFk and destination properties and then call the sms open() method', () => { + controller.$.sms = {open: () => {}}; + jest.spyOn(controller.$.sms, 'open'); + + const clientId = 101; + const expectedPhone = 111111111; + controller.newSMS = {}; + controller.showSMSDialog(); + + expect(controller.newSMS.destinationFk).toEqual(clientId); + expect(controller.newSMS.destination).toEqual(expectedPhone); + expect(controller.$.sms.open).toHaveBeenCalledWith(); + }); + }); }); diff --git a/modules/ticket/front/descriptor/locale/en.yml b/modules/ticket/front/descriptor/locale/en.yml index 4dca75a51..64075c7ef 100644 --- a/modules/ticket/front/descriptor/locale/en.yml +++ b/modules/ticket/front/descriptor/locale/en.yml @@ -1,3 +1,2 @@ -SMSPayment: >- - Verdnatura communicates: Your order is pending of payment. - Please, enter the web page and make the payment with card. Thank you. \ No newline at end of file +Make a payment: "Verdnatura communicates:\rYour order is pending of payment.\rPlease, enter the web page and make the payment with card.\rThank you." +Minimum is needed: "Verdnatura communicates:\rA minimum import of 50€ (Without BAT) is needed for your order {{ticketId}} from date {{created | date: 'dd/MM/yyyy'}} to receive it with no extra fees." diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 3df39fe28..d0e8b7bf5 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -13,7 +13,8 @@ Send Delivery Note: Enviar albarán Show pallet report: Ver hoja de pallet Change shipped hour: Cambiar hora de envío Shipped hour: Hora de envío -SMSPayment: "Verdnatura le comunica:\rSu pedido está pendiente de pago.\rPor favor, entre en la página web y efectue el pago con tarjeta.\rMuchas gracias." +Make a payment: "Verdnatura le comunica:\rSu pedido está pendiente de pago.\rPor favor, entre en la página web y efectue el pago con tarjeta.\rMuchas gracias." +Minimum is needed: "Verdnatura le recuerda:\rEs necesario llegar a un importe mínimo de 50€ (Sin IVA) en su pedido {{ticketId}} del día {{created | date: 'dd/MM/yyyy'}} para recibirlo sin portes adicionales." Ticket invoiced: Ticket facturado Make invoice: Crear factura Regenerate invoice: Regenerar factura @@ -25,4 +26,6 @@ Invoice sent for a regeneration, will be available in a few minutes: La factura Shipped hour updated: Hora de envio modificada Deleted ticket: Ticket eliminado Recalculate components: Recalcular componentes -Are you sure you want to recalculate the components?: ¿Seguro que quieres recalcular los componentes? \ No newline at end of file +Are you sure you want to recalculate the components?: ¿Seguro que quieres recalcular los componentes? +SMS Minimum import: 'SMS Importe minimo' +SMS Pending payment: 'SMS Pago pendiente' \ No newline at end of file diff --git a/modules/ticket/front/index/locale/es.yml b/modules/ticket/front/index/locale/es.yml index b29c7399d..dea55b199 100644 --- a/modules/ticket/front/index/locale/es.yml +++ b/modules/ticket/front/index/locale/es.yml @@ -2,4 +2,5 @@ Weekly tickets: Tickets programados Go to lines: Ir a lineas Not available: No disponible Payment on account...: Pago a cuenta... -Closure: Cierre \ No newline at end of file +Closure: Cierre +You cannot make a payment on account from multiple clients: No puedes realizar un pago a cuenta de clientes diferentes \ No newline at end of file diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index e7bf61cfe..42ff5f116 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -12,7 +12,7 @@ class Controller { this.edit = {}; this.moreOptions = [ { - name: 'Send SMS', + name: 'Send shortage SMS', callback: this.showSMSDialog }, { name: 'Mark as reserved', @@ -182,7 +182,6 @@ class Controller { return checkedLines.length; } - removeCheckedLines() { const sales = this.checkedLines(); @@ -448,7 +447,7 @@ class Controller { this.newSMS = { destinationFk: this.ticket.clientFk, destination: phone, - message: this.$translate.instant('SMSAvailability', params) + message: this.$translate.instant('Product not available', params) }; this.$scope.sms.open(); } diff --git a/modules/ticket/front/sale/locale/en.yml b/modules/ticket/front/sale/locale/en.yml index 469e2a04e..ec7f54160 100644 --- a/modules/ticket/front/sale/locale/en.yml +++ b/modules/ticket/front/sale/locale/en.yml @@ -1,3 +1,3 @@ -SMSAvailability: >- +Product not available: >- Verdnatura communicates: Your order {{ticketFk}} created on {{created | date: "dd/MM/yyyy"}}. {{notAvailables}} not available. Sorry for the inconvenience. \ No newline at end of file diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 74f888f56..8de8427b9 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -24,7 +24,8 @@ Sales to transfer: Líneas a transferir Destination ticket: Ticket destinatario Change ticket state to 'Ok': Cambiar estado del ticket a 'Ok' Reserved: Reservado -SMSAvailability: "Verdnatura le comunica:\rPedido {{ticketFk}} día {{created | date: 'dd/MM/yyyy'}}.\r{{notAvailables}} no disponible/s.\rDisculpe las molestias." +Send shortage SMS: Enviar SMS faltas +Product not available: "Verdnatura le comunica:\rPedido {{ticketFk}} día {{created | date: 'dd/MM/yyyy'}}.\r{{notAvailables}} no disponible/s.\rDisculpe las molestias." Continue anyway?: ¿Continuar de todas formas? This ticket is now empty: El ticket ha quedado vacio Do you want to delete it?: ¿Quieres eliminarlo?