From a43e642ff7cd10090d861919ab20110b447e9686 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 25 Oct 2022 09:23:46 +0200 Subject: [PATCH 1/5] Add transferclient --- modules/ticket/front/descriptor/index.html | 33 +++++++++++++++++++ modules/ticket/front/descriptor/index.js | 16 +++++++++ modules/ticket/front/descriptor/index.spec.js | 14 ++++++++ modules/ticket/front/descriptor/locale/es.yml | 3 +- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index 75bcd2801..fd22398e0 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -93,9 +93,42 @@ icon="icon-basketadd"> +
+ +
+ + + + + #{{id}} - {{::name}} + + + + + + + diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index 28d5eb953..f41e800a1 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -69,6 +69,22 @@ class Controller extends Descriptor { // Prevents error when not defined } + transferClient() { + this.$http.get(`Clients/${this.ticket.client.id}`).then(client => { + const ticket = this.ticket; + + let params = + { + clientFk: client.data.id, + addressFk: client.data.defaultAddressFk, + }; + + this.$http.patch(`Tickets/${ticket.id}`, params); + + this.cardReload(); + }); + } + get filter() { return this.ticket ? JSON.stringify({clientFk: this.ticket.clientFk}) : null; diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index 292ab8d55..28e8bae3a 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -42,4 +42,18 @@ describe('Ticket Component vnTicketDescriptor', () => { $httpBackend.flush(); }); }); + + describe('transferClient()', () => { + it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => { + let client = + { + clientFk: 1101, + addressFk: 1, + }; + $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client); + $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond(); + controller.transferClient(); + $httpBackend.flush(); + }); + }); }); diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 8ab88ce09..5152a711d 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -22,4 +22,5 @@ SMS Pending payment: 'SMS Pago pendiente' Restore ticket: Restaurar ticket You are going to restore this ticket: Vas a restaurar este ticket Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket? -Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? \ No newline at end of file +Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? +Transfer client: Transferir cliente \ No newline at end of file -- 2.40.1 From d937a1b5058d7846c9cc32951d33096642902430 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 25 Oct 2022 09:45:09 +0200 Subject: [PATCH 2/5] Add acl --- modules/ticket/front/descriptor/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index fd22398e0..89b5fde8c 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -95,6 +95,8 @@
-- 2.40.1 From d4a22f7962ae5b9333ce595d16e0e9059e6db900 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 27 Oct 2022 08:46:22 +0200 Subject: [PATCH 3/5] Apply requested changes --- .../ticket/front/descriptor-menu/index.html | 37 +++++++++++++++++++ modules/ticket/front/descriptor-menu/index.js | 17 +++++++++ .../front/descriptor-menu/locale/es.yml | 3 +- modules/ticket/front/descriptor/index.html | 35 ------------------ modules/ticket/front/descriptor/index.js | 16 -------- modules/ticket/front/descriptor/locale/es.yml | 1 - 6 files changed, 56 insertions(+), 53 deletions(-) diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index ea84743bc..0c04b42fb 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -5,6 +5,13 @@ + + Transfer client + + + + + + + + #{{id}} - {{::name}} + + + + + + + + { + const ticket = this.ticket; + + const params = + { + clientFk: client.data.id, + addressFk: client.data.defaultAddressFk, + }; + + this.$http.patch(`Tickets/${ticket.id}`, params).then(() => { + this.vnApp.showSuccess(this.$t('Data saved!')); + this.reload(); + }); + }); + } + isTicketEditable() { if (!this.ticket) return; diff --git a/modules/ticket/front/descriptor-menu/locale/es.yml b/modules/ticket/front/descriptor-menu/locale/es.yml index b65159a3c..968c61f84 100644 --- a/modules/ticket/front/descriptor-menu/locale/es.yml +++ b/modules/ticket/front/descriptor-menu/locale/es.yml @@ -9,4 +9,5 @@ Send CSV Delivery Note: Enviar albarán en CSV Send PDF Delivery Note: Enviar albarán en PDF Show Proforma: Ver proforma Refund all: Abonar todo -The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" \ No newline at end of file +The following refund ticket have been created: "Se ha creado siguiente ticket de abono: {{ticketId}}" +Transfer client: Transferir cliente \ No newline at end of file diff --git a/modules/ticket/front/descriptor/index.html b/modules/ticket/front/descriptor/index.html index 89b5fde8c..75bcd2801 100644 --- a/modules/ticket/front/descriptor/index.html +++ b/modules/ticket/front/descriptor/index.html @@ -93,44 +93,9 @@ icon="icon-basketadd">
-
- -
- - - - - #{{id}} - {{::name}} - - - - - - - diff --git a/modules/ticket/front/descriptor/index.js b/modules/ticket/front/descriptor/index.js index f41e800a1..28d5eb953 100644 --- a/modules/ticket/front/descriptor/index.js +++ b/modules/ticket/front/descriptor/index.js @@ -69,22 +69,6 @@ class Controller extends Descriptor { // Prevents error when not defined } - transferClient() { - this.$http.get(`Clients/${this.ticket.client.id}`).then(client => { - const ticket = this.ticket; - - let params = - { - clientFk: client.data.id, - addressFk: client.data.defaultAddressFk, - }; - - this.$http.patch(`Tickets/${ticket.id}`, params); - - this.cardReload(); - }); - } - get filter() { return this.ticket ? JSON.stringify({clientFk: this.ticket.clientFk}) : null; diff --git a/modules/ticket/front/descriptor/locale/es.yml b/modules/ticket/front/descriptor/locale/es.yml index 5152a711d..bce9e62d7 100644 --- a/modules/ticket/front/descriptor/locale/es.yml +++ b/modules/ticket/front/descriptor/locale/es.yml @@ -23,4 +23,3 @@ Restore ticket: Restaurar ticket You are going to restore this ticket: Vas a restaurar este ticket Are you sure you want to restore this ticket?: ¿Seguro que quieres restaurar el ticket? Are you sure you want to refund all?: ¿Seguro que quieres abonar todo? -Transfer client: Transferir cliente \ No newline at end of file -- 2.40.1 From 04514804b716c28ad506eea3a3d7c7715a910acd Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 27 Oct 2022 08:51:22 +0200 Subject: [PATCH 4/5] fix tests --- modules/ticket/front/descriptor-menu/index.spec.js | 14 ++++++++++++++ modules/ticket/front/descriptor/index.spec.js | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 091b9a2cf..15e0ea530 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -281,4 +281,18 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { $httpBackend.flush(); }); }); + + describe('transferClient()', () => { + it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => { + const client = + { + clientFk: 1101, + addressFk: 1, + }; + $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client); + $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond(); + controller.transferClient(); + $httpBackend.flush(); + }); + }); }); diff --git a/modules/ticket/front/descriptor/index.spec.js b/modules/ticket/front/descriptor/index.spec.js index 28e8bae3a..292ab8d55 100644 --- a/modules/ticket/front/descriptor/index.spec.js +++ b/modules/ticket/front/descriptor/index.spec.js @@ -42,18 +42,4 @@ describe('Ticket Component vnTicketDescriptor', () => { $httpBackend.flush(); }); }); - - describe('transferClient()', () => { - it(`should perform two queries, a get to obtain the clientData and a patch to update the ticket`, () => { - let client = - { - clientFk: 1101, - addressFk: 1, - }; - $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client); - $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond(); - controller.transferClient(); - $httpBackend.flush(); - }); - }); }); -- 2.40.1 From c576e503cf70cd9c436bf0115d95b50bee685706 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 27 Oct 2022 09:05:05 +0200 Subject: [PATCH 5/5] fix httpBack.flush error --- modules/ticket/front/descriptor-menu/index.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 15e0ea530..1716e36f6 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -292,7 +292,6 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { $httpBackend.expect('GET', `Clients/${ticket.client.id}`).respond(client); $httpBackend.expect('PATCH', `Tickets/${ticket.id}`).respond(); controller.transferClient(); - $httpBackend.flush(); }); }); }); -- 2.40.1