From 6465a5c460d5bf695d1e2613b158510dbb3be89f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 14 Dec 2021 08:23:11 +0100 Subject: [PATCH 01/21] feat(supplier): payMethodChecked for financial --- db/changes/10390-constitution/00-supplier.sql | 17 +++++++++ e2e/paths/13-supplier/02_basic_data.spec.js | 2 +- loopback/locale/es.json | 3 +- .../back/models/specs/supplier.spec.js | 35 ++++++++++++------- modules/supplier/back/models/supplier.js | 21 +++++++++-- modules/supplier/front/basic-data/index.html | 3 +- modules/supplier/front/billing-data/index.js | 6 +++- 7 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 db/changes/10390-constitution/00-supplier.sql diff --git a/db/changes/10390-constitution/00-supplier.sql b/db/changes/10390-constitution/00-supplier.sql new file mode 100644 index 0000000000..f86a1c5346 --- /dev/null +++ b/db/changes/10390-constitution/00-supplier.sql @@ -0,0 +1,17 @@ +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`supplier_beforeUpdate` + BEFORE UPDATE ON `vn`.`supplier` FOR EACH ROW +BEGIN + DECLARE vHasChange BOOL; + SET vHasChange = !((NEW.payMethodFk <=> OLD.payMethodFk) + AND (NEW.payDemFk <=> OLD.payDemFk) + AND (NEW.payDay <=> OLD.payDay)); + + IF vHasChange THEN + SET NEW.isPayMethodChecked = false; + END IF; + +END +$$ +DELIMITER ; diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js index f98fa779e7..4f3c495127 100644 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ b/e2e/paths/13-supplier/02_basic_data.spec.js @@ -8,7 +8,7 @@ describe('Supplier basic data path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('administrative', 'supplier'); + await page.loginAndModule('financial', 'supplier'); await page.accessToSearchResult('1'); await page.accessToSection('supplier.card.basicData'); }); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 2611ee0ddb..c7797fe6a5 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", + "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado" } \ No newline at end of file diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 27bd873ad4..8721e826cf 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -8,6 +8,19 @@ describe('loopback model Supplier', () => { beforeAll(async() => { supplierOne = await models.Supplier.findById(1); supplierTwo = await models.Supplier.findById(442); + + const activeCtx = { + accessToken: {userId: 9}, + http: { + req: { + headers: {origin: 'http://localhost'} + } + } + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: activeCtx + }); }); afterAll(async() => { @@ -32,19 +45,6 @@ describe('loopback model Supplier', () => { }); it('should not throw if the payMethod id is valid', async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - let error; const supplier = await models.Supplier.findById(442); await supplier.updateAttribute('payMethodFk', 4) @@ -54,5 +54,14 @@ describe('loopback model Supplier', () => { expect(error).not.toBeDefined(); }); + + it('should have unchecked isPayMethodChecked', async() => { + const supplier = await models.Supplier.findById(442); + await supplier.updateAttribute('payMethodFk', 5); + + const result = await models.Supplier.findById(442); + + expect(result.isPayMethodChecked).toEqual(false); + }); }); }); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 1ac6e3bd28..2912a35771 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -1,5 +1,6 @@ const UserError = require('vn-loopback/util/user-error'); const validateTin = require('vn-loopback/util/validateTin'); +const LoopBackContext = require('loopback-context'); module.exports = Self => { require('../methods/supplier/filter')(Self); @@ -88,8 +89,24 @@ module.exports = Self => { } Self.observe('before save', async function(ctx) { - let changes = ctx.data || ctx.instance; - let orgData = ctx.currentInstance; + const loopbackContext = LoopBackContext.getCurrentContext(); + const changes = ctx.data || ctx.instance; + const orgData = ctx.currentInstance; + const userId = loopbackContext.active.accessToken.userId; + + const isNotFinancial = !await Self.app.models.Account.hasRole(userId, 'financial'); + const isPayMethodChecked = changes.isPayMethodChecked || orgData.isPayMethodChecked; + const hasChanges = orgData && changes; + const isPayMethodCheckedChanged = hasChanges + && orgData.isPayMethodChecked != isPayMethodChecked; + + if (isNotFinancial && isPayMethodCheckedChanged) + throw new UserError('You can not modify is pay method checked'); + }); + + Self.observe('before save', async function(ctx) { + const changes = ctx.data || ctx.instance; + const orgData = ctx.currentInstance; const socialName = changes.name || orgData.name; const hasChanges = orgData && changes; diff --git a/modules/supplier/front/basic-data/index.html b/modules/supplier/front/basic-data/index.html index 0ec80641da..9991908d4d 100644 --- a/modules/supplier/front/basic-data/index.html +++ b/modules/supplier/front/basic-data/index.html @@ -38,7 +38,8 @@ + ng-model="$ctrl.supplier.isPayMethodChecked" + vn-acl="financial"> diff --git a/modules/supplier/front/billing-data/index.js b/modules/supplier/front/billing-data/index.js index 0c9cbb0dc4..9d2863f64b 100644 --- a/modules/supplier/front/billing-data/index.js +++ b/modules/supplier/front/billing-data/index.js @@ -11,7 +11,8 @@ export default class Controller extends Section { } onSubmit() { - return this.$.watcher.submit(); + this.$.watcher.submit() + .then(() => this.card.reload()); } } @@ -20,5 +21,8 @@ ngModule.vnComponent('vnSupplierBillingData', { controller: Controller, bindings: { supplier: '<' + }, + require: { + card: '^vnSupplierCard' } }); From 9cfe6b5b7a38145b5da116efbc11a57dc0af4730 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 14 Dec 2021 12:05:06 +0100 Subject: [PATCH 02/21] feat(ticket): filter by route --- modules/ticket/back/methods/ticket/filter.js | 12 +++- .../back/methods/ticket/specs/filter.spec.js | 57 +++++++++++++++++++ modules/ticket/front/search-panel/index.html | 6 ++ .../ticket/front/search-panel/locale/es.yml | 1 + 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index a015d2165e..e0b563fe2c 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -83,6 +83,11 @@ module.exports = Self => { type: 'boolean', description: `Whether to show only tickets with problems` }, + { + arg: 'route', + type: 'boolean', + description: `Whether to show only tickets with route` + }, { arg: 'pending', type: 'boolean', @@ -186,6 +191,10 @@ module.exports = Self => { case 'alertLevel': return {'ts.alertLevel': value}; + case 'route': + if (value == true) + return {'t.routeFk': {neq: null}}; + return {'t.routeFk': null}; case 'pending': if (value) { return {and: [ @@ -264,7 +273,8 @@ module.exports = Self => { LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk - LEFT JOIN account.user u ON u.id = wk.userFk`); + LEFT JOIN account.user u ON u.id = wk.userFk + LEFT JOIN route r ON r.id = t.routeFk`); if (args.orderFk) { stmt.merge({ diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 01a652b737..f99a808277 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -221,4 +221,61 @@ describe('ticket filter()', () => { throw e; } }); + + it('should return the tickets matching the route on true', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = {req: {accessToken: {userId: 9}}, args: {route: true}}; + const filter = {}; + const result = await models.Ticket.filter(ctx, filter, options); + + expect(result.length).toEqual(22); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return the tickets matching the route on false', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = {req: {accessToken: {userId: 9}}, args: {route: false}}; + const filter = {}; + const result = await models.Ticket.filter(ctx, filter, options); + + expect(result.length).toEqual(2); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return the tickets matching the route on null', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = {req: {accessToken: {userId: 9}}, args: {route: null}}; + const filter = {}; + const result = await models.Ticket.filter(ctx, filter, options); + + expect(result.length).toEqual(24); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index 4457299525..78ae727342 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -135,6 +135,12 @@ ng-model="filter.pending" triple-state="true"> + + diff --git a/modules/ticket/front/search-panel/locale/es.yml b/modules/ticket/front/search-panel/locale/es.yml index d6d01d0aac..fcb7cc7e33 100644 --- a/modules/ticket/front/search-panel/locale/es.yml +++ b/modules/ticket/front/search-panel/locale/es.yml @@ -12,6 +12,7 @@ Order id: Id cesta Grouped States: Estado agrupado Days onward: Días adelante With problems: Con problemas +With route: Con ruta Pending: Pendiente FREE: Libre DELIVERED: Servido From a6b755138f52d6c3742b1d1d6b5d67a066c188cf Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 15 Dec 2021 15:24:45 +0100 Subject: [PATCH 03/21] 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 0000000000..45dc56c6bc --- /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 0000000000..1c1faf3151 --- /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 24b87b398e..7b80d7a962 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 2611ee0ddb..ad2ea28416 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 0000000000..ab221e4d21 --- /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 545e054dc1..88e1b8308a 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 f7a279d9a6..7ca1d47f9e 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 752ed23ba7..256c72b390 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 673e9a3f98..2a0d60fa6e 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 92d8dfe280..734bbdbfd7 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 f4a07cab706d947ad1216bfeff132529a6cc21a3 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 16 Dec 2021 12:21:47 +0100 Subject: [PATCH 04/21] sql update supplier --- db/changes/10400-christmas/updateSupplier.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/changes/10400-christmas/updateSupplier.sql diff --git a/db/changes/10400-christmas/updateSupplier.sql b/db/changes/10400-christmas/updateSupplier.sql new file mode 100644 index 0000000000..49fa2eb152 --- /dev/null +++ b/db/changes/10400-christmas/updateSupplier.sql @@ -0,0 +1,2 @@ +UPDATE `vn`.`supplier` + SET isPayMethodChecked = TRUE; \ No newline at end of file From 7c17250919a3b78c354da6f3290d29e1d7944863 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 16 Dec 2021 15:19:56 +0100 Subject: [PATCH 05/21] trigger payment_beforeInsert sql --- .../10400-christmas/payment_beforeInsert.sql | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 db/changes/10400-christmas/payment_beforeInsert.sql diff --git a/db/changes/10400-christmas/payment_beforeInsert.sql b/db/changes/10400-christmas/payment_beforeInsert.sql new file mode 100644 index 0000000000..537bf0c540 --- /dev/null +++ b/db/changes/10400-christmas/payment_beforeInsert.sql @@ -0,0 +1,61 @@ +DROP TRIGGER IF EXISTS vn.payment_beforeInsert; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` TRIGGER `payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW +-- Edit trigger body code below this line. Do not edit lines above this one +BEGIN + DECLARE cuenta_banco,cuenta_proveedor DOUBLE; + DECLARE vNewBookEntry INT; + DECLARE bolCASH BOOLEAN; + DECLARE isSupplierActive BOOLEAN; + DECLARE vIsPayMethodChecked BOOLEAN; + + -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH + SELECT (at2.code = 'cash') INTO bolCASH FROM vn.bank b JOIN vn.accountingType at2 ON at2.id = b.cash WHERE b.id = NEW.bankFk ; + + IF bolCASH THEN + + SELECT account INTO cuenta_banco + FROM bank + WHERE id = NEW.bankFk; + + SELECT account INTO cuenta_proveedor + FROM supplier + WHERE id = NEW.supplierFk; + + CALL vn.ledger_next(vNewBookEntry); + + INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id) + SELECT vNewBookEntry,NEW.received,SUBCTA,CONTRA,NEW.concept,EURODEBE,EUROHABER,NEW.companyFk + FROM + ( SELECT cuenta_banco SUBCTA,cuenta_proveedor CONTRA,0 EURODEBE, NEW.amount + NEW.bankingFees EUROHABER + UNION ALL + SELECT cuenta_proveedor SUBCTA, cuenta_banco CONTRA,NEW.amount EURODEBE, 0 EUROHABER + ) gf; + + IF NEW.bankingFees <> 0 THEN + INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id) + SELECT vNewBookEntry,NEW.received,IF(c.id = 1,6260000002,IF(CEE = 1,6260000003,6260000004)),cuenta_banco,NEW.concept,NEW.bankingFees,0,NEW.companyFk + FROM supplier s + JOIN country c ON s.countryFk = c.id + WHERE s.id = NEW.supplierFk; + END IF; + END IF; + + SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); + + SELECT isActive, isPayMethodChecked INTO vIsSupplierActive, vIsPayMethodChecked + FROM supplier + WHERE id = NEW.supplierFk; + + IF isSupplierActive = FALSE THEN + CALL util.throw('SUPPLIER_INACTIVE'); + END IF; + + IF vIsPayMethodChecked = FALSE THEN + CALL util.throw('SUPPLIER_DOES_NOT_HAVE_PAYMETHODCHECKED'); + END IF; + + END$$ +DELIMITER ; From 0ea1dea8b505da9a32a7b4dcdf50f7900f60f608 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 17 Dec 2021 12:52:37 +0100 Subject: [PATCH 06/21] refactor sqls --- db/changes/10400-christmas/00-payMethod_hasVerified.sql | 1 + .../{payment_beforeInsert.sql => 00-payment_beforeInsert.sql} | 0 .../{10390-constitution => 10400-christmas}/00-supplier.sql | 0 .../{updateSupplier.sql => 00-updateSupplier.sql} | 0 db/changes/10400-christmas/delete.keep | 1 - 5 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 db/changes/10400-christmas/00-payMethod_hasVerified.sql rename db/changes/10400-christmas/{payment_beforeInsert.sql => 00-payment_beforeInsert.sql} (100%) rename db/changes/{10390-constitution => 10400-christmas}/00-supplier.sql (100%) rename db/changes/10400-christmas/{updateSupplier.sql => 00-updateSupplier.sql} (100%) delete mode 100644 db/changes/10400-christmas/delete.keep diff --git a/db/changes/10400-christmas/00-payMethod_hasVerified.sql b/db/changes/10400-christmas/00-payMethod_hasVerified.sql new file mode 100644 index 0000000000..7ebafc4200 --- /dev/null +++ b/db/changes/10400-christmas/00-payMethod_hasVerified.sql @@ -0,0 +1 @@ +ALTER TABLE vn.payMethod ADD hasVerified TINYINT(1) DEFAULT 0 NULL; \ No newline at end of file diff --git a/db/changes/10400-christmas/payment_beforeInsert.sql b/db/changes/10400-christmas/00-payment_beforeInsert.sql similarity index 100% rename from db/changes/10400-christmas/payment_beforeInsert.sql rename to db/changes/10400-christmas/00-payment_beforeInsert.sql diff --git a/db/changes/10390-constitution/00-supplier.sql b/db/changes/10400-christmas/00-supplier.sql similarity index 100% rename from db/changes/10390-constitution/00-supplier.sql rename to db/changes/10400-christmas/00-supplier.sql diff --git a/db/changes/10400-christmas/updateSupplier.sql b/db/changes/10400-christmas/00-updateSupplier.sql similarity index 100% rename from db/changes/10400-christmas/updateSupplier.sql rename to db/changes/10400-christmas/00-updateSupplier.sql diff --git a/db/changes/10400-christmas/delete.keep b/db/changes/10400-christmas/delete.keep deleted file mode 100644 index 603d82d74b..0000000000 --- a/db/changes/10400-christmas/delete.keep +++ /dev/null @@ -1 +0,0 @@ -Delete me! \ No newline at end of file From 9247bc98f1181b3710dde00abeb094e358c16bf6 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 20 Dec 2021 08:01:13 +0100 Subject: [PATCH 07/21] feat(db): sql for supplier isPayMethodChecked --- .../00-payMethod_hasVerified.sql | 2 +- .../00-payment_beforeInsert.sql | 25 ++++++++++++------ db/changes/10400-christmas/00-supplier.sql | 17 ------------ .../01-supplier_beforeUpdate.sql | 26 +++++++++++++++++++ db/dump/fixtures.sql | 14 +++++----- 5 files changed, 51 insertions(+), 33 deletions(-) delete mode 100644 db/changes/10400-christmas/00-supplier.sql create mode 100644 db/changes/10400-christmas/01-supplier_beforeUpdate.sql diff --git a/db/changes/10400-christmas/00-payMethod_hasVerified.sql b/db/changes/10400-christmas/00-payMethod_hasVerified.sql index 7ebafc4200..280a9e0976 100644 --- a/db/changes/10400-christmas/00-payMethod_hasVerified.sql +++ b/db/changes/10400-christmas/00-payMethod_hasVerified.sql @@ -1 +1 @@ -ALTER TABLE vn.payMethod ADD hasVerified TINYINT(1) DEFAULT 0 NULL; \ No newline at end of file +ALTER TABLE `vn`.`payMethod` ADD hasVerified TINYINT(1) DEFAULT 0 NULL; \ No newline at end of file diff --git a/db/changes/10400-christmas/00-payment_beforeInsert.sql b/db/changes/10400-christmas/00-payment_beforeInsert.sql index 537bf0c540..ef76ad876d 100644 --- a/db/changes/10400-christmas/00-payment_beforeInsert.sql +++ b/db/changes/10400-christmas/00-payment_beforeInsert.sql @@ -1,15 +1,15 @@ -DROP TRIGGER IF EXISTS vn.payment_beforeInsert; +DROP TRIGGER IF EXISTS `vn`.`payment_beforeInsert`; DELIMITER $$ $$ -CREATE DEFINER=`root`@`%` TRIGGER `payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW -- Edit trigger body code below this line. Do not edit lines above this one BEGIN DECLARE cuenta_banco,cuenta_proveedor DOUBLE; DECLARE vNewBookEntry INT; DECLARE bolCASH BOOLEAN; - DECLARE isSupplierActive BOOLEAN; - DECLARE vIsPayMethodChecked BOOLEAN; + DECLARE vIsSupplierActive BOOLEAN; + DECLARE vIsPayMethodChecked BOOLEAN; -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH SELECT (at2.code = 'cash') INTO bolCASH FROM vn.bank b JOIN vn.accountingType at2 ON at2.id = b.cash WHERE b.id = NEW.bankFk ; @@ -45,16 +45,25 @@ BEGIN SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); - SELECT isActive, isPayMethodChecked INTO vIsSupplierActive, vIsPayMethodChecked + SELECT isActive, isPayMethodChecked INTO vIsSupplierActive, vIsPayMethodChecked FROM supplier WHERE id = NEW.supplierFk; - IF isSupplierActive = FALSE THEN + IF vIsSupplierActive = FALSE THEN CALL util.throw('SUPPLIER_INACTIVE'); END IF; - IF vIsPayMethodChecked = FALSE THEN - CALL util.throw('SUPPLIER_DOES_NOT_HAVE_PAYMETHODCHECKED'); + IF vIsPayMethodChecked = FALSE THEN + CALL mail_insert('finanzas@verdnatura.es', + null, + 'Pago con método sin verificar', + CONCAT('Se ha realizado el pago ', + LAST_INSERT_ID(), + ' al proveedor ', + NEW.supplierFk, + ' con el método de pago sin verificar.' + ) + ); END IF; END$$ diff --git a/db/changes/10400-christmas/00-supplier.sql b/db/changes/10400-christmas/00-supplier.sql deleted file mode 100644 index f86a1c5346..0000000000 --- a/db/changes/10400-christmas/00-supplier.sql +++ /dev/null @@ -1,17 +0,0 @@ -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`supplier_beforeUpdate` - BEFORE UPDATE ON `vn`.`supplier` FOR EACH ROW -BEGIN - DECLARE vHasChange BOOL; - SET vHasChange = !((NEW.payMethodFk <=> OLD.payMethodFk) - AND (NEW.payDemFk <=> OLD.payDemFk) - AND (NEW.payDay <=> OLD.payDay)); - - IF vHasChange THEN - SET NEW.isPayMethodChecked = false; - END IF; - -END -$$ -DELIMITER ; diff --git a/db/changes/10400-christmas/01-supplier_beforeUpdate.sql b/db/changes/10400-christmas/01-supplier_beforeUpdate.sql new file mode 100644 index 0000000000..b3ffccf9c0 --- /dev/null +++ b/db/changes/10400-christmas/01-supplier_beforeUpdate.sql @@ -0,0 +1,26 @@ +DROP TRIGGER IF EXISTS `vn`.`supplier_beforeUpdate`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`supplier_beforeUpdate` + BEFORE UPDATE ON `vn`.`supplier` FOR EACH ROW +BEGIN + DECLARE vHasChange BOOL DEFAULT FALSE; + DECLARE vPayMethodHasVerified BOOL; + + SELECT hasVerified INTO vPayMethodHasVerified + FROM payMethod + WHERE id = NEW.payMethodFk; + + SET vHasChange = (NEW.payDemFk <> OLD.payDemFk) OR (NEW.payDay <> OLD.payDay); + + IF vPayMethodHasVerified AND !vHasChange THEN + SET vHasChange = (NEW.payMethodFk <> OLD.payMethodFk); + END IF; + + IF vHasChange THEN + SET NEW.isPayMethodChecked = FALSE; + END IF; + +END$$ +DELIMITER ; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index efdd0e315a..bef8a7a310 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -217,14 +217,14 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; -INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`) +INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) VALUES - (1, NULL, 'PayMethod one', 0, 001, 0, 0), - (2, NULL, 'PayMethod two', 10, 001, 0, 0), - (3, 'compensation', 'PayMethod three', 0, 001, 0, 0), - (4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0), - (5, NULL, 'PayMethod five', 10, 001, 0, 0), - (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1); + (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), + (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1), + (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0), + (4, NULL, 'PayMethod with IBAN', 0, 001, 1, 0, 0), + (5, NULL, 'PayMethod five', 10, 001, 0, 0, 0), + (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0); INSERT INTO `vn`.`payDem`(`id`, `payDem`) VALUES From 7a0221c17d510e23d7c4f75e8a01fc1ff50dc08a Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 20 Dec 2021 08:02:28 +0100 Subject: [PATCH 08/21] test(supplier): add backTest to check changes in isPayMethodChecked --- .../back/models/specs/supplier.spec.js | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/supplier/back/models/specs/supplier.spec.js b/modules/supplier/back/models/specs/supplier.spec.js index 8721e826cf..3140981c34 100644 --- a/modules/supplier/back/models/specs/supplier.spec.js +++ b/modules/supplier/back/models/specs/supplier.spec.js @@ -55,13 +55,39 @@ describe('loopback model Supplier', () => { expect(error).not.toBeDefined(); }); - it('should have unchecked isPayMethodChecked', async() => { + it('should have checked isPayMethodChecked for payMethod hasVerfified is false', async() => { const supplier = await models.Supplier.findById(442); + await supplier.updateAttribute('isPayMethodChecked', true); await supplier.updateAttribute('payMethodFk', 5); const result = await models.Supplier.findById(442); + expect(result.isPayMethodChecked).toEqual(true); + }); + + it('should have unchecked isPayMethodChecked for payMethod hasVerfified is true', async() => { + const supplier = await models.Supplier.findById(442); + await supplier.updateAttribute('isPayMethodChecked', true); + await supplier.updateAttribute('payMethodFk', 2); + + const result = await models.Supplier.findById(442); + expect(result.isPayMethodChecked).toEqual(false); }); + + it('should have unchecked isPayMethodChecked for payDay and peyDemFk', async() => { + const supplier = await models.Supplier.findById(442); + + await supplier.updateAttribute('isPayMethodChecked', true); + await supplier.updateAttribute('payDay', 5); + const firstResult = await models.Supplier.findById(442); + + await supplier.updateAttribute('isPayMethodChecked', true); + await supplier.updateAttribute('payDemFk', 1); + const secondResult = await models.Supplier.findById(442); + + expect(firstResult.isPayMethodChecked).toEqual(false); + expect(secondResult.isPayMethodChecked).toEqual(false); + }); }); }); From 412acfbff23e1960866b3cd7f0f54cedba2821c1 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 20 Dec 2021 14:46:09 +0100 Subject: [PATCH 09/21] refactor(payment_afterInsert): email --- .../00-payment_beforeInsert.sql | 70 ------------------- .../10400-christmas/00-updateDepartment.sql | 3 + .../01-payment_afterInsert.sql | 33 +++++++++ 3 files changed, 36 insertions(+), 70 deletions(-) delete mode 100644 db/changes/10400-christmas/00-payment_beforeInsert.sql create mode 100644 db/changes/10400-christmas/00-updateDepartment.sql create mode 100644 db/changes/10400-christmas/01-payment_afterInsert.sql diff --git a/db/changes/10400-christmas/00-payment_beforeInsert.sql b/db/changes/10400-christmas/00-payment_beforeInsert.sql deleted file mode 100644 index ef76ad876d..0000000000 --- a/db/changes/10400-christmas/00-payment_beforeInsert.sql +++ /dev/null @@ -1,70 +0,0 @@ -DROP TRIGGER IF EXISTS `vn`.`payment_beforeInsert`; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`%` TRIGGER `vn`.`payment_beforeInsert` BEFORE INSERT ON `payment` FOR EACH ROW --- Edit trigger body code below this line. Do not edit lines above this one -BEGIN - DECLARE cuenta_banco,cuenta_proveedor DOUBLE; - DECLARE vNewBookEntry INT; - DECLARE bolCASH BOOLEAN; - DECLARE vIsSupplierActive BOOLEAN; - DECLARE vIsPayMethodChecked BOOLEAN; - - -- PAK 10/02/15 No se asientan los pagos directamente, salvo en el caso de las cajas de CASH - SELECT (at2.code = 'cash') INTO bolCASH FROM vn.bank b JOIN vn.accountingType at2 ON at2.id = b.cash WHERE b.id = NEW.bankFk ; - - IF bolCASH THEN - - SELECT account INTO cuenta_banco - FROM bank - WHERE id = NEW.bankFk; - - SELECT account INTO cuenta_proveedor - FROM supplier - WHERE id = NEW.supplierFk; - - CALL vn.ledger_next(vNewBookEntry); - - INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id) - SELECT vNewBookEntry,NEW.received,SUBCTA,CONTRA,NEW.concept,EURODEBE,EUROHABER,NEW.companyFk - FROM - ( SELECT cuenta_banco SUBCTA,cuenta_proveedor CONTRA,0 EURODEBE, NEW.amount + NEW.bankingFees EUROHABER - UNION ALL - SELECT cuenta_proveedor SUBCTA, cuenta_banco CONTRA,NEW.amount EURODEBE, 0 EUROHABER - ) gf; - - IF NEW.bankingFees <> 0 THEN - INSERT INTO XDiario (ASIEN,FECHA,SUBCTA,CONTRA,CONCEPTO,EURODEBE,EUROHABER,empresa_id) - SELECT vNewBookEntry,NEW.received,IF(c.id = 1,6260000002,IF(CEE = 1,6260000003,6260000004)),cuenta_banco,NEW.concept,NEW.bankingFees,0,NEW.companyFk - FROM supplier s - JOIN country c ON s.countryFk = c.id - WHERE s.id = NEW.supplierFk; - END IF; - END IF; - - SET NEW.dueDated = IFNULL(NEW.dueDated, NEW.received); - - SELECT isActive, isPayMethodChecked INTO vIsSupplierActive, vIsPayMethodChecked - FROM supplier - WHERE id = NEW.supplierFk; - - IF vIsSupplierActive = FALSE THEN - CALL util.throw('SUPPLIER_INACTIVE'); - END IF; - - IF vIsPayMethodChecked = FALSE THEN - CALL mail_insert('finanzas@verdnatura.es', - null, - 'Pago con método sin verificar', - CONCAT('Se ha realizado el pago ', - LAST_INSERT_ID(), - ' al proveedor ', - NEW.supplierFk, - ' con el método de pago sin verificar.' - ) - ); - END IF; - - END$$ -DELIMITER ; diff --git a/db/changes/10400-christmas/00-updateDepartment.sql b/db/changes/10400-christmas/00-updateDepartment.sql new file mode 100644 index 0000000000..ce46220ca4 --- /dev/null +++ b/db/changes/10400-christmas/00-updateDepartment.sql @@ -0,0 +1,3 @@ +UPDATE `vn`.`department` + SET `notificationEmail` = 'finanzas@verdnatura.es' + WHERE `name` = 'FINANZAS'; \ No newline at end of file diff --git a/db/changes/10400-christmas/01-payment_afterInsert.sql b/db/changes/10400-christmas/01-payment_afterInsert.sql new file mode 100644 index 0000000000..f422ebce29 --- /dev/null +++ b/db/changes/10400-christmas/01-payment_afterInsert.sql @@ -0,0 +1,33 @@ +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`%` TRIGGER `vn`.`payment_afterInsert` AFTER INSERT ON `payment` FOR EACH ROW +BEGIN + DECLARE vIsPayMethodChecked BOOLEAN; + DECLARE vEmail VARCHAR(150); + + SELECT isPayMethodChecked INTO vIsPayMethodChecked + FROM supplier + WHERE id = NEW.supplierFk; + + + IF vIsPayMethodChecked = FALSE THEN + + SELECT notificationEmail INTO vEmail + FROM department + WHERE name = 'FINANZAS'; + + CALL mail_insert( + vEmail, + NULL, + 'Pago con método sin verificar', + CONCAT( + 'Se ha realizado el pago ', + NEW.id, + ' al proveedor ', + NEW.supplierFk, + ' con el método de pago sin verificar.' + ) + ); + END IF; +END$$ +DELIMITER ; From df34debcc60a86ff635b46b7423276aee22a28e5 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 Dec 2021 08:05:22 +0100 Subject: [PATCH 10/21] test(ticket_descriptor): repair --- e2e/helpers/selectors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 24b87b398e..8675797e75 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -524,7 +524,7 @@ export default { saturdayButton: '.vn-popup.shown vn-tool-bar > vn-button:nth-child(6)', acceptDialog: '.vn-dialog.shown button[response="accept"]', acceptChangeHourButton: '.vn-dialog.shown button[response="accept"]', - descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(3) > section > span', + descriptorDeliveryDate: 'vn-ticket-descriptor slot-body > .attributes > vn-label-value:nth-child(4) > section > span', acceptInvoiceOutButton: '.vn-confirm.shown button[response="accept"]', acceptDeleteStowawayButton: '.vn-dialog.shown button[response="accept"]' }, From 831bfb0352b9cefad5877c5e988a1891b58bc85a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 21 Dec 2021 08:52:39 +0100 Subject: [PATCH 11/21] change route for hasRoute --- modules/ticket/back/methods/ticket/filter.js | 4 ++-- .../ticket/back/methods/ticket/specs/filter.spec.js | 10 +++++----- modules/ticket/front/search-panel/index.html | 4 ++-- modules/ticket/front/search-panel/locale/es.yml | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 9e51d36070..58c440e950 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -84,7 +84,7 @@ module.exports = Self => { description: `Whether to show only tickets with problems` }, { - arg: 'route', + arg: 'hasRoute', type: 'boolean', description: `Whether to show only tickets with route` }, @@ -193,7 +193,7 @@ module.exports = Self => { case 'alertLevel': return {'ts.alertLevel': value}; - case 'route': + case 'hasRoute': if (value == true) return {'t.routeFk': {neq: null}}; return {'t.routeFk': null}; diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index d1d44bb9c2..b251d53356 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -228,7 +228,7 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {route: true}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: true}}; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); @@ -247,11 +247,11 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {route: false}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: false}}; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(2); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { @@ -266,11 +266,11 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {route: null}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: null}}; const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(24); + expect(result.length).toEqual(27); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/search-panel/index.html b/modules/ticket/front/search-panel/index.html index 78ae727342..b0d4963bd5 100644 --- a/modules/ticket/front/search-panel/index.html +++ b/modules/ticket/front/search-panel/index.html @@ -137,8 +137,8 @@ diff --git a/modules/ticket/front/search-panel/locale/es.yml b/modules/ticket/front/search-panel/locale/es.yml index fcb7cc7e33..52cc04d6eb 100644 --- a/modules/ticket/front/search-panel/locale/es.yml +++ b/modules/ticket/front/search-panel/locale/es.yml @@ -12,7 +12,7 @@ Order id: Id cesta Grouped States: Estado agrupado Days onward: Días adelante With problems: Con problemas -With route: Con ruta +Has route: Con ruta Pending: Pendiente FREE: Libre DELIVERED: Servido From 76ec1fceaeb2d4bfb3c3d0b88067c4ebcd4a2828 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 21 Dec 2021 09:19:28 +0100 Subject: [PATCH 12/21] fear(smart-table): now shows the default order with the column arrows Refs: 3457 --- front/core/components/smart-table/index.js | 48 +++++++++++++++---- modules/entry/front/latest-buys/index.html | 5 +- .../monitor/front/index/tickets/index.html | 17 ++++--- .../monitor/front/index/tickets/style.scss | 2 +- 4 files changed, 52 insertions(+), 20 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 93d5f93947..cb0304b344 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -44,16 +44,10 @@ export default class SmartTable extends Component { set model(value) { this._model = value; - if (value) + if (value) { this.$.model = value; - } - - get viewConfigId() { - return this._viewConfigId; - } - - set viewConfigId(value) { - this._viewConfigId = value; + this.defaultOrder(); + } } getDefaultViewConfig() { @@ -163,6 +157,40 @@ export default class SmartTable extends Component { } } + defaultOrder() { + const order = this.model.order; + if (!order) return; + + const orderFields = order.split(', '); + + for (const fieldString of orderFields) { + const field = fieldString.split(' '); + const fieldName = field[0]; + + let sortType = 'ASC'; + if (field.length === 2) + sortType = field[1]; + + const column = this.columns.find(column => column.field == fieldName); + if (column) { + this.sortCriteria.push({field: fieldName, sortType: sortType}); + + const isASC = sortType == 'ASC'; + const isDESC = sortType == 'DESC'; + + if (isDESC) { + column.element.classList.remove('asc'); + column.element.classList.add('desc'); + } + + if (isASC) { + column.element.classList.remove('desc'); + column.element.classList.add('asc'); + } + } + } + } + registerColumns() { const header = this.element.querySelector('thead > tr'); if (!header) return; @@ -175,7 +203,7 @@ export default class SmartTable extends Component { const columnElement = angular.element(column); const caption = columnElement.text().trim(); - this.columns.push({field, caption, index}); + this.columns.push({field, caption, index, element: column}); column.addEventListener('click', () => this.orderHandler(column)); } diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 32d26c3a4e..4eeeeedce7 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -1,6 +1,7 @@ @@ -34,8 +35,8 @@ Picture - - Identifier + + Item ID Packing diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index 0d7f265f81..d1c18d52f0 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -2,7 +2,7 @@ vn-id="model" url="SalesMonitors/salesFilter" limit="20" - order="shippedDate DESC, theoreticalhour, id"> + order="shipped DESC, theoreticalHour, id"> - - + + + + @@ -81,7 +83,8 @@ state: 'ticket.card.summary', params: {id: ticket.id}, target: '_blank' - }"> + }" + tabindex="2" vn-focus> + + + + diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml index 385a54917a..9faf9ac06c 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 30a42d5c88..640b0c8a73 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 20/21] 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 a7ca38173d..98e78c7aad 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': From d1c7dea218caeb4d3c7ca62e268320a6244239de Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 23 Dec 2021 08:09:48 +0100 Subject: [PATCH 21/21] fix(supplier_account): get countryFk in model.js --- modules/supplier/back/models/supplier-account.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/supplier/back/models/supplier-account.js b/modules/supplier/back/models/supplier-account.js index 2eecab8b3a..c8b2f0595b 100644 --- a/modules/supplier/back/models/supplier-account.js +++ b/modules/supplier/back/models/supplier-account.js @@ -7,12 +7,14 @@ module.exports = Self => { }); async function ibanValidation(err, done) { - let filter = { + const supplier = await Self.app.models.Supplier.findById(this.supplierFk); + const filter = { fields: ['code'], - where: {id: this.countryFk} + where: {id: supplier.countryFk} }; - let country = await Self.app.models.Country.findOne(filter); - let code = country ? country.code.toLowerCase() : null; + + const country = await Self.app.models.Country.findOne(filter); + const code = country ? country.code.toLowerCase() : null; if (code != 'es') return done();
Date: Tue, 21 Dec 2021 10:37:29 +0100 Subject: [PATCH 13/21] Updated unit tests --- .../core/components/smart-table/index.spec.js | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/front/core/components/smart-table/index.spec.js b/front/core/components/smart-table/index.spec.js index 9b8cc1d09e..94edd45bba 100644 --- a/front/core/components/smart-table/index.spec.js +++ b/front/core/components/smart-table/index.spec.js @@ -80,6 +80,45 @@ describe('Component smartTable', () => { }); }); + describe('defaultOrder', () => { + it('should insert a new object to the controller sortCriteria with a sortType value of "ASC"', () => { + const element = document.createElement('div'); + controller.model = {order: 'id'}; + controller.columns = [ + {field: 'id', element: element}, + {field: 'test1', element: element}, + {field: 'test2', element: element} + ]; + + controller.defaultOrder(); + + const firstSortCriteria = controller.sortCriteria[0]; + + expect(firstSortCriteria.field).toEqual('id'); + expect(firstSortCriteria.sortType).toEqual('ASC'); + }); + + it('should insert two new objects to the controller sortCriteria with a sortType values of "ASC" and "DESC"', () => { + const element = document.createElement('div'); + controller.model = {order: 'test1, id DESC'}; + controller.columns = [ + {field: 'id', element: element}, + {field: 'test1', element: element}, + {field: 'test2', element: element} + ]; + + controller.defaultOrder(); + + const firstSortCriteria = controller.sortCriteria[0]; + const secondSortCriteria = controller.sortCriteria[1]; + + expect(firstSortCriteria.field).toEqual('test1'); + expect(firstSortCriteria.sortType).toEqual('ASC'); + expect(secondSortCriteria.field).toEqual('id'); + expect(secondSortCriteria.sortType).toEqual('DESC'); + }); + }); + describe('addFilter()', () => { it('should call the model addFilter() with a basic where filter if exprBuilder() was not received', () => { controller.model = {addFilter: jest.fn()}; From 1d28508cba302574d90d5f540461040521fcb033 Mon Sep 17 00:00:00 2001 From: joan Date: Tue, 21 Dec 2021 12:42:18 +0100 Subject: [PATCH 14/21] Removed vn-focus directive --- modules/monitor/front/index/tickets/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitor/front/index/tickets/index.html b/modules/monitor/front/index/tickets/index.html index d1c18d52f0..2653af1956 100644 --- a/modules/monitor/front/index/tickets/index.html +++ b/modules/monitor/front/index/tickets/index.html @@ -83,8 +83,7 @@ state: 'ticket.card.summary', params: {id: ticket.id}, target: '_blank' - }" - tabindex="2" vn-focus> + }"> Date: Tue, 21 Dec 2021 14:43:53 +0100 Subject: [PATCH 15/21] 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 45dc56c6bc..4f87cb708c 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 7b80d7a962..f9fdcef407 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 dfda4dcfb7..1f3aedadf3 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 ab221e4d21..30fcf59f00 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 0000000000..9f0bcc98ac --- /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 88e1b8308a..9efd660570 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 7ca1d47f9e..fe1f5684d0 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 256c72b390..9d0f71eb88 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 2a0d60fa6e..923fe9157b 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 734bbdbfd7..e4152600f3 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 16/21] 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 923fe9157b..15ce1798b3 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 17/21] 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 30fcf59f00..41150a1e0c 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 18/21] 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 d306c6f843..591af2839e 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 19/21] 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 20c29f0eeb..7a843c830b 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}}