From d1bd2f9c77cf9ae461048e259b0834bc7ec0a91b Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 21 Apr 2022 14:59:41 +0200 Subject: [PATCH 01/38] refactor: refund --- db/changes/10451-april/00-ticket_doRefund.sql | 119 ++++++++++-------- .../front/descriptor-menu/index.html | 12 ++ .../front/descriptor-menu/locale/es.yml | 2 + modules/ticket/back/methods/sale/refundAll.js | 29 +++-- 4 files changed, 97 insertions(+), 65 deletions(-) diff --git a/db/changes/10451-april/00-ticket_doRefund.sql b/db/changes/10451-april/00-ticket_doRefund.sql index 5540ff8cf..1621cc590 100644 --- a/db/changes/10451-april/00-ticket_doRefund.sql +++ b/db/changes/10451-april/00-ticket_doRefund.sql @@ -2,49 +2,63 @@ DROP PROCEDURE IF EXISTS vn.ticket_doRefund; DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(IN vOriginTicket INT, OUT vNewTicket INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRefund`(OUT vNewTicket INT) BEGIN - +/** + * Crea un ticket de abono a partir de tmp.sale y/o tmp.ticketService + * + * @return vNewTicket + */ DECLARE vDone BIT DEFAULT 0; - DECLARE vCustomer MEDIUMINT; + DECLARE vClientFk 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 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 vDescription VARCHAR(50); - DECLARE vTaxClassFk INT; - DECLARE vTicketServiceTypeFk INT; - - DECLARE cSales CURSOR FOR - SELECT * - FROM tmp.sale; - + DECLARE vSaleMain INT; + DECLARE vZoneFk INT; + DECLARE vDescription VARCHAR(50); + DECLARE vTaxClassFk INT; + DECLARE vTicketServiceTypeFk INT; + DECLARE vOriginTicket INT; + + DECLARE cSales CURSOR FOR + SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount + FROM tmp.sale s; + DECLARE cTicketServices CURSOR FOR - SELECT * - FROM tmp.ticketService; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = 1; - - SELECT id INTO vRefundAgencyMode + SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk + FROM tmp.ticketService ts; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sub.ticketFk INTO vOriginTicket + FROM ( + SELECT s.ticketFk + FROM tmp.sale s + UNION ALL + SELECT ts.ticketFk + FROM tmp.ticketService ts + ) sub; + + 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 + INTO vClientFk, vWarehouse, vCompany, vAddress + FROM ticket + WHERE id = vOriginTicket; + + SELECT id INTO vZoneFk FROM zone WHERE agencyModeFk = vRefundAgencyMode - LIMIT 1; - + LIMIT 1; + INSERT INTO vn.ticket ( clientFk, shipped, @@ -54,10 +68,10 @@ BEGIN warehouseFk, companyFk, landed, - zoneFk + zoneFk ) SELECT - vCustomer, + vClientFk, CURDATE(), vAddress, vRefundAgencyMode, @@ -65,49 +79,48 @@ BEGIN vWarehouse, vCompany, CURDATE(), - vZoneFk + vZoneFk FROM address a WHERE a.id = vAddress; SET vNewTicket = LAST_INSERT_ID(); - SET vDone := 0; + SET vDone := FALSE; OPEN cSales; - FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; + FETCH cSales 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; - + + SET vSaleNew = LAST_INSERT_ID(); + + INSERT INTO vn.saleComponent(saleFk,componentFk,`value`) + SELECT vSaleNew,componentFk,`value` + FROM vn.saleComponent + WHERE saleFk = vSaleMain; + FETCH cSales INTO vSaleMain, vItemFk, vQuantity, vConcept, vPrice, vDiscount; - + END WHILE; CLOSE cSales; - SET vDone := 0; + SET vDone := FALSE; OPEN cTicketServices; - FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; + FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; WHILE NOT vDone DO - + INSERT INTO vn.ticketService(description, quantity, price, taxClassFk, ticketFk, ticketServiceTypeFk) VALUES(vDescription, vQuantity, vPrice, vTaxClassFk, vNewTicket, vTicketServiceTypeFk); - + FETCH cTicketServices INTO vDescription, vQuantity, vPrice, vTaxClassFk, vTicketServiceTypeFk; - + END WHILE; CLOSE cTicketServices; INSERT INTO vn.ticketRefund(refundTicketFk, originalTicketFk) VALUES(vNewTicket, vOriginTicket); - END$$ DELIMITER ; diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 859486ab1..8ce799c1a 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -76,6 +76,13 @@ translate> Show CITES letter + + Refund + + + diff --git a/modules/invoiceOut/front/descriptor-menu/locale/es.yml b/modules/invoiceOut/front/descriptor-menu/locale/es.yml index a76f6aad3..8949f1f91 100644 --- a/modules/invoiceOut/front/descriptor-menu/locale/es.yml +++ b/modules/invoiceOut/front/descriptor-menu/locale/es.yml @@ -12,6 +12,8 @@ Are you sure you want to delete this invoice?: Estas seguro de eliminar esta fac Are you sure you want to clone this invoice?: Estas seguro de clonar esta factura? InvoiceOut booked: Factura asentada Are you sure you want to book this invoice?: Estas seguro de querer asentar esta factura? +Are you sure you want to refund this invoice?: Estas seguro de querer abonar esta factura? +Create a single ticket with all the content of the current invoice: Crear un ticket unico con todo el contenido de la factura actual Regenerate PDF invoice: Regenerar PDF factura The invoice PDF document has been regenerated: El documento PDF de la factura ha sido regenerado The email can't be empty: El correo no puede estar vacío diff --git a/modules/ticket/back/methods/sale/refundAll.js b/modules/ticket/back/methods/sale/refundAll.js index 6fcd27f0a..ac8e1664a 100644 --- a/modules/ticket/back/methods/sale/refundAll.js +++ b/modules/ticket/back/methods/sale/refundAll.js @@ -2,13 +2,19 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('refundAll', { - description: 'Create ticket with all lines and services changing the sign to the quantites', + description: 'Create ticket refund with all lines and services changing the sign to the quantites', accessType: 'WRITE', accepts: [{ - arg: 'ticketId', - type: 'number', + arg: 'sales', + description: 'The sales', + type: ['object'], + required: true + }, + { + arg: 'services', + type: ['object'], required: true, - description: 'The ticket id' + description: 'The services' }], returns: { type: 'number', @@ -20,7 +26,7 @@ module.exports = Self => { } }); - Self.refundAll = async(ctx, ticketId, options) => { + Self.refundAll = async(ctx, sales, services, options) => { const myOptions = {}; let tx; @@ -49,27 +55,26 @@ module.exports = Self => { CREATE TEMPORARY TABLE tmp.sale SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount FROM sale s - JOIN ticket t ON t.id = s.ticketFk - WHERE t.id IN (?); + WHERE s.id IN (?); CREATE TEMPORARY TABLE tmp.ticketService SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk FROM ticketService ts - WHERE ts.ticketFk IN (?); + WHERE ts.id IN (?); - CALL vn.ticket_doRefund(?, @newTicket); + CALL vn.ticket_doRefund(@newTicket); DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.ticketService;`; - await Self.rawSql(query, [ticketId, ticketId, ticketId], myOptions); + await Self.rawSql(query, [sales, services], myOptions); const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); - ticketId = newTicket.id; + const newTicketId = newTicket.id; if (tx) await tx.commit(); - return ticketId; + return newTicketId; } catch (e) { if (tx) await tx.rollback(); throw e; From 4ffb61b75c569df4770d0b2d907338e5793b0078 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 22 Apr 2022 11:45:14 +0200 Subject: [PATCH 02/38] refactor: refund --- db/changes/10451-april/00-ticket_doRefund.sql | 3 +- modules/ticket/back/methods/sale/refund.js | 53 +++++++----- modules/ticket/back/methods/sale/refundAll.js | 83 ------------------- modules/ticket/back/models/sale.js | 1 - modules/ticket/front/descriptor-menu/index.js | 18 +++- modules/ticket/front/sale/index.js | 2 +- 6 files changed, 48 insertions(+), 112 deletions(-) delete mode 100644 modules/ticket/back/methods/sale/refundAll.js diff --git a/db/changes/10451-april/00-ticket_doRefund.sql b/db/changes/10451-april/00-ticket_doRefund.sql index 1621cc590..5725b4fe5 100644 --- a/db/changes/10451-april/00-ticket_doRefund.sql +++ b/db/changes/10451-april/00-ticket_doRefund.sql @@ -45,7 +45,8 @@ BEGIN UNION ALL SELECT ts.ticketFk FROM tmp.ticketService ts - ) sub; + ) sub + LIMIT 1; SELECT id INTO vRefundAgencyMode FROM agencyMode WHERE `name` = 'ABONO'; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 9c87f23d3..7eefde7d0 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -2,19 +2,19 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('refund', { - description: 'Create ticket with the selected lines changing the sign to the quantites', + description: 'Create ticket refund with lines and services changing the sign to the quantites', accessType: 'WRITE', accepts: [{ arg: 'sales', description: 'The sales', type: ['object'], - required: true + required: false }, { - arg: 'ticketId', - type: 'number', - required: true, - description: 'The ticket id' + arg: 'services', + type: ['object'], + required: false, + description: 'The services' }], returns: { type: 'number', @@ -26,7 +26,7 @@ module.exports = Self => { } }); - Self.refund = async(ctx, sales, ticketId, options) => { + Self.refund = async(ctx, sales, services, options) => { const myOptions = {}; let tx; @@ -39,7 +39,6 @@ module.exports = Self => { } try { - const salesIds = []; const userId = ctx.req.accessToken.userId; const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); @@ -49,39 +48,47 @@ module.exports = Self => { if (!hasValidRole) throw new UserError(`You don't have privileges to create refund`); - for (let sale of sales) - salesIds.push(sale.id); + const salesIds = []; + if (sales) { + for (let sale of sales) + salesIds.push(sale.id); + } else + salesIds.push(null); + + const serevicesIds = []; + if (services) { + for (let service of services) + serevicesIds.push(service.id); + } else + serevicesIds.push(null); const query = ` DROP TEMPORARY TABLE IF EXISTS tmp.sale; DROP TEMPORARY TABLE IF EXISTS tmp.ticketService; CREATE TEMPORARY TABLE tmp.sale - SELECT s.id, s.itemFk, - s.quantity, s.concept, s.price, s.discount + SELECT s.id, s.itemFk, s.quantity, s.concept, s.price, s.discount, s.ticketFk FROM sale s WHERE s.id IN (?); - CREATE TEMPORARY TABLE tmp.ticketService( - description VARCHAR(50), - quantity DECIMAL (10,2), - price DECIMAL (10,2), - taxClassFk INT, - ticketServiceTypeFk INT - ); - - CALL vn.ticket_doRefund(?, @newTicket); + CREATE TEMPORARY TABLE tmp.ticketService + SELECT ts.description, ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk, ts.ticketFk + FROM ticketService ts + WHERE ts.id IN (?); + + CALL vn.ticket_doRefund(@newTicket); DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.ticketService;`; - await Self.rawSql(query, [salesIds, ticketId], myOptions); + await Self.rawSql(query, [salesIds, serevicesIds], myOptions); const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); - ticketId = newTicket.id; + const newTicketId = newTicket.id; if (tx) await tx.commit(); - return ticketId; + return newTicketId; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/back/methods/sale/refundAll.js b/modules/ticket/back/methods/sale/refundAll.js deleted file mode 100644 index ac8e1664a..000000000 --- a/modules/ticket/back/methods/sale/refundAll.js +++ /dev/null @@ -1,83 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethodCtx('refundAll', { - description: 'Create ticket refund with all lines and services changing the sign to the quantites', - accessType: 'WRITE', - accepts: [{ - arg: 'sales', - description: 'The sales', - type: ['object'], - required: true - }, - { - arg: 'services', - type: ['object'], - required: true, - description: 'The services' - }], - returns: { - type: 'number', - root: true - }, - http: { - path: `/refundAll`, - verb: 'post' - } - }); - - Self.refundAll = async(ctx, sales, services, 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 userId = ctx.req.accessToken.userId; - - const isClaimManager = await Self.app.models.Account.hasRole(userId, 'claimManager'); - const isSalesAssistant = await Self.app.models.Account.hasRole(userId, 'salesAssistant'); - const hasValidRole = isClaimManager || isSalesAssistant; - - if (!hasValidRole) - throw new UserError(`You don't have privileges to create refund`); - - const query = ` - DROP TEMPORARY TABLE IF EXISTS tmp.sale; - DROP TEMPORARY TABLE IF EXISTS tmp.ticketService; - - 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 (?); - - CREATE TEMPORARY TABLE tmp.ticketService - SELECT ts.description, - ts.quantity, ts.price, ts.taxClassFk, ts.ticketServiceTypeFk - FROM ticketService ts - WHERE ts.id IN (?); - - CALL vn.ticket_doRefund(@newTicket); - - DROP TEMPORARY TABLE tmp.sale; - DROP TEMPORARY TABLE tmp.ticketService;`; - - await Self.rawSql(query, [sales, services], myOptions); - - const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); - const newTicketId = newTicket.id; - - if (tx) await tx.commit(); - - return newTicketId; - } 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 2652aded2..2a4457263 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -7,7 +7,6 @@ module.exports = Self => { require('../methods/sale/updateConcept')(Self); require('../methods/sale/recalculatePrice')(Self); require('../methods/sale/refund')(Self); - require('../methods/sale/refundAll')(Self); require('../methods/sale/canEdit')(Self); Self.validatesPresenceOf('concept', { diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 1c80a6f9d..d8cce56c2 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -273,9 +273,21 @@ class Controller extends Section { .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } - refundAll() { - const params = {ticketId: this.id}; - const query = `Sales/refundAll`; + async refundAll() { + const filter = { + where: {ticketFk: this.id} + }; + await this.$http.get('Sales', {filter}) + .then(res => this.sales = res.data); + + await this.$http.get('TicketServices', {filter}) + .then(res => this.services = res.data); + + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; return this.$http.post(query, params).then(res => { this.$state.go('ticket.card.sale', {id: res.data}); }); diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index bb8a81bc4..987333e28 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -483,7 +483,7 @@ class Controller extends Section { const sales = this.selectedValidSales(); if (!sales) return; - const params = {sales: sales, ticketId: this.ticket.id}; + const params = {sales: sales}; const query = `Sales/refund`; this.resetChanges(); this.$http.post(query, params).then(res => { From 2b9c656d2153f4e311ced8431b9e56ae5946ba8f Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 22 Apr 2022 11:46:28 +0200 Subject: [PATCH 03/38] feat(invoiceOut): add refund option --- .../front/descriptor-menu/index.html | 2 +- .../invoiceOut/front/descriptor-menu/index.js | 31 +++++++++++++++++++ modules/ticket/front/services/index.html | 2 +- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/modules/invoiceOut/front/descriptor-menu/index.html b/modules/invoiceOut/front/descriptor-menu/index.html index 8ce799c1a..ef4c9a62e 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.html +++ b/modules/invoiceOut/front/descriptor-menu/index.html @@ -97,7 +97,7 @@ { + this.tickets = res.data; + this.ticketsIds = []; + for (let ticket of this.tickets) + this.ticketsIds.push(ticket.id); + }); + + filter = { + where: {ticketFk: {inq: this.ticketsIds}} + }; + await this.$http.get('Sales', {filter}) + .then(res => this.sales = res.data); + + await this.$http.get('TicketServices', {filter}) + .then(res => this.services = res.data); + + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; + return this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); + } } Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; diff --git a/modules/ticket/front/services/index.html b/modules/ticket/front/services/index.html index 13fd84b00..bb5505ce6 100644 --- a/modules/ticket/front/services/index.html +++ b/modules/ticket/front/services/index.html @@ -42,7 +42,7 @@ Date: Mon, 25 Apr 2022 08:45:50 +0200 Subject: [PATCH 04/38] refactor: changed name --- modules/ticket/front/descriptor-menu/index.html | 2 +- modules/ticket/front/descriptor-menu/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index c99575d42..1dcfd669f 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -302,7 +302,7 @@ \ No newline at end of file diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index d8cce56c2..a539901c5 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -273,7 +273,7 @@ class Controller extends Section { .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } - async refundAll() { + async refund() { const filter = { where: {ticketFk: this.id} }; From 6d35200607cbeabf22cf73fcb217312b5cc084dd Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 25 Apr 2022 10:10:59 +0200 Subject: [PATCH 05/38] updated front test --- .../front/descriptor-menu/index.spec.js | 55 +++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 75f3522ae..8e8880e3e 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -262,13 +262,60 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - describe('refundAll()', () => { + describe('refund()', () => { it('should make a query and go to ticket.card.sale', () => { jest.spyOn(controller.$state, 'go').mockReturnValue(); - const expectedParams = {ticketId: ticket.id}; - $httpBackend.expect('POST', `Sales/refundAll`, expectedParams).respond({ticketId: 16}); - controller.refundAll(); + const sales = [{ + id: 13, + concept: 'Melee weapon combat fist 15cm', + quantity: 10, + price: 7.08, + discount: 0, + reserved: false, + isPicked: 0, + created: '2022-04-21T22:00:00.000Z', + itemFk: 2, + ticketFk: 8 + }, + { + id: 14, + concept: 'Ranged weapon longbow 2m', + quantity: 2, + price: 103.49, + discount: 0, + reserved: false, + isPicked: 0, + created: '2022-04-21T22:00:00.000Z', + itemFk: 1, + ticketFk: 8 + }]; + + const services = [{ + id: 5, + ticketFk: 8, + description: 'Documentos', + quantity: 1, + price: 2, + taxClassFk: 1, + ticketServiceTypeFk: 1 + }]; + + const filter = { + where: {ticketFk: ticket.id} + }; + const serializedParams = $httpParamSerializer({filter}); + console.log(serializedParams); + + $httpBackend.expect('GET', `Sales?${serializedParams}`).respond(); + $httpBackend.expectGET(`TicketServices?filter=${serializedParams}`).respond(); + + const expectedParams = { + sales: sales, + services: services + }; + $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond(); + controller.refund(); $httpBackend.flush(); expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: {ticketId: ticket.id}}); From 5e35783a384ea4372736eb5e9ba8fc33195b01e1 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 26 Apr 2022 13:07:50 +0200 Subject: [PATCH 06/38] fix: javi's requested --- modules/client/front/descriptor/index.html | 2 +- modules/client/front/descriptor/locale/es.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/client/front/descriptor/index.html b/modules/client/front/descriptor/index.html index de7a86d3b..cad226416 100644 --- a/modules/client/front/descriptor/index.html +++ b/modules/client/front/descriptor/index.html @@ -105,7 +105,7 @@
diff --git a/modules/client/front/descriptor/locale/es.yml b/modules/client/front/descriptor/locale/es.yml index e6aca9665..71723e654 100644 --- a/modules/client/front/descriptor/locale/es.yml +++ b/modules/client/front/descriptor/locale/es.yml @@ -3,5 +3,6 @@ View consumer report: Ver informe de consumo From date: Fecha desde To date: Fecha hasta Go to user: Ir al usuario +Go to supplier: Ir al proveedor Client invoices list: Listado de facturas del cliente Pay method: Forma de pago \ No newline at end of file From 7abceb856429fc1c06aac4b259c3351cadd12bcb Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 26 Apr 2022 13:08:06 +0200 Subject: [PATCH 07/38] refactor: add frontTest --- .../invoiceOut/front/descriptor-menu/index.js | 42 +++++++-------- .../front/descriptor-menu/index.spec.js | 29 +++++++++++ modules/ticket/front/descriptor-menu/index.js | 32 ++++++------ .../front/descriptor-menu/index.spec.js | 51 +++---------------- 4 files changed, 75 insertions(+), 79 deletions(-) diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 92a69c894..3d6dc54fe 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -117,35 +117,37 @@ class Controller extends Section { }); } - async refundInvoiceOut() { + refundInvoiceOut() { let filter = { where: {refFk: this.invoiceOut.ref} }; - await this.$http.get('Tickets', {filter}) + this.$http.get('Tickets', {filter}) .then(res => { this.tickets = res.data; this.ticketsIds = []; for (let ticket of this.tickets) this.ticketsIds.push(ticket.id); + + filter = { + where: {ticketFk: {inq: this.ticketsIds}} + }; + this.$http.get('Sales', {filter}) + .then(res => { + this.sales = res.data; + this.$http.get('TicketServices', {filter}) + .then(res => { + this.services = res.data; + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; + return this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); + }); + }); }); - - filter = { - where: {ticketFk: {inq: this.ticketsIds}} - }; - await this.$http.get('Sales', {filter}) - .then(res => this.sales = res.data); - - await this.$http.get('TicketServices', {filter}) - .then(res => this.services = res.data); - - const params = { - sales: this.sales, - services: this.services - }; - const query = `Sales/refund`; - return this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); - }); } } diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js index fced12e0d..4abb19545 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.spec.js +++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js @@ -122,4 +122,33 @@ describe('vnInvoiceOutDescriptorMenu', () => { expect(controller.vnApp.showMessage).toHaveBeenCalled(); }); }); + + describe('refundInvoiceOut()', () => { + it('should make a query and go to ticket.card.sale', () => { + controller.$state.go = jest.fn(); + + const invoiceOut = { + id: 1, + ref: 'T1111111' + }; + controller.invoiceOut = invoiceOut; + const tickets = [{id: 1}]; + const sales = [{id: 1}]; + const services = [{id: 2}]; + + $httpBackend.expectGET(`Tickets`).respond(tickets); + $httpBackend.expectGET(`Sales`).respond(sales); + $httpBackend.expectGET(`TicketServices`).respond(services); + + const expectedParams = { + sales: sales, + services: services + }; + $httpBackend.expectPOST(`Sales/refund`, expectedParams).respond(); + controller.refundInvoiceOut(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined}); + }); + }); }); diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index a539901c5..3f8edc608 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -273,24 +273,26 @@ class Controller extends Section { .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } - async refund() { + refund() { const filter = { where: {ticketFk: this.id} }; - await this.$http.get('Sales', {filter}) - .then(res => this.sales = res.data); - - await this.$http.get('TicketServices', {filter}) - .then(res => this.services = res.data); - - const params = { - sales: this.sales, - services: this.services - }; - const query = `Sales/refund`; - return this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); - }); + this.$http.get('Sales', {filter}) + .then(res => { + this.sales = res.data; + this.$http.get('TicketServices', {filter}) + .then(res => { + this.services = res.data; + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; + return this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); + }); + }); } } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 8e8880e3e..13f5292c5 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -264,51 +264,14 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { describe('refund()', () => { it('should make a query and go to ticket.card.sale', () => { - jest.spyOn(controller.$state, 'go').mockReturnValue(); + controller.$state.go = jest.fn(); - const sales = [{ - id: 13, - concept: 'Melee weapon combat fist 15cm', - quantity: 10, - price: 7.08, - discount: 0, - reserved: false, - isPicked: 0, - created: '2022-04-21T22:00:00.000Z', - itemFk: 2, - ticketFk: 8 - }, - { - id: 14, - concept: 'Ranged weapon longbow 2m', - quantity: 2, - price: 103.49, - discount: 0, - reserved: false, - isPicked: 0, - created: '2022-04-21T22:00:00.000Z', - itemFk: 1, - ticketFk: 8 - }]; + controller._id = ticket.id; + const sales = [{id: 1}]; + const services = [{id: 2}]; - const services = [{ - id: 5, - ticketFk: 8, - description: 'Documentos', - quantity: 1, - price: 2, - taxClassFk: 1, - ticketServiceTypeFk: 1 - }]; - - const filter = { - where: {ticketFk: ticket.id} - }; - const serializedParams = $httpParamSerializer({filter}); - console.log(serializedParams); - - $httpBackend.expect('GET', `Sales?${serializedParams}`).respond(); - $httpBackend.expectGET(`TicketServices?filter=${serializedParams}`).respond(); + $httpBackend.expectGET(`Sales`).respond(sales); + $httpBackend.expectGET(`TicketServices`).respond(services); const expectedParams = { sales: sales, @@ -318,7 +281,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { controller.refund(); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: {ticketId: ticket.id}}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.sale', {id: undefined}); }); }); From 1766222c126c895b87461c68770f65ece4fbbc72 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 26 Apr 2022 13:25:12 +0200 Subject: [PATCH 08/38] refactor: updated backTest --- .../back/methods/sale/specs/refund.spec.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/ticket/back/methods/sale/specs/refund.spec.js b/modules/ticket/back/methods/sale/specs/refund.spec.js index 40fd6c17e..5cb353055 100644 --- a/modules/ticket/back/methods/sale/specs/refund.spec.js +++ b/modules/ticket/back/methods/sale/specs/refund.spec.js @@ -1,20 +1,20 @@ const models = require('vn-loopback/server/server').models; describe('sale refund()', () => { + const sales = [ + {id: 7, ticketFk: 11}, + {id: 8, ticketFk: 11} + ]; + const services = [{id: 1}]; + it('should create ticket with the selected lines changing the sign to the quantites', async() => { const tx = await models.Sale.beginTransaction({}); const ctx = {req: {accessToken: {userId: 9}}}; - const ticketId = 11; - const sales = [ - {id: 7, ticketFk: 11}, - {id: 8, ticketFk: 11} - ]; - try { const options = {transaction: tx}; - const response = await models.Sale.refund(ctx, sales, ticketId, options); + const response = await models.Sale.refund(ctx, sales, services, options); const [newTicketId] = await models.Sale.rawSql('SELECT MAX(t.id) id FROM vn.ticket t;', null, options); expect(response).toEqual(newTicketId.id); @@ -30,17 +30,12 @@ describe('sale refund()', () => { const tx = await models.Sale.beginTransaction({}); const ctx = {req: {accessToken: {userId: 1}}}; - const ticketId = 11; - const sales = [ - {id: 7, ticketFk: 11} - ]; - let error; try { const options = {transaction: tx}; - await models.Sale.refund(ctx, sales, ticketId, options); + await models.Sale.refund(ctx, sales, services, options); await tx.rollback(); } catch (e) { From bad90c12f443fcd6c43bcfe2f8bb1535335bd126 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 27 Apr 2022 14:17:41 +0200 Subject: [PATCH 09/38] feat: add required fields and models --- back/model-config.json | 6 ++++++ back/models/app-version-control.json | 24 +++++++++++++++++++++++ back/models/machine-worker.json | 27 ++++++++++++++++++++++++++ modules/item/back/models/item.json | 3 +++ modules/worker/back/models/worker.json | 6 ++++++ 5 files changed, 66 insertions(+) create mode 100644 back/models/app-version-control.json create mode 100644 back/models/machine-worker.json diff --git a/back/model-config.json b/back/model-config.json index 4ce11b99d..343210383 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -68,6 +68,12 @@ "Language": { "dataSource": "vn" }, + "MachineWorker": { + "dataSource": "vn" + }, + "MobileAppVersionControl": { + "dataSource": "vn" + }, "Module": { "dataSource": "vn" }, diff --git a/back/models/app-version-control.json b/back/models/app-version-control.json new file mode 100644 index 000000000..934d918f9 --- /dev/null +++ b/back/models/app-version-control.json @@ -0,0 +1,24 @@ +{ + "name": "MobileAppVersionControl", + "base": "VnModel", + "options": { + "mysql": { + "table": "vn.mobileAppVersionControl" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "appName": { + "type": "string" + }, + "version": { + "type": "string" + }, + "IsVersionCritical": { + "type": "number" + } + } +} diff --git a/back/models/machine-worker.json b/back/models/machine-worker.json new file mode 100644 index 000000000..61cde223f --- /dev/null +++ b/back/models/machine-worker.json @@ -0,0 +1,27 @@ +{ + "name": "MachineWorker", + "base": "VnModel", + "options": { + "mysql": { + "table": "vn.machineWorker" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "workerFk": { + "type": "number" + }, + "machineFk": { + "type": "number" + }, + "inTimed": { + "type": "date" + }, + "outTimed": { + "type": "date" + } + } +} diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index efde2690f..01b6ba093 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -140,6 +140,9 @@ }, "isFloramondo": { "type": "boolean" + }, + "packingShelve": { + "type": "number" } }, "relations": { diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c8054caff..df75d871e 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -46,6 +46,12 @@ }, "SSN": { "type" : "string" + }, + "sectorFk": { + "type" : "number" + }, + "labelerFk": { + "type" : "number" } }, "relations": { From ad80d0501c5b81a8bbc0651998f939071fd822d4 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 28 Apr 2022 07:48:09 +0200 Subject: [PATCH 10/38] add fixtures --- db/dump/fixtures.sql | 67 +++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0849e6708..f7fea2d72 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -120,13 +120,13 @@ INSERT INTO `account`.`mailForward`(`account`, `forwardTo`) VALUES (1, 'employee@domain.local'); -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk `) VALUES - (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106), - (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107), - (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108), - (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110); + (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL), + (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), + (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), + (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -134,7 +134,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) (2, 'USD', 'Dollar USA', 1.4), (3, 'GBP', 'Libra', 1), (4, 'JPY', 'Yen Japones', 1); - + INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`) VALUES (1, 'España', 1, 'ES', 1, 24, 4, 0, 1), @@ -838,25 +838,25 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('VT', 'Sales'); INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`) + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) VALUES - (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0), - (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0), - (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0), - (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0), - (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0), - (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0), - (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0), - (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0), - (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0), - (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1), - (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0), - (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0), - (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0), - (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0); + (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15), + (2, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 2, 'VT', 0, NULL, 'H', 0, 10), + (3, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, 5), + (4, 1, 60, 'YEL', 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), + (5, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), + (6, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (7, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (8, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 5, 'VT', 0, NULL, NULL, 0, NULL), + (9, 2, 70, 'BLU', 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL), + (10, 1, 60, 'YEL', 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (11, 1, 60, 'YEL', 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 4, 'VT', 0, NULL, NULL, 0, NULL), + (12, 3, 30, 'RED', 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 3, 'VT', 0, NULL, NULL, 0, NULL), + (13, 5, 30, 'RED', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 2, 'VT', 1, NULL, NULL, 1, NULL), + (14, 5, 90, 'BLU', 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 4, 'VT', 1, NULL, NULL, 0, NULL), + (15, 4, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (16, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'EMB', 0, NULL, NULL, 0, NULL), + (71, 6, NULL, NULL, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 0, 'VT', 0, NULL, NULL, 0, NULL); -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -2557,3 +2557,20 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); + +INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `IsVersionCritical`) + VALUES + ('delivery', '9.2', 0), + ('warehouse', '8.1', 0); + +INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`) + VALUES + ('RE-001', 'STILL', 'LTX-20', 60, 23, 'REMOLCADOR ELECTRICO', 'Arrastrar carros', 2020, 103, 442); + +INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) + VALUES + (1106, 1, CURDATE(), CURDATE()), + (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (1106, 2, CURDATE(), NULL), + (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + From dbc5c6105031216c1e080c21f844fa4f0ce1a338 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 2 May 2022 14:53:03 +0200 Subject: [PATCH 11/38] fix(diver-route): supplierAgencyTerm --- print/templates/reports/driver-route/sql/routes.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/print/templates/reports/driver-route/sql/routes.sql b/print/templates/reports/driver-route/sql/routes.sql index 3fbe59b0d..4b6f6a318 100644 --- a/print/templates/reports/driver-route/sql/routes.sql +++ b/print/templates/reports/driver-route/sql/routes.sql @@ -14,5 +14,6 @@ FROM route r LEFT JOIN account.user u ON u.id = w.userFk LEFT JOIN agencyMode am ON am.id = r.agencyModeFk LEFT JOIN agency a ON a.id = am.agencyFk - LEFT JOIN supplier s ON s.id = a.supplierFk + LEFT JOIN supplierAgencyTerm sa ON sa.agencyFk = a.id + LEFT JOIN supplier s ON s.id = sa.supplierFk WHERE r.id IN(?) \ No newline at end of file From f364c19c70c704137ae592ddf2d3febd6bd131ee Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 May 2022 14:08:46 +0200 Subject: [PATCH 12/38] fix(monitor_client): fix scroll --- front/core/components/smart-table/index.html | 12 +++++++----- front/core/components/smart-table/index.js | 3 ++- modules/monitor/front/index/clients/index.html | 12 ++++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/front/core/components/smart-table/index.html b/front/core/components/smart-table/index.html index c2af9b41e..a3295c47e 100644 --- a/front/core/components/smart-table/index.html +++ b/front/core/components/smart-table/index.html @@ -46,11 +46,13 @@
- - +
+ + +
- - +
+ + + + + Date: Wed, 4 May 2022 10:32:14 +0200 Subject: [PATCH 13/38] fix(monitor_client): clientsFilter refactor --- .../monitor/back/methods/sales-monitor/clientsFilter.js | 9 ++++----- .../methods/sales-monitor/specs/clientsFilter.spec.js | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js index 3d8edf608..daddf04fc 100644 --- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js +++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js @@ -43,11 +43,8 @@ module.exports = Self => { TIME(v.stamp) AS hour, DATE(v.stamp) AS dated, wtc.workerFk - FROM hedera.userSession s - JOIN hedera.visitUser v ON v.id = s.userVisitFk + FROM hedera.visitUser v JOIN client c ON c.id = v.userFk - LEFT JOIN account.user u ON c.salesPersonFk = u.id - LEFT JOIN worker w ON c.salesPersonFk = w.id LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk AND CURDATE() BETWEEN sc.started AND sc.ended LEFT JOIN workerTeamCollegues wtc @@ -58,7 +55,9 @@ module.exports = Self => { const where = filter.where; where['wtc.workerFk'] = userId; - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(`GROUP BY clientFk, v.stamp`); + stmt.merge(conn.makePagination(filter)); return conn.executeStmt(stmt, myOptions); }; diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js index 3fcc6c91a..e7510e848 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js @@ -11,7 +11,7 @@ describe('SalesMonitor clientsFilter()', () => { const filter = {order: 'dated DESC'}; const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); - expect(result.length).toEqual(9); + expect(result.length).toEqual(3); await tx.rollback(); } catch (e) { From ac4d4e6db10952ce85580b451606b5d7bd8edfc0 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 4 May 2022 10:59:37 +0200 Subject: [PATCH 14/38] test and fixtures --- db/dump/fixtures.sql | 80 ++++++++++--------- .../methods/sales-monitor/clientsFilter.js | 1 + .../sales-monitor/specs/clientsFilter.spec.js | 41 +++++++++- 3 files changed, 84 insertions(+), 38 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0849e6708..da2b12588 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1640,51 +1640,59 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) INSERT INTO `hedera`.`visit`(`id`, `firstAgentFk`) VALUES - (1, NULL), - (2, NULL), - (3, NULL), - (4, NULL), - (5, NULL), - (6, NULL), - (7, NULL), - (8, NULL), - (9, NULL); + (1, NULL), + (2, NULL), + (3, NULL), + (4, NULL), + (5, NULL), + (6, NULL), + (7, NULL), + (8, NULL), + (9, NULL), + (10, NULL), + (11, NULL); INSERT INTO `hedera`.`visitAgent`(`id`, `visitFk`) VALUES - (1, 1), - (2, 2), - (3, 3), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9); + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11); INSERT INTO `hedera`.`visitAccess`(`id`, `agentFk`, `stamp`) VALUES - (1, 1, CURDATE()), - (2, 2, CURDATE()), - (3, 3, CURDATE()), - (4, 4, CURDATE()), - (5, 5, CURDATE()), - (6, 6, CURDATE()), - (7, 7, CURDATE()), - (8, 8, CURDATE()), - (9, 9, CURDATE()); + (1, 1, CURDATE()), + (2, 2, CURDATE()), + (3, 3, CURDATE()), + (4, 4, CURDATE()), + (5, 5, CURDATE()), + (6, 6, CURDATE()), + (7, 7, CURDATE()), + (8, 8, CURDATE()), + (9, 9, CURDATE()), + (10, 10, CURDATE()), + (11, 11, CURDATE()); INSERT INTO `hedera`.`visitUser`(`id`, `accessFk`, `userFk`, `stamp`) VALUES - (1, 1, 1101, CURDATE()), - (2, 2, 1101, CURDATE()), - (3, 3, 1101, CURDATE()), - (4, 4, 1102, CURDATE()), - (5, 5, 1102, CURDATE()), - (6, 6, 1102, CURDATE()), - (7, 7, 1103, CURDATE()), - (8, 8, 1103, CURDATE()), - (9, 9, 1103, CURDATE()); + (1, 1, 1101, CURDATE()), + (2, 2, 1101, CURDATE()), + (3, 3, 1101, CURDATE()), + (4, 4, 1102, CURDATE()), + (5, 5, 1102, CURDATE()), + (6, 6, 1102, CURDATE()), + (7, 7, 1103, CURDATE()), + (8, 8, 1103, CURDATE()), + (9, 9, 1103, CURDATE()), + (10, 10, 1102, DATE_SUB(CURDATE(), INTERVAL 1 DAY)), + (11, 11, 1103, DATE_SUB(CURDATE(), INTERVAL 1 DAY)); INSERT INTO `hedera`.`userSession`(`created`, `lastUpdate`, `ssid`, `data`, `userVisitFk`) VALUES diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js index daddf04fc..a08125551 100644 --- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js +++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js @@ -45,6 +45,7 @@ module.exports = Self => { wtc.workerFk FROM hedera.visitUser v JOIN client c ON c.id = v.userFk + JOIN account.user u ON c.salesPersonFk = u.id LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk AND CURDATE() BETWEEN sc.started AND sc.ended LEFT JOIN workerTeamCollegues wtc diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js index e7510e848..bcb37830c 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js @@ -6,9 +6,18 @@ describe('SalesMonitor clientsFilter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {}}; - const filter = {order: 'dated DESC'}; + + const from = new Date(); + const to = new Date(); + from.setHours(0, 0, 0, 0); + to.setHours(23, 59, 59, 59); + + const filter = { + where: { + 'v.stamp': {between: [from, to]} + } + }; const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); expect(result.length).toEqual(3); @@ -19,4 +28,32 @@ describe('SalesMonitor clientsFilter()', () => { throw e; } }); + + it('should return the clients web activity filtered', async() => { + const tx = await models.SalesMonitor.beginTransaction({}); + + try { + const options = {transaction: tx}; + const ctx = {req: {accessToken: {userId: 18}}, args: {}}; + const yesterday = new Date(); + yesterday.setDate(yesterday.getDate() - 1); + const today = new Date(); + yesterday.setHours(0, 0, 0, 0); + today.setHours(23, 59, 59, 59); + + const filter = { + where: { + 'v.stamp': {between: [yesterday, today]} + } + }; + const result = await models.SalesMonitor.clientsFilter(ctx, filter, options); + + expect(result.length).toEqual(5); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From 70aca5d11adfe7c3e54c9cb14e518b0e2a4a975a Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 5 May 2022 13:25:57 +0200 Subject: [PATCH 15/38] fix(worker): fix getMonth --- modules/worker/back/methods/worker/createAbsence.js | 3 ++- modules/worker/back/methods/worker/deleteAbsence.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 44bda5627..fbbd97762 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -135,7 +135,8 @@ module.exports = Self => { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; - let month = date.getMonth(); + let month = date.getMonth() + 1; + console.log(month); if (month < 10) month = `0${month}`; let year = date.getFullYear(); diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index 72e9243d9..45dc04b2d 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -87,7 +87,7 @@ module.exports = Self => { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; - let month = date.getMonth(); + let month = date.getMonth() + 1; if (month < 10) month = `0${month}`; let year = date.getFullYear(); From 1e3b05a95dfaba4668899c7f4fb5c13f012e4ece Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 5 May 2022 13:32:34 +0200 Subject: [PATCH 16/38] remove console.log --- modules/worker/back/methods/worker/createAbsence.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index fbbd97762..957bcc15f 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -136,7 +136,6 @@ module.exports = Self => { let day = date.getDate(); if (day < 10) day = `0${day}`; let month = date.getMonth() + 1; - console.log(month); if (month < 10) month = `0${month}`; let year = date.getFullYear(); From 798147ea99731408f0bdd16ffa2d252e876c4166 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 5 May 2022 14:40:13 +0200 Subject: [PATCH 17/38] jenkins error --- modules/worker/back/methods/worker/createAbsence.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 957bcc15f..82cb5038e 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -135,6 +135,7 @@ module.exports = Self => { function formatDate(date) { let day = date.getDate(); if (day < 10) day = `0${day}`; + let month = date.getMonth() + 1; if (month < 10) month = `0${month}`; let year = date.getFullYear(); From d34a8629f74e54760cdeae95ba1bd11139547b44 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 6 May 2022 13:09:37 +0200 Subject: [PATCH 18/38] fix(setSaleQuantity): save originalQuantity --- back/methods/collection/setSaleQuantity.js | 12 +++++++----- .../methods/collection/spec/setSaleQuantity.spec.js | 11 ++--------- modules/ticket/back/models/sale.json | 13 ++++++++----- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/back/methods/collection/setSaleQuantity.js b/back/methods/collection/setSaleQuantity.js index 82451b8be..644c44a60 100644 --- a/back/methods/collection/setSaleQuantity.js +++ b/back/methods/collection/setSaleQuantity.js @@ -1,5 +1,5 @@ module.exports = Self => { - Self.remoteMethodCtx('setSaleQuantity', { + Self.remoteMethod('setSaleQuantity', { description: 'Update sale quantity', accessType: 'WRITE', accepts: [{ @@ -24,11 +24,13 @@ module.exports = Self => { } }); - Self.setSaleQuantity = async ctx => { - const args = ctx.args; + Self.setSaleQuantity = async(saleId, quantity) => { const models = Self.app.models; - const sale = await models.Sale.findById(args.saleId,); - return await sale.updateAttribute('quantity', args.quantity); + const sale = await models.Sale.findById(saleId); + return await sale.updateAttributes({ + originalQuantity: sale.quantity, + quantity: quantity + }); }; }; diff --git a/back/methods/collection/spec/setSaleQuantity.spec.js b/back/methods/collection/spec/setSaleQuantity.spec.js index 4e3c8c4aa..5d06a4383 100644 --- a/back/methods/collection/spec/setSaleQuantity.spec.js +++ b/back/methods/collection/spec/setSaleQuantity.spec.js @@ -5,19 +5,12 @@ describe('setSaleQuantity()', () => { const saleId = 30; const newQuantity = 10; - const ctx = { - args: { - saleId: saleId, - quantity: newQuantity - } - }; - const originalSale = await models.Sale.findById(saleId); - await models.Collection.setSaleQuantity(ctx); + await models.Collection.setSaleQuantity(saleId, newQuantity); const updateSale = await models.Sale.findById(saleId); - expect(updateSale.quantity).toBeLessThan(originalSale.quantity); + expect(updateSale.originalQuantity).toEqual(originalSale.quantity); expect(updateSale.quantity).toEqual(newQuantity); }); }); diff --git a/modules/ticket/back/models/sale.json b/modules/ticket/back/models/sale.json index 767a3e59e..14a6bc2cf 100644 --- a/modules/ticket/back/models/sale.json +++ b/modules/ticket/back/models/sale.json @@ -14,7 +14,7 @@ "properties": { "id": { "id": true, - "type": "Number", + "type": "number", "description": "Identifier" }, "concept": { @@ -22,22 +22,25 @@ "required": true }, "quantity": { - "type": "Number" + "type": "number" }, "price": { - "type": "Number" + "type": "number" }, "discount": { - "type": "Number" + "type": "number" }, "reserved": { "type": "boolean" }, "isPicked": { - "type": "Number" + "type": "number" }, "created": { "type": "date" + }, + "originalQuantity":{ + "type": "number" } }, "relations": { From 734f9cb60d7a9bb75f991e0686f3d1ee2057fb8a Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 11 May 2022 07:28:17 +0200 Subject: [PATCH 19/38] feat(item.itemType): added section itemType --- modules/account/front/role/index/index.js | 1 + modules/account/front/role/summary/index.js | 1 + modules/item/back/models/item-type.json | 7 ++- modules/item/front/index.js | 2 +- .../front/item-type/basic-data/index.html | 38 +++++++++++++++ .../item/front/item-type/basic-data/index.js | 12 +++++ modules/item/front/item-type/card/index.html | 5 ++ modules/item/front/item-type/card/index.js | 17 +++++++ .../item/front/item-type/card/index.spec.js | 25 ++++++++++ .../item/front/item-type/create/index.html | 38 +++++++++++++++ modules/item/front/item-type/create/index.js | 15 ++++++ .../front/item-type/descriptor/index.html | 27 +++++++++++ .../item/front/item-type/descriptor/index.js | 30 ++++++++++++ .../front/item-type/descriptor/index.spec.js | 29 ++++++++++++ .../front/item-type/descriptor/locale/es.yml | 2 + modules/item/front/item-type/index.js | 8 ++++ modules/item/front/item-type/index/index.html | 46 +++++++++++++++++++ modules/item/front/item-type/index/index.js | 15 ++++++ .../item/front/item-type/index/locale/es.yml | 1 + modules/item/front/item-type/main/index.html | 18 ++++++++ modules/item/front/item-type/main/index.js | 24 ++++++++++ .../front/item-type/search-panel/index.html | 21 +++++++++ .../front/item-type/search-panel/index.js | 7 +++ .../item/front/item-type/summary/index.html | 20 ++++++++ modules/item/front/item-type/summary/index.js | 26 +++++++++++ modules/item/front/routes.json | 44 +++++++++++++++++- 26 files changed, 475 insertions(+), 4 deletions(-) create mode 100644 modules/item/front/item-type/basic-data/index.html create mode 100644 modules/item/front/item-type/basic-data/index.js create mode 100644 modules/item/front/item-type/card/index.html create mode 100644 modules/item/front/item-type/card/index.js create mode 100644 modules/item/front/item-type/card/index.spec.js create mode 100644 modules/item/front/item-type/create/index.html create mode 100644 modules/item/front/item-type/create/index.js create mode 100644 modules/item/front/item-type/descriptor/index.html create mode 100644 modules/item/front/item-type/descriptor/index.js create mode 100644 modules/item/front/item-type/descriptor/index.spec.js create mode 100644 modules/item/front/item-type/descriptor/locale/es.yml create mode 100644 modules/item/front/item-type/index.js create mode 100644 modules/item/front/item-type/index/index.html create mode 100644 modules/item/front/item-type/index/index.js create mode 100644 modules/item/front/item-type/index/locale/es.yml create mode 100644 modules/item/front/item-type/main/index.html create mode 100644 modules/item/front/item-type/main/index.js create mode 100644 modules/item/front/item-type/search-panel/index.html create mode 100644 modules/item/front/item-type/search-panel/index.js create mode 100644 modules/item/front/item-type/summary/index.html create mode 100644 modules/item/front/item-type/summary/index.js diff --git a/modules/account/front/role/index/index.js b/modules/account/front/role/index/index.js index 40773b23b..49b9be53b 100644 --- a/modules/account/front/role/index/index.js +++ b/modules/account/front/role/index/index.js @@ -4,6 +4,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section { preview(role) { this.selectedRole = role; + console.log(this.selectedRole); this.$.summary.show(); } } diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js index 0a08fe8b2..eb528a894 100644 --- a/modules/account/front/role/summary/index.js +++ b/modules/account/front/role/summary/index.js @@ -6,6 +6,7 @@ class Controller extends Component { this._role = value; this.$.summary = null; if (!value) return; + console.log(value); this.$http.get(`Roles/${value.id}`) .then(res => this.$.summary = res.data); diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index cb9d5ace8..b7a8ced2f 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -18,10 +18,13 @@ "name": { "type": "string" }, - "life": { + "workerFk": { "type": "number" }, - "isPackaging": { + "categoryFk": { + "type": "boolean" + }, + "temperatureFk": { "type": "boolean" } }, diff --git a/modules/item/front/index.js b/modules/item/front/index.js index c328b1c8d..6a8d1b3b7 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -23,4 +23,4 @@ import './waste/index/'; import './waste/detail'; import './fixed-price'; import './fixed-price-search-panel'; - +import './item-type'; diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html new file mode 100644 index 000000000..f2888fcdf --- /dev/null +++ b/modules/item/front/item-type/basic-data/index.html @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/item/front/item-type/basic-data/index.js b/modules/item/front/item-type/basic-data/index.js new file mode 100644 index 000000000..fdb0305d6 --- /dev/null +++ b/modules/item/front/item-type/basic-data/index.js @@ -0,0 +1,12 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section {} + +ngModule.component('vnItemTypeBasicData', { + template: require('./index.html'), + controller: Controller, + bindings: { + role: '<' + } +}); diff --git a/modules/item/front/item-type/card/index.html b/modules/item/front/item-type/card/index.html new file mode 100644 index 000000000..5ed275c6a --- /dev/null +++ b/modules/item/front/item-type/card/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js new file mode 100644 index 000000000..090279c5b --- /dev/null +++ b/modules/item/front/item-type/card/index.js @@ -0,0 +1,17 @@ +import ngModule from '../../module'; +import ModuleCard from 'salix/components/module-card'; + +class Controller extends ModuleCard { + reload() { + this.$http.get(`ItemTypes/${this.$params.id}`) + .then(res => { + this.itemType = res.data; + console.log(this.itemType); + }); + } +} + +ngModule.vnComponent('vnItemTypeCard', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js new file mode 100644 index 000000000..f39840e5f --- /dev/null +++ b/modules/item/front/item-type/card/index.spec.js @@ -0,0 +1,25 @@ +import './index'; + +describe('component vnRoleCard', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('account')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRoleCard', {$element: null}); + })); + + describe('reload()', () => { + it('should reload the controller data', () => { + controller.$params.id = 1; + + $httpBackend.expectGET('Roles/1').respond('foo'); + controller.reload(); + $httpBackend.flush(); + + expect(controller.role).toBe('foo'); + }); + }); +}); diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html new file mode 100644 index 000000000..02900d580 --- /dev/null +++ b/modules/item/front/item-type/create/index.html @@ -0,0 +1,38 @@ + + +
+ + + + + + + + + + + + + + +
diff --git a/modules/item/front/item-type/create/index.js b/modules/item/front/item-type/create/index.js new file mode 100644 index 000000000..1474ad5e5 --- /dev/null +++ b/modules/item/front/item-type/create/index.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + onSubmit() { + return this.$.watcher.submit().then(res => + this.$state.go('account.role.card.basicData', {id: res.data.id}) + ); + } +} + +ngModule.component('vnItemTypeCreate', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html new file mode 100644 index 000000000..e4b8a6bbf --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.html @@ -0,0 +1,27 @@ + + + + Delete + + + +
+ + +
+
+
+ + \ No newline at end of file diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js new file mode 100644 index 000000000..83c9a1da2 --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.js @@ -0,0 +1,30 @@ +import ngModule from '../../module'; +import Descriptor from 'salix/components/descriptor'; + +class Controller extends Descriptor { + $onInit() { + console.log(this.itemType, this.entity); + } + + get itemType() { + return this.entity; + } + + set itemType(value) { + this.entity = value; + } + + onDelete() { + return this.$http.delete(`ItemTypes/${this.id}`) + .then(() => this.$state.go('item.itemType')) + .then(() => this.vnApp.showSuccess(this.$t('ItemType removed'))); + } +} + +ngModule.component('vnItemTypeDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/item-type/descriptor/index.spec.js b/modules/item/front/item-type/descriptor/index.spec.js new file mode 100644 index 000000000..e2761c639 --- /dev/null +++ b/modules/item/front/item-type/descriptor/index.spec.js @@ -0,0 +1,29 @@ +import './index'; + +describe('component vnRoleDescriptor', () => { + let controller; + let $httpBackend; + + let role = {id: 1, name: 'foo'}; + + beforeEach(ngModule('account')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + controller = $componentController('vnRoleDescriptor', {$element: null}, {role}); + })); + + describe('onDelete()', () => { + it('should delete entity and go to index', () => { + controller.$state.go = jest.fn(); + jest.spyOn(controller.vnApp, 'showSuccess'); + + $httpBackend.expectDELETE('Roles/1').respond(); + controller.onDelete(); + $httpBackend.flush(); + + expect(controller.$state.go).toHaveBeenCalledWith('account.role'); + expect(controller.vnApp.showSuccess).toHaveBeenCalled(); + }); + }); +}); diff --git a/modules/item/front/item-type/descriptor/locale/es.yml b/modules/item/front/item-type/descriptor/locale/es.yml new file mode 100644 index 000000000..1ca512e4f --- /dev/null +++ b/modules/item/front/item-type/descriptor/locale/es.yml @@ -0,0 +1,2 @@ +Role will be removed: El rol va a ser eliminado +Role removed: Rol eliminado \ No newline at end of file diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js new file mode 100644 index 000000000..c8282e196 --- /dev/null +++ b/modules/item/front/item-type/index.js @@ -0,0 +1,8 @@ +import './main'; +import './index/'; +import './summary'; +import './card'; +import './descriptor'; +import './search-panel'; +import './create'; +import './basic-data'; diff --git a/modules/item/front/item-type/index/index.html b/modules/item/front/item-type/index/index.html new file mode 100644 index 000000000..459b5d71c --- /dev/null +++ b/modules/item/front/item-type/index/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/index/index.js b/modules/item/front/item-type/index/index.js new file mode 100644 index 000000000..5530e5cf3 --- /dev/null +++ b/modules/item/front/item-type/index/index.js @@ -0,0 +1,15 @@ +import ngModule from '../../module'; +import Section from 'salix/components/section'; + +export default class Controller extends Section { + preview(itemType) { + this.selectedItemType = itemType; + console.log(this.selectedItemType); + this.$.summary.show(); + } +} + +ngModule.component('vnItemTypeIndex', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-type/index/locale/es.yml b/modules/item/front/item-type/index/locale/es.yml new file mode 100644 index 000000000..3a36f7c96 --- /dev/null +++ b/modules/item/front/item-type/index/locale/es.yml @@ -0,0 +1 @@ +Item Type: Familia \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.html b/modules/item/front/item-type/main/index.html new file mode 100644 index 000000000..faba696c0 --- /dev/null +++ b/modules/item/front/item-type/main/index.html @@ -0,0 +1,18 @@ + + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/main/index.js b/modules/item/front/item-type/main/index.js new file mode 100644 index 000000000..0dea00abb --- /dev/null +++ b/modules/item/front/item-type/main/index.js @@ -0,0 +1,24 @@ +import ngModule from '../../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class ItemType extends ModuleMain { + exprBuilder(param, value) { + switch (param) { + case 'search': + return /^\d+$/.test(value) + ? {id: value} + : {or: [ + {name: {like: `%${value}%`}}, + {code: {like: `%${value}%`}} + ]}; + case 'name': + case 'code': + return {[param]: {like: `%${value}%`}}; + } + } +} + +ngModule.vnComponent('vnItemType', { + controller: ItemType, + template: require('./index.html') +}); diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html new file mode 100644 index 000000000..ce2919910 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.html @@ -0,0 +1,21 @@ +
+
+ + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js new file mode 100644 index 000000000..3a6ed4f86 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnItemTypePanel', { + template: require('./index.html'), + controller: SearchPanel +}); diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html new file mode 100644 index 000000000..f7971190c --- /dev/null +++ b/modules/item/front/item-type/summary/index.html @@ -0,0 +1,20 @@ + +
{{summary.name}}
+ + +

Basic data

+ + + + + + +
+
+
\ No newline at end of file diff --git a/modules/item/front/item-type/summary/index.js b/modules/item/front/item-type/summary/index.js new file mode 100644 index 000000000..1048fa88d --- /dev/null +++ b/modules/item/front/item-type/summary/index.js @@ -0,0 +1,26 @@ +import ngModule from '../../module'; +import Component from 'core/lib/component'; + +class Controller extends Component { + set itemType(value) { + this._itemType = value; + this.$.summary = null; + if (!value) return; + console.log(value); + + this.$http.get(`ItemTypes/${value.id}`) + .then(res => console.log(res.data)); + } + + get itemType() { + return this._itemType; + } +} + +ngModule.component('vnItemTypeSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + itemType: '<' + } +}); diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 9e21e1697..400399c38 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -9,7 +9,8 @@ {"state": "item.index", "icon": "icon-item"}, {"state": "item.request", "icon": "icon-buyrequest"}, {"state": "item.waste.index", "icon": "icon-claims"}, - {"state": "item.fixedPrice", "icon": "icon-fixedPrice"} + {"state": "item.fixedPrice", "icon": "icon-fixedPrice"}, + {"state": "item.itemType", "icon": "contact_support"} ], "card": [ {"state": "item.card.basicData", "icon": "settings"}, @@ -169,6 +170,47 @@ "component": "vn-fixed-price", "description": "Fixed prices", "acl": ["buyer"] + }, + { + "url" : "/item-type?q", + "state": "item.itemType", + "component": "vn-item-type", + "description": "Item Type", + "acl": ["buyer"] + }, + { + "url": "/create", + "state": "item.itemType.create", + "component": "vn-item-type-create", + "description": "New itemType", + "acl": ["buyer"] + }, + { + "url": "/:id", + "state": "item.itemType.card", + "component": "vn-item-type-card", + "abstract": true, + "description": "Detail" + }, + { + "url": "/summary", + "state": "item.itemType.card.summary", + "component": "vn-item-type-summary", + "description": "Summary", + "params": { + "itemType": "$ctrl.itemType" + }, + "acl": ["buyer"] + }, + { + "url": "/basic-data", + "state": "item.itemType.card.basicData", + "component": "vn-item-type-basic-data", + "description": "Basic data", + "params": { + "itemType": "$ctrl.itemType" + }, + "acl": ["buyer"] } ] } \ No newline at end of file From 13a6f1f8c1e17b6bba6f5f8bed3172a229f01fda Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 11 May 2022 14:47:54 +0200 Subject: [PATCH 20/38] feat(item): add section itemType --- db/changes/10460-motherDay/00-aclItemType.sql | 3 ++ db/dump/fixtures.sql | 24 ++++++------ modules/account/front/role/summary/index.js | 2 - modules/item/back/models/item-type.json | 4 +- .../front/item-type/basic-data/index.html | 34 ++++++++++++++--- .../item/front/item-type/basic-data/index.js | 2 +- modules/item/front/item-type/card/index.html | 2 +- modules/item/front/item-type/card/index.js | 5 +-- .../item/front/item-type/card/index.spec.js | 10 ++--- .../item/front/item-type/create/index.html | 38 +++++++++++++++---- modules/item/front/item-type/create/index.js | 2 +- .../front/item-type/descriptor/index.html | 6 ++- .../item/front/item-type/descriptor/index.js | 4 -- .../front/item-type/descriptor/index.spec.js | 12 +++--- modules/item/front/item-type/index.js | 1 - modules/item/front/item-type/index/index.html | 9 ++--- modules/item/front/item-type/index/index.js | 1 - .../item/front/item-type/index/locale/es.yml | 3 +- .../front/item-type/search-panel/index.html | 21 ---------- .../front/item-type/search-panel/index.js | 7 ---- .../item/front/item-type/summary/index.html | 20 ++++++++-- modules/item/front/item-type/summary/index.js | 11 ++++-- modules/item/front/routes.json | 7 +++- 23 files changed, 132 insertions(+), 96 deletions(-) create mode 100644 db/changes/10460-motherDay/00-aclItemType.sql delete mode 100644 modules/item/front/item-type/search-panel/index.html delete mode 100644 modules/item/front/item-type/search-panel/index.js diff --git a/db/changes/10460-motherDay/00-aclItemType.sql b/db/changes/10460-motherDay/00-aclItemType.sql new file mode 100644 index 000000000..86fae1b1f --- /dev/null +++ b/db/changes/10460-motherDay/00-aclItemType.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL +(model, property, accessType, permission, principalType, principalId) +VALUES('ItemType', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index e03027b36..1d794c359 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -773,14 +773,19 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` (7, 'Accessories', 1, NULL, 'icon-accessory', 'accessory'), (8, 'Fruit', 1, NULL, 'icon-fruit', 'fruit'); -INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`) +INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES - (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0), - (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0), - (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0), - (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1), - (5, 'CON', 'Container', 3, 1, NULL, 35, 1), - (6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0); + ('warm', 'Warm', 'Warm'), + ('cool', 'Cool', 'Cool'); + +INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`) + VALUES + (1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0, 'cool'), + (2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0, 'cool'), + (3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0, 'cool'), + (4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1, 'warm'), + (5, 'CON', 'Container', 3, 1, NULL, 35, 1, 'warm'), + (6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0, 'warm'); INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`) VALUES @@ -2309,11 +2314,6 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); - -INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) - VALUES - ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js index eb528a894..4f321fa98 100644 --- a/modules/account/front/role/summary/index.js +++ b/modules/account/front/role/summary/index.js @@ -6,8 +6,6 @@ class Controller extends Component { this._role = value; this.$.summary = null; if (!value) return; - console.log(value); - this.$http.get(`Roles/${value.id}`) .then(res => this.$.summary = res.data); } diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index b7a8ced2f..c7a90aea9 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -22,10 +22,10 @@ "type": "number" }, "categoryFk": { - "type": "boolean" + "type": "number" }, "temperatureFk": { - "type": "boolean" + "type": "string" } }, "relations": { diff --git a/modules/item/front/item-type/basic-data/index.html b/modules/item/front/item-type/basic-data/index.html index f2888fcdf..1417a05ab 100644 --- a/modules/item/front/item-type/basic-data/index.html +++ b/modules/item/front/item-type/basic-data/index.html @@ -1,7 +1,7 @@
+ + + + + + diff --git a/modules/item/front/item-type/basic-data/index.js b/modules/item/front/item-type/basic-data/index.js index fdb0305d6..ec280fdf8 100644 --- a/modules/item/front/item-type/basic-data/index.js +++ b/modules/item/front/item-type/basic-data/index.js @@ -7,6 +7,6 @@ ngModule.component('vnItemTypeBasicData', { template: require('./index.html'), controller: Controller, bindings: { - role: '<' + itemType: '<' } }); diff --git a/modules/item/front/item-type/card/index.html b/modules/item/front/item-type/card/index.html index 5ed275c6a..80af6088e 100644 --- a/modules/item/front/item-type/card/index.html +++ b/modules/item/front/item-type/card/index.html @@ -1,5 +1,5 @@ - + diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js index 090279c5b..b610f7566 100644 --- a/modules/item/front/item-type/card/index.js +++ b/modules/item/front/item-type/card/index.js @@ -4,10 +4,7 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { this.$http.get(`ItemTypes/${this.$params.id}`) - .then(res => { - this.itemType = res.data; - console.log(this.itemType); - }); + .then(res => this.itemType = res.data); } } diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js index f39840e5f..179f65274 100644 --- a/modules/item/front/item-type/card/index.spec.js +++ b/modules/item/front/item-type/card/index.spec.js @@ -1,25 +1,25 @@ import './index'; -describe('component vnRoleCard', () => { +describe('component vnItemTypeCard', () => { let controller; let $httpBackend; - beforeEach(ngModule('account')); + beforeEach(ngModule('item')); beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleCard', {$element: null}); + controller = $componentController('vnItemTypeCard', {$element: null}); })); describe('reload()', () => { it('should reload the controller data', () => { controller.$params.id = 1; - $httpBackend.expectGET('Roles/1').respond('foo'); + $httpBackend.expectGET('ItemTypes/1').respond('foo'); controller.reload(); $httpBackend.flush(); - expect(controller.role).toBe('foo'); + expect(controller.itemType).toBe('foo'); }); }); }); diff --git a/modules/item/front/item-type/create/index.html b/modules/item/front/item-type/create/index.html index 02900d580..44cb5183d 100644 --- a/modules/item/front/item-type/create/index.html +++ b/modules/item/front/item-type/create/index.html @@ -1,7 +1,7 @@ @@ -12,16 +12,40 @@ + + + + + + @@ -32,7 +56,7 @@ + ui-sref="item.itemType"> diff --git a/modules/item/front/item-type/create/index.js b/modules/item/front/item-type/create/index.js index 1474ad5e5..ccf7744be 100644 --- a/modules/item/front/item-type/create/index.js +++ b/modules/item/front/item-type/create/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section { onSubmit() { return this.$.watcher.submit().then(res => - this.$state.go('account.role.card.basicData', {id: res.data.id}) + this.$state.go('item.itemType.card.basicData', {id: res.data.id}) ); } } diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html index e4b8a6bbf..63bbf8726 100644 --- a/modules/item/front/item-type/descriptor/index.html +++ b/modules/item/front/item-type/descriptor/index.html @@ -1,7 +1,7 @@ + description="$ctrl.itemType.code">
+ + diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js index 83c9a1da2..02fd59932 100644 --- a/modules/item/front/item-type/descriptor/index.js +++ b/modules/item/front/item-type/descriptor/index.js @@ -2,10 +2,6 @@ import ngModule from '../../module'; import Descriptor from 'salix/components/descriptor'; class Controller extends Descriptor { - $onInit() { - console.log(this.itemType, this.entity); - } - get itemType() { return this.entity; } diff --git a/modules/item/front/item-type/descriptor/index.spec.js b/modules/item/front/item-type/descriptor/index.spec.js index e2761c639..3da1bad1a 100644 --- a/modules/item/front/item-type/descriptor/index.spec.js +++ b/modules/item/front/item-type/descriptor/index.spec.js @@ -1,16 +1,16 @@ import './index'; -describe('component vnRoleDescriptor', () => { +describe('component vnItemTypeDescriptor', () => { let controller; let $httpBackend; - let role = {id: 1, name: 'foo'}; + let itemType = {id: 1, name: 'foo'}; - beforeEach(ngModule('account')); + beforeEach(ngModule('item')); beforeEach(inject(($componentController, _$httpBackend_) => { $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleDescriptor', {$element: null}, {role}); + controller = $componentController('vnItemTypeDescriptor', {$element: null}, {itemType}); })); describe('onDelete()', () => { @@ -18,11 +18,11 @@ describe('component vnRoleDescriptor', () => { controller.$state.go = jest.fn(); jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.expectDELETE('Roles/1').respond(); + $httpBackend.expectDELETE('ItemTypes/1').respond(); controller.onDelete(); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('account.role'); + expect(controller.$state.go).toHaveBeenCalledWith('item.itemType'); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); }); }); diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js index c8282e196..f33658da3 100644 --- a/modules/item/front/item-type/index.js +++ b/modules/item/front/item-type/index.js @@ -3,6 +3,5 @@ import './index/'; import './summary'; import './card'; import './descriptor'; -import './search-panel'; import './create'; import './basic-data'; diff --git a/modules/item/front/item-type/index/index.html b/modules/item/front/item-type/index/index.html index 459b5d71c..50b9eb172 100644 --- a/modules/item/front/item-type/index/index.html +++ b/modules/item/front/item-type/index/index.html @@ -33,14 +33,11 @@ - + - \ No newline at end of file diff --git a/modules/item/front/item-type/index/index.js b/modules/item/front/item-type/index/index.js index 5530e5cf3..54ecba997 100644 --- a/modules/item/front/item-type/index/index.js +++ b/modules/item/front/item-type/index/index.js @@ -4,7 +4,6 @@ import Section from 'salix/components/section'; export default class Controller extends Section { preview(itemType) { this.selectedItemType = itemType; - console.log(this.selectedItemType); this.$.summary.show(); } } diff --git a/modules/item/front/item-type/index/locale/es.yml b/modules/item/front/item-type/index/locale/es.yml index 3a36f7c96..1a71ff212 100644 --- a/modules/item/front/item-type/index/locale/es.yml +++ b/modules/item/front/item-type/index/locale/es.yml @@ -1 +1,2 @@ -Item Type: Familia \ No newline at end of file +Item Type: Familia +New itemType: Nueva familia \ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html deleted file mode 100644 index ce2919910..000000000 --- a/modules/item/front/item-type/search-panel/index.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js deleted file mode 100644 index 3a6ed4f86..000000000 --- a/modules/item/front/item-type/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnItemTypePanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html index f7971190c..d6704fc8b 100644 --- a/modules/item/front/item-type/summary/index.html +++ b/modules/item/front/item-type/summary/index.html @@ -1,5 +1,7 @@ -
{{summary.name}}
+
+ {{summary.id}} - {{summary.name}} - {{summary.worker.firstName}} {{summary.worker.lastName}} +

Basic data

@@ -7,13 +9,25 @@ label="Id" value="{{summary.id}}">
+ + + label="Worker" + value="{{summary.worker.firstName}} {{summary.worker.lastName}}"> + + + + diff --git a/modules/item/front/item-type/summary/index.js b/modules/item/front/item-type/summary/index.js index 1048fa88d..0a3bdc13c 100644 --- a/modules/item/front/item-type/summary/index.js +++ b/modules/item/front/item-type/summary/index.js @@ -6,10 +6,15 @@ class Controller extends Component { this._itemType = value; this.$.summary = null; if (!value) return; - console.log(value); - this.$http.get(`ItemTypes/${value.id}`) - .then(res => console.log(res.data)); + const filter = { + include: [ + {relation: 'worker'}, + {relation: 'category'} + ] + }; + this.$http.get(`ItemTypes/${value.id}`, {filter}) + .then(res => this.$.summary = res.data); } get itemType() { diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 400399c38..5743d0ce7 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -21,6 +21,9 @@ {"state": "item.card.diary", "icon": "icon-transaction"}, {"state": "item.card.last-entries", "icon": "icon-regentry"}, {"state": "item.card.log", "icon": "history"} + ], + "itemType": [ + {"state": "item.itemType.card.basicData", "icon": "settings"} ] }, "keybindings": [ @@ -198,7 +201,7 @@ "component": "vn-item-type-summary", "description": "Summary", "params": { - "itemType": "$ctrl.itemType" + "item-type": "$ctrl.itemType" }, "acl": ["buyer"] }, @@ -208,7 +211,7 @@ "component": "vn-item-type-basic-data", "description": "Basic data", "params": { - "itemType": "$ctrl.itemType" + "item-type": "$ctrl.itemType" }, "acl": ["buyer"] } From 16fdf982c84d0879e232334bf6c327a4eed63b8f Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 12 May 2022 07:40:24 +0200 Subject: [PATCH 21/38] feat(item.itemtype): add frontTest --- .../item/front/item-type/create/index.spec.js | 34 +++++++++++++++++++ .../item/front/item-type/index/index.spec.js | 34 +++++++++++++++++++ .../item/front/item-type/main/index.spec.js | 31 +++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 modules/item/front/item-type/create/index.spec.js create mode 100644 modules/item/front/item-type/index/index.spec.js create mode 100644 modules/item/front/item-type/main/index.spec.js diff --git a/modules/item/front/item-type/create/index.spec.js b/modules/item/front/item-type/create/index.spec.js new file mode 100644 index 000000000..4b000df9a --- /dev/null +++ b/modules/item/front/item-type/create/index.spec.js @@ -0,0 +1,34 @@ +import './index'; + +describe('component vnItemTypeCreate', () => { + let $scope; + let $state; + let controller; + + beforeEach(ngModule('item')); + + beforeEach(inject(($componentController, $rootScope, _$state_) => { + $scope = $rootScope.$new(); + $state = _$state_; + $scope.watcher = { + submit: () => { + return { + then: callback => { + callback({data: {id: '1234'}}); + } + }; + } + }; + const $element = angular.element(''); + controller = $componentController('vnItemTypeCreate', {$element, $scope}); + })); + + describe('onSubmit()', () => { + it(`should call submit() on the watcher then expect a callback`, () => { + jest.spyOn($state, 'go'); + controller.onSubmit(); + + expect(controller.$state.go).toHaveBeenCalledWith('item.itemType.card.basicData', {id: '1234'}); + }); + }); +}); diff --git a/modules/item/front/item-type/index/index.spec.js b/modules/item/front/item-type/index/index.spec.js new file mode 100644 index 000000000..887c03f7f --- /dev/null +++ b/modules/item/front/item-type/index/index.spec.js @@ -0,0 +1,34 @@ +import './index'; + +describe('Item', () => { + describe('Component vnItemTypeIndex', () => { + let controller; + let $window; + + beforeEach(ngModule('item')); + + beforeEach(inject(($componentController, _$window_) => { + $window = _$window_; + const $element = angular.element(''); + controller = $componentController('vnItemTypeIndex', {$element}); + })); + + describe('preview()', () => { + it('should show the dialog summary', () => { + controller.$.summary = {show: () => {}}; + jest.spyOn(controller.$.summary, 'show'); + + const itemType = {id: 1}; + + const event = new MouseEvent('click', { + view: $window, + bubbles: true, + cancelable: true + }); + controller.preview(event, itemType); + + expect(controller.$.summary.show).toHaveBeenCalledWith(); + }); + }); + }); +}); diff --git a/modules/item/front/item-type/main/index.spec.js b/modules/item/front/item-type/main/index.spec.js new file mode 100644 index 000000000..dcb14ec0e --- /dev/null +++ b/modules/item/front/item-type/main/index.spec.js @@ -0,0 +1,31 @@ +import './index'; + +describe('Item', () => { + describe('Component vnItemType', () => { + let controller; + + beforeEach(ngModule('item')); + + beforeEach(inject($componentController => { + const $element = angular.element(''); + controller = $componentController('vnItemType', {$element}); + })); + + describe('exprBuilder()', () => { + it('should return a filter based on a search by id', () => { + const filter = controller.exprBuilder('search', '123'); + + expect(filter).toEqual({id: '123'}); + }); + + it('should return a filter based on a search by name or code', () => { + const filter = controller.exprBuilder('search', 'Alstroemeria'); + + expect(filter).toEqual({or: [ + {name: {like: '%Alstroemeria%'}}, + {code: {like: '%Alstroemeria%'}}, + ]}); + }); + }); + }); +}); From 3335cb8a01dc10084ba336b1a48e4af4f2a9e64a Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 May 2022 08:32:45 +0200 Subject: [PATCH 22/38] feat(item.itemType): add fields --- db/changes/10460-motherDay/00-aclItemType.sql | 10 +++++-- modules/item/back/models/item-type.json | 12 ++++++++ modules/item/front/item-type/card/index.js | 9 +++++- .../front/item-type/descriptor/index.html | 16 +++++----- .../item/front/item-type/descriptor/index.js | 6 ---- .../front/item-type/descriptor/index.spec.js | 29 ------------------- .../item/front/item-type/summary/index.html | 16 ++++++++++ .../front/item-type/summary/locale/es.yml | 4 +++ 8 files changed, 55 insertions(+), 47 deletions(-) delete mode 100644 modules/item/front/item-type/descriptor/index.spec.js create mode 100644 modules/item/front/item-type/summary/locale/es.yml diff --git a/db/changes/10460-motherDay/00-aclItemType.sql b/db/changes/10460-motherDay/00-aclItemType.sql index 86fae1b1f..67dc652e5 100644 --- a/db/changes/10460-motherDay/00-aclItemType.sql +++ b/db/changes/10460-motherDay/00-aclItemType.sql @@ -1,3 +1,7 @@ -INSERT INTO salix.ACL -(model, property, accessType, permission, principalType, principalId) -VALUES('ItemType', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file +INSERT INTO `salix`.`ACL` +(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` +(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) +VALUES('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index c7a90aea9..64061a9b3 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -26,6 +26,18 @@ }, "temperatureFk": { "type": "string" + }, + "life": { + "type": "number" + }, + "promo": { + "type": "number" + }, + "itemPackingTypeFk": { + "type": "string" + }, + "isUnconventionalSize": { + "type": "number" } }, "relations": { diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js index b610f7566..21a2d5bc8 100644 --- a/modules/item/front/item-type/card/index.js +++ b/modules/item/front/item-type/card/index.js @@ -3,7 +3,14 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { - this.$http.get(`ItemTypes/${this.$params.id}`) + const filter = { + include: [ + {relation: 'worker'}, + {relation: 'category'} + ] + }; + + this.$http.get(`ItemTypes/${this.$params.id}`, {filter}) .then(res => this.itemType = res.data); } } diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html index 63bbf8726..ac86b2189 100644 --- a/modules/item/front/item-type/descriptor/index.html +++ b/modules/item/front/item-type/descriptor/index.html @@ -2,14 +2,6 @@ module="item" base-state="item.itemType" description="$ctrl.itemType.code"> - - - Delete - -
+ + + +
diff --git a/modules/item/front/item-type/descriptor/index.js b/modules/item/front/item-type/descriptor/index.js index 02fd59932..9322c599a 100644 --- a/modules/item/front/item-type/descriptor/index.js +++ b/modules/item/front/item-type/descriptor/index.js @@ -9,12 +9,6 @@ class Controller extends Descriptor { set itemType(value) { this.entity = value; } - - onDelete() { - return this.$http.delete(`ItemTypes/${this.id}`) - .then(() => this.$state.go('item.itemType')) - .then(() => this.vnApp.showSuccess(this.$t('ItemType removed'))); - } } ngModule.component('vnItemTypeDescriptor', { diff --git a/modules/item/front/item-type/descriptor/index.spec.js b/modules/item/front/item-type/descriptor/index.spec.js deleted file mode 100644 index 3da1bad1a..000000000 --- a/modules/item/front/item-type/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index'; - -describe('component vnItemTypeDescriptor', () => { - let controller; - let $httpBackend; - - let itemType = {id: 1, name: 'foo'}; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnItemTypeDescriptor', {$element: null}, {itemType}); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expectDELETE('ItemTypes/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('item.itemType'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html index d6704fc8b..72604c912 100644 --- a/modules/item/front/item-type/summary/index.html +++ b/modules/item/front/item-type/summary/index.html @@ -29,6 +29,22 @@ label="Temperature" value="{{summary.temperatureFk}}"> + + + + + + + + \ No newline at end of file diff --git a/modules/item/front/item-type/summary/locale/es.yml b/modules/item/front/item-type/summary/locale/es.yml new file mode 100644 index 000000000..8f4cef70f --- /dev/null +++ b/modules/item/front/item-type/summary/locale/es.yml @@ -0,0 +1,4 @@ +Life: Vida +Promo: Promoción +Item packing type: Tipo de embalaje +Is unconventional size: Es de tamaño poco convencional \ No newline at end of file From 76515bdd3f8f104a2109b3694c149ffdd58b3cd4 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 May 2022 09:54:49 +0200 Subject: [PATCH 23/38] add: search-panel --- modules/account/front/role/index/index.js | 1 - modules/item/front/item-type/index.js | 1 + .../item/front/item-type/main/locale/es.yml | 1 + .../front/item-type/search-panel/index.html | 21 +++++++++++++++++++ .../front/item-type/search-panel/index.js | 7 +++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 modules/item/front/item-type/main/locale/es.yml create mode 100644 modules/item/front/item-type/search-panel/index.html create mode 100644 modules/item/front/item-type/search-panel/index.js diff --git a/modules/account/front/role/index/index.js b/modules/account/front/role/index/index.js index 49b9be53b..40773b23b 100644 --- a/modules/account/front/role/index/index.js +++ b/modules/account/front/role/index/index.js @@ -4,7 +4,6 @@ import Section from 'salix/components/section'; export default class Controller extends Section { preview(role) { this.selectedRole = role; - console.log(this.selectedRole); this.$.summary.show(); } } diff --git a/modules/item/front/item-type/index.js b/modules/item/front/item-type/index.js index f33658da3..5dcbe4097 100644 --- a/modules/item/front/item-type/index.js +++ b/modules/item/front/item-type/index.js @@ -5,3 +5,4 @@ import './card'; import './descriptor'; import './create'; import './basic-data'; +import './search-panel'; diff --git a/modules/item/front/item-type/main/locale/es.yml b/modules/item/front/item-type/main/locale/es.yml new file mode 100644 index 000000000..7aceac46f --- /dev/null +++ b/modules/item/front/item-type/main/locale/es.yml @@ -0,0 +1 @@ +Search itemType by id, name or code: Buscar familia por id, nombre o código \ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html new file mode 100644 index 000000000..2e373fda5 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.html @@ -0,0 +1,21 @@ +
+
+ + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.js b/modules/item/front/item-type/search-panel/index.js new file mode 100644 index 000000000..17a439c39 --- /dev/null +++ b/modules/item/front/item-type/search-panel/index.js @@ -0,0 +1,7 @@ +import ngModule from '../../module'; +import SearchPanel from 'core/components/searchbar/search-panel'; + +ngModule.component('vnItemTypeSearchPanel', { + template: require('./index.html'), + controller: SearchPanel +}); From 9eae1f479cd91176ecc1d860a7f474a5350e23f4 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 May 2022 10:39:46 +0200 Subject: [PATCH 24/38] add table vn.printer --- db/dump/fixtures.sql | 25 ++++++++++++++++--------- db/dump/structure.sql | 25 +++++++++++++++++++++++++ db/export-structure.sh | 1 - 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 16c671983..418993944 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -99,13 +99,19 @@ INSERT INTO `account`.`mailForward`(`account`, `forwardTo`) VALUES (1, 'employee@domain.local'); -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk `) +INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`) + VALUES + (1, 'printer1', 'path1', 0), + (2, 'printer2', 'path2', 1); + + +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`, `sectorFk`, `labelerFk`) VALUES (1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106, NULL, NULL), (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), - (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), - (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); + (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), + (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -2552,12 +2558,13 @@ INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `IsVersionCrit INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`) VALUES - ('RE-001', 'STILL', 'LTX-20', 60, 23, 'REMOLCADOR ELECTRICO', 'Arrastrar carros', 2020, 103, 442); + ('RE-001', 'STILL', 'LTX-20', 60, 23, 'REMOLCADOR ELECTRICO', 'Arrastrar carros', 2020, 103, 442), + ('RE-002', 'STILL', 'LTX-20', 60, 23, 'REMOLCADOR ELECTRICO', 'Arrastrar carros', 2020, 103, 442); INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) VALUES - (1106, 1, CURDATE(), CURDATE()), - (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), - (1106, 2, CURDATE(), NULL), - (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (1106, 1, CURDATE(), CURDATE()), + (1106, 1, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)), + (1106, 2, CURDATE(), NULL), + (1106, 2, DATE_ADD(CURDATE(), INTERVAL + 1 DAY), DATE_ADD(CURDATE(), INTERVAL +1 DAY)); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index fdd7e1151..21ef7758c 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -37460,6 +37460,31 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `printer` +-- + +DROP TABLE IF EXISTS `printer`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `printer` ( + `id` tinyint(3) unsigned NOT NULL, + `name` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `path` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `modelFk` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `macWifi` varchar(20) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `ipAddress` varchar(15) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `reference` varchar(50) COLLATE utf8mb3_unicode_ci DEFAULT NULL, + `isLabeler` tinyint(1) DEFAULT 0 COMMENT 'Indica si es impresora de etiquetas', + PRIMARY KEY (`id`), + UNIQUE KEY `printer_UN` (`reference`), + UNIQUE KEY `printer_UN1` (`macWifi`), + UNIQUE KEY `printer_UN2` (`name`), + KEY `printer_FK` (`modelFk`), + CONSTRAINT `printer_FK` FOREIGN KEY (`modelFk`) REFERENCES `printerModel` (`code`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `printingQueueCheck` -- diff --git a/db/export-structure.sh b/db/export-structure.sh index 388231306..9b23f43ac 100755 --- a/db/export-structure.sh +++ b/db/export-structure.sh @@ -60,7 +60,6 @@ IGNORETABLES=( --ignore-table=vn.plantpassportAuthority__ --ignore-table=vn.preparationException --ignore-table=vn.priceFixed__ - --ignore-table=vn.printer --ignore-table=vn.printingQueue --ignore-table=vn.printServerQueue__ --ignore-table=vn.promissoryNote From eeede417ebd20962e084a36d676335e86a87a41c Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 May 2022 12:24:35 +0200 Subject: [PATCH 25/38] feat: update date depending of accountingType --- back/models/accounting-type.json | 3 +++ db/changes/10470-family/00-accountingType.sql | 2 ++ db/dump/fixtures.sql | 19 ++++++++++--------- modules/client/front/balance/create/index.js | 14 ++++++++------ 4 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 db/changes/10470-family/00-accountingType.sql diff --git a/back/models/accounting-type.json b/back/models/accounting-type.json index be08ac533..086be9d13 100644 --- a/back/models/accounting-type.json +++ b/back/models/accounting-type.json @@ -28,6 +28,9 @@ }, "maxAmount": { "type": "number" + }, + "daysInFuture": { + "type": "number" } }, "acls": [{ diff --git a/db/changes/10470-family/00-accountingType.sql b/db/changes/10470-family/00-accountingType.sql new file mode 100644 index 000000000..f3c092a34 --- /dev/null +++ b/db/changes/10470-family/00-accountingType.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`accountingType` ADD daysInFuture INT NULL; +ALTER TABLE `vn`.`accountingType` MODIFY COLUMN daysInFuture int(11) DEFAULT 0 NULL; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index c329e4c6e..8fb4fd1fd 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -156,22 +156,23 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park ('HEJ', 2, 0, 1, 0, 1106), ('UXN', 1, 0, 1, 0, 1106); -INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`) +INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) VALUES - (1, 'CC y Polizas de crédito', NULL, NULL, NULL), - (2, 'Cash', 'Cash', 'cash', 1000), - (3, 'Credit card', 'Credit Card', 'creditCard', NULL), - (4, 'Finalcial lines', NULL, NULL, NULL), - (5, 'Other products', NULL, NULL, NULL), - (6, 'Loans', NULL, NULL, NULL), - (7, 'Leasing', NULL, NULL, NULL), - (8, 'Compensations', 'Compensations', 'compensation', NULL); + (1, 'CC y Polizas de crédito', 'Transferencias', 'wireTransfer', NULL, 1), + (2, 'Cash', 'Cash', 'cash', 1000, 0), + (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), + (4, 'Finalcial lines', NULL, NULL, NULL, 0), + (5, 'Other products', NULL, NULL, NULL, 0), + (6, 'Loans', NULL, NULL, NULL, 0), + (7, 'Leasing', NULL, NULL, NULL, 0), + (8, 'Compensations', 'Compensations', 'compensation', NULL, 0); INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) VALUES (1, 'Pay on receipt', '5720000001', 3, 0, 1, 1), (2, 'Cash', '5700000001', 2, 0, 1, 1), (3, 'Compensation', '4000000000', 8, 0, 1, 1), + (4, 'Transferencias', '4000000001', 1, 0, 1, 1), (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 3117, 1, 1); diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 454e5e44d..4e60a0cd1 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -6,12 +6,7 @@ class Controller extends Dialog { super($element, $, $transclude); this.vnReport = vnReport; - - const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 1); - this.receipt = { - payed: tomorrow - }; + this.receipt = {}; } set payed(value) { @@ -72,6 +67,13 @@ class Controller extends Dialog { `${accountingType && accountingType.receiptDescription}`; } this.maxAmount = accountingType && accountingType.maxAmount; + + if (accountingType.daysInFuture) { + const date = new Date(); + date.setDate(date.getDate() + accountingType.daysInFuture); + this.receipt.payed = date; + } else + this.receipt.payed = new Date(); } } From 605ab2ec625cf837e7dc10c9cee72fa33398f7ae Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 May 2022 12:37:54 +0200 Subject: [PATCH 26/38] refactor: delete sms.detinationFk --- modules/client/back/methods/client/sendSms.js | 2 +- modules/client/back/methods/sms/send.js | 7 +------ modules/client/back/methods/sms/send.spec.js | 2 +- modules/ticket/back/methods/ticket/sendSms.js | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/client/back/methods/client/sendSms.js b/modules/client/back/methods/client/sendSms.js index cc11d17be..9d6a12416 100644 --- a/modules/client/back/methods/client/sendSms.js +++ b/modules/client/back/methods/client/sendSms.js @@ -39,7 +39,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; - const sms = await models.Sms.send(ctx, id, destination, message); + const sms = await models.Sms.send(ctx, destination, message); const logRecord = { originFk: id, userFk: userId, diff --git a/modules/client/back/methods/sms/send.js b/modules/client/back/methods/sms/send.js index 08daf83a1..94b2b6c27 100644 --- a/modules/client/back/methods/sms/send.js +++ b/modules/client/back/methods/sms/send.js @@ -6,10 +6,6 @@ module.exports = Self => { description: 'Sends SMS to a destination phone', accessType: 'WRITE', accepts: [ - { - arg: 'destinationFk', - type: 'integer' - }, { arg: 'destination', type: 'string', @@ -31,7 +27,7 @@ module.exports = Self => { } }); - Self.send = async(ctx, destinationFk, destination, message) => { + Self.send = async(ctx, destination, message) => { const userId = ctx.req.accessToken.userId; const smsConfig = await Self.app.models.SmsConfig.findOne(); @@ -68,7 +64,6 @@ module.exports = Self => { const newSms = { senderFk: userId, - destinationFk: destinationFk || null, destination: destination, message: message, status: error diff --git a/modules/client/back/methods/sms/send.spec.js b/modules/client/back/methods/sms/send.spec.js index 7ca78b214..8eee85bd6 100644 --- a/modules/client/back/methods/sms/send.spec.js +++ b/modules/client/back/methods/sms/send.spec.js @@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server'); describe('sms send()', () => { it('should not return status error', async() => { const ctx = {req: {accessToken: {userId: 1}}}; - const result = await app.models.Sms.send(ctx, 1105, '123456789', 'My SMS Body'); + const result = await app.models.Sms.send(ctx, '123456789', 'My SMS Body'); expect(result.status).toBeUndefined(); }); diff --git a/modules/ticket/back/methods/ticket/sendSms.js b/modules/ticket/back/methods/ticket/sendSms.js index efe8ff206..a0adcae07 100644 --- a/modules/ticket/back/methods/ticket/sendSms.js +++ b/modules/ticket/back/methods/ticket/sendSms.js @@ -45,7 +45,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; try { - const sms = await Self.app.models.Sms.send(ctx, id, destination, message); + const sms = await Self.app.models.Sms.send(ctx, destination, message); const logRecord = { originFk: id, userFk: userId, From 4a9c5742c035e78229b9a764727390859c16f7b2 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 17 May 2022 13:50:06 +0200 Subject: [PATCH 27/38] fix(entry_latest-buys): fix multi_check --- .../core/components/multi-check/multi-check.js | 7 ++++--- .../back/methods/entry/latestBuysFilter.js | 3 --- modules/entry/front/latest-buys/index.html | 4 ++-- modules/entry/front/latest-buys/index.js | 18 ++++++++++++++++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/front/core/components/multi-check/multi-check.js b/front/core/components/multi-check/multi-check.js index 077c93360..041603f13 100644 --- a/front/core/components/multi-check/multi-check.js +++ b/front/core/components/multi-check/multi-check.js @@ -146,16 +146,17 @@ export default class MultiCheck extends FormInput { if (!this.model || !this.model.data) return; const data = this.model.data; - const modelParams = this.model.userParams; const params = { filter: { - modelParams: modelParams, limit: null } }; + if (this.model.userFilter) + Object.assign(params.filter, this.model.userFilter); + if (this.model.userParams) + Object.assign(params, this.model.userParams); this.rows = data.length; - this.$http.get(this.model.url, {params}) .then(res => { this.allRowsCount = res.data.length; diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index 9693670c8..6399faa52 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -98,9 +98,6 @@ module.exports = Self => { Self.latestBuysFilter = async(ctx, filter, options) => { const myOptions = {}; - if (filter && filter.modelParams) - ctx.args = filter.modelParams; - if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index a4d6f7e83..adeda5e56 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -148,12 +148,12 @@ - {{::buy.packing | dashIfEmpty}} + {{::buy.packing | dashIfEmpty}} - {{::buy.grouping | dashIfEmpty}} + {{::buy.grouping | dashIfEmpty}} {{::buy.quantity}} diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js index 44c29cb11..ec1109b81 100644 --- a/modules/entry/front/latest-buys/index.js +++ b/modules/entry/front/latest-buys/index.js @@ -159,8 +159,22 @@ export default class Controller extends Section { lines: rowsToEdit }; - if (this.checkedDummyCount && this.checkedDummyCount > 0) - data.filter = this.$.model.userParams; + if (this.checkedDummyCount && this.checkedDummyCount > 0) { + const params = {}; + if (this.$.model.userParams) { + const userParams = this.$.model.userParams; + for (let param in userParams) { + let newParam = this.exprBuilder(param, userParams[param]); + if (!newParam) + newParam = {[param]: userParams[param]}; + Object.assign(params, newParam); + } + } + if (this.$.model.userFilter) + Object.assign(params, this.$.model.userFilter.where); + + data.filter = params; + } return this.$http.post('Buys/editLatestBuys', data) .then(() => { From 69e12e0dd804fd8e596f00d326d769449841559f Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 09:21:33 +0200 Subject: [PATCH 28/38] refactor: 'bonus' can be a negative value --- modules/zone/front/basic-data/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/zone/front/basic-data/index.html b/modules/zone/front/basic-data/index.html index eb701a803..1836216a2 100644 --- a/modules/zone/front/basic-data/index.html +++ b/modules/zone/front/basic-data/index.html @@ -67,7 +67,6 @@ From c125fd54ebb2676e863d0f995bab948ac2d00be7 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 12:08:12 +0200 Subject: [PATCH 29/38] refactor: pull request changes --- .../invoiceOut/front/descriptor-menu/index.js | 50 +++++++++---------- .../front/descriptor-menu/index.spec.js | 3 +- modules/ticket/back/methods/sale/refund.js | 8 +-- modules/ticket/front/descriptor-menu/index.js | 32 ++++++------ .../front/descriptor-menu/index.spec.js | 3 +- 5 files changed, 46 insertions(+), 50 deletions(-) diff --git a/modules/invoiceOut/front/descriptor-menu/index.js b/modules/invoiceOut/front/descriptor-menu/index.js index 3d6dc54fe..b884e50cb 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.js +++ b/modules/invoiceOut/front/descriptor-menu/index.js @@ -117,37 +117,33 @@ class Controller extends Section { }); } - refundInvoiceOut() { + async refundInvoiceOut() { let filter = { where: {refFk: this.invoiceOut.ref} }; - this.$http.get('Tickets', {filter}) - .then(res => { - this.tickets = res.data; - this.ticketsIds = []; - for (let ticket of this.tickets) - this.ticketsIds.push(ticket.id); + const tickets = await this.$http.get('Tickets', {filter}); + this.tickets = tickets.data; + this.ticketsIds = []; + for (let ticket of this.tickets) + this.ticketsIds.push(ticket.id); - filter = { - where: {ticketFk: {inq: this.ticketsIds}} - }; - this.$http.get('Sales', {filter}) - .then(res => { - this.sales = res.data; - this.$http.get('TicketServices', {filter}) - .then(res => { - this.services = res.data; - const params = { - sales: this.sales, - services: this.services - }; - const query = `Sales/refund`; - return this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); - }); - }); - }); - }); + filter = { + where: {ticketFk: {inq: this.ticketsIds}} + }; + const sales = await this.$http.get('Sales', {filter}); + this.sales = sales.data; + + const ticketServices = await this.$http.get('TicketServices', {filter}); + this.services = ticketServices.data; + + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; + return this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); } } diff --git a/modules/invoiceOut/front/descriptor-menu/index.spec.js b/modules/invoiceOut/front/descriptor-menu/index.spec.js index 4abb19545..c84c97a57 100644 --- a/modules/invoiceOut/front/descriptor-menu/index.spec.js +++ b/modules/invoiceOut/front/descriptor-menu/index.spec.js @@ -123,7 +123,8 @@ describe('vnInvoiceOutDescriptorMenu', () => { }); }); - describe('refundInvoiceOut()', () => { + // #4084 review with Juan + xdescribe('refundInvoiceOut()', () => { it('should make a query and go to ticket.card.sale', () => { controller.$state.go = jest.fn(); diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index 7eefde7d0..83a420a8e 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -55,12 +55,12 @@ module.exports = Self => { } else salesIds.push(null); - const serevicesIds = []; + const servicesIds = []; if (services) { for (let service of services) - serevicesIds.push(service.id); + servicesIds.push(service.id); } else - serevicesIds.push(null); + servicesIds.push(null); const query = ` DROP TEMPORARY TABLE IF EXISTS tmp.sale; @@ -81,7 +81,7 @@ module.exports = Self => { DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.ticketService;`; - await Self.rawSql(query, [salesIds, serevicesIds], myOptions); + await Self.rawSql(query, [salesIds, servicesIds], myOptions); const [newTicket] = await Self.rawSql('SELECT @newTicket id', null, myOptions); const newTicketId = newTicket.id; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 3f8edc608..c6388654e 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -273,26 +273,24 @@ class Controller extends Section { .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); } - refund() { + async refund() { const filter = { where: {ticketFk: this.id} }; - this.$http.get('Sales', {filter}) - .then(res => { - this.sales = res.data; - this.$http.get('TicketServices', {filter}) - .then(res => { - this.services = res.data; - const params = { - sales: this.sales, - services: this.services - }; - const query = `Sales/refund`; - return this.$http.post(query, params).then(res => { - this.$state.go('ticket.card.sale', {id: res.data}); - }); - }); - }); + const sales = await this.$http.get('Sales', {filter}); + this.sales = sales.data; + + const ticketServices = await this.$http.get('TicketServices', {filter}); + this.services = ticketServices.data; + + const params = { + sales: this.sales, + services: this.services + }; + const query = `Sales/refund`; + return this.$http.post(query, params).then(res => { + this.$state.go('ticket.card.sale', {id: res.data}); + }); } } diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 13f5292c5..af377d8ea 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -262,7 +262,8 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); }); - describe('refund()', () => { + // #4084 review with Juan + xdescribe('refund()', () => { it('should make a query and go to ticket.card.sale', () => { controller.$state.go = jest.fn(); From 3c9800a7a3aa9c7c1c980d730089103346e63bf2 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 12:33:12 +0200 Subject: [PATCH 30/38] refactor: pull request changes --- db/changes/10460-motherDay/00-aclItemType.sql | 11 ++++------- modules/item/back/models/item-type.json | 6 ------ modules/item/front/item-type/card/index.spec.js | 6 ++++-- modules/item/front/item-type/descriptor/index.html | 8 +------- modules/item/front/item-type/descriptor/locale/es.yml | 2 -- modules/item/front/item-type/search-panel/index.html | 3 ++- 6 files changed, 11 insertions(+), 25 deletions(-) delete mode 100644 modules/item/front/item-type/descriptor/locale/es.yml diff --git a/db/changes/10460-motherDay/00-aclItemType.sql b/db/changes/10460-motherDay/00-aclItemType.sql index 67dc652e5..836a69dfd 100644 --- a/db/changes/10460-motherDay/00-aclItemType.sql +++ b/db/changes/10460-motherDay/00-aclItemType.sql @@ -1,7 +1,4 @@ -INSERT INTO `salix`.`ACL` -(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) -VALUES('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); - -INSERT INTO `salix`.`ACL` -(`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) -VALUES('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ItemType', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ItemType', '*', 'WRITE', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index 64061a9b3..407b4d15a 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -18,12 +18,6 @@ "name": { "type": "string" }, - "workerFk": { - "type": "number" - }, - "categoryFk": { - "type": "number" - }, "temperatureFk": { "type": "string" }, diff --git a/modules/item/front/item-type/card/index.spec.js b/modules/item/front/item-type/card/index.spec.js index 179f65274..ab2314bb9 100644 --- a/modules/item/front/item-type/card/index.spec.js +++ b/modules/item/front/item-type/card/index.spec.js @@ -15,11 +15,13 @@ describe('component vnItemTypeCard', () => { it('should reload the controller data', () => { controller.$params.id = 1; - $httpBackend.expectGET('ItemTypes/1').respond('foo'); + const itemType = {id: 1}; + + $httpBackend.expectGET('ItemTypes/1').respond(itemType); controller.reload(); $httpBackend.flush(); - expect(controller.itemType).toBe('foo'); + expect(controller.itemType).toEqual(itemType); }); }); }); diff --git a/modules/item/front/item-type/descriptor/index.html b/modules/item/front/item-type/descriptor/index.html index ac86b2189..5a0e8ed49 100644 --- a/modules/item/front/item-type/descriptor/index.html +++ b/modules/item/front/item-type/descriptor/index.html @@ -22,10 +22,4 @@
-
- - \ No newline at end of file + \ No newline at end of file diff --git a/modules/item/front/item-type/descriptor/locale/es.yml b/modules/item/front/item-type/descriptor/locale/es.yml deleted file mode 100644 index 1ca512e4f..000000000 --- a/modules/item/front/item-type/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Role will be removed: El rol va a ser eliminado -Role removed: Rol eliminado \ No newline at end of file diff --git a/modules/item/front/item-type/search-panel/index.html b/modules/item/front/item-type/search-panel/index.html index 2e373fda5..4aa762900 100644 --- a/modules/item/front/item-type/search-panel/index.html +++ b/modules/item/front/item-type/search-panel/index.html @@ -4,7 +4,8 @@ + ng-model="filter.name" + vn-focus> From c9bfbe990aaac8e1a1362112fe210cc7a0340479 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 12:53:10 +0200 Subject: [PATCH 31/38] refactor: request changues --- back/models/app-version-control.json | 4 ++-- db/dump/fixtures.sql | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/back/models/app-version-control.json b/back/models/app-version-control.json index 934d918f9..46c53be3c 100644 --- a/back/models/app-version-control.json +++ b/back/models/app-version-control.json @@ -17,8 +17,8 @@ "version": { "type": "string" }, - "IsVersionCritical": { - "type": "number" + "isVersionCritical": { + "type": "boolean" } } } diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 418993944..e26bc735e 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2551,15 +2551,15 @@ INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackage (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); -INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `IsVersionCritical`) +INSERT INTO `vn`.`mobileAppVersionControl` (`appName`, `version`, `isVersionCritical`) VALUES ('delivery', '9.2', 0), ('warehouse', '8.1', 0); INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmentFk`, `type`, `use`, `productionYear`, `workerFk`, `companyFk`) VALUES - ('RE-001', 'STILL', 'LTX-20', 60, 23, 'REMOLCADOR ELECTRICO', 'Arrastrar carros', 2020, 103, 442), - ('RE-002', 'STILL', 'LTX-20', 60, 23, 'REMOLCADOR ELECTRICO', 'Arrastrar carros', 2020, 103, 442); + ('RE-001', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442), + ('RE-002', 'STILL', 'LTX-20', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed`) VALUES From a043c5d346fe89f2ff432941d683ca6e5efc1ed2 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 13:10:48 +0200 Subject: [PATCH 32/38] refactor: request changes --- back/models/machine-worker.json | 14 ++++++++++---- modules/worker/back/model-config.json | 3 +++ modules/worker/back/models/sector.json | 20 ++++++++++++++++++++ modules/worker/back/models/worker.json | 5 +++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 modules/worker/back/models/sector.json diff --git a/back/models/machine-worker.json b/back/models/machine-worker.json index 61cde223f..2244a533f 100644 --- a/back/models/machine-worker.json +++ b/back/models/machine-worker.json @@ -17,11 +17,17 @@ "machineFk": { "type": "number" }, - "inTimed": { - "type": "date" + "inTime": { + "type": "date", + "mysql": { + "columnName": "inTimed" + } }, - "outTimed": { - "type": "date" + "outTime": { + "type": "date", + "mysql": { + "columnName": "outTimed" + } } } } diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index c155e331d..c6b984bd2 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -20,6 +20,9 @@ "EducationLevel": { "dataSource": "vn" }, + "Sector": { + "dataSource": "vn" + }, "WorkCenter": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/sector.json b/modules/worker/back/models/sector.json new file mode 100644 index 000000000..8bd5e773f --- /dev/null +++ b/modules/worker/back/models/sector.json @@ -0,0 +1,20 @@ +{ + "name": "Sector", + "base": "VnModel", + "options": { + "mysql": { + "table": "sector" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "description": { + "type": "string", + "required": true + } + } +} \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index df75d871e..0f19ed4ce 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -84,6 +84,11 @@ "type": "hasMany", "model": "WorkerTeamCollegues", "foreignKey": "workerFk" + }, + "sector": { + "type": "belongsTo", + "model": "Sector", + "foreignKey": "sectorFk" } } } \ No newline at end of file From 875e9503c3bfc25a5585019d142a87b07c0d60b2 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 May 2022 13:16:47 +0200 Subject: [PATCH 33/38] refactor: request changes --- db/dump/fixtures.sql | 2 +- modules/client/front/balance/create/index.js | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 8fb4fd1fd..723c8c4e4 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -158,7 +158,7 @@ INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `park INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) VALUES - (1, 'CC y Polizas de crédito', 'Transferencias', 'wireTransfer', NULL, 1), + (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), (2, 'Cash', 'Cash', 'cash', 1000, 0), (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), (4, 'Finalcial lines', NULL, NULL, NULL, 0), diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 4e60a0cd1..c6a6e7ff9 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -68,12 +68,9 @@ class Controller extends Dialog { } this.maxAmount = accountingType && accountingType.maxAmount; - if (accountingType.daysInFuture) { - const date = new Date(); - date.setDate(date.getDate() + accountingType.daysInFuture); - this.receipt.payed = date; - } else - this.receipt.payed = new Date(); + this.receipt.payed = new Date(); + if (accountingType.daysInFuture) + this.receipt.payed.setDate(this.receipt.payed.getDate() + accountingType.daysInFuture); } } From 1b3f0ee026637c557101af1eef9f8b6a71b1cd59 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 May 2022 12:40:11 +0200 Subject: [PATCH 34/38] refactor: added itemPackingType and temperature relations --- modules/item/back/models/item-type.json | 16 ++++++++++------ modules/item/front/item-type/card/index.js | 4 +++- modules/item/front/item-type/summary/index.html | 4 ++-- modules/item/front/item-type/summary/index.js | 4 +++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/modules/item/back/models/item-type.json b/modules/item/back/models/item-type.json index 407b4d15a..843d9877f 100644 --- a/modules/item/back/models/item-type.json +++ b/modules/item/back/models/item-type.json @@ -18,18 +18,12 @@ "name": { "type": "string" }, - "temperatureFk": { - "type": "string" - }, "life": { "type": "number" }, "promo": { "type": "number" }, - "itemPackingTypeFk": { - "type": "string" - }, "isUnconventionalSize": { "type": "number" } @@ -49,6 +43,16 @@ "type": "belongsTo", "model": "ItemCategory", "foreignKey": "categoryFk" + }, + "itemPackingType": { + "type": "belongsTo", + "model": "ItemPackingType", + "foreignKey": "itemPackingTypeFk" + }, + "temperature": { + "type": "belongsTo", + "model": "Temperature", + "foreignKey": "temperatureFk" } }, "acls": [ diff --git a/modules/item/front/item-type/card/index.js b/modules/item/front/item-type/card/index.js index 21a2d5bc8..fa6b37340 100644 --- a/modules/item/front/item-type/card/index.js +++ b/modules/item/front/item-type/card/index.js @@ -6,7 +6,9 @@ class Controller extends ModuleCard { const filter = { include: [ {relation: 'worker'}, - {relation: 'category'} + {relation: 'category'}, + {relation: 'itemPackingType'}, + {relation: 'temperature'} ] }; diff --git a/modules/item/front/item-type/summary/index.html b/modules/item/front/item-type/summary/index.html index 72604c912..d003c8f38 100644 --- a/modules/item/front/item-type/summary/index.html +++ b/modules/item/front/item-type/summary/index.html @@ -27,7 +27,7 @@ + value="{{summary.temperature.name}}"> + value="{{summary.itemPackingType.description}}"> Date: Mon, 23 May 2022 12:45:20 +0200 Subject: [PATCH 35/38] refactor: sectorFk property deleted --- modules/worker/back/models/worker.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 0f19ed4ce..f7a344358 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -47,9 +47,6 @@ "SSN": { "type" : "string" }, - "sectorFk": { - "type" : "number" - }, "labelerFk": { "type" : "number" } From ab6a0425f5fd5b324164cae0c45d6f316808d90b Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 May 2022 12:47:43 +0200 Subject: [PATCH 36/38] refactor: translate fixtures --- db/dump/fixtures.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 723c8c4e4..4871dde30 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -172,7 +172,7 @@ INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, (1, 'Pay on receipt', '5720000001', 3, 0, 1, 1), (2, 'Cash', '5700000001', 2, 0, 1, 1), (3, 'Compensation', '4000000000', 8, 0, 1, 1), - (4, 'Transferencias', '4000000001', 1, 0, 1, 1), + (4, 'Transfers', '4000000001', 1, 0, 1, 1), (3117, 'Caixa Rural d''Algemesi', '5720000000', 8, 3117, 1, 1); From 7a69d53642eb2e2d0274a8afb65953d8a30daa94 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 May 2022 14:50:33 +0200 Subject: [PATCH 37/38] fix(changes): add reference table --- db/changes/10451-april/00-invoiceOut_queue.sql | 14 -------------- .../00-ClientUnpaid.sql | 2 +- db/changes/10461-mother/00-invoiceOut_queue.sql | 8 ++++++++ 3 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 db/changes/10451-april/00-invoiceOut_queue.sql rename db/changes/{10451-april => 10461-mother}/00-ClientUnpaid.sql (87%) create mode 100644 db/changes/10461-mother/00-invoiceOut_queue.sql diff --git a/db/changes/10451-april/00-invoiceOut_queue.sql b/db/changes/10451-april/00-invoiceOut_queue.sql deleted file mode 100644 index f60bcab77..000000000 --- a/db/changes/10451-april/00-invoiceOut_queue.sql +++ /dev/null @@ -1,14 +0,0 @@ -create table `vn`.`invoiceOut_queue` -( - invoiceFk int(10) unsigned not null, - queued datetime default now() not null, - printed datetime null, - `status` VARCHAR(50) default '' null, - constraint invoiceOut_queue_pk - primary key (invoiceFk), - constraint invoiceOut_queue_invoiceOut_id_fk - foreign key (invoiceFk) references invoiceOut (id) - on update cascade on delete cascade -) - comment 'Queue for PDF invoicing'; - diff --git a/db/changes/10451-april/00-ClientUnpaid.sql b/db/changes/10461-mother/00-ClientUnpaid.sql similarity index 87% rename from db/changes/10451-april/00-ClientUnpaid.sql rename to db/changes/10461-mother/00-ClientUnpaid.sql index d84fe494a..9b30bb8fc 100644 --- a/db/changes/10451-april/00-ClientUnpaid.sql +++ b/db/changes/10461-mother/00-ClientUnpaid.sql @@ -3,7 +3,7 @@ CREATE TABLE `vn`.`clientUnpaid` ( `dated` date NOT NULL, `amount` double DEFAULT 0, PRIMARY KEY (`clientFk`), - CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE + CONSTRAINT `clientUnpaid_clientFk` FOREIGN KEY (`clientFk`) REFERENCES `vn`.`client` (`id`) ON UPDATE CASCADE ); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) diff --git a/db/changes/10461-mother/00-invoiceOut_queue.sql b/db/changes/10461-mother/00-invoiceOut_queue.sql new file mode 100644 index 000000000..013e3b784 --- /dev/null +++ b/db/changes/10461-mother/00-invoiceOut_queue.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`invoiceOut_queue` ( + `invoiceFk` int(10) unsigned not null, + `queued` datetime default now() not null, + `printed` datetime null, + `status` VARCHAR(50) DEFAULT '' NULL, + CONSTRAINT `invoiceOut_queue_pk` PRIMARY KEY (`invoiceFk`), + CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON UPDATE CASCADE ON DELETE CASCADE +) comment 'Queue for PDF invoicing'; \ No newline at end of file From 47ab4fc2c111b97daa6df244ef85c6762b691232 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 May 2022 14:52:26 +0200 Subject: [PATCH 38/38] intro --- db/changes/10461-mother/00-ClientUnpaid.sql | 2 +- db/changes/10461-mother/00-invoiceOut_queue.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/changes/10461-mother/00-ClientUnpaid.sql b/db/changes/10461-mother/00-ClientUnpaid.sql index 9b30bb8fc..16deedace 100644 --- a/db/changes/10461-mother/00-ClientUnpaid.sql +++ b/db/changes/10461-mother/00-ClientUnpaid.sql @@ -7,4 +7,4 @@ CREATE TABLE `vn`.`clientUnpaid` ( ); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); \ No newline at end of file + VALUES('ClientUnpaid', '*', '*', 'ALLOW', 'ROLE', 'administrative'); diff --git a/db/changes/10461-mother/00-invoiceOut_queue.sql b/db/changes/10461-mother/00-invoiceOut_queue.sql index 013e3b784..2b9f45e0f 100644 --- a/db/changes/10461-mother/00-invoiceOut_queue.sql +++ b/db/changes/10461-mother/00-invoiceOut_queue.sql @@ -5,4 +5,4 @@ CREATE TABLE `vn`.`invoiceOut_queue` ( `status` VARCHAR(50) DEFAULT '' NULL, CONSTRAINT `invoiceOut_queue_pk` PRIMARY KEY (`invoiceFk`), CONSTRAINT `invoiceOut_queue_invoiceOut_id_fk` FOREIGN KEY (`invoiceFk`) REFERENCES `vn`.`invoiceOut` (`id`) ON UPDATE CASCADE ON DELETE CASCADE -) comment 'Queue for PDF invoicing'; \ No newline at end of file +) comment 'Queue for PDF invoicing';