From a6b755138f52d6c3742b1d1d6b5d67a066c188cf Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 15 Dec 2021 15:24:45 +0100 Subject: [PATCH 1/7] feat(abono): add option "abono" in ticket_sale --- db/changes/10400-christmas/00-ACL.sql | 2 + .../10400-christmas/00-ticket_doRefund.sql | 90 +++++++++++++++++++ e2e/helpers/selectors.js | 1 + loopback/locale/es.json | 3 +- modules/ticket/back/methods/sale/payment.js | 77 ++++++++++++++++ modules/ticket/back/models/sale.js | 1 + modules/ticket/front/sale/index.html | 5 ++ modules/ticket/front/sale/index.js | 12 +++ modules/ticket/front/sale/index.spec.js | 21 +++++ modules/ticket/front/sale/locale/es.yml | 3 +- 10 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 db/changes/10400-christmas/00-ACL.sql create mode 100644 db/changes/10400-christmas/00-ticket_doRefund.sql create mode 100644 modules/ticket/back/methods/sale/payment.js diff --git a/db/changes/10400-christmas/00-ACL.sql b/db/changes/10400-christmas/00-ACL.sql new file mode 100644 index 000000000..45dc56c6b --- /dev/null +++ b/db/changes/10400-christmas/00-ACL.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Sale','payment','WRITE','ALLOW','ROLE','employee'); diff --git a/db/changes/10400-christmas/00-ticket_doRefund.sql b/db/changes/10400-christmas/00-ticket_doRefund.sql new file mode 100644 index 000000000..1c1faf315 --- /dev/null +++ b/db/changes/10400-christmas/00-ticket_doRefund.sql @@ -0,0 +1,90 @@ +DROP PROCEDURE IF EXISTS `vn`.`ticket_doRefund`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT) +BEGIN + + DECLARE vDone BIT DEFAULT 0; + DECLARE vCustomer MEDIUMINT; + DECLARE vWarehouse TINYINT; + DECLARE vCompany MEDIUMINT; + DECLARE vAddress MEDIUMINT; + DECLARE vRefundAgencyMode INT; + DECLARE vItemFk INT; + DECLARE vQuantity DECIMAL (10,2); + DECLARE vConcept VARCHAR(50); + DECLARE vPrice DECIMAL (10,2); + DECLARE vDiscount TINYINT; + DECLARE vSaleNew INT; + DECLARE vSaleMain INT; + DECLARE vZoneFk INT; + + DECLARE vRsMainTicket CURSOR FOR + SELECT * + FROM tmp.sale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; + + SELECT id INTO vRefundAgencyMode + FROM agencyMode WHERE `name` = 'ABONO'; + + SELECT clientFk, warehouseFk, companyFk, addressFk + INTO vCustomer, vWarehouse, vCompany, vAddress + FROM ticket + WHERE id = vOriginTicket; + + SELECT id INTO vZoneFk + FROM zone WHERE agencyModeFk = vRefundAgencyMode + LIMIT 1; + + INSERT INTO vn.ticket ( + clientFk, + shipped, + addressFk, + agencyModeFk, + nickname, + warehouseFk, + companyFk, + landed, + zoneFk + ) + SELECT + vCustomer, + CURDATE(), + vAddress, + vRefundAgencyMode, + a.nickname, + vWarehouse, + vCompany, + CURDATE(), + vZoneFk + FROM address a + WHERE a.id = vAddress; + + SET vNewTicket = LAST_INSERT_ID(); + + SET vDone := 0; + OPEN vRsMainTicket ; + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + + WHILE NOT vDone DO + + INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount) + VALUES( vNewTicket, vItemFk, vQuantity, vConcept, vPrice, vDiscount ); + + SET vSaleNew = LAST_INSERT_ID(); + + INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) + SELECT vSaleNew,componentFk,`value` + FROM vn.saleComponent + WHERE saleFk = vSaleMain; + + FETCH vRsMainTicket INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + + END WHILE; + CLOSE vRsMainTicket; + +END; +$$ +DELIMITER ; \ No newline at end of file diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 24b87b398..7b80d7a96 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -558,6 +558,7 @@ export default { moreMenuUnmarkReseved: 'vn-item[name="unreserve"]', moreMenuUpdateDiscount: 'vn-item[name="discount"]', moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]', + moreMenuPayment: 'vn-item[name="payment"]', moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input', transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable', diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 2611ee0dd..ad2ea2841 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -216,5 +216,6 @@ "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", - "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día" + "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", + "There is no zone for these parameters": "There is no zone for these parameters" } \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/payment.js b/modules/ticket/back/methods/sale/payment.js new file mode 100644 index 000000000..ab221e4d2 --- /dev/null +++ b/modules/ticket/back/methods/sale/payment.js @@ -0,0 +1,77 @@ +module.exports = Self => { + Self.remoteMethodCtx('payment', { + description: 'Create ticket with the selected lines changing the sign to the quantites', + accessType: 'WRITE', + accepts: [{ + arg: 'sales', + description: 'The sales', + type: ['object'], + required: true + }, + { + arg: 'ticketId', + type: 'number', + required: true, + description: 'The ticket id' + }], + returns: { + type: 'number', + root: true + }, + http: { + path: `/payment`, + verb: 'post' + } + }); + + Self.payment = async(ctx, sales, ticketId, options) => { + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const salesIds = []; + const params = []; + sales.forEach(sale => { + salesIds.push(sale.id); + params.push('?'); + }); + + const paramsString = params.join(); + + const query = ` + DROP TEMPORARY TABLE IF EXISTS tmp.sale; + CREATE TEMPORARY TABLE tmp.sale + SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount + FROM sale s + WHERE s.id IN (${paramsString}); + CALL vn.ticket_doRefund(${ticketId}, @newTicket); + DROP TEMPORARY TABLE tmp.sale;`; + + await Self.rawSql(query, salesIds, myOptions); + const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); + ticketId = newTicket.id; + console.log(ticketId); + /* + const message = $t('Deleted sales from ticket', { + ticketId: ticketId, + ticketUrl: `${origin}/#!/ticket/${ticketId}/sale`, + deletions: deletions + }); + */ + if (tx) await tx.commit(); + + return ticketId; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 545e054dc..88e1b8308 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -6,6 +6,7 @@ module.exports = Self => { require('../methods/sale/updateQuantity')(Self); require('../methods/sale/updateConcept')(Self); require('../methods/sale/recalculatePrice')(Self); + require('../methods/sale/payment')(Self); require('../methods/sale/canEdit')(Self); Self.validatesPresenceOf('concept', { diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index f7a279d9a..7ca1d47f9 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -490,4 +490,9 @@ ng-if="$ctrl.isEditable && $ctrl.hasReserves()"> Unmark as reserved + + Payment + \ No newline at end of file diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 752ed23ba..256c72b39 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -460,6 +460,18 @@ class Controller extends Section { }); } + createPayment() { + const sales = this.selectedValidSales(); + if (!sales) return; + + const params = {sales: sales, ticketId: this.ticket.id}; + const query = `Sales/payment`; + this.resetChanges(); + this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); + } + itemSearchFunc($search) { return /^\d+$/.test($search) ? {id: $search} diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 673e9a3f9..2a0d60fa6 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -701,6 +701,27 @@ describe('Ticket', () => { }); }); + describe('createPayment()', () => { + it('should make an HTTP POST query and then call to the $state go() method', () => { + jest.spyOn(controller, 'resetChanges').mockReturnThis(); + jest.spyOn(controller.$state, 'go').mockReturnThis(); + + const ticketId = 13; + const expectedResponse = {id: ticketId}; + const params = { + sales: controller.sales, + ticketId: 13 + }; + + $httpBackend.expect('POST', `Sales/payment`, params).respond(expectedResponse); + controller.createPayment(); + $httpBackend.flush(); + + expect(controller.resetChanges).toHaveBeenCalledWith(); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: ticketId}); + }); + }); + describe('itemSearchFunc()', () => { it('should return the filter by id property for an input of a number', () => { const itemId = 1; diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 92d8dfe28..734bbdbfd 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -35,4 +35,5 @@ Address: Dirección Warehouse: Almacen Agency: Agencia Shipped: F. envio -Packaging: Encajado \ No newline at end of file +Packaging: Encajado +Payment: Abono \ No newline at end of file From 5c899d28c3741ee1fd5ccb9ea18aacf3c3782178 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Dec 2021 14:43:53 +0100 Subject: [PATCH 2/7] feat(ticket_sale): add tests and refactor backRoute name --- db/changes/10400-christmas/00-ACL.sql | 2 +- e2e/helpers/selectors.js | 2 +- .../05-ticket/01-sale/02_edit_sale.spec.js | 9 +++++++ .../methods/sale/{payment.js => payBack.js} | 7 +++-- .../back/methods/sale/specs/payment.spec.js | 26 +++++++++++++++++++ modules/ticket/back/models/sale.js | 2 +- modules/ticket/front/sale/index.html | 6 ++--- modules/ticket/front/sale/index.js | 4 +-- modules/ticket/front/sale/index.spec.js | 23 +++++++--------- modules/ticket/front/sale/locale/es.yml | 2 +- 10 files changed, 56 insertions(+), 27 deletions(-) rename modules/ticket/back/methods/sale/{payment.js => payBack.js} (92%) create mode 100644 modules/ticket/back/methods/sale/specs/payment.spec.js diff --git a/db/changes/10400-christmas/00-ACL.sql b/db/changes/10400-christmas/00-ACL.sql index 45dc56c6b..4f87cb708 100644 --- a/db/changes/10400-christmas/00-ACL.sql +++ b/db/changes/10400-christmas/00-ACL.sql @@ -1,2 +1,2 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Sale','payment','WRITE','ALLOW','ROLE','employee'); + VALUES ('Sale','payBack','WRITE','ALLOW','ROLE','employee'); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7b80d7a96..f9fdcef40 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -558,7 +558,7 @@ export default { moreMenuUnmarkReseved: 'vn-item[name="unreserve"]', moreMenuUpdateDiscount: 'vn-item[name="discount"]', moreMenuRecalculatePrice: 'vn-item[name="calculatePrice"]', - moreMenuPayment: 'vn-item[name="payment"]', + moreMenuPayBack: 'vn-item[name="payBack"]', moreMenuUpdateDiscountInput: 'vn-input-number[ng-model="$ctrl.edit.discount"] input', transferQuantityInput: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable > span > text', transferQuantityCell: '.vn-popover.shown vn-table > div > vn-tbody > vn-tr > vn-td-editable', diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index dfda4dcfb..1f3aedadf 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -206,7 +206,16 @@ describe('Ticket Edit sale path', () => { expect(message.text).toContain('Data saved!'); }); + it('should select the third sale and create a pay back', async() => { + await page.waitToClick(selectors.ticketSales.firstSaleCheckbox); + await page.waitToClick(selectors.ticketSales.moreMenu); + await page.waitToClick(selectors.ticketSales.moreMenuPayBack); + await page.waitForState('ticket.card.sale'); + }); + it('should select the third sale and create a claim of it', async() => { + await page.accessToSearchResult('16'); + await page.accessToSection('ticket.card.sale'); await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox); await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); diff --git a/modules/ticket/back/methods/sale/payment.js b/modules/ticket/back/methods/sale/payBack.js similarity index 92% rename from modules/ticket/back/methods/sale/payment.js rename to modules/ticket/back/methods/sale/payBack.js index ab221e4d2..30fcf59f0 100644 --- a/modules/ticket/back/methods/sale/payment.js +++ b/modules/ticket/back/methods/sale/payBack.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('payment', { + Self.remoteMethodCtx('payBack', { description: 'Create ticket with the selected lines changing the sign to the quantites', accessType: 'WRITE', accepts: [{ @@ -19,12 +19,12 @@ module.exports = Self => { root: true }, http: { - path: `/payment`, + path: `/payBack`, verb: 'post' } }); - Self.payment = async(ctx, sales, ticketId, options) => { + Self.payBack = async(ctx, sales, ticketId, options) => { const myOptions = {}; let tx; @@ -58,7 +58,6 @@ module.exports = Self => { await Self.rawSql(query, salesIds, myOptions); const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); ticketId = newTicket.id; - console.log(ticketId); /* const message = $t('Deleted sales from ticket', { ticketId: ticketId, diff --git a/modules/ticket/back/methods/sale/specs/payment.spec.js b/modules/ticket/back/methods/sale/specs/payment.spec.js new file mode 100644 index 000000000..9f0bcc98a --- /dev/null +++ b/modules/ticket/back/methods/sale/specs/payment.spec.js @@ -0,0 +1,26 @@ +const models = require('vn-loopback/server/server').models; + +describe('sale payBack()', () => { + it('should create ticket with the selected lines changing the sign to the quantites', async() => { + const tx = await models.Sale.beginTransaction({}); + const ticketId = 11; + const sales = [ + {id: 7, ticketFk: 11}, + {id: 8, ticketFk: 11} + ]; + try { + const options = {transaction: tx}; + + const ctx = {req: {accessToken: {userId: 9}}}; + const response = await models.Sale.payBack(ctx, sales, ticketId, options); + const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options); + + expect(response).toEqual(newTicketId.id); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 88e1b8308..9efd66057 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -6,7 +6,7 @@ module.exports = Self => { require('../methods/sale/updateQuantity')(Self); require('../methods/sale/updateConcept')(Self); require('../methods/sale/recalculatePrice')(Self); - require('../methods/sale/payment')(Self); + require('../methods/sale/payBack')(Self); require('../methods/sale/canEdit')(Self); Self.validatesPresenceOf('concept', { diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 7ca1d47f9..fe1f5684d 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -491,8 +491,8 @@ Unmark as reserved - Payment + name="payBack" + ng-click="$ctrl.createPayBack()"> + Pay Back \ No newline at end of file diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 256c72b39..9d0f71eb8 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -460,12 +460,12 @@ class Controller extends Section { }); } - createPayment() { + createPayBack() { const sales = this.selectedValidSales(); if (!sales) return; const params = {sales: sales, ticketId: this.ticket.id}; - const query = `Sales/payment`; + const query = `Sales/payBack`; this.resetChanges(); this.$http.post(query, params).then(res => { this.$state.go('ticket.card.sale', {id: res.data}); diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 2a0d60fa6..923fe9157 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -2,7 +2,7 @@ import './index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -describe('Ticket', () => { +fdescribe('Ticket', () => { describe('Component vnTicketSale', () => { let controller; let $scope; @@ -701,24 +701,19 @@ describe('Ticket', () => { }); }); - describe('createPayment()', () => { + describe('createPayBack()', () => { it('should make an HTTP POST query and then call to the $state go() method', () => { - jest.spyOn(controller, 'resetChanges').mockReturnThis(); - jest.spyOn(controller.$state, 'go').mockReturnThis(); + jest.spyOn(controller, 'selectedValidSales').mockReturnValue(controller.sales); + jest.spyOn(controller, 'resetChanges'); + jest.spyOn(controller.$state, 'go'); - const ticketId = 13; - const expectedResponse = {id: ticketId}; - const params = { - sales: controller.sales, - ticketId: 13 - }; - - $httpBackend.expect('POST', `Sales/payment`, params).respond(expectedResponse); - controller.createPayment(); + const expectedId = 9999; + $httpBackend.expect('POST', `Sales/payBack`).respond(200, expectedId); + controller.createPayBack(); $httpBackend.flush(); expect(controller.resetChanges).toHaveBeenCalledWith(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: ticketId}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: expectedId}); }); }); diff --git a/modules/ticket/front/sale/locale/es.yml b/modules/ticket/front/sale/locale/es.yml index 734bbdbfd..e4152600f 100644 --- a/modules/ticket/front/sale/locale/es.yml +++ b/modules/ticket/front/sale/locale/es.yml @@ -36,4 +36,4 @@ Warehouse: Almacen Agency: Agencia Shipped: F. envio Packaging: Encajado -Payment: Abono \ No newline at end of file +Pay Back: Abono \ No newline at end of file From 19e50d2156958451efa9dbf3754147649b2029db Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Dec 2021 15:00:06 +0100 Subject: [PATCH 3/7] fix(ticket_sale): front test --- modules/ticket/front/sale/index.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 923fe9157..15ce1798b 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -2,7 +2,7 @@ import './index.js'; import watcher from 'core/mocks/watcher'; import crudModel from 'core/mocks/crud-model'; -fdescribe('Ticket', () => { +describe('Ticket', () => { describe('Component vnTicketSale', () => { let controller; let $scope; From 6bd48ab30b59720ab49332c234227f8f382806ef Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 21 Dec 2021 15:06:57 +0100 Subject: [PATCH 4/7] delete comment --- modules/ticket/back/methods/sale/payBack.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/sale/payBack.js b/modules/ticket/back/methods/sale/payBack.js index 30fcf59f0..41150a1e0 100644 --- a/modules/ticket/back/methods/sale/payBack.js +++ b/modules/ticket/back/methods/sale/payBack.js @@ -58,13 +58,7 @@ module.exports = Self => { await Self.rawSql(query, salesIds, myOptions); const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); ticketId = newTicket.id; - /* - const message = $t('Deleted sales from ticket', { - ticketId: ticketId, - ticketUrl: `${origin}/#!/ticket/${ticketId}/sale`, - deletions: deletions - }); - */ + if (tx) await tx.commit(); return ticketId; From 9287f25f241f6b836b40d54e76ca25d1733bee43 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 22 Dec 2021 09:46:18 +0100 Subject: [PATCH 5/7] fix(client_balance): fix if value is 0 --- modules/client/front/balance/create/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index d306c6f84..591af2839 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -82,7 +82,7 @@ class Controller extends Dialog { } set amountToReturn(value) { - if (!value) return; + if (isNaN(value)) return; value = value.toFixed(2); From 5d3fedcbeda52adb1d8451ddf8ad6c2ccf92b6f0 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 22 Dec 2021 12:52:14 +0100 Subject: [PATCH 6/7] feat(print_claim-pickup-order): add client.phone --- .../reports/claim-pickup-order/claim-pickup-order.html | 4 ++++ print/templates/reports/claim-pickup-order/locale/es.yml | 1 + print/templates/reports/claim-pickup-order/sql/client.sql | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 20c29f0ee..7a843c830 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -23,6 +23,10 @@ {{$t('clientId')}} {{client.id}} + + {{$t('phone')}} + {{client.phone}} + {{$t('date')}} {{dated}} diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml index 385a54917..9faf9ac06 100644 --- a/print/templates/reports/claim-pickup-order/locale/es.yml +++ b/print/templates/reports/claim-pickup-order/locale/es.yml @@ -9,6 +9,7 @@ reference: Referencia concept: Concepto clientSignature: Firma del cliente claim: Reclamación {0} +phone: Teléfono sections: agency: description: 'Para agilizar su recogida, por favor, póngase en contacto con la oficina diff --git a/print/templates/reports/claim-pickup-order/sql/client.sql b/print/templates/reports/claim-pickup-order/sql/client.sql index 30a42d5c8..640b0c8a7 100644 --- a/print/templates/reports/claim-pickup-order/sql/client.sql +++ b/print/templates/reports/claim-pickup-order/sql/client.sql @@ -8,7 +8,8 @@ SELECT a.street, a.nickname, p.name AS province, - ct.country + ct.country, + IFNULL(c.phone, cc.phone) AS phone FROM claim cl JOIN client c ON c.id = cl.clientFk JOIN account.user u ON u.id = c.id @@ -17,4 +18,6 @@ FROM claim cl LEFT JOIN province p ON p.id = a.provinceFk LEFT JOIN autonomy amy ON amy.id = p.autonomyFk LEFT JOIN country ct ON ct.id = amy.countryFk -WHERE cl.id = ? \ No newline at end of file + LEFT JOIN clientContact cc ON cc.clientFk = c.id +WHERE cl.id = ? +LIMIT 1; \ No newline at end of file From a6e5123949d79e5ab57ba754aeb0872ebbd01d7c Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 22 Dec 2021 13:16:45 +0100 Subject: [PATCH 7/7] feat: add filter by item.longName --- modules/item/back/methods/item/filter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index a7ca38173..98e78c7aa 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -112,7 +112,10 @@ module.exports = Self => { case 'search': return /^\d+$/.test(value) ? {or: [{'i.id': value}, codeWhere]} - : {or: [{'i.name': {like: `%${value}%`}}, codeWhere]}; + : {or: [ + {'i.name': {like: `%${value}%`}}, + {'i.longName': {like: `%${value}%`}}, + codeWhere]}; case 'id': case 'isActive': case 'typeFk':