diff --git a/db/changes/10002-lent/00-greugesShipped.sql b/db/changes/10002-lent/00-greugesShipped.sql new file mode 100644 index 000000000..25cb4df2f --- /dev/null +++ b/db/changes/10002-lent/00-greugesShipped.sql @@ -0,0 +1 @@ +ALTER TABLE `vn2008`.`Greuges` CHANGE COLUMN `Fecha` `Fecha` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ; \ No newline at end of file diff --git a/modules/claim/front/action/index.html b/modules/claim/front/action/index.html index 7bace5a0e..44f9bb68c 100644 --- a/modules/claim/front/action/index.html +++ b/modules/claim/front/action/index.html @@ -30,7 +30,7 @@ vn-one label="Responsability" value="$ctrl.claim.responsibility" - max="5" + max="$ctrl.maxResponsibility" min="1" step="1" vn-acl="salesAssistant" @@ -191,4 +191,10 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js index ec93f2ae1..0b12a54d0 100644 --- a/modules/claim/front/action/index.js +++ b/modules/claim/front/action/index.js @@ -23,6 +23,7 @@ class Controller { ] }; this.resolvedState = 3; + this.maxResponsibility = 5; } openAddSalesDialog() { @@ -135,9 +136,29 @@ class Controller { this.$http.post(query, data).then(() => { this.card.reload(); this.vnApp.showSuccess(this.$translate.instant('Data saved!')); + if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2) + this.$.updateGreuge.show(); }); } + onUpdateGreugeResponse(response) { + if (response !== 'ACCEPT') + return; + let greugeTypeFreight = 7; + let query = `claim/api/Greuges/`; + let data = { + clientFk: this.claim.clientFk, + description: `claim: ${this.claim.id}`, + amount: 11, + greugeTypeFk: greugeTypeFreight, + ticketFk: this.claim.ticketFk + }; + + this.$http.post(query, data).then(() => { + this.card.reload(); + this.vnApp.showSuccess(this.$translate.instant('Greuge inserted!')); + }); + } // Item Descriptor showDescriptor(event, itemFk) { this.quicklinks = { diff --git a/modules/claim/front/action/index.spec.js b/modules/claim/front/action/index.spec.js index 22f3f321b..9842bf646 100644 --- a/modules/claim/front/action/index.spec.js +++ b/modules/claim/front/action/index.spec.js @@ -158,5 +158,37 @@ describe('claim', () => { expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); }); }); + + describe('onUpdateGreugeResponse()', () => { + it('should do nothing', () => { + spyOn(controller.card, 'reload'); + spyOn(controller.vnApp, 'showSuccess'); + + controller.onUpdateGreugeResponse('CANCEL'); + + expect(controller.card.reload).not.toHaveBeenCalledWith(); + expect(controller.vnApp.showSuccess).not.toHaveBeenCalledWith('Greuge inserted!'); + }); + + it('should perform a insert into greuges', () => { + spyOn(controller.card, 'reload'); + spyOn(controller.vnApp, 'showSuccess'); + controller.claim.clientFk = 101; + controller.claim.id = 11; + let data = { + clientFk: 101, + description: `claim: ${controller.claim.id}`, + amount: 11, + greugeTypeFk: 7, + ticketFk: controller.claim.ticketFk + }; + $httpBackend.expect('POST', `claim/api/Greuges/`, data).respond(); + controller.onUpdateGreugeResponse('ACCEPT'); + $httpBackend.flush(); + + expect(controller.card.reload).toHaveBeenCalledWith(); + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Greuge inserted!'); + }); + }); }); }); diff --git a/modules/claim/front/action/locale/es.yml b/modules/claim/front/action/locale/es.yml index 8112d3c89..3950ec06a 100644 --- a/modules/claim/front/action/locale/es.yml +++ b/modules/claim/front/action/locale/es.yml @@ -5,4 +5,7 @@ Import claim: Importar reclamacion Imports claim details: Importa detalles de la reclamacion Import ticket: Importar ticket Imports ticket lines: Importa las lineas de un ticket -Regularize: Regularizar \ No newline at end of file +Regularize: Regularizar +Do you want to insert greuges?: Desea insertar greuges? +Insert greuges on client card: Insertar greuges en la ficha del cliente +Greuge inserted: Greuge insertado \ No newline at end of file