diff --git a/db/changes/230801/00-ticketConfig.sql b/db/changes/230801/00-ticketConfig.sql new file mode 100644 index 000000000..ca63dbf63 --- /dev/null +++ b/db/changes/230801/00-ticketConfig.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`ticketConfig` ADD daysForWarningClaim INT DEFAULT 2 NOT NULL COMMENT 'dias restantes hasta que salte el aviso de reclamación fuerade plazo'; diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index a1c96e7f6..d757fbd1a 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -14,6 +14,15 @@ }, "scopeDays": { "type": "number" + }, + "pickingDelay": { + "type": "number" + }, + "packagingInvoicingDated": { + "type": "date" + }, + "daysForWarningClaim": { + "type": "number" } } } diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 6fc986e8f..6c37230ae 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -481,6 +481,13 @@ on-accept="$ctrl.transferSales($ctrl.transfer.ticketId)"> + + + Add claim + { + this.ticketConfig = res.data; + }); + } get isClaimable() { if (this.ticket) { @@ -184,6 +194,16 @@ class Controller extends Section { } createClaim() { + const timeDifference = new Date().getTime() - new Date(this.ticket.shipped).getTime(); + const pastDays = Math.floor(timeDifference / 86400000); + + if (pastDays >= this.ticketConfig[0].daysForWarningClaim) + this.$.claimConfirm.show(); + else + this.onCreateClaimAccepted(); + } + + onCreateClaimAccepted() { const sales = this.selectedValidSales(); const params = {ticketId: this.ticket.id, sales: sales}; this.resetChanges(); diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 8585503cc..c35ed3d9a 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -45,6 +45,7 @@ describe('Ticket', () => { $scope.model = crudModel; $scope.editDiscount = {relocate: () => {}, hide: () => {}}; $scope.editPricePopover = {relocate: () => {}}; + $scope.claimConfirm = {show: () => {}}; $httpBackend = _$httpBackend_; Object.defineProperties($state.params, { id: { @@ -61,6 +62,10 @@ describe('Ticket', () => { controller.card = {reload: () => {}}; controller._ticket = ticket; controller._sales = sales; + controller.ticketConfig = [ + {daysForWarningClaim: 1} + ]; + $httpBackend.expect('GET', 'TicketConfigs').respond(200); })); describe('ticket() setter', () => { @@ -113,7 +118,6 @@ describe('Ticket', () => { it('should make an HTTP GET query and return the worker mana', () => { controller.edit = {}; const expectedAmount = 250; - $httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount); $httpBackend.expect('GET', 'Sales/usesMana').respond(200); $httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount); @@ -279,7 +283,17 @@ describe('Ticket', () => { }); describe('createClaim()', () => { - it('should perform a query and call windows open', () => { + it('should call to the claimConfirm show() method', () => { + jest.spyOn(controller.$.claimConfirm, 'show').mockReturnThis(); + + controller.createClaim(); + + expect(controller.$.claimConfirm.show).toHaveBeenCalledWith(); + }); + }); + + describe('onCreateClaimAccepted()', () => { + it('should perform a query and call window open', () => { jest.spyOn(controller, 'resetChanges').mockReturnThis(); jest.spyOn(controller.$state, 'go').mockReturnThis(); @@ -290,7 +304,7 @@ describe('Ticket', () => { const expectedParams = {ticketId: 1, sales: [firstSale]}; $httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1}); - controller.createClaim(); + controller.onCreateClaimAccepted(); $httpBackend.flush(); expect(controller.resetChanges).toHaveBeenCalledWith(); diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 41ba52d17..bb61db824 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -40,4 +40,5 @@ Refund: Abono Promotion mana: Maná promoción Claim mana: Maná reclamación History: Historial -Select lines to see the options: Seleccione lineas para ver las opciones +Do you want to continue?: ¿Desea continuar? +Claim out of time: Reclamación fuera de plazo