From 624f4707aca2ac1e13f2e5d97c8d1be816c2979e Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 26 Jun 2024 10:43:02 +0200 Subject: [PATCH 001/145] feat: refs #7197 filter by correcting --- .../invoiceIn/back/methods/invoice-in/filter.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 0d3b5f14a..91d358016 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -82,7 +82,11 @@ module.exports = Self => { { arg: 'correctedFk', type: 'number', - description: 'The corrected invoice', + description: 'The rectified invoice', + }, + { + arg: 'correctingFk', + type: 'Boolean', } ], returns: { @@ -111,6 +115,7 @@ module.exports = Self => { } let correctings; + let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ fields: ['correctingFk'], @@ -118,6 +123,9 @@ module.exports = Self => { }); } + if (args.correctingFk || args.correctingFk === false) + correcteds = await models.InvoiceInCorrection.find(); + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -141,6 +149,10 @@ module.exports = Self => { return {[`ii.${param}`]: value}; case 'awbCode': return {'sub.code': value}; + case 'correctingFk': + return args.correctingFk + ? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}} + : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; } From 4bef3e9107375adbe80e844f71b9c5de8526b889 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 3 Jul 2024 17:09:10 +0200 Subject: [PATCH 002/145] refs #7531 Modify zone_getAddresses --- .../vn/procedures/zone_getAddresses.sql | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index ce7b0204e..c3a21aa83 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,7 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vLanded DATE + vDated DATE, + vDepartment INT ) BEGIN /** @@ -12,6 +13,7 @@ BEGIN * * @param vSelf Id de zona * @param vDated Fecha de entrega + * @param vDepartment Departamento del trabajador * @return Un select */ CALL zone_getPostalCode(vSelf); @@ -22,34 +24,47 @@ BEGIN WHERE id NOT IN ( SELECT clientFk FROM vn.ticket - WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) + WHERE landed BETWEEN vDated AND util.dayEnd(vDated) ) + ), + hasTicketShippedToday AS ( + SELECT clientFk, + IF (COUNT(*) > 0, TRUE, FALSE) hasTicketShipped + FROM vn.ticket + WHERE shipped BETWEEN vDated AND util.dayEnd(vDated) + GROUP BY clientFk ) SELECT c.id clientFk, - c.name, - c.phone, - bt.description, - c.salesPersonFk, - u.name username, - aai.invoiced, - cnb.lastShipped - FROM vn.client c - JOIN notHasTicket ON notHasTicket.id = c.id - LEFT JOIN account.`user` u ON u.id = c.salesPersonFk - JOIN vn.`address` a ON a.clientFk = c.id - JOIN vn.postCode pc ON pc.code = a.postalCode - JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk - JOIN vn.zoneGeo zg ON zg.name = a.postalCode - JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk - LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id - LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id - JOIN vn.clientType ct ON ct.code = c.typeFk - JOIN vn.businessType bt ON bt.code = c.businessTypeFk - WHERE a.isActive - AND c.isActive - AND ct.code = 'normal' - AND bt.code <> 'worker' - GROUP BY c.id; + c.name, + c.phone, + bt.description, + c.salesPersonFk, + u.name username, + aai.invoiced, + cnb.lastShipped, + ht.hasTicketShipped + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN vn.workerDepartment wd ON wd.workerFk = w.id + JOIN vn.department d ON d.id = wd.departmentFk + JOIN notHasTicket ON notHasTicket.id = c.id + LEFT JOIN account.`user` u ON u.id = c.salesPersonFk + JOIN vn.`address` a ON a.clientFk = c.id + JOIN vn.postCode pc ON pc.code = a.postalCode + JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk + JOIN vn.zoneGeo zg ON zg.name = a.postalCode + JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk + LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id + LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id + JOIN vn.clientType ct ON ct.code = c.typeFk + JOIN vn.businessType bt ON bt.code = c.businessTypeFk + LEFT JOIN hasTicketShippedToday ht ON ht.clientFk = c.id + WHERE a.isActive + AND c.isActive + AND ct.code = 'normal' + AND bt.code <> 'worker' + AND d.id = vDepartment + GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; END$$ From dce62245e9ffbe7cb639776b0785c8f0a262a0bb Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 4 Jul 2024 13:10:32 +0200 Subject: [PATCH 003/145] chore: refs #7197 add supplierActivityFk filter --- modules/invoiceIn/back/methods/invoice-in/filter.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 91d358016..d72d7fc63 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -87,6 +87,10 @@ module.exports = Self => { { arg: 'correctingFk', type: 'Boolean', + }, + { + arg: 'supplierActivityFk', + type: 'string', } ], returns: { @@ -155,6 +159,8 @@ module.exports = Self => { : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; + case 'supplierActivityFk': + return {'s.supplierActivityFk': value}; } }); From 460723bd7aaf4c6503c90126b01187adefeb6f5d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 10:08:04 +0200 Subject: [PATCH 004/145] refactor: refs #6453 order_confirmWithUser --- .../procedures/order_confirmWithUser.sql | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 9c932aaa1..d85eb7f71 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -28,11 +28,8 @@ BEGIN DECLARE vClientId INT; DECLARE vCompanyId INT; DECLARE vAgencyModeId INT; - DECLARE TICKET_FREE INT DEFAULT 2; DECLARE vCalc INT; DECLARE vIsLogifloraItem BOOL; - DECLARE vOldQuantity INT; - DECLARE vNewQuantity INT; DECLARE vIsTaxDataChecked BOOL; DECLARE cDates CURSOR FOR @@ -40,14 +37,15 @@ BEGIN FROM `order` o JOIN order_row r ON r.order_id = o.id LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id - WHERE o.id = vSelf AND r.amount != 0 + WHERE o.id = vSelf + AND r.amount GROUP BY r.warehouse_id; DECLARE cRows CURSOR FOR SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo FROM order_row r JOIN vn.item i ON i.id = r.item_id - WHERE r.amount != 0 + WHERE r.amount AND r.warehouse_id = vWarehouse AND r.order_id = vSelf ORDER BY r.rate DESC; @@ -62,10 +60,20 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, a.clientFk, - o.company_id, o.agency_id, c.isTaxDataChecked - INTO vDelivery, vAddress, vNotes, vClientId, - vCompanyId, vAgencyModeId, vIsTaxDataChecked + SELECT o.date_send, + o.address_id, + o.note, + a.clientFk, + o.company_id, + o.agency_id, + c.isTaxDataChecked + INTO vDelivery, + vAddress, + vNotes, + vClientId, + vCompanyId, + vAgencyModeId, + vIsTaxDataChecked FROM hedera.`order` o JOIN vn.address a ON a.id = o.address_id JOIN vn.client c ON c.id = a.clientFk @@ -73,11 +81,11 @@ BEGIN -- Verifica si el cliente tiene los datos comprobados IF NOT vIsTaxDataChecked THEN - CALL util.throw ('clientNotVerified'); + CALL util.throw('clientNotVerified'); END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); + CALL vn.zone_getShipped(vDelivery, vAddress, vAgencyModeId, FALSE); -- Trabajador que realiza la accion IF vUserId IS NULL THEN @@ -94,7 +102,7 @@ BEGIN FROM order_row WHERE order_id = vSelf AND amount > 0; IF NOT vOk THEN - CALL util.throw ('ORDER_EMPTY'); + CALL util.throw('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido @@ -112,23 +120,22 @@ BEGIN END IF; -- Busca un ticket existente que coincida con los parametros - WITH tPrevia AS - (SELECT DISTINCT s.ticketFk + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) + ) SELECT t.id INTO vTicket FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o - ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND vWarehouse = t.warehouseFk + AND o.date_send = t.landed + AND DATE(t.shipped) = vShipment WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL @@ -136,11 +143,8 @@ BEGIN LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado - IF vTicket IS NULL - THEN - + IF vTicket IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( vClientId, vShipment, @@ -158,7 +162,7 @@ BEGIN INSERT INTO vn.ticketTracking SET ticketFk = vTicket, userFk = vUserId, - stateFk = TICKET_FREE; + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); END IF; INSERT IGNORE INTO vn.orderTicket @@ -166,21 +170,17 @@ BEGIN ticketFk = vTicket; -- Añade las notas - - IF vNotes IS NOT NULL AND vNotes != '' - THEN + IF vNotes IS NOT NULL AND vNotes <> '' THEN INSERT INTO vn.ticketObservation SET ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */ , + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; -- Añade los movimientos y sus componentes - OPEN cRows; - lRows: LOOP SET vDone = FALSE; FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; @@ -191,7 +191,7 @@ BEGIN SET vSale = NULL; - SELECT s.id, s.quantity INTO vSale, vOldQuantity + SELECT s.id INTO vSale FROM vn.sale s WHERE ticketFk = vTicket AND price = vPrice @@ -204,10 +204,6 @@ BEGIN SET quantity = quantity + vAmount, originalQuantity = quantity WHERE id = vSale; - - SELECT s.quantity INTO vNewQuantity - FROM vn.sale s - WHERE id = vSale; ELSE -- Obtiene el coste SELECT SUM(rc.`price`) valueSum INTO vPriceFixed @@ -236,7 +232,8 @@ BEGIN GROUP BY vSale, rc.componentFk; END IF; - UPDATE order_row SET Id_Movimiento = vSale + UPDATE order_row + SET Id_Movimiento = vSale WHERE id = vRowId; -- Inserta en putOrder si la compra es de Floramondo @@ -245,13 +242,13 @@ BEGIN SET @available := 0; - SELECT GREATEST(0,available) INTO @available + SELECT GREATEST(0, available) INTO @available FROM cache.availableNoRaids WHERE calc_id = vCalc AND item_id = vItem; UPDATE cache.availableNoRaids - SET available = GREATEST(0,available - vAmount) + SET available = GREATEST(0, available - vAmount) WHERE item_id = vItem AND calc_id = vCalc; @@ -283,13 +280,13 @@ BEGIN LIMIT 1; END IF; END LOOP; - CLOSE cRows; END LOOP; - CLOSE cDates; - UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() + UPDATE `order` + SET confirmed = TRUE, + confirm_date = util.VN_NOW() WHERE id = vSelf; COMMIT; From b06832735260c32f1388512e15c00a02a7050fe5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 10:49:39 +0200 Subject: [PATCH 005/145] refactor: refs #6453 order_confirmWithUser --- db/routines/hedera/procedures/order_confirmWithUser.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index d85eb7f71..3801e935b 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -97,18 +97,17 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vSelf AND amount > 0; + FROM order_row + WHERE order_id = vSelf + AND amount > 0; IF NOT vOk THEN CALL util.throw('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido - OPEN cDates; - lDates: LOOP SET vTicket = NULL; From b75bdc07c29f78b248357f3c445277bdfd0009d0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 08:10:34 +0200 Subject: [PATCH 006/145] refactor: refs #6453 order_confirmWithUser --- .../procedures/order_confirmWithUser.sql | 142 +++++++++--------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 3801e935b..76ff4e723 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -1,36 +1,40 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(vSelf INT, vUserId INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`( + vSelf INT, + vUserFk INT +) BEGIN /** - * Confirms an order, creating each of its tickets on the corresponding - * date, store and user. + * Confirms an order, creating each of its tickets on + * the corresponding date, store and user. * * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vOk BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWarehouse INT; + DECLARE vIsOk BOOL; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vTicket INT; + DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItem INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); - DECLARE vSale INT; + DECLARE vSaleFk INT; DECLARE vRate INT; - DECLARE vRowId INT; + DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); DECLARE vDelivery DATE; - DECLARE vAddress INT; + DECLARE vAddressFk INT; DECLARE vIsConfirmed BOOL; - DECLARE vClientId INT; - DECLARE vCompanyId INT; - DECLARE vAgencyModeId INT; - DECLARE vCalc INT; + DECLARE vClientFk INT; + DECLARE vCompanyFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vCalcFk INT; DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; + DECLARE vAvailable INT; DECLARE cDates CURSOR FOR SELECT zgs.shipped, r.warehouse_id @@ -46,12 +50,11 @@ BEGIN FROM order_row r JOIN vn.item i ON i.id = r.item_id WHERE r.amount - AND r.warehouse_id = vWarehouse + AND r.warehouse_id = vWarehouseFk AND r.order_id = vSelf ORDER BY r.rate DESC; - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -68,13 +71,13 @@ BEGIN o.agency_id, c.isTaxDataChecked INTO vDelivery, - vAddress, + vAddressFk, vNotes, - vClientId, - vCompanyId, - vAgencyModeId, + vClientFk, + vCompanyFk, + vAgencyModeFk, vIsTaxDataChecked - FROM hedera.`order` o + FROM `order` o JOIN vn.address a ON a.id = o.address_id JOIN vn.client c ON c.id = a.clientFk WHERE o.id = vSelf; @@ -85,11 +88,11 @@ BEGIN END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped(vDelivery, vAddress, vAgencyModeId, FALSE); + CALL vn.zone_getShipped(vDelivery, vAddressFk, vAgencyModeFk, FALSE); -- Trabajador que realiza la accion - IF vUserId IS NULL THEN - SELECT employeeFk INTO vUserId FROM orderConfig; + IF vUserFk IS NULL THEN + SELECT employeeFk INTO vUserFk FROM orderConfig; END IF; START TRANSACTION; @@ -97,12 +100,12 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vOk + SELECT COUNT(*) > 0 INTO vIsOk FROM order_row WHERE order_id = vSelf AND amount > 0; - IF NOT vOk THEN + IF NOT vIsOk THEN CALL util.throw('ORDER_EMPTY'); END IF; @@ -110,9 +113,9 @@ BEGIN OPEN cDates; lDates: LOOP - SET vTicket = NULL; + SET vTicketFk = NULL; SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouse; + FETCH cDates INTO vShipment, vWarehouseFk; IF vDone THEN LEAVE lDates; @@ -126,13 +129,13 @@ BEGIN JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) ) - SELECT t.id INTO vTicket + SELECT t.id INTO vTicketFk FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id JOIN hedera.`order` o ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk + AND vWarehouseFk = t.warehouseFk AND o.date_send = t.landed AND DATE(t.shipped) = vShipment WHERE o.id = vSelf @@ -142,36 +145,36 @@ BEGIN LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado - IF vTicket IS NULL THEN + IF vTicketFk IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); CALL vn.ticket_add( - vClientId, + vClientFk, vShipment, - vWarehouse, - vCompanyId, - vAddress, - vAgencyModeId, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, NULL, vDelivery, - vUserId, + vUserFk, TRUE, - vTicket + vTicketFk ); ELSE INSERT INTO vn.ticketTracking - SET ticketFk = vTicket, - userFk = vUserId, + SET ticketFk = vTicketFk, + userFk = vUserFk, stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); END IF; INSERT IGNORE INTO vn.orderTicket SET orderFk = vSelf, - ticketFk = vTicket; + ticketFk = vTicketFk; -- Añade las notas IF vNotes IS NOT NULL AND vNotes <> '' THEN INSERT INTO vn.ticketObservation SET - ticketFk = vTicket, + ticketFk = vTicketFk, observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE @@ -182,74 +185,71 @@ BEGIN OPEN cRows; lRows: LOOP SET vDone = FALSE; - FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH cRows INTO vRowFk, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; IF vDone THEN LEAVE lRows; END IF; - SET vSale = NULL; + SET vSaleFk = NULL; - SELECT s.id INTO vSale + SELECT s.id INTO vSaleFk FROM vn.sale s - WHERE ticketFk = vTicket + WHERE ticketFk = vTicketFk AND price = vPrice AND itemFk = vItem AND discount = 0 LIMIT 1; - IF vSale THEN + IF vSaleFk THEN UPDATE vn.sale SET quantity = quantity + vAmount, originalQuantity = quantity - WHERE id = vSale; + WHERE id = vSaleFk; ELSE -- Obtiene el coste SELECT SUM(rc.`price`) valueSum INTO vPriceFixed FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase - WHERE rc.rowFk = vRowId; + WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale SET itemFk = vItem, - ticketFk = vTicket, + ticketFk = vTicketFk, concept = vConcept, quantity = vAmount, price = vPrice, priceFixed = vPriceFixed, isPriceFixed = TRUE; - SET vSale = LAST_INSERT_ID(); + SET vSaleFk = LAST_INSERT_ID(); - INSERT INTO vn.saleComponent - (saleFk, componentFk, `value`) - SELECT vSale, rc.componentFk, rc.price + INSERT INTO vn.saleComponent (saleFk, componentFk, `value`) + SELECT vSaleFk, rc.componentFk, rc.price FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - WHERE rc.rowFk = vRowId - GROUP BY vSale, rc.componentFk; + WHERE rc.rowFk = vRowFk + GROUP BY vSaleFk, rc.componentFk; END IF; UPDATE order_row - SET Id_Movimiento = vSale - WHERE id = vRowId; + SET Id_Movimiento = vSaleFk + WHERE id = vRowFk; -- Inserta en putOrder si la compra es de Floramondo IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment); + CALL cache.availableNoRaids_refresh(vCalcFk, FALSE,vWarehouseFk, vShipment); - SET @available := 0; - - SELECT GREATEST(0, available) INTO @available + SELECT GREATEST(0, available) INTO vAvailable FROM cache.availableNoRaids - WHERE calc_id = vCalc + WHERE calc_id = vCalcFk AND item_id = vItem; UPDATE cache.availableNoRaids SET available = GREATEST(0, available - vAmount) WHERE item_id = vItem - AND calc_id = vCalc; + AND calc_id = vCalcFk; INSERT INTO edi.putOrder ( deliveryInformationID, @@ -262,20 +262,20 @@ BEGIN ) SELECT di.ID, i.supplyResponseFk, - CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask), + CEIL((vAmount - vAvailable)/ sr.NumberOfItemsPerCask), o.address_id , - vClientId, + vClientFk, IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSale + vSaleFk FROM edi.deliveryInformation di JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId + LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk JOIN edi.floraHollandConfig fhc - JOIN hedera.`order` o ON o.id = vSelf + JOIN `order` o ON o.id = vSelf WHERE i.id = vItem AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > @available + AND vAmount > vAvailable LIMIT 1; END IF; END LOOP; From a8d03450732bd24292696ca17ba73c5efe703586 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 08:18:33 +0200 Subject: [PATCH 007/145] refactor: refs #6453 order_confirmWithUser --- .../procedures/order_confirmWithUser.sql | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 76ff4e723..61a7421cf 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -17,7 +17,7 @@ BEGIN DECLARE vShipment DATE; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); - DECLARE vItem INT; + DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); @@ -46,12 +46,12 @@ BEGIN GROUP BY r.warehouse_id; DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo - FROM order_row r - JOIN vn.item i ON i.id = r.item_id + SELECT r.id, r.itemFk, i.name, r.amount, r.price, r.rate, i.isFloramondo + FROM orderRow r + JOIN vn.item i ON i.id = r.itemFk WHERE r.amount - AND r.warehouse_id = vWarehouseFk - AND r.order_id = vSelf + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vSelf ORDER BY r.rate DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -185,7 +185,7 @@ BEGIN OPEN cRows; lRows: LOOP SET vDone = FALSE; - FETCH cRows INTO vRowFk, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH cRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; IF vDone THEN LEAVE lRows; @@ -197,7 +197,7 @@ BEGIN FROM vn.sale s WHERE ticketFk = vTicketFk AND price = vPrice - AND itemFk = vItem + AND itemFk = vItemFk AND discount = 0 LIMIT 1; @@ -215,7 +215,7 @@ BEGIN WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale - SET itemFk = vItem, + SET itemFk = vItemFk, ticketFk = vTicketFk, concept = vConcept, quantity = vAmount, @@ -244,11 +244,11 @@ BEGIN SELECT GREATEST(0, available) INTO vAvailable FROM cache.availableNoRaids WHERE calc_id = vCalcFk - AND item_id = vItem; + AND item_id = vItemFk; UPDATE cache.availableNoRaids SET available = GREATEST(0, available - vAmount) - WHERE item_id = vItem + WHERE item_id = vItemFk AND calc_id = vCalcFk; INSERT INTO edi.putOrder ( @@ -273,7 +273,7 @@ BEGIN LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk JOIN edi.floraHollandConfig fhc JOIN `order` o ON o.id = vSelf - WHERE i.id = vItem + WHERE i.id = vItemFk AND di.LatestOrderDateTime > util.VN_NOW() AND vAmount > vAvailable LIMIT 1; From 0e760ba5057b97b55e97c9d1c3bd6a5481eed5dd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 08:23:43 +0200 Subject: [PATCH 008/145] refactor: refs #6453 order_confirmWithUser --- .../hedera/procedures/order_confirmWithUser.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 61a7421cf..b5962ec88 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -37,13 +37,13 @@ BEGIN DECLARE vAvailable INT; DECLARE cDates CURSOR FOR - SELECT zgs.shipped, r.warehouse_id + SELECT zgs.shipped, r.warehouseFk FROM `order` o - JOIN order_row r ON r.order_id = o.id - LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id + JOIN orderRow r ON r.orderFk = o.id + LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouseFk WHERE o.id = vSelf AND r.amount - GROUP BY r.warehouse_id; + GROUP BY r.warehouseFk; DECLARE cRows CURSOR FOR SELECT r.id, r.itemFk, i.name, r.amount, r.price, r.rate, i.isFloramondo @@ -101,8 +101,8 @@ BEGIN -- Check order is not empty SELECT COUNT(*) > 0 INTO vIsOk - FROM order_row - WHERE order_id = vSelf + FROM orderRow + WHERE orderFk = vSelf AND amount > 0; IF NOT vIsOk THEN @@ -233,8 +233,8 @@ BEGIN GROUP BY vSaleFk, rc.componentFk; END IF; - UPDATE order_row - SET Id_Movimiento = vSaleFk + UPDATE orderRow + SET saleFk = vSaleFk WHERE id = vRowFk; -- Inserta en putOrder si la compra es de Floramondo From a1d3d2f2f8ea12ef313e705cf372bf4ceae82674 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 10:30:24 +0200 Subject: [PATCH 009/145] refactor: refs #6453 Major changes --- .../procedures/order_confirmWithUser.sql | 214 ++++++++++++------ 1 file changed, 141 insertions(+), 73 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index b5962ec88..bf4408fbc 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWi ) BEGIN /** - * Confirms an order, creating each of its tickets on - * the corresponding date, store and user. + * Confirms an order, creating each of its tickets + * on the corresponding date, store and user. * * @param vSelf The order identifier * @param vUser The user identifier @@ -25,7 +25,7 @@ BEGIN DECLARE vRate INT; DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); - DECLARE vDelivery DATE; + DECLARE vLanded DATE; DECLARE vAddressFk INT; DECLARE vIsConfirmed BOOL; DECLARE vClientFk INT; @@ -35,8 +35,9 @@ BEGIN DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; DECLARE vAvailable INT; + DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE cDates CURSOR FOR + DECLARE vDates CURSOR FOR SELECT zgs.shipped, r.warehouseFk FROM `order` o JOIN orderRow r ON r.orderFk = o.id @@ -45,8 +46,25 @@ BEGIN AND r.amount GROUP BY r.warehouseFk; - DECLARE cRows CURSOR FOR - SELECT r.id, r.itemFk, i.name, r.amount, r.price, r.rate, i.isFloramondo + DECLARE vDistinctItemPackingType CURSOR FOR + SELECT DISTINCT i.itemPackingTypeFk + FROM `order` o + JOIN orderRow r ON r.orderFk = o.id + JOIN vn.item i ON i.id = r.itemFk + WHERE o.id = vSelf + AND r.warehouseFk = vWarehouseFk + AND r.amount + ORDER BY i.itemPackingTypeFk DESC; + + DECLARE vRows CURSOR FOR + SELECT r.id, + r.itemFk, + i.name, + r.amount, + r.price, + r.rate, + i.itemPackingTypeFk, + i.isFloramondo FROM orderRow r JOIN vn.item i ON i.id = r.itemFk WHERE r.amount @@ -70,7 +88,7 @@ BEGIN o.company_id, o.agency_id, c.isTaxDataChecked - INTO vDelivery, + INTO vLanded, vAddressFk, vNotes, vClientFk, @@ -88,7 +106,7 @@ BEGIN END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped(vDelivery, vAddressFk, vAgencyModeFk, FALSE); + CALL vn.zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, FALSE); -- Trabajador que realiza la accion IF vUserFk IS NULL THEN @@ -110,88 +128,135 @@ BEGIN END IF; -- Crea los tickets del pedido - OPEN cDates; - lDates: - LOOP + OPEN vDates; + lDates: LOOP SET vTicketFk = NULL; SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouseFk; + FETCH vDates INTO vShipment, vWarehouseFk; IF vDone THEN LEAVE lDates; END IF; + CREATE OR REPLACE TEMPORARY TABLE tTicketByItemPackingType( + itemPackingTypeFk VARCHAR(1), + ticketFk INT, + PRIMARY KEY(itemPackingTypeFk, ticketFk) + ) ENGINE = MEMORY; + -- Busca un ticket existente que coincida con los parametros - WITH tPrevia AS ( - SELECT DISTINCT s.ticketFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) - SELECT t.id INTO vTicketFk - FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'FREE' - LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o ON o.address_id = t.addressFk - AND vWarehouseFk = t.warehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment - WHERE o.id = vSelf - AND t.refFk IS NULL - AND tp.ticketFk IS NULL - AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) - LIMIT 1; + OPEN vDistinctItemPackingType; + lDistinctItemPackingType: LOOP + SET vItemPackingTypeFk = NULL; + SET vDone = FALSE; + FETCH vDistinctItemPackingType INTO vItemPackingTypeFk; - -- Crea el ticket en el caso de no existir uno adecuado - IF vTicketFk IS NULL THEN - SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( - vClientFk, - vShipment, - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - NULL, - vDelivery, - vUserFk, - TRUE, - vTicketFk - ); - ELSE - INSERT INTO vn.ticketTracking - SET ticketFk = vTicketFk, - userFk = vUserFk, - stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); - END IF; + IF vDone THEN + LEAVE lDistinctItemPackingType; + END IF; - INSERT IGNORE INTO vn.orderTicket - SET orderFk = vSelf, - ticketFk = vTicketFk; + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk + FROM vn.sale s + JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) + ), + tTicketSameItemPackingType AS ( + SELECT t.id, COUNT(*) = SUM(IF( + vItemPackingTypeFk IS NOT NULL, + i.itemPackingTypeFk = vItemPackingTypeFk, + i.itemPackingTypeFk IS NULL + )) hasSameItemPackingType + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.shipped = vShipment + GROUP BY t.id + HAVING hasSameItemPackingType + ) + SELECT t.id INTO vTicketFk + FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' + LEFT JOIN tPrevia tp ON tp.ticketFk = t.id + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.warehouseFk = vWarehouseFk + AND o.date_send = t.landed + AND DATE(t.shipped) = vShipment + JOIN tTicketSameItemPackingType tt ON tt.id = t.id + WHERE o.id = vSelf + AND t.refFk IS NULL + AND tp.ticketFk IS NULL + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) + LIMIT 1; - -- Añade las notas - IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, - observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), - `description` = vNotes - ON DUPLICATE KEY UPDATE - `description` = CONCAT(VALUES(`description`),'. ', `description`); - END IF; + -- Crea el ticket en el caso de no existir uno adecuado + IF vTicketFk IS NULL THEN + SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); + CALL vn.ticket_add( + vClientFk, + vShipment, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + NULL, + vLanded, + vUserFk, + TRUE, + vTicketFk + ); + ELSE + INSERT INTO vn.ticketTracking + SET ticketFk = vTicketFk, + userFk = vUserFk, + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); + END IF; + + INSERT IGNORE INTO vn.orderTicket + SET orderFk = vSelf, + ticketFk = vTicketFk; + + -- Añade las notas + IF vNotes IS NOT NULL AND vNotes <> '' THEN + INSERT INTO vn.ticketObservation SET + ticketFk = vTicketFk, + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), + `description` = vNotes + ON DUPLICATE KEY UPDATE + `description` = CONCAT(VALUES(`description`),'. ', `description`); + END IF; + + INSERT INTO tTicketByItemPackingType + SET itemPackingTypeFk = vItemPackingTypeFk, + ticketFk = vTicketFk; + END LOOP; + CLOSE vDistinctItemPackingType; -- Añade los movimientos y sus componentes - OPEN cRows; + OPEN vRows; lRows: LOOP + SET vSaleFk = NULL; SET vDone = FALSE; - FETCH cRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH vRows INTO vRowFk, + vItemFk, + vConcept, + vAmount, + vPrice, + vRate, + vItemPackingTypeFk, + vIsLogifloraItem; IF vDone THEN LEAVE lRows; END IF; - SET vSaleFk = NULL; + SELECT ticketFk INTO vTicketFk + FROM tTicketByItemPackingType + WHERE IF(vItemPackingTypeFk IS NOT NULL, + itemPackingTypeFk = vItemPackingTypeFk, + itemPackingTypeFk IS NULL) SELECT s.id INTO vSaleFk FROM vn.sale s @@ -211,7 +276,8 @@ BEGIN SELECT SUM(rc.`price`) valueSum INTO vPriceFixed FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase + JOIN vn.componentType ct ON ct.id = c.typeFk + AND ct.isBase WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale @@ -279,9 +345,9 @@ BEGIN LIMIT 1; END IF; END LOOP; - CLOSE cRows; + CLOSE vRows; END LOOP; - CLOSE cDates; + CLOSE vDates; UPDATE `order` SET confirmed = TRUE, @@ -289,5 +355,7 @@ BEGIN WHERE id = vSelf; COMMIT; + + DROP TEMPORARY TABLE tTicketByItemPackingType; END$$ DELIMITER ; From 7e415181c2afb40421ca3bf109533ea674c9606b Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 11:26:45 +0200 Subject: [PATCH 010/145] refactor: refs #6453 Major changes --- .../procedures/order_confirmWithUser.sql | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index bf4408fbc..246648e18 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -36,6 +36,7 @@ BEGIN DECLARE vIsTaxDataChecked BOOL; DECLARE vAvailable INT; DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vCountDistinctItemPackingTypeFk INT; DECLARE vDates CURSOR FOR SELECT zgs.shipped, r.warehouseFk @@ -54,7 +55,7 @@ BEGIN WHERE o.id = vSelf AND r.warehouseFk = vWarehouseFk AND r.amount - ORDER BY i.itemPackingTypeFk DESC; + ORDER BY i.itemPackingTypeFk DESC; -- El último siempre NULL!! DECLARE vRows CURSOR FOR SELECT r.id, @@ -155,6 +156,28 @@ BEGIN LEAVE lDistinctItemPackingType; END IF; + IF vItemPackingTypeFk IS NULL THEN + SELECT COUNT(*) INTO vCountDistinctItemPackingTypeFk + FROM tTicketByItemPackingType; + + CASE + WHEN vCountDistinctItemPackingTypeFk = 1 THEN + INSERT INTO tTicketByItemPackingType + SET itemPackingTypeFk = vItemPackingTypeFk, + ticketFk = (SELECT ticketFk FROM tTicketByItemPackingType); + LEAVE lDistinctItemPackingType; + WHEN vCountDistinctItemPackingTypeFk > 1 THEN + INSERT INTO tTicketByItemPackingType + SET itemPackingTypeFk = vItemPackingTypeFk, + ticketFk = ( + SELECT ticketFk + FROM tTicketByItemPackingType + WHERE itemPackingTypeFk = 'H' + ); + LEAVE lDistinctItemPackingType; + END CASE; + END IF; + WITH tPrevia AS ( SELECT DISTINCT s.ticketFk FROM vn.sale s From 15f580508bf3e4cfcb32bd63b49847c8e8e6ba98 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 11:29:14 +0200 Subject: [PATCH 011/145] refactor: refs #6453 Minor changes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 246648e18..fe0f33b3f 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -55,7 +55,8 @@ BEGIN WHERE o.id = vSelf AND r.warehouseFk = vWarehouseFk AND r.amount - ORDER BY i.itemPackingTypeFk DESC; -- El último siempre NULL!! + ORDER BY i.itemPackingTypeFk DESC; + -- El último siempre NULL, es imprescindible para la lógica !!! DECLARE vRows CURSOR FOR SELECT r.id, From 6dc464d26b15de4f83815ff01a44bce620f74233 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 11 Jul 2024 07:14:02 +0200 Subject: [PATCH 012/145] refactor: refs #6453 Minor changes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index fe0f33b3f..c48b74dd7 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -162,6 +162,8 @@ BEGIN FROM tTicketByItemPackingType; CASE + WHEN NOT vCountDistinctItemPackingTypeFk THEN + -- Code WHEN vCountDistinctItemPackingTypeFk = 1 THEN INSERT INTO tTicketByItemPackingType SET itemPackingTypeFk = vItemPackingTypeFk, @@ -196,6 +198,7 @@ BEGIN JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk WHERE t.shipped = vShipment + AND t.warehouseFk= vWarehouseFk GROUP BY t.id HAVING hasSameItemPackingType ) From 38d863aac63c76873eed12cdf8461c99786e587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 18:44:24 +0200 Subject: [PATCH 013/145] feat: refactor buyUltimate refs #7736 --- .../cache/procedures/last_buy_refresh.sql | 2 +- .../vn/procedures/available_traslate.sql | 2 +- db/routines/vn/procedures/buyUltimate.sql | 31 +--- .../vn/procedures/buyUltimateFromInterval.sql | 150 +-------------- db/routines/vn/procedures/buy_getUltimate.sql | 48 +++++ .../buy_getUltimateFromInterval .sql | 174 ++++++++++++++++++ .../vn/procedures/buy_updateGrouping.sql | 2 +- .../vn/procedures/buy_updatePacking.sql | 2 +- .../vn/procedures/catalog_calculate.sql | 2 +- .../vn/procedures/entry_getTransfer.sql | 2 +- .../vn/procedures/itemShelving_addByClaim.sql | 2 +- .../itemShelving_getItemDetails.sql | 2 +- db/routines/vn/procedures/item_devalueA2.sql | 2 +- db/routines/vn/procedures/item_getInfo.sql | 6 +- .../vn/procedures/item_multipleBuy.sql | 2 +- .../vn/procedures/item_valuateInventory.sql | 2 +- .../vn/procedures/sale_getProblems.sql | 2 +- .../vn/procedures/sale_recalcComponent.sql | 2 +- .../vn/procedures/sale_replaceItem.sql | 4 +- .../vn/procedures/sale_setProblemRounding.sql | 2 +- db/routines/vn/procedures/stockTraslation.sql | 2 +- .../vn/procedures/ticket_componentPreview.sql | 7 +- .../procedures/ticket_setProblemRounding.sql | 2 +- .../entry/back/methods/entry/addFromBuy.js | 4 +- .../entry/back/methods/entry/importBuys.js | 3 +- .../entry/back/methods/entry/lastItemBuys.js | 3 +- .../methods/order/getItemTypeAvailable.js | 15 +- 27 files changed, 265 insertions(+), 212 deletions(-) create mode 100644 db/routines/vn/procedures/buy_getUltimate.sql create mode 100644 db/routines/vn/procedures/buy_getUltimateFromInterval .sql diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql index 49ef4ee5e..0f80163fb 100644 --- a/db/routines/cache/procedures/last_buy_refresh.sql +++ b/db/routines/cache/procedures/last_buy_refresh.sql @@ -30,7 +30,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buyUltimateFromInterval(NULL, started, ended); + CALL vn.buy_getUltimateFromInterval (NULL, NULL, started, ended); DELETE FROM last_buy; diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index d33a8e10e..e4ba13d79 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -47,7 +47,7 @@ proc: BEGIN -- Tabla con el ultimo dia de last_buy para cada producto -- que hace un replace de la anterior. - CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); + CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE()); INSERT INTO tItemRange SELECT t.itemFk, tr.landed diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql index 98b16cbc0..7026c8c82 100644 --- a/db/routines/vn/procedures/buyUltimate.sql +++ b/db/routines/vn/procedures/buyUltimate.sql @@ -5,39 +5,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`( ) BEGIN /** + * DEPRECATED usar buy_getUltimate * Calcula las últimas compras realizadas hasta una fecha * + * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén * @param vDated Compras hasta fecha * @return tmp.buyUltimate */ - CALL cache.last_buy_refresh (FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(itemFk)) - ENGINE = MEMORY - SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing - FROM cache.last_buy - WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - - IF vDated >= util.VN_CURDATE() THEN - CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); - - REPLACE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed <= vDated - AND NOT isIgnored; - - INSERT IGNORE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed > vDated - ORDER BY isIgnored = FALSE DESC; - END IF; + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 5879b58e1..75dfff489 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -6,6 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInte ) BEGIN /** + * DEPRECATED usar buy_getUltimateFromInterval * Calcula las últimas compras realizadas * desde un rango de fechas. * @@ -14,153 +15,6 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM - (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; + CALL vn.buy_getUltimateFromInterval (NULL,vWarehouseFk,vStarted,vEnded); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql new file mode 100644 index 000000000..36ae10fd8 --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -0,0 +1,48 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas hasta una fecha + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @param vDated Compras hasta fecha + * @return tmp.buyUltimate + */ + CALL cache.last_buy_refresh (FALSE); + + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; + CREATE TEMPORARY TABLE tmp.buyUltimate + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(itemFk)) + ENGINE = MEMORY + SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing + FROM cache.last_buy + WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL) + AND (item_id = vItemFk OR vItemFk IS NULL); + + IF vDated >= util.VN_CURDATE() THEN + CALL buyUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + + REPLACE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed <= vDated + AND NOT isIgnored; + + INSERT IGNORE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed > vDated + ORDER BY isIgnored = FALSE DESC; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval .sql b/db/routines/vn/procedures/buy_getUltimateFromInterval .sql new file mode 100644 index 000000000..4dafd105f --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval .sql @@ -0,0 +1,174 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval `( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); + END IF; + + -- Item + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; + CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index fb7adc0a3..45a619262 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -8,7 +8,7 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL vn.buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE vn.buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/buy_updatePacking.sql b/db/routines/vn/procedures/buy_updatePacking.sql index d86edc98f..0ee9d4c80 100644 --- a/db/routines/vn/procedures/buy_updatePacking.sql +++ b/db/routines/vn/procedures/buy_updatePacking.sql @@ -8,7 +8,7 @@ BEGIN * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 963e33507..887492b35 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -74,7 +74,7 @@ BEGIN CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buyUltimate(vWarehouseFk, vShipped); + CALL vn.buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index 165c87dc7..5bf049b6e 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -97,7 +97,7 @@ BEGIN FROM tmp.itemList; END IF; - CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded); + CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded); CREATE OR REPLACE TEMPORARY TABLE tTransfer ENGINE = MEMORY diff --git a/db/routines/vn/procedures/itemShelving_addByClaim.sql b/db/routines/vn/procedures/itemShelving_addByClaim.sql index 851162952..4ff2955c7 100644 --- a/db/routines/vn/procedures/itemShelving_addByClaim.sql +++ b/db/routines/vn/procedures/itemShelving_addByClaim.sql @@ -15,7 +15,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index c01bc348c..b097c2d17 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -23,7 +23,7 @@ BEGIN FROM operator WHERE workerFk = account.myUser_getId(); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE()); SELECT buyFk INTO vBuyFk FROM tmp.buyUltimate diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index c9f716d8f..0cfcfcc7e 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -93,7 +93,7 @@ BEGIN ORDER BY created DESC LIMIT 1; - CALL buyUltimate(vWarehouseFk, vCurdate); + CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate); SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal FROM tmp.buyUltimate bu diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index 50ab880a0..f569d235b 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -14,9 +14,11 @@ BEGIN CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - + SELECT barcodeToItem(vBarcode) INTO vItemFk; + + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); + SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock WHERE itemFk = vItemFk diff --git a/db/routines/vn/procedures/item_multipleBuy.sql b/db/routines/vn/procedures/item_multipleBuy.sql index ba49f8d36..0a08f5015 100644 --- a/db/routines/vn/procedures/item_multipleBuy.sql +++ b/db/routines/vn/procedures/item_multipleBuy.sql @@ -13,7 +13,7 @@ BEGIN */ ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate (NULL, vWarehouseFk, vDate); CREATE OR REPLACE TEMPORARY TABLE tmp (KEY (itemFk)) diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index 18aefdf7b..71f1459eb 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -181,7 +181,7 @@ BEGIN AND e.isConfirmed ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - CALL buyUltimate(NULL, vDateDayEnd); + CALL buy_getUltimate (NULL, NULL, vDateDayEnd); DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index ba4ff5857..64ecb898d 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -276,7 +276,7 @@ BEGIN ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem ,saleFk FROM ( diff --git a/db/routines/vn/procedures/sale_recalcComponent.sql b/db/routines/vn/procedures/sale_recalcComponent.sql index 54297571a..f3c188404 100644 --- a/db/routines/vn/procedures/sale_recalcComponent.sql +++ b/db/routines/vn/procedures/sale_recalcComponent.sql @@ -78,7 +78,7 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.zoneGetLanded; -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index a4aefc088..573d5b488 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -53,7 +53,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSaleFk; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(vNewItemFk, vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing INTO vGrouping,vGroupingMode,vPacking @@ -61,6 +61,8 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; + DROP TEMPORARY TABLE tmp.buyUltimate; + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql index f58d00799..894749c7b 100644 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ b/db/routines/vn/procedures/sale_setProblemRounding.sql @@ -19,7 +19,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSelf; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale SELECT vSelf saleFk, diff --git a/db/routines/vn/procedures/stockTraslation.sql b/db/routines/vn/procedures/stockTraslation.sql index c681112f1..f9175dc2a 100644 --- a/db/routines/vn/procedures/stockTraslation.sql +++ b/db/routines/vn/procedures/stockTraslation.sql @@ -36,6 +36,6 @@ BEGIN WHERE warehouse_id = vAuctionWarehouseFk ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); - CALL buyUltimate(vAuctionWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_componentPreview.sql b/db/routines/vn/procedures/ticket_componentPreview.sql index 729e3a743..4bcd8c8ec 100644 --- a/db/routines/vn/procedures/ticket_componentPreview.sql +++ b/db/routines/vn/procedures/ticket_componentPreview.sql @@ -56,13 +56,12 @@ BEGIN FROM zone WHERE id = vZoneFk; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, + SELECT vWarehouseFk warehouseFk, + NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql index fb580eacf..551cf67d1 100644 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ b/db/routines/vn/procedures/ticket_setProblemRounding.sql @@ -16,7 +16,7 @@ BEGIN FROM ticket WHERE id = vSelf; - CALL buyUltimate(vWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk, isProblemCalcNeeded)) diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index e5cc427a8..212aed7ea 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -52,8 +52,8 @@ module.exports = Self => { else { const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions); await Self.rawSql( - 'CALL vn.buyUltimate(?,?)', - [userConfig.warehouseFk, null], + 'CALL vn.buy_getUltimate(?,?,?)', + [args.item, userConfig.warehouseFk, null], myOptions ); let buyUltimate = await Self.rawSql( diff --git a/modules/entry/back/methods/entry/importBuys.js b/modules/entry/back/methods/entry/importBuys.js index 812775a1b..e3fd653bb 100644 --- a/modules/entry/back/methods/entry/importBuys.js +++ b/modules/entry/back/methods/entry/importBuys.js @@ -73,7 +73,8 @@ module.exports = Self => { }, myOptions); const travel = entry.travel(); - await Self.rawSql('CALL buyUltimate(?, ?)', [ + await Self.rawSql('CALL buy_getUltimate(?, ?, ?)', [ + null, travel.warehouseInFk, travel.landed ], myOptions); diff --git a/modules/entry/back/methods/entry/lastItemBuys.js b/modules/entry/back/methods/entry/lastItemBuys.js index 63e6d38f2..012b99d17 100644 --- a/modules/entry/back/methods/entry/lastItemBuys.js +++ b/modules/entry/back/methods/entry/lastItemBuys.js @@ -50,7 +50,8 @@ module.exports = Self => { const stmts = []; let stmt; - stmt = new ParameterizedSQL(`CALL buyUltimate(?, ?)`, [ + stmt = new ParameterizedSQL(`CALL buy_getUltimate(?, ?, ?)`, [ + null, travel.warehouseInFk, travel.landed ]); diff --git a/modules/order/back/methods/order/getItemTypeAvailable.js b/modules/order/back/methods/order/getItemTypeAvailable.js index b84863953..fd7be5d57 100644 --- a/modules/order/back/methods/order/getItemTypeAvailable.js +++ b/modules/order/back/methods/order/getItemTypeAvailable.js @@ -44,16 +44,14 @@ module.exports = Self => { ]); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.item'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.item + `CREATE OR REPLACE TEMPORARY TABLE tmp.item (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT DISTINCT - i.id AS itemFk, - it.id AS typeFk, + i.id itemFk, + it.id typeFk, it.name, - ic.name AS categoryName + ic.name categoryName FROM tmp.availableCalc ac JOIN cache.available a ON a.calc_id = ac.calcFk JOIN vn.item i ON i.id = a.item_id @@ -64,7 +62,7 @@ module.exports = Self => { stmts.push(stmt); stmt = new ParameterizedSQL( - 'CALL vn.catalog_calculate(?, ?, ?,?)', [ + 'CALL vn.catalog_calculate(?, ?, ?, ?)', [ order.landed, order.addressFk, order.agencyModeFk, @@ -74,7 +72,7 @@ module.exports = Self => { stmts.push(stmt); stmt = new ParameterizedSQL(` - SELECT i.typeFk AS id, i.name, i.categoryName + SELECT i.typeFk id, i.name, i.categoryName FROM tmp.item i JOIN tmp.ticketCalculateItem tci ON tci.itemFk = i.itemFk GROUP BY i.typeFk` @@ -85,7 +83,6 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const result = await Self.rawStmt(sql, myOptions); - return result[categoriesIndex]; }; }; From d6a949a9f38f22bfd2487bf93b246e9e7527f687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 18:55:58 +0200 Subject: [PATCH 014/145] feat: refactor buyUltimate refs #7736 --- .../cache/procedures/last_buy_refresh.sql | 2 +- .../vn/procedures/buyUltimateFromInterval.sql | 2 +- .../buy_getUltimateFromInterval .sql | 174 ------------------ 3 files changed, 2 insertions(+), 176 deletions(-) delete mode 100644 db/routines/vn/procedures/buy_getUltimateFromInterval .sql diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql index 0f80163fb..555ae0b8d 100644 --- a/db/routines/cache/procedures/last_buy_refresh.sql +++ b/db/routines/cache/procedures/last_buy_refresh.sql @@ -30,7 +30,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buy_getUltimateFromInterval (NULL, NULL, started, ended); + CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended); DELETE FROM last_buy; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 75dfff489..8aea38ee0 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -15,6 +15,6 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - CALL vn.buy_getUltimateFromInterval (NULL,vWarehouseFk,vStarted,vEnded); + CALL vn.buy_getUltimateFromInterval(NULL,vWarehouseFk,vStarted,vEnded); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval .sql b/db/routines/vn/procedures/buy_getUltimateFromInterval .sql deleted file mode 100644 index 4dafd105f..000000000 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval .sql +++ /dev/null @@ -1,174 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval `( - vItemFk INT, - vWarehouseFk SMALLINT, - vStarted DATE, - vEnded DATE -) -BEGIN -/** - * Calcula las últimas compras realizadas - * desde un rango de fechas. - * - * @param vItemFk Id del artículo - * @param vWarehouseFk Id del almacén si es NULL se actualizan todos - * @param vStarted Fecha inicial - * @param vEnded Fecha fin - * @return tmp.buyUltimateFromInterval - */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.quantity = 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM - (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.quantity = 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; -END$$ -DELIMITER ; From 50e2c03d3e1a2caac3643d49ad2cf220c5050a04 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 16 Jul 2024 18:56:00 +0200 Subject: [PATCH 015/145] refs #7531 Requested modifications in redmine --- .../vn/procedures/zone_getAddresses.sql | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index c3a21aa83..417b8c7a3 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,40 +1,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vDated DATE, - vDepartment INT + vShipped DATE, + vDepartmentFk INT ) BEGIN /** * Devuelve un listado de todos los clientes activos * con consignatarios a los que se les puede - * vender producto para esa zona y no tiene un ticket - * para ese día. + * vender producto para esa zona. * * @param vSelf Id de zona - * @param vDated Fecha de entrega - * @param vDepartment Departamento del trabajador + * @param vShipped Fecha de envio + * @param vDepartmentFk Id de departamento * @return Un select */ CALL zone_getPostalCode(vSelf); - WITH notHasTicket AS ( - SELECT id - FROM vn.client - WHERE id NOT IN ( - SELECT clientFk - FROM vn.ticket - WHERE landed BETWEEN vDated AND util.dayEnd(vDated) - ) - ), - hasTicketShippedToday AS ( - SELECT clientFk, - IF (COUNT(*) > 0, TRUE, FALSE) hasTicketShipped + WITH clientWithTicket AS ( + SELECT clientFk FROM vn.ticket - WHERE shipped BETWEEN vDated AND util.dayEnd(vDated) - GROUP BY clientFk + WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) ) - SELECT c.id clientFk, + SELECT c.id, c.name, c.phone, bt.description, @@ -42,12 +30,12 @@ BEGIN u.name username, aai.invoiced, cnb.lastShipped, - ht.hasTicketShipped + cwt.clientFk FROM vn.client c JOIN vn.worker w ON w.id = c.salesPersonFk JOIN vn.workerDepartment wd ON wd.workerFk = w.id JOIN vn.department d ON d.id = wd.departmentFk - JOIN notHasTicket ON notHasTicket.id = c.id + LEFT JOIN clientWithTicket cwt ON cwt.clientFk = c.id LEFT JOIN account.`user` u ON u.id = c.salesPersonFk JOIN vn.`address` a ON a.clientFk = c.id JOIN vn.postCode pc ON pc.code = a.postalCode @@ -58,12 +46,11 @@ BEGIN LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id JOIN vn.clientType ct ON ct.code = c.typeFk JOIN vn.businessType bt ON bt.code = c.businessTypeFk - LEFT JOIN hasTicketShippedToday ht ON ht.clientFk = c.id WHERE a.isActive AND c.isActive AND ct.code = 'normal' AND bt.code <> 'worker' - AND d.id = vDepartment + AND d.id = vDepartmentFk GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From 5ca2a432daece8d1013b7c0737a50f3c859f4472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 18:58:26 +0200 Subject: [PATCH 016/145] feat: refactor buyUltimate refs #7736 --- .../buy_getUltimateFromInterval.sql | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 db/routines/vn/procedures/buy_getUltimateFromInterval.sql diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql new file mode 100644 index 000000000..45d1122ae --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -0,0 +1,174 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); + END IF; + + -- Item + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; + CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END$$ +DELIMITER ; From 4ee0bd687fb040f2cc9fae0a9594be4c268fdbdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 19:01:02 +0200 Subject: [PATCH 017/145] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buyUltimateFromInterval.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 8aea38ee0..9709f2edc 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -15,6 +15,6 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - CALL vn.buy_getUltimateFromInterval(NULL,vWarehouseFk,vStarted,vEnded); + CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 36ae10fd8..d16f89295 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -26,7 +26,7 @@ BEGIN AND (item_id = vItemFk OR vItemFk IS NULL); IF vDated >= util.VN_CURDATE() THEN - CALL buyUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); REPLACE INTO tmp.buyUltimate SELECT itemFk, buyFk, warehouseFk, landed landing From a6e6f435f75a976cf517c5e11d7ef1a0a32d6ab2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 18 Jul 2024 15:21:59 +0200 Subject: [PATCH 018/145] refs #7531 No assigned department --- db/routines/vn/procedures/zone_getAddresses.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 417b8c7a3..0622ece1b 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -50,7 +50,7 @@ BEGIN AND c.isActive AND ct.code = 'normal' AND bt.code <> 'worker' - AND d.id = vDepartmentFk + AND (d.id = vDepartmentFk OR NOT vDepartmentFk) GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From 5f29384389c741e2e0d79cde820eb992a026a75d Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 10:49:45 +0200 Subject: [PATCH 019/145] feat: #6453 Rollback always split by itemPackingType --- .../procedures/order_confirmWithUser.sql | 190 +++++------------- 1 file changed, 55 insertions(+), 135 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index c48b74dd7..86489b080 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -47,17 +47,6 @@ BEGIN AND r.amount GROUP BY r.warehouseFk; - DECLARE vDistinctItemPackingType CURSOR FOR - SELECT DISTINCT i.itemPackingTypeFk - FROM `order` o - JOIN orderRow r ON r.orderFk = o.id - JOIN vn.item i ON i.id = r.itemFk - WHERE o.id = vSelf - AND r.warehouseFk = vWarehouseFk - AND r.amount - ORDER BY i.itemPackingTypeFk DESC; - -- El último siempre NULL, es imprescindible para la lógica !!! - DECLARE vRows CURSOR FOR SELECT r.id, r.itemFk, @@ -140,126 +129,65 @@ BEGIN LEAVE lDates; END IF; - CREATE OR REPLACE TEMPORARY TABLE tTicketByItemPackingType( - itemPackingTypeFk VARCHAR(1), - ticketFk INT, - PRIMARY KEY(itemPackingTypeFk, ticketFk) - ) ENGINE = MEMORY; - -- Busca un ticket existente que coincida con los parametros - OPEN vDistinctItemPackingType; - lDistinctItemPackingType: LOOP - SET vItemPackingTypeFk = NULL; - SET vDone = FALSE; - FETCH vDistinctItemPackingType INTO vItemPackingTypeFk; + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk + FROM vn.sale s + JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) + ) + SELECT t.id INTO vTicketFk + FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' + LEFT JOIN tPrevia tp ON tp.ticketFk = t.id + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.warehouseFk = vWarehouseFk + AND o.date_send = t.landed + AND DATE(t.shipped) = vShipment + WHERE o.id = vSelf + AND t.refFk IS NULL + AND tp.ticketFk IS NULL + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) + LIMIT 1; - IF vDone THEN - LEAVE lDistinctItemPackingType; - END IF; + -- Crea el ticket en el caso de no existir uno adecuado + IF vTicketFk IS NULL THEN + SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); + CALL vn.ticket_add( + vClientFk, + vShipment, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + NULL, + vLanded, + vUserFk, + TRUE, + vTicketFk + ); + ELSE + INSERT INTO vn.ticketTracking + SET ticketFk = vTicketFk, + userFk = vUserFk, + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); + END IF; - IF vItemPackingTypeFk IS NULL THEN - SELECT COUNT(*) INTO vCountDistinctItemPackingTypeFk - FROM tTicketByItemPackingType; + INSERT IGNORE INTO vn.orderTicket + SET orderFk = vSelf, + ticketFk = vTicketFk; - CASE - WHEN NOT vCountDistinctItemPackingTypeFk THEN - -- Code - WHEN vCountDistinctItemPackingTypeFk = 1 THEN - INSERT INTO tTicketByItemPackingType - SET itemPackingTypeFk = vItemPackingTypeFk, - ticketFk = (SELECT ticketFk FROM tTicketByItemPackingType); - LEAVE lDistinctItemPackingType; - WHEN vCountDistinctItemPackingTypeFk > 1 THEN - INSERT INTO tTicketByItemPackingType - SET itemPackingTypeFk = vItemPackingTypeFk, - ticketFk = ( - SELECT ticketFk - FROM tTicketByItemPackingType - WHERE itemPackingTypeFk = 'H' - ); - LEAVE lDistinctItemPackingType; - END CASE; - END IF; - - WITH tPrevia AS ( - SELECT DISTINCT s.ticketFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ), - tTicketSameItemPackingType AS ( - SELECT t.id, COUNT(*) = SUM(IF( - vItemPackingTypeFk IS NOT NULL, - i.itemPackingTypeFk = vItemPackingTypeFk, - i.itemPackingTypeFk IS NULL - )) hasSameItemPackingType - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.shipped = vShipment - AND t.warehouseFk= vWarehouseFk - GROUP BY t.id - HAVING hasSameItemPackingType - ) - SELECT t.id INTO vTicketFk - FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'FREE' - LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o ON o.address_id = t.addressFk - AND t.warehouseFk = vWarehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment - JOIN tTicketSameItemPackingType tt ON tt.id = t.id - WHERE o.id = vSelf - AND t.refFk IS NULL - AND tp.ticketFk IS NULL - AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) - LIMIT 1; - - -- Crea el ticket en el caso de no existir uno adecuado - IF vTicketFk IS NULL THEN - SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( - vClientFk, - vShipment, - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - NULL, - vLanded, - vUserFk, - TRUE, - vTicketFk - ); - ELSE - INSERT INTO vn.ticketTracking - SET ticketFk = vTicketFk, - userFk = vUserFk, - stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); - END IF; - - INSERT IGNORE INTO vn.orderTicket - SET orderFk = vSelf, - ticketFk = vTicketFk; - - -- Añade las notas - IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, - observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), - `description` = vNotes - ON DUPLICATE KEY UPDATE - `description` = CONCAT(VALUES(`description`),'. ', `description`); - END IF; - - INSERT INTO tTicketByItemPackingType - SET itemPackingTypeFk = vItemPackingTypeFk, - ticketFk = vTicketFk; - END LOOP; - CLOSE vDistinctItemPackingType; + -- Añade las notas + IF vNotes IS NOT NULL AND vNotes <> '' THEN + INSERT INTO vn.ticketObservation SET + ticketFk = vTicketFk, + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), + `description` = vNotes + ON DUPLICATE KEY UPDATE + `description` = CONCAT(VALUES(`description`),'. ', `description`); + END IF; -- Añade los movimientos y sus componentes OPEN vRows; @@ -279,12 +207,6 @@ BEGIN LEAVE lRows; END IF; - SELECT ticketFk INTO vTicketFk - FROM tTicketByItemPackingType - WHERE IF(vItemPackingTypeFk IS NOT NULL, - itemPackingTypeFk = vItemPackingTypeFk, - itemPackingTypeFk IS NULL) - SELECT s.id INTO vSaleFk FROM vn.sale s WHERE ticketFk = vTicketFk @@ -382,7 +304,5 @@ BEGIN WHERE id = vSelf; COMMIT; - - DROP TEMPORARY TABLE tTicketByItemPackingType; END$$ DELIMITER ; From 578de51f7e689b7ddc9ab03d5bf8015eb2c181f5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 10:54:40 +0200 Subject: [PATCH 020/145] feat: #6453 Refactor --- db/routines/hedera/procedures/order_confirmWithUser.sql | 7 ------- 1 file changed, 7 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 86489b080..841a69390 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -22,21 +22,16 @@ BEGIN DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); DECLARE vSaleFk INT; - DECLARE vRate INT; DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); DECLARE vLanded DATE; DECLARE vAddressFk INT; - DECLARE vIsConfirmed BOOL; DECLARE vClientFk INT; DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; DECLARE vCalcFk INT; DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; - DECLARE vAvailable INT; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vCountDistinctItemPackingTypeFk INT; DECLARE vDates CURSOR FOR SELECT zgs.shipped, r.warehouseFk @@ -53,7 +48,6 @@ BEGIN i.name, r.amount, r.price, - r.rate, i.itemPackingTypeFk, i.isFloramondo FROM orderRow r @@ -199,7 +193,6 @@ BEGIN vConcept, vAmount, vPrice, - vRate, vItemPackingTypeFk, vIsLogifloraItem; From b2a8326170594eca7aff3f5127516ee97cfa399a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 19 Jul 2024 12:44:45 +0200 Subject: [PATCH 021/145] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buyUltimateFromInterval.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- db/routines/vn/procedures/buy_getUltimateFromInterval.sql | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 9709f2edc..acb6282de 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -6,7 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInte ) BEGIN /** - * DEPRECATED usar buy_getUltimateFromInterval + * @deprecated Usar buy_getUltimateFromInterval * Calcula las últimas compras realizadas * desde un rango de fechas. * diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index d16f89295..164fb3266 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -13,7 +13,7 @@ BEGIN * @param vDated Compras hasta fecha * @return tmp.buyUltimate */ - CALL cache.last_buy_refresh (FALSE); + CALL cache.last_buy_refresh(FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; CREATE TEMPORARY TABLE tmp.buyUltimate diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql index 45d1122ae..df0d6a20e 100644 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -25,8 +25,8 @@ BEGIN END IF; -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval (PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) ENGINE = MEMORY @@ -97,7 +97,8 @@ BEGIN LIMIT 10000000000000000000) sub GROUP BY itemFk, warehouseFk; - -- ItemOriginal + -- ItemOriginal + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) SELECT itemFk, warehouseFk, From 15e1f9763a8ce938f9b924f7a5c2d06590238bdc Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 19 Jul 2024 12:58:34 +0200 Subject: [PATCH 022/145] BREACKING CHANGE: claim redirect to lilium --- e2e/helpers/selectors.js | 63 ---- e2e/paths/06-claim/01_basic_data.spec.js | 61 ---- e2e/paths/06-claim/03_claim_action.spec.js | 54 ---- e2e/paths/06-claim/04_summary.spec.js | 96 ------ e2e/paths/06-claim/05_descriptor.spec.js | 58 ---- e2e/paths/06-claim/06_note.spec.js | 46 --- e2e/tests.js | 1 - modules/claim/front/action/index.html | 188 ------------ modules/claim/front/action/index.js | 233 --------------- modules/claim/front/action/index.spec.js | 167 ----------- modules/claim/front/action/locale/en.yml | 1 - modules/claim/front/action/locale/es.yml | 13 - modules/claim/front/action/style.scss | 46 --- modules/claim/front/basic-data/index.html | 66 ----- modules/claim/front/basic-data/index.js | 20 -- modules/claim/front/basic-data/index.spec.js | 28 -- modules/claim/front/basic-data/locale/es.yml | 9 - modules/claim/front/basic-data/style.scss | 3 - modules/claim/front/card/index.html | 5 - modules/claim/front/card/index.js | 68 ----- modules/claim/front/card/index.spec.js | 29 -- modules/claim/front/descriptor/index.js | 4 +- modules/claim/front/detail/index.html | 178 ------------ modules/claim/front/detail/index.js | 203 ------------- modules/claim/front/detail/index.spec.js | 150 ---------- modules/claim/front/detail/locale/es.yml | 11 - modules/claim/front/detail/style.scss | 30 -- modules/claim/front/development/index.html | 2 - modules/claim/front/development/index.js | 21 -- modules/claim/front/index.js | 12 - modules/claim/front/index/index.html | 83 ------ modules/claim/front/index/index.js | 82 ------ modules/claim/front/log/index.html | 4 - modules/claim/front/log/index.js | 7 - modules/claim/front/main/index.html | 19 -- modules/claim/front/main/index.js | 13 +- modules/claim/front/note/create/index.html | 30 -- modules/claim/front/note/create/index.js | 22 -- modules/claim/front/note/index/index.html | 32 -- modules/claim/front/note/index/index.js | 25 -- modules/claim/front/note/index/style.scss | 5 - modules/claim/front/photos/index.html | 1 - modules/claim/front/photos/index.js | 21 -- modules/claim/front/search-panel/index.html | 84 ------ modules/claim/front/search-panel/index.js | 14 - .../claim/front/search-panel/locale/es.yml | 7 - modules/claim/front/summary/index.html | 273 ------------------ modules/claim/front/summary/index.js | 103 ------- modules/claim/front/summary/index.spec.js | 55 ---- modules/claim/front/summary/style.scss | 28 -- modules/item/front/diary/index.html | 2 +- modules/item/front/diary/index.js | 4 + modules/ticket/front/sale/index.html | 2 +- modules/ticket/front/sale/index.js | 6 +- modules/ticket/front/summary/index.html | 4 +- modules/ticket/front/summary/index.js | 4 + 56 files changed, 31 insertions(+), 2765 deletions(-) delete mode 100644 e2e/paths/06-claim/01_basic_data.spec.js delete mode 100644 e2e/paths/06-claim/03_claim_action.spec.js delete mode 100644 e2e/paths/06-claim/04_summary.spec.js delete mode 100644 e2e/paths/06-claim/05_descriptor.spec.js delete mode 100644 e2e/paths/06-claim/06_note.spec.js delete mode 100644 modules/claim/front/action/index.html delete mode 100644 modules/claim/front/action/index.js delete mode 100644 modules/claim/front/action/index.spec.js delete mode 100644 modules/claim/front/action/locale/en.yml delete mode 100644 modules/claim/front/action/locale/es.yml delete mode 100644 modules/claim/front/action/style.scss delete mode 100644 modules/claim/front/basic-data/index.html delete mode 100644 modules/claim/front/basic-data/index.js delete mode 100644 modules/claim/front/basic-data/index.spec.js delete mode 100644 modules/claim/front/basic-data/locale/es.yml delete mode 100644 modules/claim/front/basic-data/style.scss delete mode 100644 modules/claim/front/card/index.html delete mode 100644 modules/claim/front/card/index.js delete mode 100644 modules/claim/front/card/index.spec.js delete mode 100644 modules/claim/front/detail/index.html delete mode 100644 modules/claim/front/detail/index.js delete mode 100644 modules/claim/front/detail/index.spec.js delete mode 100644 modules/claim/front/detail/locale/es.yml delete mode 100644 modules/claim/front/detail/style.scss delete mode 100644 modules/claim/front/development/index.html delete mode 100644 modules/claim/front/development/index.js delete mode 100644 modules/claim/front/index/index.html delete mode 100644 modules/claim/front/index/index.js delete mode 100644 modules/claim/front/log/index.html delete mode 100644 modules/claim/front/log/index.js delete mode 100644 modules/claim/front/note/create/index.html delete mode 100644 modules/claim/front/note/create/index.js delete mode 100644 modules/claim/front/note/index/index.html delete mode 100644 modules/claim/front/note/index/index.js delete mode 100644 modules/claim/front/note/index/style.scss delete mode 100644 modules/claim/front/photos/index.html delete mode 100644 modules/claim/front/photos/index.js delete mode 100644 modules/claim/front/search-panel/index.html delete mode 100644 modules/claim/front/search-panel/index.js delete mode 100644 modules/claim/front/search-panel/locale/es.yml delete mode 100644 modules/claim/front/summary/index.html delete mode 100644 modules/claim/front/summary/index.js delete mode 100644 modules/claim/front/summary/index.spec.js delete mode 100644 modules/claim/front/summary/style.scss diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 685345273..097c6e1ab 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -738,69 +738,6 @@ export default { worker: 'vn-worker-autocomplete[ng-model="$ctrl.userFk"]', saveStateButton: `button[type=submit]` }, - claimsIndex: { - searchResult: 'vn-claim-index vn-card > vn-table > div > vn-tbody > a' - }, - claimDescriptor: { - moreMenu: 'vn-claim-descriptor vn-icon-button[icon=more_vert]', - moreMenuDeleteClaim: '.vn-menu [name="deleteClaim"]', - acceptDeleteClaim: '.vn-confirm.shown button[response="accept"]' - }, - claimSummary: { - header: 'vn-claim-summary > vn-card > h5', - state: 'vn-claim-summary vn-label-value[label="State"] > section > span', - observation: 'vn-claim-summary vn-horizontal.text', - firstSaleItemId: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(1) > span', - firstSaleDescriptorImage: '.vn-popover.shown vn-item-descriptor img', - itemDescriptorPopover: '.vn-popover.shown vn-item-descriptor', - itemDescriptorPopoverItemDiaryButton: '.vn-popover vn-item-descriptor vn-quick-link[icon="icon-transaction"] > a', - firstDevelopmentWorker: 'vn-claim-summary vn-horizontal > vn-auto:nth-child(4) vn-table > div > vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(4) > span', - firstDevelopmentWorkerGoToClientButton: '.vn-popover vn-worker-descriptor vn-quick-link[icon="person"] > a', - firstActionTicketId: 'vn-claim-summary > vn-card > vn-horizontal > vn-auto:nth-child(5) vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > span', - firstActionTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor' - }, - claimBasicData: { - claimState: 'vn-claim-basic-data vn-autocomplete[ng-model="$ctrl.claim.claimStateFk"]', - packages: 'vn-input-number[ng-model="$ctrl.claim.packages"]', - saveButton: `button[type=submit]` - }, - claimDetail: { - secondItemDiscount: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(6) > span', - discount: '.vn-popover.shown vn-input-number[ng-model="$ctrl.newDiscount"]', - discoutPopoverMana: '.vn-popover.shown .content > div > vn-horizontal > h5', - addItemButton: 'vn-claim-detail a vn-float-button', - firstClaimableSaleFromTicket: '.vn-dialog.shown vn-tbody > vn-tr', - claimDetailLine: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr', - totalClaimed: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-horizontal > div > vn-label-value:nth-child(2) > section > span', - secondItemDeleteButton: 'vn-claim-detail > vn-vertical > vn-card > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(8) > vn-icon-button > button > vn-icon > i' - }, - claimDevelopment: { - addDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > vn-vertical > vn-one > vn-icon-button > button > vn-icon', - firstDeleteDevelopmentButton: 'vn-claim-development > vn-vertical > vn-card > vn-vertical > form > vn-horizontal:nth-child(2) > vn-icon-button > button > vn-icon', - firstClaimReason: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', - firstClaimResult: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', - firstClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', - firstClaimWorker: 'vn-claim-development vn-horizontal:nth-child(1) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]', - firstClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(1) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', - secondClaimReason: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimReasonFk"]', - secondClaimResult: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResultFk"]', - secondClaimResponsible: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimResponsibleFk"]', - secondClaimWorker: 'vn-claim-development vn-horizontal:nth-child(2) vn-worker-autocomplete[ng-model="claimDevelopment.workerFk"]', - secondClaimRedelivery: 'vn-claim-development vn-horizontal:nth-child(2) vn-autocomplete[ng-model="claimDevelopment.claimRedeliveryFk"]', - saveDevelopmentButton: 'button[type=submit]' - }, - claimNote: { - addNoteFloatButton: 'vn-float-button', - note: 'vn-textarea[ng-model="$ctrl.note.text"]', - saveButton: 'button[type=submit]', - firstNoteText: 'vn-claim-note .text' - }, - claimAction: { - importClaimButton: 'vn-claim-action vn-button[label="Import claim"]', - anyLine: 'vn-claim-action vn-tbody > vn-tr', - firstDeleteLine: 'vn-claim-action tr:nth-child(2) vn-icon-button[icon="delete"]', - isPaidWithManaCheckbox: 'vn-claim-action vn-check[ng-model="$ctrl.claim.isChargedToMana"]' - }, ordersIndex: { secondSearchResultTotal: 'vn-order-index vn-card > vn-table > div > vn-tbody .vn-tr:nth-child(2) vn-td:nth-child(9)', advancedSearchButton: 'vn-order-search-panel vn-submit[label="Search"]', diff --git a/e2e/paths/06-claim/01_basic_data.spec.js b/e2e/paths/06-claim/01_basic_data.spec.js deleted file mode 100644 index 33c68183f..000000000 --- a/e2e/paths/06-claim/01_basic_data.spec.js +++ /dev/null @@ -1,61 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Claim edit basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should log in as claimManager then reach basic data of the target claim`, async() => { - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult('1'); - await page.accessToSection('claim.card.basicData'); - }); - - it(`should edit claim state and observation fields`, async() => { - await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Resuelto'); - await page.clearInput(selectors.claimBasicData.packages); - await page.write(selectors.claimBasicData.packages, '2'); - await page.waitToClick(selectors.claimBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should have been redirected to the next section of claims as the role is claimManager`, async() => { - await page.waitForState('claim.card.detail'); - }); - - it('should confirm the claim state was edited', async() => { - await page.reloadSection('claim.card.basicData'); - await page.waitForSelector(selectors.claimBasicData.claimState); - const result = await page.waitToGetProperty(selectors.claimBasicData.claimState, 'value'); - - expect(result).toEqual('Resuelto'); - }); - - it('should confirm the claim packages was edited', async() => { - const result = await page - .waitToGetProperty(selectors.claimBasicData.packages, 'value'); - - expect(result).toEqual('2'); - }); - - it(`should edit the claim to leave it untainted`, async() => { - await page.autocompleteSearch(selectors.claimBasicData.claimState, 'Pendiente'); - await page.clearInput(selectors.claimBasicData.packages); - await page.write(selectors.claimBasicData.packages, '0'); - await page.waitToClick(selectors.claimBasicData.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/06-claim/03_claim_action.spec.js b/e2e/paths/06-claim/03_claim_action.spec.js deleted file mode 100644 index ac6f72e37..000000000 --- a/e2e/paths/06-claim/03_claim_action.spec.js +++ /dev/null @@ -1,54 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer.js'; - -describe('Claim action path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult('2'); - await page.accessToSection('claim.card.action'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should import the claim', async() => { - await page.waitToClick(selectors.claimAction.importClaimButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should delete the first line', async() => { - await page.waitToClick(selectors.claimAction.firstDeleteLine); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should refresh the view to check not have lines', async() => { - await page.reloadSection('claim.card.action'); - const result = await page.countElement(selectors.claimAction.anyLine); - - expect(result).toEqual(0); - }); - - it('should check the "is paid with mana" checkbox', async() => { - await page.waitToClick(selectors.claimAction.isPaidWithManaCheckbox); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the "is paid with mana" is checked', async() => { - await page.reloadSection('claim.card.action'); - const isPaidWithManaCheckbox = await page.checkboxState(selectors.claimAction.isPaidWithManaCheckbox); - - expect(isPaidWithManaCheckbox).toBe('checked'); - }); -}); diff --git a/e2e/paths/06-claim/04_summary.spec.js b/e2e/paths/06-claim/04_summary.spec.js deleted file mode 100644 index dda8484a6..000000000 --- a/e2e/paths/06-claim/04_summary.spec.js +++ /dev/null @@ -1,96 +0,0 @@ - -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer.js'; - -describe('Claim summary path', () => { - let browser; - let page; - const claimId = '4'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should navigate to the target claim summary section', async() => { - await page.loginAndModule('salesPerson', 'claim'); - await page.accessToSearchResult(claimId); - await page.waitForState('claim.card.summary'); - }); - - it(`should display details from the claim and it's client on the top of the header`, async() => { - await page.waitForTextInElement(selectors.claimSummary.header, 'Tony Stark'); - const result = await page.waitToGetProperty(selectors.claimSummary.header, 'innerText'); - - expect(result).toContain('4 -'); - expect(result).toContain('Tony Stark'); - }); - - it('should display the claim state', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.state, 'innerText'); - - expect(result).toContain('Resuelto'); - }); - - it('should display the observation', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'innerText'); - - expect(result).toContain('Wisi forensibus mnesarchum in cum. Per id impetus abhorreant'); - }); - - it('should display the claimed line(s)', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.firstSaleItemId, 'innerText'); - - expect(result).toContain('2'); - }); - - it(`should click on the first sale ID making the item descriptor visible`, async() => { - const firstItem = selectors.claimSummary.firstSaleItemId; - await page.evaluate(selectors => { - document.querySelector(selectors).scrollIntoView(); - }, firstItem); - await page.click(firstItem); - await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage); - const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover); - - expect(visible).toBeTruthy(); - }); - - it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => { - await page.waitForSelector(selectors.claimSummary.itemDescriptorPopoverItemDiaryButton, {visible: true}); - - await page.closePopup(); - }); - - it('should display the claim development details', async() => { - const result = await page.waitToGetProperty(selectors.claimSummary.firstDevelopmentWorker, 'innerText'); - - expect(result).toContain('salesAssistantNick'); - }); - - it(`should click on the first development worker making the worker descriptor visible`, async() => { - await page.waitToClick(selectors.claimSummary.firstDevelopmentWorker); - - const visible = await page.isVisible(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton); - - expect(visible).toBeTruthy(); - }); - - it(`should check the url for the go to clientlink of the descriptor is for the right client id`, async() => { - await page.waitForSelector(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton, {visible: true}); - - await page.closePopup(); - }); - - it(`should click on the first action ticket ID making the ticket descriptor visible`, async() => { - await page.waitToClick(selectors.claimSummary.firstActionTicketId); - await page.waitForSelector(selectors.claimSummary.firstActionTicketDescriptor); - const visible = await page.isVisible(selectors.claimSummary.firstActionTicketDescriptor); - - expect(visible).toBeTruthy(); - }); -}); diff --git a/e2e/paths/06-claim/05_descriptor.spec.js b/e2e/paths/06-claim/05_descriptor.spec.js deleted file mode 100644 index 49912b26a..000000000 --- a/e2e/paths/06-claim/05_descriptor.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer.js'; - -describe('Claim descriptor path', () => { - let browser; - let page; - const claimId = '1'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should now navigate to the target claim summary section', async() => { - await page.loginAndModule('salesPerson', 'claim'); - await page.accessToSearchResult(claimId); - await page.waitForState('claim.card.summary'); - }); - - it(`should not be able to see the delete claim button of the descriptor more menu`, async() => { - await page.waitToClick(selectors.claimDescriptor.moreMenu); - await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {hidden: true}); - }); - - it(`should log in as claimManager and navigate to the target claim`, async() => { - await page.loginAndModule('claimManager', 'claim'); - await page.accessToSearchResult(claimId); - await page.waitForState('claim.card.summary'); - }); - - it(`should be able to see the delete claim button of the descriptor more menu`, async() => { - await page.waitToClick(selectors.claimDescriptor.moreMenu); - await page.waitForSelector(selectors.claimDescriptor.moreMenuDeleteClaim, {visible: true}); - }); - - it(`should delete the claim`, async() => { - await page.waitToClick(selectors.claimDescriptor.moreMenuDeleteClaim); - await page.waitToClick(selectors.claimDescriptor.acceptDeleteClaim); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Claim deleted!'); - }); - - it(`should have been relocated to the claim index`, async() => { - await page.waitForState('claim.index'); - }); - - it(`should search for the deleted claim to find no results`, async() => { - await page.doSearch(claimId); - const nResults = await page.countElement(selectors.claimsIndex.searchResult); - - expect(nResults).toEqual(0); - }); -}); diff --git a/e2e/paths/06-claim/06_note.spec.js b/e2e/paths/06-claim/06_note.spec.js deleted file mode 100644 index 830f77cbe..000000000 --- a/e2e/paths/06-claim/06_note.spec.js +++ /dev/null @@ -1,46 +0,0 @@ -import selectors from '../../helpers/selectors'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Claim Add note path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesPerson', 'claim'); - await page.accessToSearchResult('2'); - await page.accessToSection('claim.card.note.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should reach the claim note index`, async() => { - await page.waitForState('claim.card.note.index'); - }); - - it(`should click on the add new note button`, async() => { - await page.waitToClick(selectors.claimNote.addNoteFloatButton); - await page.waitForState('claim.card.note.create'); - }); - - it(`should create a new note`, async() => { - await page.waitForSelector(selectors.claimNote.note); - await page.type(`${selectors.claimNote.note} textarea`, 'The delivery was unsuccessful'); - await page.waitToClick(selectors.claimNote.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should redirect back to the claim notes page`, async() => { - await page.waitForState('claim.card.note.index'); - }); - - it('should confirm the note was created', async() => { - const result = await page.waitToGetProperty(selectors.claimNote.firstNoteText, 'innerText'); - - expect(result).toEqual('The delivery was unsuccessful'); - }); -}); diff --git a/e2e/tests.js b/e2e/tests.js index 829056f4c..a9c662dc4 100644 --- a/e2e/tests.js +++ b/e2e/tests.js @@ -41,7 +41,6 @@ async function test() { `./e2e/paths/03*/*[sS]pec.js`, `./e2e/paths/04*/*[sS]pec.js`, `./e2e/paths/05*/*[sS]pec.js`, - `./e2e/paths/06*/*[sS]pec.js`, `./e2e/paths/07*/*[sS]pec.js`, `./e2e/paths/08*/*[sS]pec.js`, `./e2e/paths/09*/*[sS]pec.js`, diff --git a/modules/claim/front/action/index.html b/modules/claim/front/action/index.html deleted file mode 100644 index 9da51b8de..000000000 --- a/modules/claim/front/action/index.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - - - - - -
- - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - IdTicket - Destination - - Landed - - Quantity - - Description - - Price - - Disc. - Total
- - - - - {{::saleClaimed.itemFk}} - - - - {{::saleClaimed.ticketFk}} - - - - - {{::saleClaimed.landed | date: 'dd/MM/yyyy'}}{{::saleClaimed.quantity}}{{::saleClaimed.concept}}{{::saleClaimed.price | currency: 'EUR':2}}{{::saleClaimed.discount}} %{{saleClaimed.total | currency: 'EUR':2}} - - -
-
-
- - - - -
- - - - - - - - - - -
-
{{$ctrl.$t('Change destination to all selected rows', {total: $ctrl.checked.length})}}
- - - - -
-
- - - - -
diff --git a/modules/claim/front/action/index.js b/modules/claim/front/action/index.js deleted file mode 100644 index 10b629f27..000000000 --- a/modules/claim/front/action/index.js +++ /dev/null @@ -1,233 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.newDestination; - this.filter = { - include: [ - {relation: 'sale', - scope: { - fields: ['concept', 'ticketFk', 'price', 'quantity', 'discount', 'itemFk'], - include: { - relation: 'ticket' - } - } - }, - {relation: 'claimBeggining'}, - {relation: 'claimDestination'} - ] - }; - this.getResolvedState(); - this.maxResponsibility = 5; - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'claimDestinationFk', - autocomplete: { - url: 'ClaimDestinations', - showField: 'description', - valueField: 'id' - } - }, - { - field: 'landed', - searchable: false - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'itemFk': - case 'ticketFk': - case 'claimDestinationFk': - case 'quantity': - case 'price': - case 'discount': - case 'total': - return {[param]: value}; - case 'concept': - return {[param]: {like: `%${value}%`}}; - case 'landed': - return {[param]: {between: this.dateRange(value)}}; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - - get checked() { - const salesClaimed = this.$.model.data || []; - - const checkedSalesClaimed = []; - for (let saleClaimed of salesClaimed) { - if (saleClaimed.$checked) - checkedSalesClaimed.push(saleClaimed); - } - - return checkedSalesClaimed; - } - - updateDestination(saleClaimed, claimDestinationFk) { - const data = {rows: [saleClaimed], claimDestinationFk: claimDestinationFk}; - this.$http.post(`Claims/updateClaimDestination`, data).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }).catch(e => { - this.$.model.refresh(); - throw e; - }); - } - - removeSales(saleClaimed) { - const params = {sales: [saleClaimed]}; - this.$http.post(`ClaimEnds/deleteClamedSales`, params).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - getResolvedState() { - const query = `ClaimStates/findOne`; - const params = { - filter: { - where: { - code: 'resolved' - } - } - }; - this.$http.get(query, params).then(res => - this.resolvedStateId = res.data.id - ); - } - - importToNewRefundTicket() { - let query = `ClaimBeginnings/${this.$params.id}/importToNewRefundTicket`; - return this.$http.post(query).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - focusLastInput() { - let inputs = document.querySelectorAll('#claimDestinationFk'); - inputs[inputs.length - 1].querySelector('input').focus(); - this.calculateTotals(); - } - - calculateTotals() { - this.claimedTotal = 0; - this.salesClaimed.forEach(sale => { - const price = sale.quantity * sale.price; - const discount = (sale.discount * (sale.quantity * sale.price)) / 100; - this.claimedTotal += price - discount; - }); - } - - regularize() { - const query = `Claims/${this.$params.id}/regularizeClaim`; - return this.$http.post(query).then(() => { - if (this.claim.responsibility >= Math.ceil(this.maxResponsibility) / 2) - this.$.updateGreuge.show(); - else - this.vnApp.showSuccess(this.$t('Data saved!')); - - this.card.reload(); - }); - } - - getGreugeTypeId() { - const params = {filter: {where: {code: 'freightPickUp'}}}; - const query = `GreugeTypes/findOne`; - return this.$http.get(query, {params}).then(res => { - this.greugeTypeFreightId = res.data.id; - - return res; - }); - } - - getGreugeConfig() { - const query = `GreugeConfigs/findOne`; - return this.$http.get(query).then(res => { - this.freightPickUpPrice = res.data.freightPickUpPrice; - - return res; - }); - } - - onUpdateGreugeAccept() { - const promises = []; - promises.push(this.getGreugeTypeId()); - promises.push(this.getGreugeConfig()); - - return Promise.all(promises).then(() => { - return this.updateGreuge({ - clientFk: this.claim.clientFk, - description: this.$t('ClaimGreugeDescription', { - claimId: this.claim.id - }).toUpperCase(), - amount: this.freightPickUpPrice, - greugeTypeFk: this.greugeTypeFreightId, - ticketFk: this.claim.ticketFk - }); - }); - } - - updateGreuge(data) { - return this.$http.post(`Greuges`, data).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.vnApp.showMessage(this.$t('Greuge added')); - }); - } - - save(data) { - const query = `Claims/${this.$params.id}/updateClaimAction`; - this.$http.patch(query, data) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))); - } - - onSave() { - this.vnApp.showSuccess(this.$t('Data saved!')); - } - - onResponse() { - const rowsToEdit = []; - for (let row of this.checked) - rowsToEdit.push({id: row.id}); - - const data = { - rows: rowsToEdit, - claimDestinationFk: this.newDestination - }; - - const query = `Claims/updateClaimDestination`; - this.$http.post(query, data) - .then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } -} - -ngModule.vnComponent('vnClaimAction', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - }, - require: { - card: '^vnClaimCard' - } -}); diff --git a/modules/claim/front/action/index.spec.js b/modules/claim/front/action/index.spec.js deleted file mode 100644 index e773511bf..000000000 --- a/modules/claim/front/action/index.spec.js +++ /dev/null @@ -1,167 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('claim', () => { - describe('Component vnClaimAction', () => { - let controller; - let $httpBackend; - let $state; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$state_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $state = _$state_; - $state.params.id = 1; - - controller = $componentController('vnClaimAction', {$element: null}); - controller.claim = {ticketFk: 1}; - controller.$.model = {refresh: () => {}}; - controller.$.addSales = { - hide: () => {}, - show: () => {} - }; - controller.$.lastTicketsModel = crudModel; - controller.$.lastTicketsPopover = { - hide: () => {}, - show: () => {} - }; - controller.card = {reload: () => {}}; - $httpBackend.expectGET(`ClaimStates/findOne`).respond({}); - })); - - describe('getResolvedState()', () => { - it('should return the resolved state id', () => { - $httpBackend.expectGET(`ClaimStates/findOne`).respond({id: 1}); - controller.getResolvedState(); - $httpBackend.flush(); - - expect(controller.resolvedStateId).toEqual(1); - }); - }); - - describe('calculateTotals()', () => { - it('should calculate the total price of the items claimed', () => { - controller.salesClaimed = [ - {quantity: 5, price: 2, discount: 0}, - {quantity: 10, price: 2, discount: 0}, - {quantity: 10, price: 2, discount: 0} - ]; - controller.calculateTotals(); - - expect(controller.claimedTotal).toEqual(50); - }); - }); - - describe('importToNewRefundTicket()', () => { - it('should perform a post query and add lines from a new ticket', () => { - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expect('POST', `ClaimBeginnings/1/importToNewRefundTicket`).respond({}); - controller.importToNewRefundTicket(); - $httpBackend.flush(); - - expect(controller.$.model.refresh).toHaveBeenCalled(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('regularize()', () => { - it('should perform a post query and reload the claim card', () => { - jest.spyOn(controller.card, 'reload'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expect('POST', `Claims/1/regularizeClaim`).respond({}); - controller.regularize(); - $httpBackend.flush(); - - expect(controller.card.reload).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('save()', () => { - it('should perform a patch query and show a success message', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const data = {pickup: 'agency'}; - $httpBackend.expect('PATCH', `Claims/1/updateClaimAction`, data).respond({}); - controller.save(data); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onUpdateGreugeAccept()', () => { - const greugeTypeId = 7; - const freightPickUpPrice = 11; - - it('should make a query and get the greugeTypeId and greuge config', () => { - $httpBackend.expectRoute('GET', `GreugeTypes/findOne`).respond({id: greugeTypeId}); - $httpBackend.expectGET(`GreugeConfigs/findOne`).respond({freightPickUpPrice}); - controller.onUpdateGreugeAccept(); - $httpBackend.flush(); - - expect(controller.greugeTypeFreightId).toEqual(greugeTypeId); - expect(controller.freightPickUpPrice).toEqual(freightPickUpPrice); - }); - - it('should perform a insert into greuges', done => { - jest.spyOn(controller, 'getGreugeTypeId').mockReturnValue(new Promise(resolve => { - return resolve({id: greugeTypeId}); - })); - jest.spyOn(controller, 'getGreugeConfig').mockReturnValue(new Promise(resolve => { - return resolve({freightPickUpPrice}); - })); - jest.spyOn(controller, 'updateGreuge').mockReturnValue(new Promise(resolve => { - return resolve(true); - })); - - controller.claim.clientFk = 1101; - controller.claim.id = 11; - - controller.onUpdateGreugeAccept().then(() => { - expect(controller.updateGreuge).toHaveBeenCalledWith(jasmine.any(Object)); - done(); - }).catch(done.fail); - }); - }); - - describe('updateGreuge()', () => { - it('should make a query and then call to showSuccess() and showMessage() methods', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.vnApp, 'showMessage'); - - const freightPickUpPrice = 11; - const greugeTypeId = 7; - const expectedData = { - clientFk: 1101, - description: `claim: ${controller.claim.id}`, - amount: freightPickUpPrice, - greugeTypeFk: greugeTypeId, - ticketFk: controller.claim.ticketFk - }; - $httpBackend.expect('POST', `Greuges`, expectedData).respond(200); - controller.updateGreuge(expectedData); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Greuge added'); - }); - }); - - describe('onResponse()', () => { - it('should perform a post query and show a success message', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - $httpBackend.expect('POST', `Claims/updateClaimDestination`).respond({}); - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/claim/front/action/locale/en.yml b/modules/claim/front/action/locale/en.yml deleted file mode 100644 index faab67c06..000000000 --- a/modules/claim/front/action/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -ClaimGreugeDescription: Claim id {{claimId}} \ No newline at end of file diff --git a/modules/claim/front/action/locale/es.yml b/modules/claim/front/action/locale/es.yml deleted file mode 100644 index 97640d9dc..000000000 --- a/modules/claim/front/action/locale/es.yml +++ /dev/null @@ -1,13 +0,0 @@ -Destination: Destino -Action: Actuaciones -Total claimed: Total Reclamado -Import claim: Importar reclamacion -Imports claim details: Importa detalles de la reclamacion -Regularize: Regularizar -Do you want to insert greuges?: Desea insertar greuges? -Insert greuges on client card: Insertar greuges en la ficha del cliente -Greuge added: Greuge añadido -ClaimGreugeDescription: Reclamación id {{claimId}} -Change destination: Cambiar destino -Change destination to all selected rows: Cambiar destino a {{total}} fila(s) seleccionada(s) -Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s) diff --git a/modules/claim/front/action/style.scss b/modules/claim/front/action/style.scss deleted file mode 100644 index cda6779c8..000000000 --- a/modules/claim/front/action/style.scss +++ /dev/null @@ -1,46 +0,0 @@ -vn-claim-action { - .header { - display: flex; - justify-content: space-between; - align-items: center; - align-content: center; - - vn-tool-bar { - flex: none - } - - .vn-check { - flex: none; - } - } - - vn-dialog[vn-id=addSales] { - tpl-body { - width: 950px; - div { - div.buttons { - display: none; - } - vn-table{ - min-width: 950px; - } - } - } - } - - vn-popover.lastTicketsPopover { - vn-table { - min-width: 650px; - overflow: auto - } - - div.ticketList { - overflow: auto; - max-height: 350px; - } - } - - .right { - margin-left: 370px; - } -} \ No newline at end of file diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html deleted file mode 100644 index 45bc1823d..000000000 --- a/modules/claim/front/basic-data/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/claim/front/basic-data/index.js b/modules/claim/front/basic-data/index.js deleted file mode 100644 index 818012bb9..000000000 --- a/modules/claim/front/basic-data/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - onSubmit() { - this.$.watcher.submit().then(() => { - if (this.aclService.hasAny(['claimManager'])) - this.$state.go('claim.card.detail'); - }); - } -} - -ngModule.vnComponent('vnClaimBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/basic-data/index.spec.js b/modules/claim/front/basic-data/index.spec.js deleted file mode 100644 index 638f88418..000000000 --- a/modules/claim/front/basic-data/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; - -describe('Claim', () => { - describe('Component vnClaimBasicData', () => { - let controller; - let $scope; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $scope.watcher = watcher; - const $element = angular.element(''); - controller = $componentController('vnClaimBasicData', {$element, $scope}); - })); - - describe('onSubmit()', () => { - it(`should redirect to 'claim.card.detail' state`, () => { - jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true); - jest.spyOn(controller.$state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('claim.card.detail'); - }); - }); - }); -}); diff --git a/modules/claim/front/basic-data/locale/es.yml b/modules/claim/front/basic-data/locale/es.yml deleted file mode 100644 index 5250d266c..000000000 --- a/modules/claim/front/basic-data/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Contact: Contacto -Claim state: Estado de la reclamación -Is paid with mana: Cargado al maná -Responsability: Responsabilidad -Company: Empresa -Sales/Client: Comercial/Cliente -Pick up: Recoger -When checked will notify to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial -Packages received: Bultos recibidos diff --git a/modules/claim/front/basic-data/style.scss b/modules/claim/front/basic-data/style.scss deleted file mode 100644 index e80361ca8..000000000 --- a/modules/claim/front/basic-data/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -vn-claim-basic-data vn-date-picker { - padding-left: 80px; -} diff --git a/modules/claim/front/card/index.html b/modules/claim/front/card/index.html deleted file mode 100644 index 1db6b38db..000000000 --- a/modules/claim/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js deleted file mode 100644 index 5dad0dfc2..000000000 --- a/modules/claim/front/card/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['name'] - } - } - } - }, { - relation: 'ticket', - scope: { - fields: ['zoneFk', 'addressFk'], - include: [ - { - relation: 'zone', - scope: { - fields: ['name'] - } - }, - { - relation: 'address', - scope: { - fields: ['provinceFk'], - include: { - relation: 'province', - scope: { - fields: ['name'] - } - } - } - }] - } - }, { - relation: 'claimState', - scope: { - fields: ['id', 'description'] - } - }, { - relation: 'client', - scope: { - fields: ['salesPersonFk', 'name', 'email'], - include: { - relation: 'salesPersonUser' - } - } - } - ] - }; - - this.$http.get(`Claims/${this.$params.id}`, {filter}) - .then(res => this.claim = res.data); - } -} - -ngModule.vnComponent('vnClaimCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/card/index.spec.js b/modules/claim/front/card/index.spec.js deleted file mode 100644 index aa796c1e3..000000000 --- a/modules/claim/front/card/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import './index.js'; - -describe('Claim', () => { - describe('Component vnClaimCard', () => { - let controller; - let $httpBackend; - let data = {id: 1, name: 'fooName'}; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$httpBackend_, $stateParams) => { - $httpBackend = _$httpBackend_; - - let $element = angular.element('
'); - controller = $componentController('vnClaimCard', {$element}); - - $stateParams.id = data.id; - $httpBackend.whenRoute('GET', 'Claims/:id').respond(data); - })); - - it('should request data and set it on the controller', () => { - controller.reload(); - $httpBackend.flush(); - - expect(controller.claim).toEqual(data); - }); - }); -}); - diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 5e9ea5140..337233059 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -29,9 +29,9 @@ class Controller extends Descriptor { deleteClaim() { return this.$http.delete(`Claims/${this.claim.id}`) - .then(() => { + .then(async() => { this.vnApp.showSuccess(this.$t('Claim deleted!')); - this.$state.go('claim.index'); + window.location.href = await this.vnApp.getUrl(`claim/`); }); } } diff --git a/modules/claim/front/detail/index.html b/modules/claim/front/detail/index.html deleted file mode 100644 index a2a08a5db..000000000 --- a/modules/claim/front/detail/index.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - - - - - - - - - Landed - Quantity - Claimed - Description - Price - Disc. - Total - - - - - - {{::saleClaimed.sale.ticket.landed | date:'dd/MM/yyyy'}} - {{::saleClaimed.sale.quantity}} - - - - - - - {{::saleClaimed.sale.concept}} - - - {{::saleClaimed.sale.price | currency: 'EUR':2}} - - - {{saleClaimed.sale.discount}} % - - - - {{$ctrl.getSaleTotal(saleClaimed.sale) | currency: 'EUR':2}} - - - - - - - - - - - - - - - - - - Claimable sales from ticket {{$ctrl.claim.ticketFk}} - - - - - - - Landed - Quantity - Description - Price - Disc. - Total - - - - - {{sale.landed | date: 'dd/MM/yyyy'}} - {{sale.quantity}} - - - {{sale.itemFk}} - {{sale.concept}} - - - {{sale.price | currency: 'EUR':2}} - {{sale.discount}} % - - {{(sale.quantity * sale.price) - ((sale.discount * (sale.quantity * sale.price))/100) | currency: 'EUR':2}} - - - - - - - - - - -
- - -
- -
MANÁ: {{$ctrl.mana | currency: 'EUR':0}}
-
-
- - -
-

Total claimed price

-

{{$ctrl.newPrice | currency: 'EUR':2}} -

-
-
-
-
-
- - \ No newline at end of file diff --git a/modules/claim/front/detail/index.js b/modules/claim/front/detail/index.js deleted file mode 100644 index 56f39e074..000000000 --- a/modules/claim/front/detail/index.js +++ /dev/null @@ -1,203 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.edit = {}; - this.filter = { - where: {claimFk: this.$params.id}, - include: [ - { - relation: 'sale', - scope: { - fields: ['concept', 'ticketFk', 'price', 'quantity', 'discount', 'itemFk'], - include: { - relation: 'ticket' - } - } - } - ] - }; - } - - get claim() { - return this._claim; - } - - set claim(value) { - this._claim = value; - - if (value) { - this.isClaimEditable(); - this.isTicketEditable(); - } - } - - set salesClaimed(value) { - this._salesClaimed = value; - - if (value) this.calculateTotals(); - } - - get salesClaimed() { - return this._salesClaimed; - } - - get newDiscount() { - return this._newDiscount; - } - - set newDiscount(value) { - this._newDiscount = value; - this.updateNewPrice(); - } - - get isClaimManager() { - return this.aclService.hasAny(['claimManager']); - } - - openAddSalesDialog() { - this.getClaimableFromTicket(); - this.$.addSales.show(); - } - - getClaimableFromTicket() { - let config = {params: {ticketFk: this.claim.ticketFk}}; - let query = `Sales/getClaimableFromTicket`; - this.$http.get(query, config).then(res => { - if (res.data) - this.salesToClaim = res.data; - }); - } - - addClaimedSale(index) { - let sale = this.salesToClaim[index]; - let saleToAdd = {saleFk: sale.saleFk, claimFk: this.claim.id, quantity: sale.quantity}; - let query = `ClaimBeginnings/`; - this.$http.post(query, saleToAdd).then(() => { - this.$.addSales.hide(); - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - - if (this.aclService.hasAny(['claimManager'])) - this.$state.go('claim.card.development'); - }); - } - - showDeleteConfirm($index) { - this.claimedIndex = $index; - this.$.confirm.show(); - } - - deleteClaimedSale() { - this.$.model.remove(this.claimedIndex); - this.$.model.save().then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.calculateTotals(); - }); - } - - setClaimedQuantity(id, claimedQuantity) { - let params = {quantity: claimedQuantity}; - let query = `ClaimBeginnings/${id}`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.calculateTotals(); - }); - } - - calculateTotals() { - this.paidTotal = 0.0; - this.claimedTotal = 0.0; - if (!this._salesClaimed) return; - - this._salesClaimed.forEach(sale => { - let orgSale = sale.sale; - this.paidTotal += this.getSaleTotal(orgSale); - - const price = sale.quantity * orgSale.price; - const discount = ((orgSale.discount * price) / 100); - - this.claimedTotal += price - discount; - }); - } - - getSaleTotal(sale) { - let total = 0.0; - - const price = sale.quantity * sale.price; - const discount = ((sale.discount * price) / 100); - - total += price - discount; - return total; - } - - getSalespersonMana() { - this.$http.get(`Tickets/${this.claim.ticketFk}/getSalesPersonMana`).then(res => { - this.mana = res.data; - }); - } - - isTicketEditable() { - if (!this.claim) return; - - this.$http.get(`Tickets/${this.claim.ticketFk}/isEditable`).then(res => { - this.isEditable = res.data; - }); - } - - isClaimEditable() { - if (!this.claim) return; - - this.$http.get(`ClaimStates/${this.claim.claimStateFk}/isEditable`).then(res => { - this.isRewritable = res.data; - }); - } - - showEditPopover(event, saleClaimed) { - if (this.aclService.hasAny(['claimManager'])) { - this.saleClaimed = saleClaimed; - this.$.editPopover.parent = event.target; - this.$.editPopover.show(); - } - } - - updateDiscount() { - const claimedSale = this.saleClaimed.sale; - if (this.newDiscount != claimedSale.discount) { - const params = {salesIds: [claimedSale.id], newDiscount: this.newDiscount}; - const query = `Tickets/${claimedSale.ticketFk}/updateDiscount`; - - this.$http.post(query, params).then(() => { - claimedSale.discount = this.newDiscount; - this.calculateTotals(); - this.clearDiscount(); - - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - this.$.editPopover.hide(); - } - - updateNewPrice() { - this.newPrice = (this.saleClaimed.quantity * this.saleClaimed.sale.price) - - ((this.newDiscount * (this.saleClaimed.quantity * this.saleClaimed.sale.price)) / 100); - } - - clearDiscount() { - this.newDiscount = null; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnClaimDetail', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/detail/index.spec.js b/modules/claim/front/detail/index.spec.js deleted file mode 100644 index 1ef779fd7..000000000 --- a/modules/claim/front/detail/index.spec.js +++ /dev/null @@ -1,150 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('claim', () => { - describe('Component vnClaimDetail', () => { - let $scope; - let controller; - let $httpBackend; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $scope = $rootScope.$new(); - $scope.descriptor = { - show: () => {} - }; - $httpBackend = _$httpBackend_; - $httpBackend.whenGET('Claims/ClaimBeginnings').respond({}); - $httpBackend.whenGET(`Tickets/1/isEditable`).respond(true); - $httpBackend.whenGET(`ClaimStates/2/isEditable`).respond(true); - const $element = angular.element(''); - controller = $componentController('vnClaimDetail', {$element, $scope}); - controller.claim = { - ticketFk: 1, - id: 2, - claimStateFk: 2} - ; - controller.salesToClaim = [{saleFk: 1}, {saleFk: 2}]; - controller.salesClaimed = [{id: 1, sale: {}}]; - controller.$.model = crudModel; - controller.$.addSales = { - hide: () => {}, - show: () => {} - }; - controller.$.editPopover = { - hide: () => {} - }; - jest.spyOn(controller.aclService, 'hasAny').mockReturnValue(true); - })); - - describe('openAddSalesDialog()', () => { - it('should call getClaimableFromTicket and $.addSales.show', () => { - jest.spyOn(controller, 'getClaimableFromTicket'); - jest.spyOn(controller.$.addSales, 'show'); - controller.openAddSalesDialog(); - - expect(controller.getClaimableFromTicket).toHaveBeenCalledWith(); - expect(controller.$.addSales.show).toHaveBeenCalledWith(); - }); - }); - - describe('getClaimableFromTicket()', () => { - it('should make a query and set salesToClaim', () => { - $httpBackend.expectGET(`Sales/getClaimableFromTicket?ticketFk=1`).respond(200, 1); - controller.getClaimableFromTicket(); - $httpBackend.flush(); - - expect(controller.salesToClaim).toEqual(1); - }); - }); - - describe('addClaimedSale(index)', () => { - it('should make a post and call refresh, hide and showSuccess', () => { - jest.spyOn(controller.$.addSales, 'hide'); - jest.spyOn(controller.$state, 'go'); - $httpBackend.expectPOST(`ClaimBeginnings/`).respond({}); - controller.addClaimedSale(1); - $httpBackend.flush(); - - expect(controller.$.addSales.hide).toHaveBeenCalledWith(); - expect(controller.$state.go).toHaveBeenCalledWith('claim.card.development'); - }); - }); - - describe('deleteClaimedSale()', () => { - it('should make a delete and call refresh and showSuccess', () => { - const claimedIndex = 1; - controller.claimedIndex = claimedIndex; - jest.spyOn(controller.$.model, 'remove'); - jest.spyOn(controller.$.model, 'save'); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.deleteClaimedSale(); - - expect(controller.$.model.remove).toHaveBeenCalledWith(claimedIndex); - expect(controller.$.model.save).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('setClaimedQuantity(id, claimedQuantity)', () => { - it('should make a patch and call refresh and showSuccess', () => { - const id = 1; - const claimedQuantity = 1; - - jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.expectPATCH(`ClaimBeginnings/${id}`).respond({}); - controller.setClaimedQuantity(id, claimedQuantity); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('calculateTotals()', () => { - it('should set paidTotal and claimedTotal to 0 if salesClaimed has no data', () => { - controller.salesClaimed = []; - controller.calculateTotals(); - - expect(controller.paidTotal).toEqual(0); - expect(controller.claimedTotal).toEqual(0); - }); - }); - - describe('updateDiscount()', () => { - it('should perform a query if the new discount differs from the claim discount', () => { - controller.saleClaimed = {sale: { - discount: 5, - id: 7, - ticketFk: 1, - price: 2, - quantity: 10}}; - controller.newDiscount = 10; - - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller, 'calculateTotals'); - jest.spyOn(controller, 'clearDiscount'); - jest.spyOn(controller.$.editPopover, 'hide'); - - $httpBackend.when('POST', 'Tickets/1/updateDiscount').respond({}); - controller.updateDiscount(); - $httpBackend.flush(); - - expect(controller.calculateTotals).toHaveBeenCalledWith(); - expect(controller.clearDiscount).toHaveBeenCalledWith(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.editPopover.hide).toHaveBeenCalledWith(); - }); - }); - - describe('isTicketEditable()', () => { - it('should check if the ticket assigned to the claim is editable', () => { - controller.isTicketEditable(); - $httpBackend.flush(); - - expect(controller.isEditable).toBeTruthy(); - }); - }); - }); -}); diff --git a/modules/claim/front/detail/locale/es.yml b/modules/claim/front/detail/locale/es.yml deleted file mode 100644 index 53f9e9b1d..000000000 --- a/modules/claim/front/detail/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Claimed: Reclamados -Disc.: Dto. -Attended by: Atendida por -Landed: F. entrega -Price: Precio -Claimable sales from ticket: Lineas reclamables del ticket -Detail: Detalles -Add sale item: Añadir artículo -Insuficient permisos: Permisos insuficientes -Total claimed price: Precio total reclamado -Delete sale from claim?: ¿Borrar la linea de la reclamación? \ No newline at end of file diff --git a/modules/claim/front/detail/style.scss b/modules/claim/front/detail/style.scss deleted file mode 100644 index 470c83034..000000000 --- a/modules/claim/front/detail/style.scss +++ /dev/null @@ -1,30 +0,0 @@ -@import "variables"; - -.vn-popover .discount-popover { - width: 256px; - - .header { - background-color: $color-main; - color: $color-font-dark; - - h5 { - color: inherit; - margin: 0 auto; - } - } - .simulatorTitle { - margin-bottom: 0; - font-size: .75rem; - color: $color-main; - } - vn-label-value { - padding-bottom: 20px; - } - .simulator{ - text-align: center; - } -} - -.next{ - float: right; -} diff --git a/modules/claim/front/development/index.html b/modules/claim/front/development/index.html deleted file mode 100644 index 7fb3b870e..000000000 --- a/modules/claim/front/development/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/claim/front/development/index.js b/modules/claim/front/development/index.js deleted file mode 100644 index 7b31bd17f..000000000 --- a/modules/claim/front/development/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - this.$state.go('claim.card.summary', {id: this.$params.id}); - window.location.href = await this.vnApp.getUrl(`claim/${this.$params.id}/development`); - } -} - -ngModule.vnComponent('vnClaimDevelopment', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/index.js b/modules/claim/front/index.js index 473f6a4d3..16397df28 100644 --- a/modules/claim/front/index.js +++ b/modules/claim/front/index.js @@ -1,16 +1,4 @@ export * from './module'; import './main'; -import './index/'; -import './action'; -import './basic-data'; -import './card'; -import './detail'; import './descriptor'; -import './development'; -import './search-panel'; -import './summary'; -import './photos'; -import './log'; -import './note/index'; -import './note/create'; diff --git a/modules/claim/front/index/index.html b/modules/claim/front/index/index.html deleted file mode 100644 index 6b2481429..000000000 --- a/modules/claim/front/index/index.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Id - - Client - - Created - - Worker - - State -
{{::claim.id}} - - {{::claim.clientName}} - - {{::claim.created | date:'dd/MM/yyyy'}} - - {{::claim.workerName}} - - - - {{::claim.stateDescription}} - - - - -
-
-
-
- - - - - - - - diff --git a/modules/claim/front/index/index.js b/modules/claim/front/index/index.js deleted file mode 100644 index e3fdabf79..000000000 --- a/modules/claim/front/index/index.js +++ /dev/null @@ -1,82 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'clientName', - autocomplete: { - url: 'Clients', - showField: 'name', - valueField: 'name' - } - }, - { - field: 'workerFk', - autocomplete: { - url: 'Workers/activeWithInheritedRole', - where: `{role: 'salesPerson'}`, - searchFunction: '{firstName: $search}', - showField: 'name', - valueField: 'id', - } - }, - { - field: 'claimStateFk', - autocomplete: { - url: 'ClaimStates', - showField: 'description', - valueField: 'id', - } - }, - { - field: 'created', - searchable: false - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'clientName': - return {'cl.clientName': {like: `%${value}%`}}; - case 'clientFk': - case 'claimStateFk': - case 'workerFk': - return {[`cl.${param}`]: value}; - } - } - - stateColor(code) { - switch (code) { - case 'pending': - return 'warning'; - case 'managed': - return 'notice'; - case 'resolved': - return 'success'; - } - } - - preview(claim) { - this.claimSelected = claim; - this.$.summary.show(); - } - - reload() { - this.$.model.refresh(); - } -} - -ngModule.vnComponent('vnClaimIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/log/index.html b/modules/claim/front/log/index.html deleted file mode 100644 index 500a626d6..000000000 --- a/modules/claim/front/log/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/modules/claim/front/log/index.js b/modules/claim/front/log/index.js deleted file mode 100644 index 0143a612b..000000000 --- a/modules/claim/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnClaimLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/claim/front/main/index.html b/modules/claim/front/main/index.html index f38cc573f..e69de29bb 100644 --- a/modules/claim/front/main/index.html +++ b/modules/claim/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/claim/front/main/index.js b/modules/claim/front/main/index.js index 0c5c7d728..cbbbe0c7e 100644 --- a/modules/claim/front/main/index.js +++ b/modules/claim/front/main/index.js @@ -1,7 +1,18 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; +export default class Claim extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`Claim/`); + } +} + ngModule.vnComponent('vnClaim', { - controller: ModuleMain, + controller: Claim, template: require('./index.html') }); + diff --git a/modules/claim/front/note/create/index.html b/modules/claim/front/note/create/index.html deleted file mode 100644 index 8a882a4f5..000000000 --- a/modules/claim/front/note/create/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - -
- - - - - - - - - - - - -
diff --git a/modules/claim/front/note/create/index.js b/modules/claim/front/note/create/index.js deleted file mode 100644 index 40ae9309b..000000000 --- a/modules/claim/front/note/create/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.note = { - claimFk: parseInt(this.$params.id), - workerFk: window.localStorage.currentUserWorkerId, - text: null - }; - } - - cancel() { - this.$state.go('claim.card.note.index', {id: this.$params.id}); - } -} - -ngModule.vnComponent('vnClaimNoteCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/note/index/index.html b/modules/claim/front/note/index/index.html deleted file mode 100644 index 8ffe19c2b..000000000 --- a/modules/claim/front/note/index/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -
- - {{::note.worker.firstName}} {{::note.worker.lastName}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
-
- - - \ No newline at end of file diff --git a/modules/claim/front/note/index/index.js b/modules/claim/front/note/index/index.js deleted file mode 100644 index 5a2fd96d3..000000000 --- a/modules/claim/front/note/index/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - order: 'created DESC', - }; - this.include = { - relation: 'worker', - scope: { - fields: ['id', 'firstName', 'lastName'] - } - }; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnClaimNote', { - template: require('./index.html'), - controller: Controller, -}); diff --git a/modules/claim/front/note/index/style.scss b/modules/claim/front/note/index/style.scss deleted file mode 100644 index 44ae2cee7..000000000 --- a/modules/claim/front/note/index/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -vn-client-note { - .note:last-child { - margin-bottom: 0; - } -} \ No newline at end of file diff --git a/modules/claim/front/photos/index.html b/modules/claim/front/photos/index.html deleted file mode 100644 index 8b1378917..000000000 --- a/modules/claim/front/photos/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/claim/front/photos/index.js b/modules/claim/front/photos/index.js deleted file mode 100644 index c9fada9a4..000000000 --- a/modules/claim/front/photos/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - const url = await this.vnApp.getUrl(`claim/${this.$params.id}/photos`); - window.location.href = url; - } -} - -ngModule.vnComponent('vnClaimPhotos', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<' - } -}); diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html deleted file mode 100644 index 260f86801..000000000 --- a/modules/claim/front/search-panel/index.html +++ /dev/null @@ -1,84 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - {{description}} - - - - - - - {{::id}} - {{::name}} - - - - - - - - - - -
-
diff --git a/modules/claim/front/search-panel/index.js b/modules/claim/front/search-panel/index.js deleted file mode 100644 index 2400b8ede..000000000 --- a/modules/claim/front/search-panel/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } -} -ngModule.vnComponent('vnClaimSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/claim/front/search-panel/locale/es.yml b/modules/claim/front/search-panel/locale/es.yml deleted file mode 100644 index 1f892a742..000000000 --- a/modules/claim/front/search-panel/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Ticket id: Id ticket -Client id: Id cliente -Nickname: Alias -From: Desde -To: Hasta -Agency: Agencia -Warehouse: Almacén \ No newline at end of file diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html deleted file mode 100644 index b5225e6f4..000000000 --- a/modules/claim/front/summary/index.html +++ /dev/null @@ -1,273 +0,0 @@ - - - -
- - - - {{::$ctrl.summary.claim.id}} - {{::$ctrl.summary.claim.client.name}} - - -
- - -

- - Basic data - -

- - - - - - - - -
- -

- - Observations - -

-

- Observations -

-
- - {{::note.worker.firstName}} {{::note.worker.lastName}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
- -

- - Detail - -

-

- Detail -

- - - - - Item - Landed - Quantity - Claimed - Description - Price - Disc. - Total - - - - - - - {{::saleClaimed.sale.itemFk}} - - - {{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}} - {{::saleClaimed.sale.quantity}} - {{::saleClaimed.quantity}} - {{::saleClaimed.sale.concept}} - {{::saleClaimed.sale.price | currency: 'EUR':2}} - {{::saleClaimed.sale.discount}} % - - {{saleClaimed.sale.quantity * saleClaimed.sale.price * - ((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}} - - - - - -
- -

Photos

- -
-
-
- -
-
-
- -

- - Development - -

-

- Development -

- - - - - Reason - Result - Responsible - Worker - Redelivery - - - - - {{::development.claimReason.description}} - {{::development.claimResult.description}} - {{::development.claimResponsible.description}} - - - {{::development.worker.user.nickname}} - - - {{::development.claimRedelivery.description}} - - - - -
- -

- - Action - -

-

- Action -

- - - - - - - - - - - Item - Ticket - Destination - Landed - Quantity - Description - Price - Disc. - Total - - - - - - - {{::action.sale.itemFk}} - - - - - {{::action.sale.ticket.id}} - - - {{::action.claimBeggining.description}} - {{::action.sale.ticket.landed | date: 'dd/MM/yyyy'}} - {{::action.sale.quantity}} - {{::action.sale.concept}} - {{::action.sale.price}} - {{::action.sale.discount}} % - - {{action.sale.quantity * action.sale.price * - ((100 - action.sale.discount) / 100) | currency: 'EUR':2}} - - - - - -
-
-
- - - - - - diff --git a/modules/claim/front/summary/index.js b/modules/claim/front/summary/index.js deleted file mode 100644 index 7cd4805e9..000000000 --- a/modules/claim/front/summary/index.js +++ /dev/null @@ -1,103 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; -import './style.scss'; - -class Controller extends Summary { - constructor($element, $, vnFile) { - super($element, $); - this.vnFile = vnFile; - this.filter = { - include: [ - { - relation: 'dms' - } - ] - }; - } - - $onChanges() { - if (this.claim && this.claim.id) - this.loadData(); - } - - loadData() { - return this.$http.get(`Claims/${this.claim.id}/getSummary`).then(res => { - if (res && res.data) - this.summary = res.data; - }); - } - - reload() { - this.loadData() - .then(() => { - if (this.card) - this.card.reload(); - - if (this.parentReload) - this.parentReload(); - }); - } - - get isSalesPerson() { - return this.aclService.hasAny(['salesPerson']); - } - - get isClaimManager() { - return this.aclService.hasAny(['claimManager']); - } - - get claim() { - return this._claim; - } - - set claim(value) { - this._claim = value; - - // Get DMS on summary load - if (value) { - this.$.$applyAsync(() => this.loadDms()); - this.loadData(); - } - } - - loadDms() { - this.$.model.where = { - claimFk: this.claim.id - }; - this.$.model.refresh(); - } - - getImagePath(dmsId) { - return this.vnFile.getPath(`/api/dms/${dmsId}/downloadFile`); - } - - changeState(value) { - const params = { - id: this.claim.id, - claimStateFk: value - }; - - this.$http.patch(`Claims/updateClaim/${this.claim.id}`, params) - .then(() => { - this.reload(); - }) - .then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnClaimSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - claim: '<', - model: ' { - describe('Component summary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('claim')); - - beforeEach(inject(($componentController, _$httpBackend_, $rootScope) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnClaimSummary', {$element, $scope}); - controller.claim = {id: 1}; - controller.$.model = crudModel; - })); - - describe('loadData()', () => { - it('should perform a query to set summary', () => { - $httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24); - controller.loadData(); - $httpBackend.flush(); - - expect(controller.summary).toEqual(24); - }); - }); - - describe('changeState()', () => { - it('should make an HTTP post query, then call the showSuccess()', () => { - jest.spyOn(controller.vnApp, 'showSuccess').mockReturnThis(); - - const expectedParams = {id: 1, claimStateFk: 1}; - $httpBackend.when('GET', `Claims/1/getSummary`).respond(200, 24); - $httpBackend.expect('PATCH', `Claims/updateClaim/1`, expectedParams).respond(200); - controller.changeState(1); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('$onChanges()', () => { - it('should call loadData when $onChanges is called', () => { - jest.spyOn(controller, 'loadData'); - - controller.$onChanges(); - - expect(controller.loadData).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/claim/front/summary/style.scss b/modules/claim/front/summary/style.scss deleted file mode 100644 index 5b4e32f7a..000000000 --- a/modules/claim/front/summary/style.scss +++ /dev/null @@ -1,28 +0,0 @@ -@import "./variables"; - -vn-claim-summary { - section.photo { - height: 248px; - } - .photo .image { - border-radius: 3px; - } - vn-textarea *{ - height: 80px; - } - - .video { - width: 100%; - height: 100%; - object-fit: cover; - cursor: pointer; - box-shadow: 0 2px 2px 0 rgba(0,0,0,.14), - 0 3px 1px -2px rgba(0,0,0,.2), - 0 1px 5px 0 rgba(0,0,0,.12); - border: 2px solid transparent; - - } - .video:hover { - border: 2px solid $color-primary - } -} \ No newline at end of file diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 481cec51a..8eb486385 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -60,7 +60,7 @@ on-last="$ctrl.scrollToLine(sale.lastPreparedLineFk)" ng-attr-id="vnItemDiary-{{::sale.lineFk}}"> - + diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 1d2e34a66..199682a77 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -91,6 +91,10 @@ class Controller extends Section { if (this.$state.getCurrentPath()[2].state.name === 'item') this.card.reload(); } + + async goToLilium(section, id) { + window.location.href = await this.vnApp.getUrl(`claim/${id}/${section}`); + } } Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location']; diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 262395d16..dafae8974 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -81,7 +81,7 @@ - + diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 7ff8d89e3..4f8494ed0 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -214,7 +214,7 @@ class Controller extends Section { const params = {ticketId: this.ticket.id, sales: sales}; this.resetChanges(); this.$http.post(`Claims/createFromSales`, params) - .then(res => this.$state.go('claim.card.basicData', {id: res.data.id})); + .then(async res => window.location.href = await this.vnApp.getUrl(`claim/${res.data.id}/basic-data`)); } showTransferPopover(event) { @@ -558,6 +558,10 @@ class Controller extends Section { changedModelId: saleId }); } + + async goToLilium(section, id) { + window.location.href = await this.vnApp.getUrl(`claim/${id}/${section}`); + } } ngModule.vnComponent('vnTicketSale', { diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 025078d36..7ee260f74 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -152,13 +152,13 @@ - + - + Date: Fri, 19 Jul 2024 15:11:14 +0200 Subject: [PATCH 023/145] eat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 164fb3266..66e92c50e 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -6,7 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( ) BEGIN /** - * Calcula las últimas compras realizadas hasta una fecha + * Calcula las últimas compras realizadas hasta una fecha. * * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén From d7b9a3ffd02a0571d7f3a014a33425e1c0827082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Jul 2024 11:58:51 +0200 Subject: [PATCH 024/145] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buy_getUltimate.sql | 3 +-- .../vn/procedures/buy_getUltimateFromInterval.sql | 2 +- db/routines/vn/procedures/buy_updateGrouping.sql | 10 +++++++--- db/routines/vn/procedures/catalog_calculate.sql | 2 +- db/routines/vn/procedures/item_getInfo.sql | 15 +++++++++------ modules/entry/back/methods/entry/addFromBuy.js | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 66e92c50e..023e81774 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -15,8 +15,7 @@ BEGIN */ CALL cache.last_buy_refresh(FALSE); - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate (PRIMARY KEY (itemFk, warehouseFk), INDEX(itemFk)) ENGINE = MEMORY diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql index df0d6a20e..c340686ba 100644 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -21,7 +21,7 @@ BEGIN END IF; IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); + SET vStarted = vEnded - INTERVAL 1 MONTH; END IF; -- Item diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index 45a619262..0d97fd8bf 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`( + vWarehouseFk INT, + vItemFk INT, + vGrouping INT +) BEGIN /** * Actualiza el grouping de las últimas compras de un artículo @@ -8,9 +12,9 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); - UPDATE vn.buy b + UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk SET b.`grouping` = vGrouping WHERE bu.warehouseFk = vWarehouseFk diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 887492b35..6c4affa9d 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -74,7 +74,7 @@ BEGIN CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buy_getUltimate(NULL, vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index f569d235b..5cd4fb31e 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`( + `vBarcode` VARCHAR(22), + `vWarehouseFk` INT +) BEGIN /** * Devuelve información relativa al item correspondiente del vBarcode pasado @@ -11,13 +14,13 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; + DECLARE vDated DATE; + + SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated; CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - - SELECT barcodeToItem(vBarcode) INTO vItemFk; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index 212aed7ea..c75c1935a 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -52,7 +52,7 @@ module.exports = Self => { else { const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions); await Self.rawSql( - 'CALL vn.buy_getUltimate(?,?,?)', + 'CALL buy_getUltimate(?, ?, ?)', [args.item, userConfig.warehouseFk, null], myOptions ); From b086cc7658772b58c4ffd6fea4d6a7935c3a92c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Jul 2024 13:34:04 +0200 Subject: [PATCH 025/145] feat: refactor buyUltimate refs #7736 --- .../buy_getUltimateFromInterval.sql | 12 ++++---- .../vn/procedures/catalog_calculate.sql | 30 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql index c340686ba..2115beb95 100644 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -115,12 +115,12 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk ORDER BY t.landed DESC, b.id DESC LIMIT 10000000000000000000) sub GROUP BY itemFk, warehouseFk; diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 6c4affa9d..8432e8dea 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -29,7 +29,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); + CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot( @@ -86,17 +86,17 @@ BEGIN LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id AND anr.calc_id = vAvailableNoRaidsCalc JOIN tmp.item i ON i.itemFk = a.item_id - JOIN vn.item it ON it.id = i.itemFk - JOIN vn.`zone` z ON z.id = vZoneFk + JOIN item it ON it.id = i.itemFk + JOIN `zone` z ON z.id = vZoneFk LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed - FROM vn.addressFilter af + FROM addressFilter af JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk + FROM address ad + JOIN province p ON p.id = ad.provinceFk WHERE ad.id = vAddressFk ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) @@ -108,18 +108,18 @@ BEGIN OR ISNULL(af.afterDated)) ) sub ON sub.isVNHSupplier = v.isVNHSupplier AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird)) - JOIN vn.agencyMode am ON am.id = vAgencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN vn.itemType itt ON itt.id = it.typeFk - JOIN vn.itemCategory itc on itc.id = itt.categoryFk - JOIN vn.address ad ON ad.id = vAddressFk - LEFT JOIN vn.clientItemType cit + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN agency ag ON ag.id = am.agencyFk + JOIN itemType itt ON itt.id = it.typeFk + JOIN itemCategory itc on itc.id = itt.categoryFk + JOIN address ad ON ad.id = vAddressFk + LEFT JOIN clientItemType cit ON cit.clientFk = ad.clientFk AND cit.itemTypeFk = itt.id - LEFT JOIN vn.zoneItemType zit + LEFT JOIN zoneItemType zit ON zit.zoneFk = vZoneFk AND zit.itemTypeFk = itt.id - LEFT JOIN vn.agencyModeItemType ait + LEFT JOIN agencyModeItemType ait ON ait.agencyModeFk = vAgencyModeFk AND ait.itemTypeFk = itt.id WHERE a.calc_id = vAvailableCalc @@ -133,7 +133,7 @@ BEGIN DROP TEMPORARY TABLE tmp.buyUltimate; - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); INSERT INTO tmp.ticketCalculateItem( itemFk, From 33a71867bda9cd58ce2297d7a73fe051391949ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Jul 2024 13:39:48 +0200 Subject: [PATCH 026/145] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buyUltimate.sql | 4 ++-- db/routines/vn/procedures/buy_updateGrouping.sql | 2 +- db/routines/vn/procedures/catalog_calculate.sql | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql index 7026c8c82..e743b8c90 100644 --- a/db/routines/vn/procedures/buyUltimate.sql +++ b/db/routines/vn/procedures/buyUltimate.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`( ) BEGIN /** - * DEPRECATED usar buy_getUltimate - * Calcula las últimas compras realizadas hasta una fecha + * @deprecated Usar buy_getUltimate + * Calcula las últimas compras realizadas hasta una fecha. * * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index 0d97fd8bf..e589fbd2a 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -12,7 +12,7 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 8432e8dea..2a0157881 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -72,8 +72,8 @@ BEGIN LEAVE l; END IF; - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) From a7f725a194232d375661a2662be71ea91d167ce3 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 24 Jul 2024 07:25:43 +0200 Subject: [PATCH 027/145] feat: refs #7774 ticket_cloneWeekly --- .../vn/procedures/ticket_cloneWeekly.sql | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index fd45dc9fa..06d1554ce 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -17,6 +17,10 @@ BEGIN DECLARE vYear INT; DECLARE vSalesPersonFK INT; DECLARE vItemPicker INT; + DECLARE vTicketfailed INT; + DECLARE vSubjectsTicketfailed VARCHAR(50); + DECLARE vMessagesTicketfailed TEXT; + DECLARE rsTicket CURSOR FOR SELECT tt.ticketFk, @@ -185,8 +189,11 @@ BEGIN IF (vLanding IS NULL) THEN - SELECT e.email INTO vSalesPersonEmail + SELECT IFNULL(d.notificationEmail,e.email) INTO vSalesPersonEmail FROM client c + JOIN worker w ON w.id = c.salesPersonFk + JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk + JOIN department d ON d.id = wd.departmentFk JOIN account.emailUser e ON e.userFk = c.salesPersonFk WHERE c.id = vClientFk; @@ -213,6 +220,37 @@ BEGIN END; END LOOP; CLOSE rsTicket; + + WITH tOrigin AS ( + SELECT tt.ticketFk, + t.clientFk, + t.warehouseFk, + t.companyFk, + t.addressFk, + tt.agencyModeFk, + ti.dated + FROM ticketWeekly tt + JOIN ticket t ON tt.ticketFk = t.id + JOIN tmp.time ti + WHERE WEEKDAY(ti.dated) = tt.weekDay + ),total AS( + SELECT tor.ticketFk, tc.id + FROM tOrigin tor + JOIN sale so ON tor.ticketFk = so.ticketFk + LEFT JOIN ticket tc ON tc.id = tor.ticketFk + AND DATE(tc.shipped) = tor.dated + LEFT JOIN sale sc ON sc.ticketFk = tc.id + WHERE sc.id IS NULL + GROUP BY tor.ticketFk, tc.id + )SELECT COUNT(DISTINCT ticketFk) INTO vTicketfailed + FROM total; + + IF vTicketfailed THEN + SET vSubjectsTicketfailed = 'Turnos - Tickets que no se han clonado '; + SET vMessagesTicketfailed = 'No se ha podido clonar tickets revisar que tickets han sido y mirar por que no se han clonado'; + CALL mail_insert('nocontestar@verdnatura.es', NULL, vSubjectsTicketfailed, vMessagesTicketfailed); + END IF; + DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded; END$$ DELIMITER ; From 5a9ab843568e2fdcda02df303d55cf363c75a86c Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 24 Jul 2024 09:14:28 +0200 Subject: [PATCH 028/145] feat: refs #7646 delete scannableCodeType --- .../11165-grayAralia/00-firstScript.sql | 7 ++++++ .../collection-label/collection-label.html | 6 +---- .../collection-label/collection-label.js | 23 ++----------------- .../collection-label/sql/barcodeType.sql | 3 --- 4 files changed, 10 insertions(+), 29 deletions(-) create mode 100644 db/versions/11165-grayAralia/00-firstScript.sql delete mode 100644 print/templates/reports/collection-label/sql/barcodeType.sql diff --git a/db/versions/11165-grayAralia/00-firstScript.sql b/db/versions/11165-grayAralia/00-firstScript.sql new file mode 100644 index 000000000..2e0e2a329 --- /dev/null +++ b/db/versions/11165-grayAralia/00-firstScript.sql @@ -0,0 +1,7 @@ +-- Place your SQL code here +ALTER TABLE IF EXISTS vn.productionConfig +CHANGE COLUMN IF EXISTS scannableCodeType scannableCodeType__ enum('qr','barcode') + CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'barcode' NOT NULL, +CHANGE COLUMN IF EXISTS scannablePreviusCodeType scannablePreviusCodeType__ enum('qr','barcode') + CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'barcode' NOT NULL; + diff --git a/print/templates/reports/collection-label/collection-label.html b/print/templates/reports/collection-label/collection-label.html index 65709ead0..1f57fc3d9 100644 --- a/print/templates/reports/collection-label/collection-label.html +++ b/print/templates/reports/collection-label/collection-label.html @@ -10,14 +10,10 @@ {{dashIfEmpty(labelData.shipped)}} - + {{dashIfEmpty(labelData.workerCode)}} - -
- {{dashIfEmpty(labelData.workerCode)}} - {{labelCount || labelData.labelCount || 0}} diff --git a/print/templates/reports/collection-label/collection-label.js b/print/templates/reports/collection-label/collection-label.js index f2f697ae6..4aeaca854 100644 --- a/print/templates/reports/collection-label/collection-label.js +++ b/print/templates/reports/collection-label/collection-label.js @@ -1,7 +1,5 @@ -const {DOMImplementation, XMLSerializer} = require('xmldom'); const vnReport = require('../../../core/mixins/vn-report.js'); const {toDataURL} = require('qrcode'); -const jsBarcode = require('jsbarcode'); module.exports = { name: 'collection-label', @@ -30,11 +28,8 @@ module.exports = { const labels = await this.rawSqlFromDef('labelsData', [ticketIds]); - const [{scannableCodeType}] = await this.rawSqlFromDef('barcodeType'); - if (scannableCodeType === 'qr') { - for (const labelData of labels) - labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk); - } + for (const labelData of labels) + labelData.qrData = await this.getQr(labelData?.ticketFk, labelData?.workerFk); this.labelsData = labels; this.checkMainEntity(this.labelsData); @@ -50,20 +45,6 @@ module.exports = { }); return toDataURL(QRdata, {margin: 0}); }, - getBarcode(id) { - const xmlSerializer = new XMLSerializer(); - const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); - const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - - jsBarcode(svgNode, id, { - xmlDocument: document, - format: 'code128', - displayValue: false, - width: 3.8, - height: 115, - }); - return xmlSerializer.serializeToString(svgNode); - }, getVertical(labelData) { let value; if (labelData.collectionFk) { diff --git a/print/templates/reports/collection-label/sql/barcodeType.sql b/print/templates/reports/collection-label/sql/barcodeType.sql deleted file mode 100644 index 0700c95a2..000000000 --- a/print/templates/reports/collection-label/sql/barcodeType.sql +++ /dev/null @@ -1,3 +0,0 @@ -SELECT scannableCodeType - FROM productionConfig - LIMIT 1 \ No newline at end of file From cf3ee07dd2361e236b59faf18d53527fd5a302ee Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 10:03:51 +0200 Subject: [PATCH 029/145] feat: refs #7713 Created ACLLog --- .../salix/triggers/ACL_afterDelete.sql | 12 +++++++++ .../salix/triggers/ACL_beforeInsert.sql | 8 ++++++ .../salix/triggers/ACL_beforeUpdate.sql | 8 ++++++ .../11166-azureDracena/00-firstScript.sql | 25 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 db/routines/salix/triggers/ACL_afterDelete.sql create mode 100644 db/routines/salix/triggers/ACL_beforeInsert.sql create mode 100644 db/routines/salix/triggers/ACL_beforeUpdate.sql create mode 100644 db/versions/11166-azureDracena/00-firstScript.sql diff --git a/db/routines/salix/triggers/ACL_afterDelete.sql b/db/routines/salix/triggers/ACL_afterDelete.sql new file mode 100644 index 000000000..18689dfb0 --- /dev/null +++ b/db/routines/salix/triggers/ACL_afterDelete.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_afterDelete` + AFTER DELETE ON `ACL` + FOR EACH ROW +BEGIN + INSERT INTO ACL + SET `action` = 'delete', + `changedModel` = 'Acl', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/salix/triggers/ACL_beforeInsert.sql b/db/routines/salix/triggers/ACL_beforeInsert.sql new file mode 100644 index 000000000..94fb51ada --- /dev/null +++ b/db/routines/salix/triggers/ACL_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeInsert` + BEFORE INSERT ON `ACL` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/salix/triggers/ACL_beforeUpdate.sql b/db/routines/salix/triggers/ACL_beforeUpdate.sql new file mode 100644 index 000000000..b214fc9f6 --- /dev/null +++ b/db/routines/salix/triggers/ACL_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_beforeUpdate` + BEFORE UPDATE ON `ACL` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/versions/11166-azureDracena/00-firstScript.sql b/db/versions/11166-azureDracena/00-firstScript.sql new file mode 100644 index 000000000..ba087b5a8 --- /dev/null +++ b/db/versions/11166-azureDracena/00-firstScript.sql @@ -0,0 +1,25 @@ +CREATE OR REPLACE TABLE `salix`.`ACLLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('Acl') NOT NULL DEFAULT 'Acl', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `logRateuserFk` (`userFk`), + KEY `ACLLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `ACLLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `aclUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE salix.ACL + ADD editorFk int(10) unsigned DEFAULT NULL NULL; + +ALTER TABLE vn.ticket + CHANGE editorFk editorFk int(10) unsigned DEFAULT NULL NULL AFTER risk; From d0dfb95718f2924ff8d054d8a1cc7efada9e63c2 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 24 Jul 2024 13:56:21 +0200 Subject: [PATCH 030/145] feat: refs #7774 --- .../vn/procedures/ticket_cloneWeekly.sql | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index 06d1554ce..f689f2600 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -18,9 +18,6 @@ BEGIN DECLARE vSalesPersonFK INT; DECLARE vItemPicker INT; DECLARE vTicketfailed INT; - DECLARE vSubjectsTicketfailed VARCHAR(50); - DECLARE vMessagesTicketfailed TEXT; - DECLARE rsTicket CURSOR FOR SELECT tt.ticketFk, @@ -221,36 +218,6 @@ BEGIN END LOOP; CLOSE rsTicket; - WITH tOrigin AS ( - SELECT tt.ticketFk, - t.clientFk, - t.warehouseFk, - t.companyFk, - t.addressFk, - tt.agencyModeFk, - ti.dated - FROM ticketWeekly tt - JOIN ticket t ON tt.ticketFk = t.id - JOIN tmp.time ti - WHERE WEEKDAY(ti.dated) = tt.weekDay - ),total AS( - SELECT tor.ticketFk, tc.id - FROM tOrigin tor - JOIN sale so ON tor.ticketFk = so.ticketFk - LEFT JOIN ticket tc ON tc.id = tor.ticketFk - AND DATE(tc.shipped) = tor.dated - LEFT JOIN sale sc ON sc.ticketFk = tc.id - WHERE sc.id IS NULL - GROUP BY tor.ticketFk, tc.id - )SELECT COUNT(DISTINCT ticketFk) INTO vTicketfailed - FROM total; - - IF vTicketfailed THEN - SET vSubjectsTicketfailed = 'Turnos - Tickets que no se han clonado '; - SET vMessagesTicketfailed = 'No se ha podido clonar tickets revisar que tickets han sido y mirar por que no se han clonado'; - CALL mail_insert('nocontestar@verdnatura.es', NULL, vSubjectsTicketfailed, vMessagesTicketfailed); - END IF; - DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded; END$$ DELIMITER ; From 000a967a03404c047f41b510caad37d3d66f933c Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 26 Jul 2024 07:12:51 +0200 Subject: [PATCH 031/145] feat: refs #6403 packingSite to productionConfig --- db/versions/11170-redPaniculata/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11170-redPaniculata/00-firstScript.sql diff --git a/db/versions/11170-redPaniculata/00-firstScript.sql b/db/versions/11170-redPaniculata/00-firstScript.sql new file mode 100644 index 000000000..b5d34c082 --- /dev/null +++ b/db/versions/11170-redPaniculata/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.packingSite DROP COLUMN IF EXISTS hasNewLabelMrwMethod; + +ALTER TABLE vn.productionConfig ADD IF NOT EXISTS hasNewLabelMrwMethod BOOL DEFAULT TRUE NOT NULL + COMMENT 'column to activate the new mrw integration'; From 5264d6c9739afe1e66524ff216075f809daba008 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 29 Jul 2024 10:35:01 +0200 Subject: [PATCH 032/145] feat(postcode_town): refs #7679 add requireds --- back/models/postcode.json | 5 +++-- back/models/town.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/back/models/postcode.json b/back/models/postcode.json index eadc2c86c..bad6be5d7 100644 --- a/back/models/postcode.json +++ b/back/models/postcode.json @@ -9,7 +9,8 @@ "properties": { "code": { "id": true, - "type": "string" + "type": "string", + "required": true } }, "relations": { @@ -47,4 +48,4 @@ } } } -} \ No newline at end of file +} diff --git a/back/models/town.json b/back/models/town.json index 4ad729791..e5d39314b 100644 --- a/back/models/town.json +++ b/back/models/town.json @@ -12,7 +12,8 @@ "type": "number" }, "name": { - "type": "string" + "type": "string", + "required": true } }, "relations": { @@ -54,4 +55,4 @@ "fields": ["id", "name", "provinceFk"] } } -} \ No newline at end of file +} From 4c602800ea9183a72ef358e29a5141286711bb5c Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 11:46:59 +0200 Subject: [PATCH 033/145] feat: refs #6453 Added new ticket search --- .../procedures/order_confirmWithUser.sql | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 841a69390..48f97c9b6 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -123,14 +123,14 @@ BEGIN LEAVE lDates; END IF; - -- Busca un ticket existente que coincida con los parametros + -- Busca un ticket libre disponible WITH tPrevia AS ( SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) + ), SELECT t.id INTO vTicketFk FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' @@ -146,6 +146,37 @@ BEGIN AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) LIMIT 1; + -- Comprobamos si hay un ticket de previa disponible + IF vTicketFk IS NULL THEN + WITH tItemPackingTypeOrder AS ( + SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes, + o.address_id + FROM vn.item i + JOIN orderRow oro ON oro.itemFk = i.id + JOIN `order` o ON o.id = oro.orderFk + WHERE oro.orderFk = vSelf + ), + tItemPackingTypeTicket AS ( + SELECT t.id, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes + FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'ON_PREVIOUS' + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN tItemPackingTypeOrder ipto + WHERE t.refFk IS NULL + AND DATE(t.shipped) = vShipment + AND t.warehouseFk = vWarehouseFk + AND t.addressFk = ipto.address_id + GROUP BY t.id + ) + SELECT iptt.id INTO vTicketFk + FROM tItemPackingTypeTicket iptt + JOIN tItemPackingTypeOrder ipto + WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes) + LIMIT 1 + END IF; + -- Crea el ticket en el caso de no existir uno adecuado IF vTicketFk IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); From e53b12d51bc220990d3e90ea0f20a2985adec303 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 12:31:44 +0200 Subject: [PATCH 034/145] feat: refs #6453 Fixes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 48f97c9b6..cf0f9aead 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -20,6 +20,7 @@ BEGIN DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; + DECLARE vAvailable INT; DECLARE vPrice DECIMAL(10,2); DECLARE vSaleFk INT; DECLARE vRowFk INT; @@ -48,7 +49,6 @@ BEGIN i.name, r.amount, r.price, - i.itemPackingTypeFk, i.isFloramondo FROM orderRow r JOIN vn.item i ON i.id = r.itemFk @@ -130,7 +130,7 @@ BEGIN JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ), + ) SELECT t.id INTO vTicketFk FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' @@ -174,7 +174,7 @@ BEGIN FROM tItemPackingTypeTicket iptt JOIN tItemPackingTypeOrder ipto WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes) - LIMIT 1 + LIMIT 1; END IF; -- Crea el ticket en el caso de no existir uno adecuado @@ -224,7 +224,6 @@ BEGIN vConcept, vAmount, vPrice, - vItemPackingTypeFk, vIsLogifloraItem; IF vDone THEN From 6ad3d5a5ebdc37873d5c6dc3791e6529fe1308bb Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 12:36:08 +0200 Subject: [PATCH 035/145] feat: refs #6453 Minor changes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index cf0f9aead..4fcee91f7 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -15,6 +15,7 @@ BEGIN DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; + DECLARE vShipmentDayEnd DATE; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItemFk INT; @@ -123,13 +124,15 @@ BEGIN LEAVE lDates; END IF; + SET vShipmentDayEnd = util.dayEnd(vShipment); + -- Busca un ticket libre disponible WITH tPrevia AS ( SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd ) SELECT t.id INTO vTicketFk FROM vn.ticket t @@ -139,7 +142,7 @@ BEGIN JOIN hedera.`order` o ON o.address_id = t.addressFk AND t.warehouseFk = vWarehouseFk AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL @@ -165,7 +168,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN tItemPackingTypeOrder ipto WHERE t.refFk IS NULL - AND DATE(t.shipped) = vShipment + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd AND t.warehouseFk = vWarehouseFk AND t.addressFk = ipto.address_id GROUP BY t.id From 254cced550a5a417e840fe844ac46250ba319ecd Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 29 Jul 2024 13:40:30 +0200 Subject: [PATCH 036/145] chore: refs #6989 add config model --- back/model-config.json | 3 +++ back/models/config.json | 22 +++++++++++++++++++ db/routines/vn/procedures/item_getBalance.sql | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 back/models/config.json diff --git a/back/model-config.json b/back/model-config.json index a16fe4e8a..13c06ef54 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -28,6 +28,9 @@ "Company": { "dataSource": "vn" }, + "Config": { + "dataSource": "vn" + }, "Continent": { "dataSource": "vn" }, diff --git a/back/models/config.json b/back/models/config.json new file mode 100644 index 000000000..e5ba1f134 --- /dev/null +++ b/back/models/config.json @@ -0,0 +1,22 @@ +{ + "name": "Config", + "base": "VnModel", + "options": { + "mysql": { + "table": "config" + } + }, + "properties": { + "inventoried": { + "type": "date" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 0de59b478..3a594c81c 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -240,7 +240,7 @@ BEGIN NULL reference, NULL entityType, NULL entityId, - 'Inventario calculado', + 'Inventario calculado' entityName, @a invalue, NULL `out`, @a balance, From a01ae9b7b8d35ea976c8510e25c47164274d0125 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 14:09:55 +0200 Subject: [PATCH 037/145] fix: refs #7756 Foreign keys invoiceOut --- db/versions/11172-blueFern/00-firstScript.sql | 1 + db/versions/11172-blueFern/01-firstScript.sql | 1 + db/versions/11172-blueFern/02-firstScript.sql | 1 + db/versions/11172-blueFern/03-firstScript.sql | 1 + db/versions/11172-blueFern/04-firstScript.sql | 1 + db/versions/11172-blueFern/05-firstScript.sql | 1 + db/versions/11172-blueFern/06-firstScript.sql | 1 + db/versions/11172-blueFern/07-firstScript.sql | 1 + db/versions/11172-blueFern/08-firstScript.sql | 1 + db/versions/11172-blueFern/09-firstScript.sql | 1 + db/versions/11172-blueFern/10-firstScript.sql | 2 ++ db/versions/11172-blueFern/11-firstScript.sql | 2 ++ db/versions/11172-blueFern/12-firstScript.sql | 2 ++ db/versions/11172-blueFern/13-firstScript.sql | 2 ++ db/versions/11172-blueFern/14-firstScript.sql | 2 ++ 15 files changed, 20 insertions(+) create mode 100644 db/versions/11172-blueFern/00-firstScript.sql create mode 100644 db/versions/11172-blueFern/01-firstScript.sql create mode 100644 db/versions/11172-blueFern/02-firstScript.sql create mode 100644 db/versions/11172-blueFern/03-firstScript.sql create mode 100644 db/versions/11172-blueFern/04-firstScript.sql create mode 100644 db/versions/11172-blueFern/05-firstScript.sql create mode 100644 db/versions/11172-blueFern/06-firstScript.sql create mode 100644 db/versions/11172-blueFern/07-firstScript.sql create mode 100644 db/versions/11172-blueFern/08-firstScript.sql create mode 100644 db/versions/11172-blueFern/09-firstScript.sql create mode 100644 db/versions/11172-blueFern/10-firstScript.sql create mode 100644 db/versions/11172-blueFern/11-firstScript.sql create mode 100644 db/versions/11172-blueFern/12-firstScript.sql create mode 100644 db/versions/11172-blueFern/13-firstScript.sql create mode 100644 db/versions/11172-blueFern/14-firstScript.sql diff --git a/db/versions/11172-blueFern/00-firstScript.sql b/db/versions/11172-blueFern/00-firstScript.sql new file mode 100644 index 000000000..04e0813d5 --- /dev/null +++ b/db/versions/11172-blueFern/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.ticket DROP FOREIGN KEY ticket_FK; \ No newline at end of file diff --git a/db/versions/11172-blueFern/01-firstScript.sql b/db/versions/11172-blueFern/01-firstScript.sql new file mode 100644 index 000000000..64255f9de --- /dev/null +++ b/db/versions/11172-blueFern/01-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut DROP KEY Id_Factura; diff --git a/db/versions/11172-blueFern/02-firstScript.sql b/db/versions/11172-blueFern/02-firstScript.sql new file mode 100644 index 000000000..e76b7f7d6 --- /dev/null +++ b/db/versions/11172-blueFern/02-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned NOT NULL; \ No newline at end of file diff --git a/db/versions/11172-blueFern/03-firstScript.sql b/db/versions/11172-blueFern/03-firstScript.sql new file mode 100644 index 000000000..e6def98a4 --- /dev/null +++ b/db/versions/11172-blueFern/03-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceCorrection DROP FOREIGN KEY corrected_fk; diff --git a/db/versions/11172-blueFern/04-firstScript.sql b/db/versions/11172-blueFern/04-firstScript.sql new file mode 100644 index 000000000..a19bc336e --- /dev/null +++ b/db/versions/11172-blueFern/04-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceCorrection DROP FOREIGN KEY correcting_fk; diff --git a/db/versions/11172-blueFern/05-firstScript.sql b/db/versions/11172-blueFern/05-firstScript.sql new file mode 100644 index 000000000..9f5ec2871 --- /dev/null +++ b/db/versions/11172-blueFern/05-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOutExpense DROP FOREIGN KEY invoiceOutExpence_FK_1; diff --git a/db/versions/11172-blueFern/06-firstScript.sql b/db/versions/11172-blueFern/06-firstScript.sql new file mode 100644 index 000000000..2c16e9b77 --- /dev/null +++ b/db/versions/11172-blueFern/06-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOutTax DROP FOREIGN KEY invoiceOutFk; diff --git a/db/versions/11172-blueFern/07-firstScript.sql b/db/versions/11172-blueFern/07-firstScript.sql new file mode 100644 index 000000000..bec72a131 --- /dev/null +++ b/db/versions/11172-blueFern/07-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut DROP PRIMARY KEY; diff --git a/db/versions/11172-blueFern/08-firstScript.sql b/db/versions/11172-blueFern/08-firstScript.sql new file mode 100644 index 000000000..316db2e32 --- /dev/null +++ b/db/versions/11172-blueFern/08-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_pk PRIMARY KEY (id); diff --git a/db/versions/11172-blueFern/09-firstScript.sql b/db/versions/11172-blueFern/09-firstScript.sql new file mode 100644 index 000000000..553d7857e --- /dev/null +++ b/db/versions/11172-blueFern/09-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_unique UNIQUE KEY (`ref`); diff --git a/db/versions/11172-blueFern/10-firstScript.sql b/db/versions/11172-blueFern/10-firstScript.sql new file mode 100644 index 000000000..e1847a877 --- /dev/null +++ b/db/versions/11172-blueFern/10-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK + FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/11-firstScript.sql b/db/versions/11172-blueFern/11-firstScript.sql new file mode 100644 index 000000000..720b7962e --- /dev/null +++ b/db/versions/11172-blueFern/11-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK + FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/12-firstScript.sql b/db/versions/11172-blueFern/12-firstScript.sql new file mode 100644 index 000000000..35099bd5d --- /dev/null +++ b/db/versions/11172-blueFern/12-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 + FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11172-blueFern/13-firstScript.sql b/db/versions/11172-blueFern/13-firstScript.sql new file mode 100644 index 000000000..f1aa0a216 --- /dev/null +++ b/db/versions/11172-blueFern/13-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/14-firstScript.sql b/db/versions/11172-blueFern/14-firstScript.sql new file mode 100644 index 000000000..ba570e20c --- /dev/null +++ b/db/versions/11172-blueFern/14-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; From 434dfe4ae45740e8d60f603eeae7941231c9632e Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 29 Jul 2024 15:03:40 +0200 Subject: [PATCH 038/145] fix: refs #7679 postcode filter --- back/methods/postcode/filter.js | 36 +++++++++++++++------------------ loopback/locale/en.json | 4 +++- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index 8b0f64d97..fc7905215 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -11,13 +11,11 @@ module.exports = Self => { arg: 'filter', type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - http: {source: 'query'} }, { arg: 'search', type: 'string', description: 'Value to filter', - http: {source: 'query'} }, ], returns: { @@ -29,13 +27,11 @@ module.exports = Self => { verb: 'GET', }, }); - Self.filter = async(ctx, filter, options) => { + Self.filter = async(filter = {}, search, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - filter = ctx?.filter ?? {}; - const conn = Self.dataSource.connector; const where = buildFilter(filter?.where, (param, value) => { switch (param) { @@ -50,27 +46,27 @@ module.exports = Self => { }; } }) ?? {}; - delete ctx.filter.where; + delete filter.where; const stmts = []; let stmt; stmt = new ParameterizedSQL(` - SELECT - pc.townFk, - t.provinceFk, - p.countryFk, - pc.code, - t.name as town, - p.name as province, - c.name country - FROM - postCode pc - JOIN town t on t.id = pc.townFk - JOIN province p on p.id = t.provinceFk - JOIN country c on c.id = p.countryFk + SELECT + pc.townFk, + t.provinceFk, + p.countryFk, + pc.code, + t.name as town, + p.name as province, + c.name country + FROM + postCode pc + JOIN town t on t.id = pc.townFk + JOIN province p on p.id = t.provinceFk + JOIN country c on c.id = p.countryFk `); - stmt.merge(conn.makeSuffix({where, ...ctx})); + stmt.merge(conn.makeSuffix({where})); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 382a2824c..06538a524 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -233,5 +233,7 @@ "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated", "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", "Cannot add holidays on this day": "Cannot add holidays on this day", - "Cannot send mail": "Cannot send mail" + "Cannot send mail": "Cannot send mail", + "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", + "This postcode already exists": "This postcode already exists" } \ No newline at end of file From 6c1de1d6bd85802bcd2ed273fc1a489831d6c1fe Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 Jul 2024 07:55:14 +0200 Subject: [PATCH 039/145] refs #7801 frenchGoLabel --- .../email/printer-setup/locale/fr.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 print/templates/email/printer-setup/locale/fr.yml diff --git a/print/templates/email/printer-setup/locale/fr.yml b/print/templates/email/printer-setup/locale/fr.yml new file mode 100644 index 000000000..0c9f7031a --- /dev/null +++ b/print/templates/email/printer-setup/locale/fr.yml @@ -0,0 +1,39 @@ +subject: Instalation et configuration de l'imprimante +title: "Merci pour votre confiance !" +description: + dear: Cher client + instructions: Veuillez suivre les instructions spécifiées dans cet e-mail pour procéder à l'installation de l'imprimante. + followGuide: Vous pouvez utiliser comme guide la vidéo du montage du ruban et de la bande. +
https://www.youtube.com/watch?v=qhb0kgQF3o8. Vous + aurez également besoin de GoLabel, le programme pour imprimer les bandes. + downloadFrom: Vous pouvez le télécharger depuis ce lien. https://cdn.verdnatura.es/public/GoLabel.zip + downloadDriver: Vous pouvez télécharger le pilote de l'imprimante depuis ce lien. https://es.seagullscientific.com/support/downloads/drivers/godex/download/ +sections: + GoLabel: + title: Utilisation de GoLabel + description: Pour utiliser le programme d'impression des bandes, suivez ces étapes + steps: + - Ci-joint à cet e-mail, vous trouverez le fichier 'model.ezp' (le modèle de bandes de corona standard). Téléchargez-le et vous le trouverez probablement dans le dossier 'Téléchargements'. + - Ouvrez le programme GoLabel. + - Cliquez sur l'icône de la barre supérieure en forme de dossier avec une feuille. + - Sélectionnez le fichier nommé 'model.ezp' (qui se trouve probablement dans 'Téléchargements'), puis cliquez sur Ouvrir. + - Une fois le fichier ouvert, double-cliquez sur le texte. Dans la boîte qui s'ouvre, cliquez sur le texte d'exemple (dans ce cas "TUS HERMANOS") et il apparaîtra dans la même zone à gauche pour que vous puissiez l'éditer et écrire ce que vous souhaitez. + - Lorsque vous avez le texte souhaité, cliquez sur le bouton 'OK'. + - Allez dans 'Fichier' → 'Enregistrer sous' et enregistrez-le sur le bureau sous un autre nom. + - Ensuite, pour imprimer, vous devez d'abord configurer l'imprimante. + - Cliquez sur la huitième icône de la barre supérieure, qui sera ici une imprimante avec un engrenage orange. + - Une fois là, cliquez sur le menu déroulant du modèle d'imprimante et choisissez le modèle qui correspond au vôtre 'G***'. + - Cliquez sur 'Enregistrer' et notre imprimante sera configurée et prête. + - Et enfin, pour imprimer, cliquez sur la neuvième icône, qui correspond à une imprimante bleue. + help: + title: "Avez-vous besoin d'aide ?" + description: Si vous avez besoin d'aide, téléchargez notre programme de support afin que nous puissions nous connecter à distance à votre ordinateur et effectuer l'installation. Veuillez nous fournir un horaire de contact pour vous assister, et nous vous contacterons. + remoteSupport: Vous pouvez télécharger le programme depuis ce lien. http://soporte.verdnatura.es. +help: Pour toute question que vous pourriez avoir, n'hésitez pas à nous la poser. Nous sommes là pour vous aider ! +salesPersonName: Je suis votre commercial et mon nom est +salesPersonPhone: Téléphone et WhatsApp. +salesPersonEmail: Adresse e-mail. From fcd26784bfb60dae6fcbf44677beae279acad9fc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 08:37:35 +0200 Subject: [PATCH 040/145] build: init version 2434 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9016f74a6..261b877dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.32.0", + "version": "24.34.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From dbe0f4497c880fafde27066d5ba70991b59c381f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 08:59:03 +0200 Subject: [PATCH 041/145] fix(postcode_filter): add limit --- back/methods/postcode/filter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index fc7905215..37cc0c148 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -67,10 +67,12 @@ module.exports = Self => { `); stmt.merge(conn.makeSuffix({where})); + stmt.merge(conn.makeLimit(filter)); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); + return itemsIndex === 0 ? result : result[itemsIndex]; }; }; From 766da06c2fe150638a9d58b12888edb0ac9eb65c Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 30 Jul 2024 09:40:34 +0200 Subject: [PATCH 042/145] feat: refs #7524 add mock limit on find query --- back/model-config.json | 3 +++ back/models/ormConfig.json | 26 +++++++++++++++++++ .../11175-pinkChico/00-firstScript.sql | 8 ++++++ loopback/common/models/vn-model.js | 24 ++++++++++++++++- loopback/locale/es.json | 3 ++- 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 back/models/ormConfig.json create mode 100644 db/versions/11175-pinkChico/00-firstScript.sql diff --git a/back/model-config.json b/back/model-config.json index a16fe4e8a..9884eadfb 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -115,6 +115,9 @@ "NotificationSubscription": { "dataSource": "vn" }, + "OrmConfig": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, diff --git a/back/models/ormConfig.json b/back/models/ormConfig.json new file mode 100644 index 000000000..ef4c2b181 --- /dev/null +++ b/back/models/ormConfig.json @@ -0,0 +1,26 @@ +{ + "name": "OrmConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "ormConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "selectLimit": { + "type": "number" + } + }, + "acls": [ + { + "accessType": "*", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/versions/11175-pinkChico/00-firstScript.sql b/db/versions/11175-pinkChico/00-firstScript.sql new file mode 100644 index 000000000..349f4c7f7 --- /dev/null +++ b/db/versions/11175-pinkChico/00-firstScript.sql @@ -0,0 +1,8 @@ +USE vn; + +CREATE TABLE IF NOT EXISTS ormConfig ( + id int(5) NOT NULL AUTO_INCREMENT primary key, + selectLimit int(5) NOT NULL +); + +INSERT IGNORE INTO ormConfig SET selectLimit = 1000; \ No newline at end of file diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 22b535f62..30a2da6be 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -5,6 +5,7 @@ const utils = require('loopback/lib/utils'); module.exports = function(Self) { Self.ParameterizedSQL = ParameterizedSQL; + let isSelect; require('../methods/vn-model/getSetValues')(Self); require('../methods/vn-model/getEnumValues')(Self); @@ -13,7 +14,6 @@ module.exports = function(Self) { Object.assign(Self, { setup() { Self.super_.setup.call(this); - /** * Setting a global transaction timeout to find out if the service * is blocked because the connection pool is empty. @@ -28,6 +28,28 @@ module.exports = function(Self) { }; }); + /* + * Intercept GET request for find + */ + this.beforeRemote('find', async function(ctx) { + isSelect = true; + const filter = ctx.args.filter || {}; + // const models = this.app.models; + if (filter.limit === undefined) { + // WIP + // const {limit} = await models.OrmConfig.findOne(); Not working + // const [{selectLimit: limit}] = await this.rawSql('SELECT selectLimit FROM ormConfig', null); + filter.limit = 1/* limit */; + ctx.args.filter = filter; + } + }); + + this.observe('loaded', async function({data}) { + if (!isSelect) return; + const length = Array.isArray(data) ? data.length : data ? 1 : 0; + if (length >= 1) throw new UserError('Too many records'); + }); + // Register field ACL validation /* this.beforeRemote('prototype.patchAttributes', ctx => this.checkUpdateAcls(ctx)); diff --git a/loopback/locale/es.json b/loopback/locale/es.json index acc3d69f6..c2973bf62 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -368,5 +368,6 @@ "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", - "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "Too many records": "Demasiados registros" } \ No newline at end of file From 82c28e03991565d494e12fb678ed0e80cc3019eb Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 30 Jul 2024 10:01:05 +0200 Subject: [PATCH 043/145] chore: refs #7524 WIP limit call --- loopback/common/models/vn-model.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 30a2da6be..0b16c6532 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -34,11 +34,8 @@ module.exports = function(Self) { this.beforeRemote('find', async function(ctx) { isSelect = true; const filter = ctx.args.filter || {}; - // const models = this.app.models; + // console.log(this.dataSource, Self.dataSource); undefined/null if (filter.limit === undefined) { - // WIP - // const {limit} = await models.OrmConfig.findOne(); Not working - // const [{selectLimit: limit}] = await this.rawSql('SELECT selectLimit FROM ormConfig', null); filter.limit = 1/* limit */; ctx.args.filter = filter; } From 2ac8760061506f713e5e4fbde9e9f0bfb6e86560 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 10:13:32 +0200 Subject: [PATCH 044/145] test: fix postcode filter back test --- back/methods/postcode/filter.js | 7 +-- back/methods/postcode/specs/filter.spec.js | 57 ++++++++-------------- 2 files changed, 20 insertions(+), 44 deletions(-) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index 37cc0c148..f350b1ea9 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -12,11 +12,6 @@ module.exports = Self => { type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', }, - { - arg: 'search', - type: 'string', - description: 'Value to filter', - }, ], returns: { type: ['object'], @@ -27,7 +22,7 @@ module.exports = Self => { verb: 'GET', }, }); - Self.filter = async(filter = {}, search, options) => { + Self.filter = async(filter = {}, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/back/methods/postcode/specs/filter.spec.js b/back/methods/postcode/specs/filter.spec.js index 60ac24809..391b1e196 100644 --- a/back/methods/postcode/specs/filter.spec.js +++ b/back/methods/postcode/specs/filter.spec.js @@ -1,17 +1,14 @@ const {models} = require('vn-loopback/server/server'); -describe('Postcode filter()', () => { +fdescribe('Postcode filter()', () => { it('should retrieve with no filter', async() => { const tx = await models.Postcode.beginTransaction({}); const options = {transaction: tx}; try { - const ctx = { - filter: { - }, + const results = await models.Postcode.filter({ limit: 1 - }; - const results = await models.Postcode.filter(ctx, options); + }, options); expect(results.length).toEqual(1); await tx.rollback(); @@ -26,14 +23,11 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 46, - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({ + where: { + search: 46, + } + }, options); expect(results.length).toEqual(4); await tx.rollback(); @@ -48,14 +42,9 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'Alz', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({where: { + search: 'Alz', + }}, options); expect(results.length).toEqual(1); await tx.rollback(); @@ -70,14 +59,9 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'one', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({where: { + search: 'one', + }}, options); expect(results.length).toEqual(4); await tx.rollback(); @@ -92,14 +76,11 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'Ec', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({ + where: { + search: 'Ec', + } + }, options); expect(results.length).toEqual(1); await tx.rollback(); From b6abcbe0907eb78e28feab73800ac5abebb064e0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 10:14:20 +0200 Subject: [PATCH 045/145] feat: refs #6453 Requested changes --- .../procedures/order_confirmWithUser.sql | 65 +++---------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 4fcee91f7..17798caf8 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -11,11 +11,11 @@ BEGIN * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vIsOk BOOL; + DECLARE vHasRows BOOL; DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vShipmentDayEnd DATE; + DECLARE vShipmentDayEnd DATETIME; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItemFk INT; @@ -32,7 +32,6 @@ BEGIN DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; DECLARE vCalcFk INT; - DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; DECLARE vDates CURSOR FOR @@ -49,8 +48,7 @@ BEGIN r.itemFk, i.name, r.amount, - r.price, - i.isFloramondo + r.price FROM orderRow r JOIN vn.item i ON i.id = r.itemFk WHERE r.amount @@ -104,12 +102,12 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vIsOk + SELECT COUNT(*) > 0 INTO vHasRows FROM orderRow WHERE orderFk = vSelf AND amount > 0; - IF NOT vIsOk THEN + IF NOT vHasRows THEN CALL util.throw('ORDER_EMPTY'); END IF; @@ -209,8 +207,8 @@ BEGIN -- Añade las notas IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, + INSERT INTO vn.ticketObservation + SET ticketFk = vTicketFk, observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE @@ -222,12 +220,7 @@ BEGIN lRows: LOOP SET vSaleFk = NULL; SET vDone = FALSE; - FETCH vRows INTO vRowFk, - vItemFk, - vConcept, - vAmount, - vPrice, - vIsLogifloraItem; + FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice; IF vDone THEN LEAVE lRows; @@ -277,48 +270,6 @@ BEGIN UPDATE orderRow SET saleFk = vSaleFk WHERE id = vRowFk; - - -- Inserta en putOrder si la compra es de Floramondo - IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalcFk, FALSE,vWarehouseFk, vShipment); - - SELECT GREATEST(0, available) INTO vAvailable - FROM cache.availableNoRaids - WHERE calc_id = vCalcFk - AND item_id = vItemFk; - - UPDATE cache.availableNoRaids - SET available = GREATEST(0, available - vAmount) - WHERE item_id = vItemFk - AND calc_id = vCalcFk; - - INSERT INTO edi.putOrder ( - deliveryInformationID, - supplyResponseId, - quantity , - EndUserPartyId, - EndUserPartyGLN, - FHAdminNumber, - saleFk - ) - SELECT di.ID, - i.supplyResponseFk, - CEIL((vAmount - vAvailable)/ sr.NumberOfItemsPerCask), - o.address_id , - vClientFk, - IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSaleFk - FROM edi.deliveryInformation di - JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk - JOIN edi.floraHollandConfig fhc - JOIN `order` o ON o.id = vSelf - WHERE i.id = vItemFk - AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > vAvailable - LIMIT 1; - END IF; END LOOP; CLOSE vRows; END LOOP; From b17b5a1b21955ae12d517fb208f0ad094473a42f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 10:15:09 +0200 Subject: [PATCH 046/145] test: fix postcode filter back test --- back/methods/postcode/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/postcode/specs/filter.spec.js b/back/methods/postcode/specs/filter.spec.js index 391b1e196..abf450a19 100644 --- a/back/methods/postcode/specs/filter.spec.js +++ b/back/methods/postcode/specs/filter.spec.js @@ -1,6 +1,6 @@ const {models} = require('vn-loopback/server/server'); -fdescribe('Postcode filter()', () => { +describe('Postcode filter()', () => { it('should retrieve with no filter', async() => { const tx = await models.Postcode.beginTransaction({}); const options = {transaction: tx}; From 1f80117ff749021ca6ae5070986c78f122337b99 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 10:24:50 +0200 Subject: [PATCH 047/145] fix: refs #6861 Column --- db/routines/vn/procedures/itemShelvingSale_setQuantity.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 30abefec8..9d21e6a6f 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -103,7 +103,7 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) SELECT vSaleFk, vSectorFk; CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; From 01562420d4861b6c392a7209c92cc5ab9b6d1955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 30 Jul 2024 10:14:15 +0000 Subject: [PATCH 048/145] Actualizar db/routines/vn/procedures/itemShelvingSale_reallocate.sql --- .../itemShelvingSale_reallocate.sql | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index a60287caa..0ce4440e6 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -1,55 +1,55 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( - vItemShelvingFk INT(10), - vItemFk INT(10), - vSectorFk INT -) -BEGIN -/** - * Elimina reservas de un itemShelving e intenta reservar en otra ubicación - * - * @param vItemShelvingFk Id itemShelving - * @param vItemFk Id del artículo - * @param vSectorFk Id del sector - */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - UPDATE itemShelving - SET visible = 0, - available = 0 - WHERE id = vItemShelvingFk - AND itemFk = vItemFk; - - SELECT iss.id - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND iss.itemFk = vItemFk - AND NOT iss.isPicked - FOR UPDATE; - - INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) - SELECT DISTINCT iss.saleFk - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - - DELETE iss - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - COMMIT; - - CALL itemShelvingSale_doReserve(); -END$$ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( + vItemShelvingFk INT(10), + vItemFk INT(10), + vSectorFk INT +) +BEGIN +/** + * Elimina reservas de un itemShelving e intenta reservar en otra ubicación + * + * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND iss.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT DISTINCT iss.saleFk, vSectorFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); +END$$ DELIMITER ; \ No newline at end of file From eaa366ff39c4f1a75b34538e502ed6e15bc4d7c8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 12:36:02 +0200 Subject: [PATCH 049/145] feat workerActivity refs #6078 --- back/methods/workerActivity/add.js | 55 +++++++++++++++++++ back/methods/workerActivity/specs/add.spec.js | 41 ++++++++++++++ back/models/workerActivity.js | 3 + back/models/workerActivity.json | 22 ++++---- 4 files changed, 110 insertions(+), 11 deletions(-) create mode 100644 back/methods/workerActivity/add.js create mode 100644 back/methods/workerActivity/specs/add.spec.js create mode 100644 back/models/workerActivity.js diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js new file mode 100644 index 000000000..94c1bf57e --- /dev/null +++ b/back/methods/workerActivity/add.js @@ -0,0 +1,55 @@ + +module.exports = Self => { + Self.remoteMethodCtx('add', { + description: 'Add activity if the activity is different or is the same but have exceed time for break', + accessType: 'WRITE', + accepts: [ + { + arg: 'code', + type: 'string', + description: 'Code for activity' + }, + { + arg: 'model', + type: 'string', + description: 'Origin model from insert' + }, + + ], + http: { + path: `/add`, + verb: 'POST' + } + }); + + Self.add = async(ctx, code, model, options) => { + const userId = ctx.req.accessToken.userId; + + const result = await await Self.rawSql(` + INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) + SELECT ?, + ?, + ? + FROM workerTimeControlParams wtcp + LEFT JOIN ( + SELECT wa.workerFk, + wa.created, + wat.code + FROM workerActivity wa + LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk + WHERE wa.workerFk = ? + ORDER BY wa.created DESC + LIMIT 1 + ) sub ON TRUE + WHERE sub.workerFk IS NULL + OR sub.code <> ? + OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` + , [userId, code, model, userId, code]); + console.log('*******'); + console.log('*******' + userId); + console.log('*******' + code); + console.log('*******' + model); + + return result; + }; +}; diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js new file mode 100644 index 000000000..b0a69dc35 --- /dev/null +++ b/back/methods/workerActivity/specs/add.spec.js @@ -0,0 +1,41 @@ +const {models} = require('vn-loopback'); + +describe('workerActivity insert()', () => { + beforeAll(async() => { + ctx = { + req: { + accessToken: {}, + headers: {origin: 'http://localhost'}, + __: value => value + } + }; + }); + + fit('should insert in workerActivity', async() => { + const tx = await models.WorkerActivity.beginTransaction({}); + + try { + await models.WorkerActivityType.create( + {'code': 'STOP', 'description': 'STOP'} + ); + const options = {transaction: tx}; + ctx.req.accessToken.userId = 1106; + + models.WorkerActivity.add(ctx, 'STOP', 'APP', options); + const wac = await models.WorkerActivity.find( + {'wokerFk': 1106} + ); + console.log('----' + JSON.stringify(wac, null, 2)); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + const count = await models.WorkerActivity.count( + {'workerFK': 1106} + ); + + expect(count).toEqual(1); + }); +}); diff --git a/back/models/workerActivity.js b/back/models/workerActivity.js new file mode 100644 index 000000000..b3bb2c160 --- /dev/null +++ b/back/models/workerActivity.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/workerActivity/add')(Self); +}; diff --git a/back/models/workerActivity.json b/back/models/workerActivity.json index e3b994f77..ecd92bbce 100644 --- a/back/models/workerActivity.json +++ b/back/models/workerActivity.json @@ -22,18 +22,18 @@ }, "description": { "type": "string" + } + }, + "relations": { + "workerFk": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" }, - "relations": { - "workerFk": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "workerActivityTypeFk": { - "type": "belongsTo", - "model": "WorkerActivityType", - "foreignKey": "workerActivityTypeFk" - } + "workerActivityTypeFk": { + "type": "belongsTo", + "model": "WorkerActivityType", + "foreignKey": "workerActivityTypeFk" } } } \ No newline at end of file From 2015256f5d6a3416eb903d7e0f6b8e82af5ac5f6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 12:38:13 +0200 Subject: [PATCH 050/145] hotFix reallocate resfs #6861 --- db/versions/11177-crimsonPaniculata/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11177-crimsonPaniculata/00-firstScript.sql diff --git a/db/versions/11177-crimsonPaniculata/00-firstScript.sql b/db/versions/11177-crimsonPaniculata/00-firstScript.sql new file mode 100644 index 000000000..79bcf1291 --- /dev/null +++ b/db/versions/11177-crimsonPaniculata/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.itemShelvingSaleReserve DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK; + +ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK + FOREIGN KEY IF NOT EXISTS (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file From 9e486e4affa8593546602921ef393a18caf7533e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 13:04:33 +0200 Subject: [PATCH 051/145] hotFix reallocate iss refs #6861 --- db/routines/vn/procedures/itemShelvingSale_reallocate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index 0ce4440e6..d5b89c373 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -30,7 +30,7 @@ BEGIN FROM itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk WHERE iss.itemShelvingFk = vItemShelvingFk - AND iss.itemFk = vItemFk + AND ish.itemFk = vItemFk AND NOT iss.isPicked FOR UPDATE; From 80ad1f30af043ff4e20881fae72526add266d680 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 13:50:47 +0200 Subject: [PATCH 052/145] fix: refs #7811 Variables pm2 --- back/process.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/back/process.yml b/back/process.yml index a29323240..08fee7a93 100644 --- a/back/process.yml +++ b/back/process.yml @@ -2,6 +2,5 @@ apps: - script: ./loopback/server/server.js name: salix-back instances: 1 - max_restarts: 3 - restart_delay: 15000 + max_restarts: 0 node_args: --tls-min-v1.0 --openssl-legacy-provider From 4ef57e68692bc81008343a01a9840358d1a43d9c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 14:17:41 +0200 Subject: [PATCH 053/145] fix: refs #7821 Added orders in item_getMinacum --- db/routines/vn/procedures/item_getMinacum.sql | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index a3ebedb12..c0bdb7e7d 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -1,35 +1,38 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`( + vWarehouseFk TINYINT, + vDated DATE, + vRange INT, + vItemFk INT +) BEGIN /** - * Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de - * NULL para todo. + * Cálculo del mínimo acumulado, para un item/almacén + * especificado, en caso de NULL para todo. * - * @param vWarehouseFk -> warehouseFk - * @param vDatedFrom -> fecha inicio - * @param vRange -> número de días a considerar - * @param vItemFk -> Identificador de item + * @param vWarehouseFk Id warehouse + * @param vDated Fecha inicio + * @param vRange Número de días a considerar + * @param vItemFk Id de artículo * @return tmp.itemMinacum */ - DECLARE vDatedTo DATETIME; + DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY); - SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc; - CREATE TEMPORARY TABLE tmp.itemCalc + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY SELECT sub.itemFk, sub.dated, CAST(SUM(sub.quantity) AS SIGNED) quantity, sub.warehouseFk - FROM (SELECT s.itemFk, + FROM ( + SELECT s.itemFk, DATE(t.shipped) dated, -s.quantity quantity, t.warehouseFk FROM sale s JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + WHERE t.shipped BETWEEN vDated AND vDatedTo AND t.warehouseFk AND s.quantity != 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) @@ -42,10 +45,10 @@ BEGIN FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDatedFrom AND vDatedTo + WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL SELECT b.itemFk, @@ -55,20 +58,35 @@ BEGIN FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) AND !e.isRaid + UNION ALL + SELECT r.itemFk, + r.shipment, + -r.amount, + r.warehouseFk + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN vn.client c ON c.id = o.customer_id + WHERE r.shipment BETWEEN vDated AND vDatedTo + AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) + AND r.created >= ( + SELECT SUBTIME(util.VN_NOW(), reserveTime) + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND (vItemFk IS NULL OR r.itemFk = vItemFk) + AND r.amount <> 0 ) sub GROUP BY sub.itemFk, sub.warehouseFk, sub.dated; - CALL item_getAtp(vDatedFrom); - DROP TEMPORARY TABLE tmp.itemCalc; + CALL item_getAtp(vDated); - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; - CREATE TEMPORARY TABLE tmp.itemMinacum + CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY SELECT i.itemFk, @@ -77,6 +95,8 @@ BEGIN FROM tmp.itemAtp i HAVING amount != 0; - DROP TEMPORARY TABLE tmp.itemAtp; + DROP TEMPORARY TABLE + tmp.itemAtp, + tmp.itemCalc; END$$ DELIMITER ; From 961d05ab354944977308c5db39dc4398fce6442a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 14:19:04 +0200 Subject: [PATCH 054/145] fix: refs #7821 Added orders in item_getMinacum --- db/routines/vn/procedures/item_getMinacum.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index c0bdb7e7d..2b51355d5 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -34,7 +34,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDated AND vDatedTo AND t.warehouseFk - AND s.quantity != 0 + AND s.quantity <> 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) UNION ALL @@ -93,7 +93,7 @@ BEGIN i.warehouseFk, i.quantity amount FROM tmp.itemAtp i - HAVING amount != 0; + HAVING amount <> 0; DROP TEMPORARY TABLE tmp.itemAtp, From d97aba8e10127c2522d30f87d1b7294e55fdf22d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 17:28:55 +0200 Subject: [PATCH 055/145] hotFix getTickets refs #6861 --- back/methods/collection/getTickets.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index b79dbc93a..2a2b67524 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -57,8 +57,10 @@ module.exports = Self => { ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving, COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving, sh.code, - IFNULL(p2.code, p.code) parkingCode, - IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder, + p2.code parkingCode, + p2.pickingOrder pickingOrder, + p.code parkingCodePrevia, + p.pickingOrder pickingOrderPrevia, iss.id itemShelvingSaleFk, iss.isPicked FROM ticketCollection tc @@ -95,8 +97,10 @@ module.exports = Self => { ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder), COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) , sh.code, - IFNULL(p2.code, p.code), - IFNULL(p2.pickingOrder, p.pickingOrder), + p2.code, + p2.pickingOrder, + p.code, + p.pickingOrder, iss.id itemShelvingSaleFk, iss.isPicked FROM sectorCollection sc From 59df0b38863853fa5ace13efdf68e9fd49ceb113 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 17:46:21 +0200 Subject: [PATCH 056/145] feat workerActivity refs #6078 --- back/methods/workerActivity/add.js | 4 ---- back/methods/workerActivity/specs/add.spec.js | 4 ---- 2 files changed, 8 deletions(-) diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js index 94c1bf57e..587ebfae7 100644 --- a/back/methods/workerActivity/add.js +++ b/back/methods/workerActivity/add.js @@ -45,10 +45,6 @@ module.exports = Self => { OR sub.code <> ? OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` , [userId, code, model, userId, code]); - console.log('*******'); - console.log('*******' + userId); - console.log('*******' + code); - console.log('*******' + model); return result; }; diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js index b0a69dc35..1ca4be74f 100644 --- a/back/methods/workerActivity/specs/add.spec.js +++ b/back/methods/workerActivity/specs/add.spec.js @@ -22,10 +22,6 @@ describe('workerActivity insert()', () => { ctx.req.accessToken.userId = 1106; models.WorkerActivity.add(ctx, 'STOP', 'APP', options); - const wac = await models.WorkerActivity.find( - {'wokerFk': 1106} - ); - console.log('----' + JSON.stringify(wac, null, 2)); await tx.rollback(); } catch (e) { From 3c620462774897ab40dd1c9c48ed519117909dcb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 06:43:19 +0200 Subject: [PATCH 057/145] feat workerActivity refs #6078 --- back/methods/workerActivity/specs/add.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js index 1ca4be74f..3f9657c67 100644 --- a/back/methods/workerActivity/specs/add.spec.js +++ b/back/methods/workerActivity/specs/add.spec.js @@ -11,7 +11,7 @@ describe('workerActivity insert()', () => { }; }); - fit('should insert in workerActivity', async() => { + it('should insert in workerActivity', async() => { const tx = await models.WorkerActivity.beginTransaction({}); try { From 952b7a5054efff1b7ce6b34a33cbb87c3f13cda3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 07:10:38 +0200 Subject: [PATCH 058/145] hotFix model itemShelving refs #7805 --- modules/item/back/models/item-shelving.json | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 893a1f81d..40f2a2852 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -1,9 +1,9 @@ { "name": "ItemShelving", "base": "VnModel", - "mixins": { - "Loggable": true - }, + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "itemShelving" @@ -17,27 +17,27 @@ }, "shelvingFk": { "type": "string" - }, + }, "itemFk": { "type": "number" - }, + }, "created": { "type": "date" - }, + }, "grouping": { "type": "number" - }, - "isChecked": { - "type": "boolean" + }, + "isChecked": { + "type": "number" }, "packing": { "type": "number" - }, - "visible": { - "type": "number" }, - "userFk": { - "type": "number" + "visible": { + "type": "number" + }, + "userFk": { + "type": "number" } }, "relations": { @@ -56,6 +56,6 @@ "model": "Shelving", "foreignKey": "shelvingFk", "primaryKey": "code" - } + } } -} +} \ No newline at end of file From 07b6d2aca9ae9f3f7536ecc127afcb955866c935 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 31 Jul 2024 08:59:33 +0200 Subject: [PATCH 059/145] feat: refs #7644 Added comment if has itemOriginalFk --- print/templates/reports/buy-label/buy-label.js | 3 +-- print/templates/reports/buy-label/sql/buys.sql | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js index 7d626c052..48ffe336c 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -15,7 +15,6 @@ module.exports = { }, methods: { getBarcode(id) { - const xmlSerializer = new XMLSerializer(); const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); @@ -26,7 +25,7 @@ module.exports = { width: 3.8, height: 115, }); - return xmlSerializer.serializeToString(svgNode); + return new XMLSerializer().serializeToString(svgNode); } }, props: { diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql index 015a74797..44b1b4bad 100644 --- a/print/templates/reports/buy-label/sql/buys.sql +++ b/print/templates/reports/buy-label/sql/buys.sql @@ -21,12 +21,13 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, b.id, b.itemFk, p.name producer, - i.comment + IF(i2.id, i2.comment, i.comment) comment FROM buy b JOIN item i ON i.id = b.itemFk LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN item i2 ON i2.id = b.itemOriginalFk JOIN numbers num WHERE b.entryFk = ? AND num.n <= b.stickers From cc78355aad92cdd9c446637abe17e29f43061f92 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 31 Jul 2024 09:26:55 +0200 Subject: [PATCH 060/145] fix: refs #7821 Requested changes --- db/routines/vn/procedures/item_getMinacum.sql | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index 2b51355d5..1decf881d 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -8,7 +8,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`( BEGIN /** * Cálculo del mínimo acumulado, para un item/almacén - * especificado, en caso de NULL para todo. + * especificado, en caso de NULL para todos. * * @param vWarehouseFk Id warehouse * @param vDated Fecha inicio @@ -47,7 +47,7 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL @@ -60,10 +60,10 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND !e.isRaid + AND NOT e.isRaid UNION ALL SELECT r.itemFk, r.shipment, @@ -71,11 +71,11 @@ BEGIN r.warehouseFk FROM hedera.orderRow r JOIN hedera.`order` o ON o.id = r.orderFk - JOIN vn.client c ON c.id = o.customer_id + JOIN client c ON c.id = o.customer_id WHERE r.shipment BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) AND r.created >= ( - SELECT SUBTIME(util.VN_NOW(), reserveTime) + SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND FROM hedera.orderConfig ) AND NOT o.confirmed @@ -89,11 +89,11 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT i.itemFk, - i.warehouseFk, - i.quantity amount - FROM tmp.itemAtp i - HAVING amount <> 0; + SELECT itemFk, + warehouseFk, + quantity amount + FROM tmp.itemAtp + WHERE quantity <> 0; DROP TEMPORARY TABLE tmp.itemAtp, From dca7900ab231cbb52944a77e4264b2a35adbc270 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 31 Jul 2024 11:31:02 +0200 Subject: [PATCH 061/145] fix: refs #7818 entry_splitByShelving --- db/routines/vn/procedures/entry_splitByShelving.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index eb07c12b7..f46278e5a 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -110,7 +110,7 @@ BEGIN UPDATE itemShelving SET isSplit = TRUE - WHERE shelvingFk = vShelvingFk; + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; END LOOP; CLOSE cur; END$$ From 77fa4dd4979d1148cec6cb02cdeb87020685a436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 14:38:12 +0200 Subject: [PATCH 062/145] fix: refs #7213 componentLack y setRisk --- db/routines/vn/procedures/sale_setProblemComponentLack.sql | 2 +- .../vn/procedures/sale_setProblemComponentLackByComponent.sql | 4 ++-- db/routines/vn/procedures/ticket_setRisk.sql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemComponentLack.sql b/db/routines/vn/procedures/sale_setProblemComponentLack.sql index aa5f5f1be..23eb77c2e 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLack.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLack.sql @@ -14,7 +14,7 @@ BEGIN ENGINE = MEMORY SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem, - ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded FROM sale WHERE id = vSelf; diff --git a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql index 2ee49b656..cdf28ac09 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql @@ -14,9 +14,9 @@ BEGIN ENGINE = MEMORY SELECT saleFk, sale_hasComponentLack(saleFk) hasProblem, - ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded FROM ( - SELECT s.id saleFk, s.ticketFk + SELECT s.id saleFk, s.ticketFk, s.quantity FROM ticket t JOIN sale s ON s.ticketFk = t.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index bd5d1e9f9..b88e60a37 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -85,7 +85,7 @@ BEGIN UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id SET t.risk = NULL - WHERE tr.isProblemCalcNeeded + WHERE NOT tr.isProblemCalcNeeded ORDER BY t.id; DROP TEMPORARY TABLE tTicketRisk; From 6c0aae04c004d97d6fe31d4faa739ae5faf2be04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 14:59:12 +0200 Subject: [PATCH 063/145] fix: refs #7213 componentLack y setRisk --- db/routines/vn/procedures/ticket_setRisk.sql | 140 ++++++++----------- 1 file changed, 62 insertions(+), 78 deletions(-) diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index b88e60a37..535cd0787 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -1,94 +1,78 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`( - vClientFk INT) + vClientFk INT +) BEGIN /** - * Update the risk for a client with pending tickets + * Update the risk for a client with pending tickets. * * @param vClientFk Id cliente */ - DECLARE vHasDebt BOOL; - DECLARE vStarted DATETIME; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` - WHERE id = vClientFk - AND typeFk = 'normal'; - - IF vHasDebt THEN - - SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted - FROM clientConfig; - + IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN CREATE OR REPLACE TEMPORARY TABLE tTicketRisk - (KEY (ticketFk)) + (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - WITH ticket AS( - SELECT id ticketFk, - companyFk, - DATE(shipped) dated, - totalWithVat, - ticket_isProblemCalcNeeded(id) isProblemCalcNeeded - FROM vn.ticket - WHERE clientFk = vClientFk - AND refFk IS NULL - AND NOT isDeleted - AND IFNULL(totalWithVat, 0) <> 0 - AND shipped > vStarted - ), balance AS( - SELECT SUM(amount)amount, companyFk - FROM ( - SELECT amount, companyFk - FROM vn.clientRisk - WHERE clientFk = vClientFk - UNION ALL - SELECT -(SUM(amount) / 100) amount, tm.companyFk - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk - WHERE clientFk = vClientFk - AND receiptFk IS NULL - AND status = 'ok' - ) sub - WHERE companyFk - GROUP BY companyFk - ), uninvoiced AS( - SELECT companyFk, dated, SUM(totalWithVat) amount - FROM ticket - GROUP BY companyFk, dated - ), receipt AS( - SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount - FROM vn.receipt - WHERE clientFk = vClientFk - AND payed > util.VN_CURDATE() - GROUP BY companyFk, DATE(payed) - ), risk AS( - SELECT b.companyFk, - ui.dated, - SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) + - b.amount + - SUM(IFNULL(r.amount, 0)) amount - FROM balance b - JOIN uninvoiced ui ON ui.companyFk = b.companyFk - LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk - GROUP BY b.companyFk, ui.dated - ) - SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded - FROM ticket ti - JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk; + WITH ticket AS ( + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), balance AS ( + SELECT SUM(amount)amount, companyFk + FROM ( + SELECT amount, companyFk + FROM vn.clientRisk + WHERE clientFk = vClientFk + UNION ALL + SELECT -(SUM(amount) / 100) amount, tm.companyFk + FROM hedera.tpvTransaction t + JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk + WHERE clientFk = vClientFk + AND receiptFk IS NULL + AND `status` = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), uninvoiced AS ( + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated + ), receipt AS ( + SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount + FROM vn.receipt + WHERE clientFk = vClientFk + AND payed > util.VN_CURDATE() + GROUP BY companyFk, DATE(payed) + ), risk AS ( + SELECT b.companyFk, + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + + b.amount + + SUM(IFNULL(r.amount, 0)) amount + FROM balance b + JOIN uninvoiced ui ON ui.companyFk = b.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk + GROUP BY b.companyFk, ui.dated + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = tr.amount - WHERE tr.isProblemCalcNeeded - ORDER BY t.id; - - UPDATE ticket t - JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = NULL - WHERE NOT tr.isProblemCalcNeeded - ORDER BY t.id; + SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL); DROP TEMPORARY TABLE tTicketRisk; - END IF; + END IF; END$$ DELIMITER ; \ No newline at end of file From 65e9ed301ff370f6f0e019c44ecfda47adf526f3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 18:11:03 +0200 Subject: [PATCH 064/145] hotFix itemShelving refs #6861 --- .../itemShelvingSale_addBySaleGroup.sql | 46 +++++++++++++++++++ .../vn/procedures/itemShelving_get.sql | 3 +- .../vn/triggers/itemShelving_beforeUpdate.sql | 4 -- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql b/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql new file mode 100644 index 000000000..285b9f93f --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql @@ -0,0 +1,46 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`( + vSaleGroupFk INT(11) +) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * a través del saleGroup + * + * @param vSaleGroupFk Identificador de saleGroup + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT s.id + FROM saleGroupDetail sgd + JOIN sale s ON sgd.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sgd.saleGroupFk = vSaleGroupFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 1be762f09..d42446b06 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -16,7 +16,8 @@ BEGIN ish.id, s.priority, ish.isChecked, - ic.url + ic.url, + ish.available FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index 214c64b45..961d89f65 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -9,9 +9,5 @@ BEGIN SET NEW.userFk = account.myUser_getId(); END IF; - IF (NEW.visible <> OLD.visible) THEN - SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0); - END IF; - END$$ DELIMITER ; From 70b931553bf91c2bda7509b01023b96a34f4178f Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 18:14:09 +0200 Subject: [PATCH 065/145] hotFix itemShelving refs #6861 --- modules/item/back/models/item-shelving.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 40f2a2852..5df3b0703 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -38,6 +38,9 @@ }, "userFk": { "type": "number" + }, + "available": { + "type": "number" } }, "relations": { From 5b0dcee62d5be611423328fe6583b11237953071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 18:41:18 +0200 Subject: [PATCH 066/145] hotfix: getBuys add field comment Ticket 207748 --- modules/entry/back/methods/entry/getBuys.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index bd9c5db7a..245dada09 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -101,7 +101,8 @@ module.exports = Self => { 'groupingMode', 'inkFk', 'originFk', - 'producerFk' + 'producerFk', + 'comment' ], include: [ { From 77f6e80066b37174020dfd76446dbbd97cf5212b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 17:38:50 +0000 Subject: [PATCH 067/145] Actualizar db/routines/vn/procedures/ticket_setRisk.sql --- db/routines/vn/procedures/ticket_setRisk.sql | 113 ++++++++++--------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index 535cd0787..e3cbaf231 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -13,60 +13,65 @@ BEGIN (PRIMARY KEY (ticketFk)) ENGINE = MEMORY WITH ticket AS ( - SELECT t.id ticketFk, - t.companyFk, - DATE(t.shipped) dated, - t.totalWithVat, - ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded - FROM vn.ticket t - JOIN vn.clientConfig cc - WHERE t.clientFk = vClientFk - AND t.refFk IS NULL - AND NOT t.isDeleted - AND IFNULL(t.totalWithVat, 0) <> 0 - AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) - ), balance AS ( - SELECT SUM(amount)amount, companyFk - FROM ( - SELECT amount, companyFk - FROM vn.clientRisk - WHERE clientFk = vClientFk - UNION ALL - SELECT -(SUM(amount) / 100) amount, tm.companyFk - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk - WHERE clientFk = vClientFk - AND receiptFk IS NULL - AND `status` = 'ok' - ) sub - WHERE companyFk - GROUP BY companyFk - ), uninvoiced AS ( - SELECT companyFk, dated, SUM(totalWithVat) amount - FROM ticket - GROUP BY companyFk, dated - ), receipt AS ( - SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount - FROM vn.receipt - WHERE clientFk = vClientFk - AND payed > util.VN_CURDATE() - GROUP BY companyFk, DATE(payed) - ), risk AS ( - SELECT b.companyFk, - ui.dated, - SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + - b.amount + - SUM(IFNULL(r.amount, 0)) amount - FROM balance b - JOIN uninvoiced ui ON ui.companyFk = b.companyFk - LEFT JOIN receipt r ON r.dated > ui.dated - AND r.companyFk = ui.companyFk - GROUP BY b.companyFk, ui.dated - ) - SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded - FROM ticket ti - JOIN risk r ON r.dated = ti.dated - AND r.companyFk = ti.companyFk; + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), uninvoiced AS ( + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated + ), companies AS ( + SELECT DISTINCT companyFk FROM uninvoiced + ), balance AS ( + SELECT SUM(IFNULL(amount, 0))amount, companyFk + FROM ( + SELECT cr.amount, c.companyFk + FROM companies c + LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk + AND cr.clientFk = vClientFk + UNION ALL + SELECT -(SUM(t.amount) / 100) amount, c.companyFk + FROM companies c + LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk + LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id + AND t.clientFk = vClientFk + AND t.receiptFk IS NULL + AND t.`status` = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), receipt AS ( + SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount + FROM vn.receipt r + JOIN companies c ON c.companyFk = r.companyFk + WHERE r.clientFk = vClientFk + AND r.payed > util.VN_CURDATE() + GROUP BY r.companyFk, DATE(r.payed) + ), risk AS ( + SELECT b.companyFk, + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + + b.amount + + SUM(IFNULL(r.amount, 0)) amount + FROM balance b + JOIN uninvoiced ui ON ui.companyFk = b.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk + GROUP BY b.companyFk, ui.dated + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id From ed283cac4648e9ba9b9e6fa4fbf2813055d60c33 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 1 Aug 2024 13:15:11 +0200 Subject: [PATCH 068/145] feat: deleted worker module code & redirect to Lilium --- .../01-department/01_summary.spec.js | 29 - .../01-department/02-basicData.spec.js | 43 -- e2e/paths/03-worker/01_summary.spec.js | 34 -- e2e/paths/03-worker/02_basicData.spec.js | 40 -- e2e/paths/03-worker/03_pbx.spec.js | 32 -- e2e/paths/03-worker/04_time_control.spec.js | 65 --- e2e/paths/03-worker/05_calendar.spec.js | 114 ---- e2e/paths/03-worker/06_create.spec.js | 73 --- e2e/paths/03-worker/08_add_notes.spec.js | 42 -- modules/worker/front/basic-data/index.html | 93 ---- modules/worker/front/basic-data/index.js | 27 - modules/worker/front/basic-data/locale/es.yml | 9 - modules/worker/front/calendar/index.html | 114 ---- modules/worker/front/calendar/index.js | 302 ----------- modules/worker/front/calendar/index.spec.js | 346 ------------ modules/worker/front/calendar/locale/es.yml | 15 - modules/worker/front/calendar/style.scss | 65 --- modules/worker/front/create/index.html | 198 ------- modules/worker/front/create/index.js | 141 ----- modules/worker/front/create/index.spec.js | 133 ----- modules/worker/front/create/locale/es.yml | 13 - modules/worker/front/dms/create/index.html | 94 ---- modules/worker/front/dms/create/index.js | 113 ---- modules/worker/front/dms/create/index.spec.js | 77 --- modules/worker/front/dms/create/style.scss | 7 - modules/worker/front/dms/edit/index.html | 87 --- modules/worker/front/dms/edit/index.js | 94 ---- modules/worker/front/dms/edit/index.spec.js | 82 --- modules/worker/front/dms/edit/style.scss | 7 - modules/worker/front/dms/index/index.html | 106 ---- modules/worker/front/dms/index/index.js | 75 --- modules/worker/front/dms/index/index.spec.js | 37 -- modules/worker/front/dms/index/locale/es.yml | 9 - modules/worker/front/dms/index/style.scss | 6 - modules/worker/front/dms/locale/en.yml | 2 - modules/worker/front/dms/locale/es.yml | 20 - modules/worker/front/index.js | 15 - modules/worker/front/index/index.html | 57 -- modules/worker/front/index/index.js | 31 -- modules/worker/front/index/locale/es.yml | 1 - modules/worker/front/log/index.html | 1 - modules/worker/front/log/index.js | 7 - modules/worker/front/main/index.html | 18 - modules/worker/front/main/index.js | 10 +- modules/worker/front/note/create/index.html | 30 -- modules/worker/front/note/create/index.js | 21 - .../worker/front/note/create/index.spec.js | 22 - .../worker/front/note/create/locale/es.yml | 2 - modules/worker/front/note/index/index.html | 32 -- modules/worker/front/note/index/index.js | 22 - modules/worker/front/note/index/style.scss | 5 - modules/worker/front/notifications/index.html | 2 - modules/worker/front/notifications/index.js | 21 - modules/worker/front/pbx/index.html | 28 - modules/worker/front/pbx/index.js | 25 - modules/worker/front/pda/index.js | 18 - modules/worker/front/routes.json | 164 +----- modules/worker/front/search-panel/index.html | 67 --- modules/worker/front/search-panel/index.js | 7 - modules/worker/front/time-control/index.html | 219 -------- modules/worker/front/time-control/index.js | 507 ------------------ .../worker/front/time-control/index.spec.js | 286 ---------- .../worker/front/time-control/locale/es.yml | 22 - modules/worker/front/time-control/style.scss | 52 -- 64 files changed, 17 insertions(+), 4419 deletions(-) delete mode 100644 e2e/paths/03-worker/01-department/01_summary.spec.js delete mode 100644 e2e/paths/03-worker/01-department/02-basicData.spec.js delete mode 100644 e2e/paths/03-worker/01_summary.spec.js delete mode 100644 e2e/paths/03-worker/02_basicData.spec.js delete mode 100644 e2e/paths/03-worker/03_pbx.spec.js delete mode 100644 e2e/paths/03-worker/04_time_control.spec.js delete mode 100644 e2e/paths/03-worker/05_calendar.spec.js delete mode 100644 e2e/paths/03-worker/06_create.spec.js delete mode 100644 e2e/paths/03-worker/08_add_notes.spec.js delete mode 100644 modules/worker/front/basic-data/index.html delete mode 100644 modules/worker/front/basic-data/index.js delete mode 100644 modules/worker/front/basic-data/locale/es.yml delete mode 100644 modules/worker/front/calendar/index.html delete mode 100644 modules/worker/front/calendar/index.js delete mode 100644 modules/worker/front/calendar/index.spec.js delete mode 100644 modules/worker/front/calendar/locale/es.yml delete mode 100644 modules/worker/front/calendar/style.scss delete mode 100644 modules/worker/front/create/index.html delete mode 100644 modules/worker/front/create/index.js delete mode 100644 modules/worker/front/create/index.spec.js delete mode 100644 modules/worker/front/create/locale/es.yml delete mode 100644 modules/worker/front/dms/create/index.html delete mode 100644 modules/worker/front/dms/create/index.js delete mode 100644 modules/worker/front/dms/create/index.spec.js delete mode 100644 modules/worker/front/dms/create/style.scss delete mode 100644 modules/worker/front/dms/edit/index.html delete mode 100644 modules/worker/front/dms/edit/index.js delete mode 100644 modules/worker/front/dms/edit/index.spec.js delete mode 100644 modules/worker/front/dms/edit/style.scss delete mode 100644 modules/worker/front/dms/index/index.html delete mode 100644 modules/worker/front/dms/index/index.js delete mode 100644 modules/worker/front/dms/index/index.spec.js delete mode 100644 modules/worker/front/dms/index/locale/es.yml delete mode 100644 modules/worker/front/dms/index/style.scss delete mode 100644 modules/worker/front/dms/locale/en.yml delete mode 100644 modules/worker/front/dms/locale/es.yml delete mode 100644 modules/worker/front/index/index.html delete mode 100644 modules/worker/front/index/index.js delete mode 100644 modules/worker/front/index/locale/es.yml delete mode 100644 modules/worker/front/log/index.html delete mode 100644 modules/worker/front/log/index.js delete mode 100644 modules/worker/front/note/create/index.html delete mode 100644 modules/worker/front/note/create/index.js delete mode 100644 modules/worker/front/note/create/index.spec.js delete mode 100644 modules/worker/front/note/create/locale/es.yml delete mode 100644 modules/worker/front/note/index/index.html delete mode 100644 modules/worker/front/note/index/index.js delete mode 100644 modules/worker/front/note/index/style.scss delete mode 100644 modules/worker/front/notifications/index.html delete mode 100644 modules/worker/front/notifications/index.js delete mode 100644 modules/worker/front/pbx/index.html delete mode 100644 modules/worker/front/pbx/index.js delete mode 100644 modules/worker/front/pda/index.js delete mode 100644 modules/worker/front/search-panel/index.html delete mode 100644 modules/worker/front/search-panel/index.js delete mode 100644 modules/worker/front/time-control/index.html delete mode 100644 modules/worker/front/time-control/index.js delete mode 100644 modules/worker/front/time-control/index.spec.js delete mode 100644 modules/worker/front/time-control/locale/es.yml delete mode 100644 modules/worker/front/time-control/style.scss diff --git a/e2e/paths/03-worker/01-department/01_summary.spec.js b/e2e/paths/03-worker/01-department/01_summary.spec.js deleted file mode 100644 index e4bf8fc2d..000000000 --- a/e2e/paths/03-worker/01-department/01_summary.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -import selectors from '../../../helpers/selectors.js'; -import getBrowser from '../../../helpers/puppeteer'; - -describe('department summary path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSection('worker.department'); - await page.doSearch('INFORMATICA'); - await page.click(selectors.department.firstDepartment); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the employee summary section and check all properties', async() => { - expect(await page.waitToGetProperty(selectors.departmentSummary.header, 'innerText')).toEqual('INFORMATICA'); - expect(await page.getProperty(selectors.departmentSummary.name, 'innerText')).toEqual('INFORMATICA'); - expect(await page.getProperty(selectors.departmentSummary.code, 'innerText')).toEqual('it'); - expect(await page.getProperty(selectors.departmentSummary.chat, 'innerText')).toEqual('informatica-cau'); - expect(await page.getProperty(selectors.departmentSummary.bossDepartment, 'innerText')).toEqual(''); - expect(await page.getProperty(selectors.departmentSummary.email, 'innerText')).toEqual('-'); - expect(await page.getProperty(selectors.departmentSummary.clientFk, 'innerText')).toEqual('-'); - }); -}); diff --git a/e2e/paths/03-worker/01-department/02-basicData.spec.js b/e2e/paths/03-worker/01-department/02-basicData.spec.js deleted file mode 100644 index 219d1426c..000000000 --- a/e2e/paths/03-worker/01-department/02-basicData.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import getBrowser from '../../../helpers/puppeteer'; -import selectors from '../../../helpers/selectors.js'; - -const $ = { - form: 'vn-worker-department-basic-data form', -}; - -describe('department summary path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSection('worker.department'); - await page.doSearch('INFORMATICA'); - await page.click(selectors.department.firstDepartment); - }); - - beforeEach(async() => { - await page.accessToSection('worker.department.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should edit the department basic data and confirm the department data was edited`, async() => { - const values = { - Name: 'Informatica', - Code: 'IT', - Chat: 'informatica-cau', - Email: 'it@verdnatura.es', - }; - - await page.fillForm($.form, values); - const formValues = await page.fetchForm($.form, Object.keys(values)); - const message = await page.sendForm($.form, values); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js deleted file mode 100644 index 51992b41d..000000000 --- a/e2e/paths/03-worker/01_summary.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker summary path', () => { - const workerId = 3; - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'worker'); - const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); - }); - await page.accessToSearchResult('agencyNick'); - await httpDataResponse; - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the employee summary section and check all properties', async() => { - expect(await page.getProperty(selectors.workerSummary.header, 'innerText')).toEqual('agency agency'); - expect(await page.getProperty(selectors.workerSummary.id, 'innerText')).toEqual('3'); - expect(await page.getProperty(selectors.workerSummary.email, 'innerText')).toEqual('agency@verdnatura.es'); - expect(await page.getProperty(selectors.workerSummary.department, 'innerText')).toEqual('CAMARA'); - expect(await page.getProperty(selectors.workerSummary.userId, 'innerText')).toEqual('3'); - expect(await page.getProperty(selectors.workerSummary.userName, 'innerText')).toEqual('agency'); - expect(await page.getProperty(selectors.workerSummary.role, 'innerText')).toEqual('agency'); - expect(await page.getProperty(selectors.workerSummary.extension, 'innerText')).toEqual('1101'); - expect(await page.getProperty(selectors.workerSummary.locker, 'innerText')).toEqual('-'); - }); -}); diff --git a/e2e/paths/03-worker/02_basicData.spec.js b/e2e/paths/03-worker/02_basicData.spec.js deleted file mode 100644 index 66a597dd1..000000000 --- a/e2e/paths/03-worker/02_basicData.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker basic data path', () => { - const workerId = 1106; - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); - }); - await page.accessToSearchResult('David Charles Haller'); - await httpDataResponse; - await page.accessToSection('worker.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the form and then reload the section and check the data was edited', async() => { - await page.overwrite(selectors.workerBasicData.name, 'David C.'); - await page.overwrite(selectors.workerBasicData.surname, 'H.'); - await page.overwrite(selectors.workerBasicData.phone, '444332211'); - await page.click(selectors.workerBasicData.saveButton); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - - await page.reloadSection('worker.card.basicData'); - - expect(await page.waitToGetProperty(selectors.workerBasicData.name, 'value')).toEqual('David C.'); - expect(await page.waitToGetProperty(selectors.workerBasicData.surname, 'value')).toEqual('H.'); - expect(await page.waitToGetProperty(selectors.workerBasicData.phone, 'value')).toEqual('444332211'); - }); -}); diff --git a/e2e/paths/03-worker/03_pbx.spec.js b/e2e/paths/03-worker/03_pbx.spec.js deleted file mode 100644 index 0e8003c47..000000000 --- a/e2e/paths/03-worker/03_pbx.spec.js +++ /dev/null @@ -1,32 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker pbx path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSearchResult('employee'); - await page.accessToSection('worker.card.pbx'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should receive an error when the extension exceeds 4 characters and then sucessfully save the changes', async() => { - await page.write(selectors.workerPbx.extension, '55555'); - await page.click(selectors.workerPbx.saveButton); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('Extension format is invalid'); - - await page.overwrite(selectors.workerPbx.extension, '4444'); - await page.click(selectors.workerPbx.saveButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved! User must access web'); - }); -}); diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js deleted file mode 100644 index c6589d2e3..000000000 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker time control path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('salesBoss', 'worker'); - await page.accessToSearchResult('HankPym'); - await page.accessToSection('worker.card.timeControl'); - }); - - afterAll(async() => { - await browser.close(); - }); - - const eightAm = '08:00'; - const fourPm = '16:00'; - const hankPymId = 1107; - - it('should go to the next month, go to current month and go 1 month in the past', async() => { - let date = Date.vnNew(); - date.setDate(1); - date.setMonth(date.getMonth() + 1); - let month = date.toLocaleString('default', {month: 'long'}); - - await page.waitToClick(selectors.workerTimeControl.nextMonthButton); - let result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); - - expect(result).toContain(month); - - date = Date.vnNew(); - date.setDate(1); - month = date.toLocaleString('default', {month: 'long'}); - - await page.waitToClick(selectors.workerTimeControl.previousMonthButton); - result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); - - expect(result).toContain(month); - - date = Date.vnNew(); - date.setDate(1); - date.setMonth(date.getMonth() - 1); - const timestamp = Math.round(date.getTime() / 1000); - month = date.toLocaleString('default', {month: 'long'}); - - await page.loginAndModule('salesBoss', 'worker'); - await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`); - await page.waitToClick(selectors.workerTimeControl.secondWeekDay); - - result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText'); - - expect(result).toContain(month); - }); - - it('should change week of month', async() => { - await page.click(selectors.workerTimeControl.thrirdWeekDay); - const result = await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText'); - - expect(result).toEqual('00:00 h.'); - }); -}); diff --git a/e2e/paths/03-worker/05_calendar.spec.js b/e2e/paths/03-worker/05_calendar.spec.js deleted file mode 100644 index f0af0a053..000000000 --- a/e2e/paths/03-worker/05_calendar.spec.js +++ /dev/null @@ -1,114 +0,0 @@ -/* eslint-disable max-len */ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker calendar path', () => { - const reasonableTimeBetweenClicks = 300; - const date = Date.vnNew(); - const lastYear = (date.getFullYear() - 1).toString(); - - let browser; - let page; - - async function accessAs(user) { - await page.loginAndModule(user, 'worker'); - await page.accessToSearchResult('Charles Xavier'); - await page.accessToSection('worker.card.calendar'); - } - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - accessAs('hr'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as hr', () => { - it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => { - await page.waitToClick(selectors.workerCalendar.holidays); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.penultimateMondayOfJanuary); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.absence); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.lastMondayOfMarch); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.halfHoliday); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.fistMondayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.furlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondTuesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondWednesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondThursdayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.halfFurlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.click(selectors.workerCalendar.secondFridayOfJun); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1.5 '); - }); - }); - - describe(`as salesBoss`, () => { - it(`should log in, get to Charles Xavier's calendar, undo what was done here, and check the total holidays used are back to what it was`, async() => { - accessAs('salesBoss'); - - await page.waitToClick(selectors.workerCalendar.holidays); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.penultimateMondayOfJanuary); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.absence); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.lastMondayOfMarch); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.halfHoliday); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.fistMondayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.furlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondTuesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondWednesdayOfMay); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondThursdayOfMay); - - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.halfFurlough); - await page.waitForTimeout(reasonableTimeBetweenClicks); - await page.waitToClick(selectors.workerCalendar.secondFridayOfJun); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 '); - }); - }); - - describe(`as Charles Xavier`, () => { - it('should log in and get to his calendar, make a futile attempt to add holidays, check the total holidays used are now the initial ones and use the year selector to go to the previous year', async() => { - accessAs('CharlesXavier'); - await page.waitToClick(selectors.workerCalendar.holidays); - await page.waitForTimeout(reasonableTimeBetweenClicks); - - await page.click(selectors.workerCalendar.penultimateMondayOfJanuary); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 '); - - await page.autocompleteSearch(selectors.workerCalendar.year, lastYear); - - expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 '); - }); - }); -}); diff --git a/e2e/paths/03-worker/06_create.spec.js b/e2e/paths/03-worker/06_create.spec.js deleted file mode 100644 index 2accdfc31..000000000 --- a/e2e/paths/03-worker/06_create.spec.js +++ /dev/null @@ -1,73 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker create path', () => { - let browser; - let page; - let newWorker; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.waitToClick(selectors.workerCreate.newWorkerButton); - await page.waitForState('worker.create'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should insert default data', async() => { - await page.write(selectors.workerCreate.firstname, 'Victor'); - await page.write(selectors.workerCreate.lastname, 'Von Doom'); - await page.write(selectors.workerCreate.fi, '78457139E'); - await page.write(selectors.workerCreate.phone, '12356789'); - await page.write(selectors.workerCreate.postcode, '46680'); - await page.write(selectors.workerCreate.street, 'S/ DOOMSTADT'); - await page.write(selectors.workerCreate.email, 'doctorDoom@marvel.com'); - await page.write(selectors.workerCreate.iban, 'ES9121000418450200051332'); - - // should check for autocompleted worker code and worker user name - const workerCode = await page - .waitToGetProperty(selectors.workerCreate.code, 'value'); - - newWorker = await page - .waitToGetProperty(selectors.workerCreate.user, 'value'); - - expect(workerCode).toEqual('VVD'); - expect(newWorker).toContain('victorvd'); - - // should fail if necessary data is void - await page.waitToClick(selectors.workerCreate.createButton); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('is a required argument'); - - // should create a new worker and go to worker basic data' - await page.pickDate(selectors.workerCreate.birth, new Date(1962, 8, 5)); - await page.autocompleteSearch(selectors.workerCreate.boss, 'deliveryAssistant'); - await page.waitToClick(selectors.workerCreate.createButton); - message = await page.waitForSnackbar(); - await page.waitForState('worker.card.basicData'); - - expect(message.text).toContain('Data saved!'); - - // 'rollback' - await page.loginAndModule('itManagement', 'account'); - await page.accessToSearchResult(newWorker); - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deactivateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('User deactivated!'); - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.disableAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Account disabled!'); - }); -}); diff --git a/e2e/paths/03-worker/08_add_notes.spec.js b/e2e/paths/03-worker/08_add_notes.spec.js deleted file mode 100644 index bdc475c90..000000000 --- a/e2e/paths/03-worker/08_add_notes.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Worker Add notes path', () => { - let browser; - let page; - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('hr', 'worker'); - await page.accessToSearchResult('Bruce Banner'); - await page.accessToSection('worker.card.note.index'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should reach the notes index`, async() => { - await page.waitForState('worker.card.note.index'); - }); - - it(`should click on the add note button`, async() => { - await page.waitToClick(selectors.workerNotes.addNoteFloatButton); - await page.waitForState('worker.card.note.create'); - }); - - it(`should create a note`, async() => { - await page.waitForSelector(selectors.workerNotes.note); - await page.type(`${selectors.workerNotes.note} textarea`, 'Meeting with Black Widow 21st 9am'); - await page.waitToClick(selectors.workerNotes.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the note was created', async() => { - const result = await page.waitToGetProperty(selectors.workerNotes.firstNoteText, 'innerText'); - - expect(result).toEqual('Meeting with Black Widow 21st 9am'); - }); -}); diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html deleted file mode 100644 index bece1b6fd..000000000 --- a/modules/worker/front/basic-data/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js deleted file mode 100644 index ea75d7b97..000000000 --- a/modules/worker/front/basic-data/index.js +++ /dev/null @@ -1,27 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.maritalStatus = [ - {code: 'M', name: this.$t('Married')}, - {code: 'S', name: this.$t('Single')} - ]; - } - onSubmit() { - return this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.vnComponent('vnWorkerBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - }, - require: { - card: '^vnWorkerCard' - } -}); diff --git a/modules/worker/front/basic-data/locale/es.yml b/modules/worker/front/basic-data/locale/es.yml deleted file mode 100644 index edf08de90..000000000 --- a/modules/worker/front/basic-data/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Marital status: Estado civil -Origin country: País origen -Education level: Nivel educación -SSN: NSS -Married: Casado/a -Single: Soltero/a -Business phone: Teléfono de empresa -Mobile extension: Extensión móvil -Locker: Taquilla diff --git a/modules/worker/front/calendar/index.html b/modules/worker/front/calendar/index.html deleted file mode 100644 index 1b0608633..000000000 --- a/modules/worker/front/calendar/index.html +++ /dev/null @@ -1,114 +0,0 @@ - - -
-
- - - - - - -
-
-
- Autonomous worker -
- -
-
-
{{'Contract' | translate}} #{{$ctrl.businessId}}
-
- {{'Used' | translate}} {{$ctrl.contractHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.contractHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.contractHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- {{'Paid holidays' | translate}} {{$ctrl.contractHolidays.payedHolidays || 0}} {{'days' | translate}} -
-
- -
-
{{'Year' | translate}} {{$ctrl.year}}
-
- {{'Used' | translate}} {{$ctrl.yearHolidays.holidaysEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHolidays || 0}} {{'days' | translate}} -
-
- {{'Spent' | translate}} {{$ctrl.yearHolidays.hoursEnjoyed || 0}} - {{'of' | translate}} {{$ctrl.yearHolidays.totalHours || 0}} {{'hours' | translate}} -
-
- -
- - - - -
#{{businessFk}}
-
- {{started | date: 'dd/MM/yyyy'}} - {{ended ? (ended | date: 'dd/MM/yyyy') : 'Indef.'}} -
-
-
-
-
- - - - - - {{absenceType.name}} - -
-
- - - - Festive - - - - - Current day - -
-
-
- - - - diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js deleted file mode 100644 index 5606ad0ce..000000000 --- a/modules/worker/front/calendar/index.js +++ /dev/null @@ -1,302 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.date = Date.vnNew(); - this.events = {}; - this.buildYearFilter(); - } - - get year() { - return this.date.getFullYear(); - } - - set year(value) { - const newYear = Date.vnNew(); - newYear.setFullYear(value); - - this.date = newYear; - - this.refresh() - .then(() => this.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()); - } - - get businessId() { - return this._businessId; - } - - set businessId(value) { - if (!this.card.hasWorkCenter) return; - - this._businessId = value; - if (value) { - this.refresh() - .then(() => this.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()); - } - } - - get date() { - return this._date; - } - - set date(value) { - this._date = value; - value.setHours(0, 0, 0, 0); - - this.months = new Array(12); - - for (let i = 0; i < this.months.length; i++) { - const now = new Date(value.getTime()); - now.setDate(1); - now.setMonth(i); - this.months[i] = now; - } - } - - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - if (value) { - this.getIsSubordinate(); - this.getActiveContract(); - } - } - - buildYearFilter() { - const now = Date.vnNew(); - now.setFullYear(now.getFullYear() + 1); - - const maxYear = now.getFullYear(); - const minRange = maxYear - 5; - - const years = []; - for (let i = maxYear; i > minRange; i--) - years.push({year: i}); - - this.yearFilter = years; - } - - getIsSubordinate() { - this.$http.get(`Workers/${this.worker.id}/isSubordinate`) - .then(res => this.isSubordinate = res.data); - } - - getActiveContract() { - this.$http.get(`Workers/${this.worker.id}/activeContract`) - .then(res => { - if (res.data) this.businessId = res.data.businessFk; - }); - } - - getContractHolidays() { - this.getHolidays({ - businessFk: this.businessId, - year: this.year - }, data => this.contractHolidays = data); - } - - getYearHolidays() { - this.getHolidays({ - year: this.year - }, data => this.yearHolidays = data); - } - - getHolidays(params, cb) { - this.$http.get(`Workers/${this.worker.id}/holidays`, {params}) - .then(res => cb(res.data)); - } - - onData(data) { - this.events = {}; - this.calendar = data.calendar; - - let addEvent = (day, newEvent) => { - const timestamp = new Date(day).getTime(); - const event = this.events[timestamp]; - - if (event) { - const oldName = event.name; - Object.assign(event, newEvent); - event.name = `${oldName}, ${event.name}`; - } else - this.events[timestamp] = newEvent; - }; - - if (data.holidays) { - data.holidays.forEach(holiday => { - const holidayDetail = holiday.detail && holiday.detail.name; - const holidayType = holiday.type && holiday.type.name; - const holidayName = holidayDetail || holidayType; - - addEvent(holiday.dated, { - name: holidayName, - className: 'festive' - }); - }); - } - if (data.absences) { - data.absences.forEach(absence => { - let type = absence.absenceType; - addEvent(absence.dated, { - name: type.name, - color: type.rgb, - type: type.code, - absenceId: absence.id - }); - }); - } - } - - repaint() { - let calendars = this.element.querySelectorAll('vn-calendar'); - for (let calendar of calendars) - calendar.$ctrl.repaint(); - } - - formatDay(day, element) { - let event = this.events[day.getTime()]; - if (!event) return; - - let dayNumber = element.firstElementChild; - dayNumber.title = event.name; - dayNumber.style.backgroundColor = event.color; - - if (event.border) - dayNumber.style.border = event.border; - - if (event.className) - dayNumber.classList.add(event.className); - } - - pick(absenceType) { - if (!this.isSubordinate) return; - if (absenceType == this.absenceType) - absenceType = null; - - this.absenceType = absenceType; - } - - onSelection($event, $days) { - if (!this.absenceType) - return this.vnApp.showMessage(this.$t('Choose an absence type from the right menu')); - - const day = $days[0]; - const stamp = day.getTime(); - const event = this.events[stamp]; - const calendar = $event.target.closest('vn-calendar').$ctrl; - - if (event && event.absenceId) { - if (event.type == this.absenceType.code) - this.delete(calendar, day, event); - else - this.edit(calendar, event); - } else - this.create(calendar, day); - } - - create(calendar, dated) { - const absenceType = this.absenceType; - const params = { - dated: dated, - absenceTypeId: absenceType.id, - businessFk: this.businessId - }; - - const path = `Workers/${this.$params.id}/createAbsence`; - this.$http.post(path, params).then(res => { - const newEvent = res.data; - this.events[dated.getTime()] = { - name: absenceType.name, - color: absenceType.rgb, - type: absenceType.code, - absenceId: newEvent.id - }; - - this.repaintCanceller(() => - this.refresh() - .then(calendar.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()) - .then(() => this.repaint()) - ); - }); - } - - edit(calendar, event) { - const absenceType = this.absenceType; - const params = { - absenceId: event.absenceId, - absenceTypeId: absenceType.id - }; - const path = `Workers/${this.$params.id}/updateAbsence`; - this.$http.patch(path, params).then(() => { - event.color = absenceType.rgb; - event.name = absenceType.name; - event.type = absenceType.code; - - this.repaintCanceller(() => - this.refresh() - .then(calendar.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()) - ); - }); - } - - delete(calendar, day, event) { - const params = {absenceId: event.absenceId}; - const path = `Workers/${this.$params.id}/deleteAbsence`; - this.$http.delete(path, {params}).then(() => { - delete this.events[day.getTime()]; - - this.repaintCanceller(() => - this.refresh() - .then(calendar.repaint()) - .then(() => this.getContractHolidays()) - .then(() => this.getYearHolidays()) - .then(() => this.repaint()) - ); - }); - } - - repaintCanceller(cb) { - if (this.canceller) { - clearTimeout(this.canceller); - this.canceller = null; - } - - this.canceller = setTimeout( - () => cb(), 500); - } - - refresh() { - const params = { - workerFk: this.$params.id, - businessFk: this.businessId, - year: this.year - }; - return this.$http.get(`Calendars/absences`, {params}) - .then(res => this.onData(res.data)); - } -} - -ngModule.vnComponent('vnWorkerCalendar', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - }, - require: { - card: '^vnWorkerCard' - } -}); diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js deleted file mode 100644 index 5d7ae0795..000000000 --- a/modules/worker/front/calendar/index.spec.js +++ /dev/null @@ -1,346 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnWorkerCalendar', () => { - let $httpBackend; - let $httpParamSerializer; - let $scope; - let controller; - let year = Date.vnNew().getFullYear(); - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnWorkerCalendar', {$element, $scope}); - controller.isSubordinate = true; - controller.absenceType = {id: 1, name: 'Holiday', code: 'holiday', rgb: 'red'}; - controller.$params.id = 1106; - controller._worker = {id: 1106}; - controller.card = { - hasWorkCenter: true - }; - })); - - describe('year() getter', () => { - it(`should return the year number of the calendar date`, () => { - expect(controller.year).toEqual(year); - }); - }); - - describe('year() setter', () => { - it(`should set the year of the calendar date`, () => { - jest.spyOn(controller, 'refresh').mockReturnValue(Promise.resolve()); - - const previousYear = year - 1; - controller.year = previousYear; - - expect(controller.year).toEqual(previousYear); - expect(controller.date.getFullYear()).toEqual(previousYear); - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('businessId() setter', () => { - it(`should set the contract id and then call to the refresh method`, () => { - jest.spyOn(controller, 'refresh').mockReturnValue(Promise.resolve()); - - controller.businessId = 1106; - - expect(controller.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('months property', () => { - it(`should return an array of twelve months length`, () => { - const started = new Date(year, 0, 1); - const ended = new Date(year, 11, 1); - - expect(controller.months.length).toEqual(12); - expect(controller.months[0]).toEqual(started); - expect(controller.months[11]).toEqual(ended); - }); - }); - - describe('worker() setter', () => { - it(`should perform a get query and set the reponse data on the model`, () => { - controller.getIsSubordinate = jest.fn(); - controller.getActiveContract = jest.fn(); - - let today = Date.vnNew(); - let tomorrow = new Date(today.getTime()); - tomorrow.setDate(tomorrow.getDate() + 1); - - let yesterday = new Date(today.getTime()); - yesterday.setDate(yesterday.getDate() - 1); - - controller.worker = {id: 1107}; - - expect(controller.getIsSubordinate).toHaveBeenCalledWith(); - expect(controller.getActiveContract).toHaveBeenCalledWith(); - }); - }); - - describe('getIsSubordinate()', () => { - it(`should return whether the worker is a subordinate`, () => { - $httpBackend.expect('GET', `Workers/1106/isSubordinate`).respond(true); - controller.getIsSubordinate(); - $httpBackend.flush(); - - expect(controller.isSubordinate).toBe(true); - }); - }); - - describe('getActiveContract()', () => { - it(`should return the current contract and then set the businessId property`, () => { - jest.spyOn(controller, 'refresh').mockReturnValue(Promise.resolve()); - - $httpBackend.expect('GET', `Workers/1106/activeContract`).respond({businessFk: 1106}); - controller.getActiveContract(); - $httpBackend.flush(); - - expect(controller.businessId).toEqual(1106); - }); - }); - - describe('getContractHolidays()', () => { - it(`should return the worker holidays amount and then set the contractHolidays property`, () => { - const today = Date.vnNew(); - const year = today.getFullYear(); - - const serializedParams = $httpParamSerializer({year}); - $httpBackend.expect('GET', `Workers/1106/holidays?${serializedParams}`).respond({totalHolidays: 28}); - controller.getContractHolidays(); - $httpBackend.flush(); - - expect(controller.contractHolidays).toEqual({totalHolidays: 28}); - }); - }); - - describe('formatDay()', () => { - it(`should set the day element style`, () => { - const today = Date.vnNew(); - - controller.events[today.getTime()] = { - name: 'Holiday', - color: '#000' - }; - - const dayElement = angular.element('
')[0]; - const dayNumber = dayElement.firstElementChild; - - controller.formatDay(today, dayElement); - - expect(dayNumber.title).toEqual('Holiday'); - expect(dayNumber.style.backgroundColor).toEqual('rgb(0, 0, 0)'); - }); - }); - - describe('pick()', () => { - it(`should set the absenceType property to null if they match with the current one`, () => { - const absenceType = {id: 1, name: 'Holiday'}; - controller.absenceType = absenceType; - controller.pick(absenceType); - - expect(controller.absenceType).toBeNull(); - }); - - it(`should set the absenceType property`, () => { - const absenceType = {id: 1, name: 'Holiday'}; - const expectedAbsence = {id: 2, name: 'Leave of absence'}; - controller.absenceType = absenceType; - controller.pick(expectedAbsence); - - expect(controller.absenceType).toEqual(expectedAbsence); - }); - }); - - describe('onSelection()', () => { - it(`should show an snackbar message if no absence type is selected`, () => { - jest.spyOn(controller.vnApp, 'showMessage').mockReturnThis(); - - const $event = {}; - const $days = []; - controller.absenceType = null; - controller.onSelection($event, $days); - - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Choose an absence type from the right menu'); - }); - - it(`should call to the create() method`, () => { - jest.spyOn(controller, 'create').mockReturnThis(); - - const selectedDay = Date.vnNew(); - const $event = { - target: { - closest: () => { - return {$ctrl: {}}; - } - } - }; - const $days = [selectedDay]; - controller.absenceType = {id: 1}; - controller.onSelection($event, $days); - - expect(controller.create).toHaveBeenCalledWith(jasmine.any(Object), selectedDay); - }); - - it(`should call to the delete() method`, () => { - jest.spyOn(controller, 'delete').mockReturnThis(); - - const selectedDay = Date.vnNew(); - const expectedEvent = { - dated: selectedDay, - type: 'holiday', - absenceId: 1 - }; - const $event = { - target: { - closest: () => { - return {$ctrl: {}}; - } - } - }; - const $days = [selectedDay]; - controller.events[selectedDay.getTime()] = expectedEvent; - controller.absenceType = {id: 1, code: 'holiday'}; - controller.onSelection($event, $days); - - expect(controller.delete).toHaveBeenCalledWith(jasmine.any(Object), selectedDay, expectedEvent); - }); - - it(`should call to the edit() method`, () => { - jest.spyOn(controller, 'edit').mockReturnThis(); - - const selectedDay = Date.vnNew(); - const expectedEvent = { - dated: selectedDay, - type: 'leaveOfAbsence', - absenceId: 1 - }; - const $event = { - target: { - closest: () => { - return {$ctrl: {}}; - } - } - }; - const $days = [selectedDay]; - controller.events[selectedDay.getTime()] = expectedEvent; - controller.absenceType = {id: 1, code: 'holiday'}; - controller.onSelection($event, $days); - - expect(controller.edit).toHaveBeenCalledWith(jasmine.any(Object), expectedEvent); - }); - }); - - describe('create()', () => { - it(`should make a HTTP POST query and then call to the repaintCanceller() method`, () => { - jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - - const dated = Date.vnNew(); - const calendarElement = {}; - const expectedResponse = {id: 10}; - - $httpBackend.expect('POST', `Workers/1106/createAbsence`).respond(200, expectedResponse); - controller.create(calendarElement, dated); - $httpBackend.flush(); - - const createdEvent = controller.events[dated.getTime()]; - const absenceType = controller.absenceType; - - expect(createdEvent.absenceId).toEqual(expectedResponse.id); - expect(createdEvent.color).toEqual(absenceType.rgb); - expect(controller.repaintCanceller).toHaveBeenCalled(); - }); - }); - - describe('edit()', () => { - it(`should make a HTTP PATCH query and then call to the repaintCanceller() method`, () => { - jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - - const event = {absenceId: 10}; - const calendarElement = {}; - const newAbsenceType = { - id: 2, - name: 'Leave of absence', - code: 'leaveOfAbsence', - rgb: 'purple' - }; - controller.absenceType = newAbsenceType; - - const expectedParams = {absenceId: 10, absenceTypeId: 2}; - $httpBackend.expect('PATCH', `Workers/1106/updateAbsence`, expectedParams).respond(200); - controller.edit(calendarElement, event); - $httpBackend.flush(); - - expect(event.name).toEqual(newAbsenceType.name); - expect(event.color).toEqual(newAbsenceType.rgb); - expect(event.type).toEqual(newAbsenceType.code); - expect(controller.repaintCanceller).toHaveBeenCalled(); - }); - }); - - describe('delete()', () => { - it(`should make a HTTP DELETE query and then call to the repaintCanceller() method`, () => { - jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - - const expectedParams = {absenceId: 10}; - const calendarElement = {}; - const selectedDay = Date.vnNew(); - const expectedEvent = { - dated: selectedDay, - type: 'leaveOfAbsence', - absenceId: 10 - }; - - controller.events[selectedDay.getTime()] = expectedEvent; - - const serializedParams = $httpParamSerializer(expectedParams); - $httpBackend.expect('DELETE', `Workers/1106/deleteAbsence?${serializedParams}`).respond(200); - controller.delete(calendarElement, selectedDay, expectedEvent); - $httpBackend.flush(); - - const event = controller.events[selectedDay.getTime()]; - - expect(event).toBeUndefined(); - expect(controller.repaintCanceller).toHaveBeenCalled(); - }); - }); - - describe('repaintCanceller()', () => { - it(`should cancell the callback execution timer`, () => { - jest.spyOn(window, 'clearTimeout'); - jest.spyOn(window, 'setTimeout'); - - const timeoutId = 90; - controller.canceller = timeoutId; - - controller.repaintCanceller(() => { - return 'My callback'; - }); - - expect(window.clearTimeout).toHaveBeenCalledWith(timeoutId); - expect(window.setTimeout).toHaveBeenCalledWith(jasmine.any(Function), 500); - }); - }); - - describe('refresh()', () => { - it(`should make a HTTP GET query and then call to the onData() method`, () => { - jest.spyOn(controller, 'onData').mockReturnThis(); - - const expecteResponse = [{id: 1}]; - const expectedParams = {workerFk: controller.worker.id, year: year}; - const serializedParams = $httpParamSerializer(expectedParams); - $httpBackend.expect('GET', `Calendars/absences?${serializedParams}`).respond(200, expecteResponse); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.onData).toHaveBeenCalledWith(expecteResponse); - }); - }); - }); -}); diff --git a/modules/worker/front/calendar/locale/es.yml b/modules/worker/front/calendar/locale/es.yml deleted file mode 100644 index 50bb4bb52..000000000 --- a/modules/worker/front/calendar/locale/es.yml +++ /dev/null @@ -1,15 +0,0 @@ -Calendar: Calendario -Contract: Contrato -Festive: Festivo -Used: Utilizados -Spent: Utilizadas -Year: Año -of: de -days: días -hours: horas -Choose an absence type from the right menu: Elige un tipo de ausencia desde el menú de la derecha -To start adding absences, click an absence type from the right menu and then on the day you want to add an absence: Para empezar a añadir ausencias, haz clic en un tipo de ausencia desde el menu de la derecha y después en el día que quieres añadir la ausencia -You can just add absences within the current year: Solo puedes añadir ausencias dentro del año actual -Current day: Día actual -Paid holidays: Vacaciones pagadas -Autonomous worker: Trabajador autónomo diff --git a/modules/worker/front/calendar/style.scss b/modules/worker/front/calendar/style.scss deleted file mode 100644 index e99f64689..000000000 --- a/modules/worker/front/calendar/style.scss +++ /dev/null @@ -1,65 +0,0 @@ -@import "variables"; - -vn-worker-calendar { - .calendars { - position: relative; - display: flex; - flex-wrap: wrap; - justify-content: center; - align-items: center; - box-sizing: border-box; - padding: $spacing-md; - - & > vn-calendar { - border: $border-thin; - margin: $spacing-md; - padding: $spacing-xs; - max-width: 288px; - } - } - - vn-chip.selectable { - cursor: pointer - } - - vn-chip.selectable:hover { - opacity: 0.8 - } - - vn-chip vn-avatar { - text-align: center; - color: white - } - - vn-icon[icon="info"] { - position: absolute; - top: 16px; - right: 16px - } - - vn-side-menu div > .input { - border-bottom: $border-thin; - } - - .festive, - vn-avatar.today { - color: $color-font; - width: 24px; - min-width: 24px; - height: 24px - } - - .festive { - border: 2px solid $color-alert - } - - vn-avatar.today { - border: 2px solid $color-font-link - } - - .check { - margin-top: 0.5px; - margin-left: -3px; - font-size: 125%; - } -} diff --git a/modules/worker/front/create/index.html b/modules/worker/front/create/index.html deleted file mode 100644 index 3030ffecd..000000000 --- a/modules/worker/front/create/index.html +++ /dev/null @@ -1,198 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - {{code}} - {{town.name}} ({{town.province.name}}, - {{town.province.country.name}}) - - - - - - - - {{name}} ({{country.name}}) - - - - - - {{name}}, {{province.name}} - ({{province.country.name}}) - - - - - - - - - - - - - - - - - - - - - - - - {{bic}} {{name}} - - - - - - - - - - - - - -
- - - diff --git a/modules/worker/front/create/index.js b/modules/worker/front/create/index.js deleted file mode 100644 index e6d65221f..000000000 --- a/modules/worker/front/create/index.js +++ /dev/null @@ -1,141 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.worker = {companyFk: this.vnConfig.user.companyFk}; - this.$http.get(`WorkerConfigs/findOne`, {field: ['payMethodFk']}).then(res => { - if (res.data) this.worker.payMethodFk = res.data.payMethodFk; - }); - } - - onSubmit() { - if (!this.worker.iban && !this.worker.bankEntityFk) { - delete this.worker.iban; - delete this.worker.bankEntityFk; - } - - return this.$.watcher.submit().then(json => { - this.$state.go('worker.card.basicData', {id: json.data.id}); - }); - } - - get ibanCountry() { - if (!this.worker || !this.worker.iban) return false; - - let countryCode = this.worker.iban.substr(0, 2); - - return countryCode; - } - - autofillBic() { - if (!this.worker || !this.worker.iban) return; - - let bankEntityId = parseInt(this.worker.iban.substr(4, 4)); - let filter = {where: {id: bankEntityId}}; - - this.$http.get(`BankEntities`, {filter}).then(response => { - const hasData = response.data && response.data[0]; - - if (hasData) - this.worker.bankEntityFk = response.data[0].id; - else if (!hasData) - this.worker.bankEntityFk = null; - }); - } - - generateCodeUser() { - if (!this.worker.firstName || !this.worker.lastNames) return; - - const totalName = this.worker.firstName.concat(' ' + this.worker.lastNames).toLowerCase(); - const totalNameArray = totalName.split(' '); - let newCode = ''; - - for (let part of totalNameArray) - newCode += part.charAt(0); - - this.worker.code = newCode.toUpperCase().slice(0, 3); - this.worker.name = totalNameArray[0] + newCode.slice(1); - - if (!this.worker.companyFk) - this.worker.companyFk = this.vnConfig.user.companyFk; - } - - get province() { - return this._province; - } - - // Province auto complete - set province(selection) { - this._province = selection; - - if (!selection) return; - - const country = selection.country; - - if (!this.worker.countryFk) - this.worker.countryFk = country.id; - } - - get town() { - return this._town; - } - - // Town auto complete - set town(selection) { - this._town = selection; - - if (!selection) return; - - const province = selection.province; - const country = province.country; - const postcodes = selection.postcodes; - - if (!this.worker.provinceFk) - this.worker.provinceFk = province.id; - - if (!this.worker.countryFk) - this.worker.countryFk = country.id; - - if (postcodes.length === 1) - this.worker.postcode = postcodes[0].code; - } - - get postcode() { - return this._postcode; - } - - // Postcode auto complete - set postcode(selection) { - this._postcode = selection; - - if (!selection) return; - - const town = selection.town; - const province = town.province; - const country = province.country; - - if (!this.worker.city) - this.worker.city = town.name; - - if (!this.worker.provinceFk) - this.worker.provinceFk = province.id; - - if (!this.worker.countryFk) - this.worker.countryFk = country.id; - } - - onResponse(response) { - this.worker.postcode = response.code; - this.worker.city = response.city; - this.worker.provinceFk = response.provinceFk; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/worker/front/create/index.spec.js b/modules/worker/front/create/index.spec.js deleted file mode 100644 index c2e9acce0..000000000 --- a/modules/worker/front/create/index.spec.js +++ /dev/null @@ -1,133 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnWorkerCreate', () => { - let $scope; - let $state; - let controller; - - beforeEach(ngModule('worker')); - - 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('vnWorkerCreate', {$element, $scope}); - controller.worker = {}; - controller.vnConfig = {user: {companyFk: 1}}; - })); - - describe('onSubmit()', () => { - it(`should call submit() on the watcher then expect a callback`, () => { - jest.spyOn($state, 'go'); - controller.onSubmit(); - - expect(controller.$state.go).toHaveBeenCalledWith('worker.card.basicData', {id: '1234'}); - }); - }); - - describe('province() setter', () => { - it(`should set countryFk property`, () => { - controller.worker.countryFk = null; - controller.province = { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }; - - expect(controller.worker.countryFk).toEqual(2); - }); - }); - - describe('town() setter', () => { - it(`should set provinceFk property`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [] - }; - - expect(controller.worker.provinceFk).toEqual(1); - }); - - it(`should set provinceFk property and fill the postalCode if there's just one`, () => { - controller.town = { - provinceFk: 1, - code: 46001, - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - }, - postcodes: [{code: '46001'}] - }; - - expect(controller.worker.provinceFk).toEqual(1); - expect(controller.worker.postcode).toEqual('46001'); - }); - }); - - describe('postcode() setter', () => { - it(`should set the town, provinceFk and contryFk properties`, () => { - controller.postcode = { - townFk: 1, - code: 46001, - town: { - id: 1, - name: 'New York', - province: { - id: 1, - name: 'New york', - country: { - id: 2, - name: 'USA' - } - } - } - }; - - expect(controller.worker.city).toEqual('New York'); - expect(controller.worker.provinceFk).toEqual(1); - expect(controller.worker.countryFk).toEqual(2); - }); - }); - - describe('generateCodeUser()', () => { - it(`should generate worker code, name and company `, () => { - controller.worker = { - firstName: 'default', - lastNames: 'generate worker' - }; - - controller.generateCodeUser(); - - expect(controller.worker.code).toEqual('DGW'); - expect(controller.worker.name).toEqual('defaultgw'); - expect(controller.worker.companyFk).toEqual(controller.vnConfig.user.companyFk); - }); - }); - }); -}); diff --git a/modules/worker/front/create/locale/es.yml b/modules/worker/front/create/locale/es.yml deleted file mode 100644 index 4e8d2df1e..000000000 --- a/modules/worker/front/create/locale/es.yml +++ /dev/null @@ -1,13 +0,0 @@ -Firstname: Nombre -Lastname: Apellidos -Fi: DNI/NIF/NIE -Birth: Fecha de nacimiento -Worker code: Código de trabajador -Province: Provincia -City: Población -ProfileType: Tipo de perfil -Street: Dirección -Postcode: Código postal -Web user: Usuario Web -Access permission: Permiso de acceso -Pay method: Método de pago diff --git a/modules/worker/front/dms/create/index.html b/modules/worker/front/dms/create/index.html deleted file mode 100644 index 0f2d51dd3..000000000 --- a/modules/worker/front/dms/create/index.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/worker/front/dms/create/index.js b/modules/worker/front/dms/create/index.js deleted file mode 100644 index ff6112211..000000000 --- a/modules/worker/front/dms/create/index.js +++ /dev/null @@ -1,113 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.dms = { - files: [], - hasFile: false, - hasFileAttached: false - }; - } - - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - - if (value) { - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const params = {filter: { - where: {code: 'hhrrData'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - const dmsType = res.data && res.data; - const companyId = this.vnConfig.companyFk; - const warehouseId = this.vnConfig.warehouseFk; - const defaultParams = { - reference: this.worker.id, - warehouseId: warehouseId, - companyId: companyId, - dmsTypeId: dmsType.id, - description: this.$t('WorkerFileDescription', { - dmsTypeName: dmsType.name, - workerId: this.worker.id, - workerName: this.worker.name - }).toUpperCase() - }; - - this.dms = Object.assign(this.dms, defaultParams); - }); - } - - onSubmit() { - const query = `Workers/${this.worker.id}/uploadFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.watcher.updateOriginalData(); - this.$state.go('worker.card.dms.index'); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerDmsCreate', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/dms/create/index.spec.js b/modules/worker/front/dms/create/index.spec.js deleted file mode 100644 index 08a2a5981..000000000 --- a/modules/worker/front/dms/create/index.spec.js +++ /dev/null @@ -1,77 +0,0 @@ -import './index'; - -describe('Client', () => { - describe('Component vnWorkerDmsCreate', () => { - let $element; - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($compile, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $element = $compile(``)($rootScope); - controller = $element.controller('vnWorkerDmsCreate'); - controller._worker = {id: 1101, name: 'Bruce wayne'}; - $httpBackend.whenRoute('GET', `Warehouses?filter=%7B%7D`).respond([{$oldData: {}}]); - })); - - describe('worker() setter', () => { - it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller.worker = { - id: 15, - name: 'Bruce wayne' - }; - - expect(controller.worker).toBeDefined(); - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - $httpBackend.whenRoute('GET', `DmsTypes`).respond({id: 12, code: 'hhrrData'}); - const params = {filter: { - where: {code: 'hhrrData'} - }}; - let serializedParams = $httpParamSerializer(params); - $httpBackend.when('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 12, code: 'hhrrData'}); - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.reference).toEqual(1101); - expect(controller.dms.dmsTypeId).toEqual(12); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - }); -}); diff --git a/modules/worker/front/dms/create/style.scss b/modules/worker/front/dms/create/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/worker/front/dms/create/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/worker/front/dms/edit/index.html b/modules/worker/front/dms/edit/index.html deleted file mode 100644 index 39d4af801..000000000 --- a/modules/worker/front/dms/edit/index.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/worker/front/dms/edit/index.js b/modules/worker/front/dms/edit/index.js deleted file mode 100644 index 31d4c2853..000000000 --- a/modules/worker/front/dms/edit/index.js +++ /dev/null @@ -1,94 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - - if (value) { - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const path = `Dms/${this.$params.dmsId}`; - this.$http.get(path).then(res => { - const dms = res.data && res.data; - this.dms = { - reference: dms.reference, - warehouseId: dms.warehouseFk, - companyId: dms.companyFk, - dmsTypeId: dms.dmsTypeFk, - description: dms.description, - hasFile: dms.hasFile, - hasFileAttached: false, - files: [] - }; - }); - } - - onSubmit() { - const query = `dms/${this.$params.dmsId}/updateFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.watcher.updateOriginalData(); - this.$state.go('worker.card.dms.index'); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } -} - -ngModule.vnComponent('vnWorkerDmsEdit', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/dms/edit/index.spec.js b/modules/worker/front/dms/edit/index.spec.js deleted file mode 100644 index 0b69f2894..000000000 --- a/modules/worker/front/dms/edit/index.spec.js +++ /dev/null @@ -1,82 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnClientDmsEdit', () => { - let controller; - let $scope; - let $element; - let $httpBackend; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $element = angular.element(` { - it('should set the worker data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller._worker = undefined; - controller.worker = { - id: 1106 - }; - - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.worker).toBeDefined(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const dmsId = 4; - const expectedResponse = { - reference: 1101, - warehouseFk: 1, - companyFk: 442, - dmsTypeFk: 3, - description: 'Test', - hasFile: false, - hasFileAttached: false - }; - - $httpBackend.expect('GET', `Dms/${dmsId}`).respond(expectedResponse); - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.reference).toEqual(1101); - expect(controller.dms.dmsTypeId).toEqual(3); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.dms = {hasFileAttached: false}; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - }); -}); diff --git a/modules/worker/front/dms/edit/style.scss b/modules/worker/front/dms/edit/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/worker/front/dms/edit/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/worker/front/dms/index/index.html b/modules/worker/front/dms/index/index.html deleted file mode 100644 index 310fb95d1..000000000 --- a/modules/worker/front/dms/index/index.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - Id - Order - Reference - Description - Original - File - Created - - - - - - - - {{::document.id}} - - - {{::document.dms.hardCopyNumber}} - - - - - {{::document.dms.reference}} - - - - - {{::document.dms.description}} - - - - - - - - - {{::document.dms.file}} - - - - {{::document.dms.created | date:'dd/MM/yyyy HH:mm'}} - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/worker/front/dms/index/index.js b/modules/worker/front/dms/index/index.js deleted file mode 100644 index 6fdc46dbb..000000000 --- a/modules/worker/front/dms/index/index.js +++ /dev/null @@ -1,75 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - constructor($element, $, vnFile) { - super($element, $); - this.vnFile = vnFile; - this.filter = { - include: { - relation: 'dms', - scope: { - fields: [ - 'dmsTypeFk', - 'reference', - 'hardCopyNumber', - 'workerFk', - 'description', - 'hasFile', - 'file', - 'created', - 'companyFk', - 'warehouseFk', - ], - include: [ - { - relation: 'dmsType', - scope: { - fields: ['name'], - }, - }, - { - relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['name'], - }, - }, - }, - }, - ], - }, - }, - }; - } - - deleteDms(index) { - const workerDmsId = this.workerDms[index].dmsFk; - return this.$http.post(`WorkerDms/${workerDmsId}/removeFile`) - .then(() => { - this.$.model.remove(index); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - downloadFile(dmsId, isDocuware) { - if (isDocuware) return this.vnFile.download(`api/workerDms/${dmsId}/docuwareDownload`); - this.vnFile.download(`api/workerDms/${dmsId}/downloadFile`); - } - - async openDocuware() { - const url = await this.vnApp.getUrl(`WebClient`, 'docuware'); - if (url) window.open(url).focus(); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnWorkerDmsIndex', { - template: require('./index.html'), - controller: Controller, -}); diff --git a/modules/worker/front/dms/index/index.spec.js b/modules/worker/front/dms/index/index.spec.js deleted file mode 100644 index 9c1e87011..000000000 --- a/modules/worker/front/dms/index/index.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import './index'; -import crudModel from 'core/mocks/crud-model'; - -describe('Worker', () => { - describe('Component vnWorkerDmsIndex', () => { - let $scope; - let $httpBackend; - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - controller = $componentController('vnWorkerDmsIndex', {$element: null, $scope}); - controller.$.model = crudModel; - })); - - describe('deleteDms()', () => { - it('should make an HTTP Post query', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$.model, 'remove'); - - const workerDmsId = 4; - const dmsIndex = 0; - controller.workerDms = [{id: 1, dmsFk: 4}]; - - $httpBackend.expectPOST(`WorkerDms/${workerDmsId}/removeFile`).respond(); - controller.deleteDms(dmsIndex); - $httpBackend.flush(); - - expect(controller.$.model.remove).toHaveBeenCalledWith(dmsIndex); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/worker/front/dms/index/locale/es.yml b/modules/worker/front/dms/index/locale/es.yml deleted file mode 100644 index b6feb4206..000000000 --- a/modules/worker/front/dms/index/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Are you sure?: Estas seguro? -Download file: Descargar fichero -File: Fichero -File deleted: Fichero eliminado -Hard copy: Copia -My documentation: Mi documentacion -Remove file: Eliminar fichero -This file will be deleted: Este fichero va a ser borrado -Type: Tipo \ No newline at end of file diff --git a/modules/worker/front/dms/index/style.scss b/modules/worker/front/dms/index/style.scss deleted file mode 100644 index a6758e2e6..000000000 --- a/modules/worker/front/dms/index/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -vn-client-risk-index { - .totalBox { - display: table; - float: right; - } -} \ No newline at end of file diff --git a/modules/worker/front/dms/locale/en.yml b/modules/worker/front/dms/locale/en.yml deleted file mode 100644 index 766853fca..000000000 --- a/modules/worker/front/dms/locale/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -ClientFileDescription: "{{dmsTypeName}} from client {{clientName}} id {{clientId}}" -ContentTypesInfo: Allowed file types {{allowedContentTypes}} \ No newline at end of file diff --git a/modules/worker/front/dms/locale/es.yml b/modules/worker/front/dms/locale/es.yml deleted file mode 100644 index fa4178d35..000000000 --- a/modules/worker/front/dms/locale/es.yml +++ /dev/null @@ -1,20 +0,0 @@ -Reference: Referencia -Description: Descripción -Company: Empresa -Upload file: Subir fichero -Edit file: Editar fichero -Upload: Subir -File: Fichero -WorkerFileDescription: "{{dmsTypeName}} del empleado {{workerName}} id {{workerId}}" -ContentTypesInfo: "Tipos de archivo permitidos: {{allowedContentTypes}}" -Generate identifier for original file: Generar identificador para archivo original -Are you sure you want to continue?: ¿Seguro que quieres continuar? -File management: Gestión documental -Hard copy: Copia -This file will be deleted: Este fichero va a ser borrado -Are you sure?: ¿Seguro? -File deleted: Fichero eliminado -Remove file: Eliminar fichero -Download file: Descargar fichero -Created: Creado -Employee: Empleado \ No newline at end of file diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index 5c03dc8de..26cb403bb 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -1,24 +1,9 @@ export * from './module'; import './main'; -import './index/'; import './summary'; import './card'; -import './create'; import './descriptor'; import './descriptor-popover'; -import './search-panel'; -import './basic-data'; -import './pbx'; -import './pda'; import './department'; -import './calendar'; -import './time-control'; -import './log'; -import './dms/index'; -import './dms/create'; -import './dms/edit'; -import './note/index'; -import './note/create'; -import './notifications'; diff --git a/modules/worker/front/index/index.html b/modules/worker/front/index/index.html deleted file mode 100644 index 7044ca551..000000000 --- a/modules/worker/front/index/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - diff --git a/modules/worker/front/index/index.js b/modules/worker/front/index/index.js deleted file mode 100644 index 77dd872e1..000000000 --- a/modules/worker/front/index/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(event, worker) { - if (event.defaultPrevented) return; - - event.preventDefault(); - event.stopPropagation(); - - this.selectedWorker = worker; - this.$.preview.show(); - } - - goToTimeControl(event, workerId) { - if (event.defaultPrevented) return; - - event.preventDefault(); - event.stopPropagation(); - this.$state.go('worker.card.timeControl', {id: workerId}, {absolute: true}); - } - - onMoreChange(callback) { - callback.call(this); - } -} - -ngModule.vnComponent('vnWorkerIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/worker/front/index/locale/es.yml b/modules/worker/front/index/locale/es.yml deleted file mode 100644 index df6383273..000000000 --- a/modules/worker/front/index/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -New worker: Nuevo trabajador diff --git a/modules/worker/front/log/index.html b/modules/worker/front/log/index.html deleted file mode 100644 index 090dbf2e3..000000000 --- a/modules/worker/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/worker/front/log/index.js b/modules/worker/front/log/index.js deleted file mode 100644 index e30ce7e22..000000000 --- a/modules/worker/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnWorkerLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/worker/front/main/index.html b/modules/worker/front/main/index.html index 376c8f534..e69de29bb 100644 --- a/modules/worker/front/main/index.html +++ b/modules/worker/front/main/index.html @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/worker/front/main/index.js b/modules/worker/front/main/index.js index d97a2d636..29da1bcc1 100644 --- a/modules/worker/front/main/index.js +++ b/modules/worker/front/main/index.js @@ -1,7 +1,15 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Worker extends ModuleMain {} +export default class Worker extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`worker/`); + } +} ngModule.vnComponent('vnWorker', { controller: Worker, diff --git a/modules/worker/front/note/create/index.html b/modules/worker/front/note/create/index.html deleted file mode 100644 index d09fc2da5..000000000 --- a/modules/worker/front/note/create/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - -
- - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/worker/front/note/create/index.js b/modules/worker/front/note/create/index.js deleted file mode 100644 index 81ee247db..000000000 --- a/modules/worker/front/note/create/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.note = { - workerFk: parseInt(this.$params.id), - text: null - }; - } - - cancel() { - this.$state.go('worker.card.note.index', {id: this.$params.id}); - } -} - -ngModule.vnComponent('vnNoteWorkerCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/worker/front/note/create/index.spec.js b/modules/worker/front/note/create/index.spec.js deleted file mode 100644 index d900c8ee0..000000000 --- a/modules/worker/front/note/create/index.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -import './index'; - -describe('Worker', () => { - describe('Component vnNoteWorkerCreate', () => { - let $state; - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, _$state_) => { - $state = _$state_; - $state.params.id = '1234'; - const $element = angular.element(''); - controller = $componentController('vnNoteWorkerCreate', {$element, $state}); - })); - - it('should define workerFk using $state.params.id', () => { - expect(controller.note.workerFk).toBe(1234); - expect(controller.note.worker).toBe(undefined); - }); - }); -}); diff --git a/modules/worker/front/note/create/locale/es.yml b/modules/worker/front/note/create/locale/es.yml deleted file mode 100644 index bfe773f48..000000000 --- a/modules/worker/front/note/create/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New note: Nueva nota -Note: Nota \ No newline at end of file diff --git a/modules/worker/front/note/index/index.html b/modules/worker/front/note/index/index.html deleted file mode 100644 index 9f5c27008..000000000 --- a/modules/worker/front/note/index/index.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -
- - {{::note.user.nickname}} - {{::note.created | date:'dd/MM/yyyy HH:mm'}} - - - {{::note.text}} - -
-
-
- - - diff --git a/modules/worker/front/note/index/index.js b/modules/worker/front/note/index/index.js deleted file mode 100644 index d20971413..000000000 --- a/modules/worker/front/note/index/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.filter = { - order: 'created DESC', - }; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnWorkerNote', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/note/index/style.scss b/modules/worker/front/note/index/style.scss deleted file mode 100644 index 5ff6baf4f..000000000 --- a/modules/worker/front/note/index/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -vn-worker-note { - .note:last-child { - margin-bottom: 0; - } -} \ No newline at end of file diff --git a/modules/worker/front/notifications/index.html b/modules/worker/front/notifications/index.html deleted file mode 100644 index 7fb3b870e..000000000 --- a/modules/worker/front/notifications/index.html +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/modules/worker/front/notifications/index.js b/modules/worker/front/notifications/index.js deleted file mode 100644 index 622892979..000000000 --- a/modules/worker/front/notifications/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - const url = await this.vnApp.getUrl(`worker/${this.$params.id}/notifications`); - window.open(url).focus(); - } -} - -ngModule.vnComponent('vnWorkerNotifications', { - template: require('./index.html'), - controller: Controller, - bindings: { - ticket: '<' - } -}); diff --git a/modules/worker/front/pbx/index.html b/modules/worker/front/pbx/index.html deleted file mode 100644 index e1ca61a4a..000000000 --- a/modules/worker/front/pbx/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js deleted file mode 100644 index 3b6443d3c..000000000 --- a/modules/worker/front/pbx/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - onSubmit() { - const sip = this.worker.sip; - const params = { - userFk: this.worker.id, - extension: sip.extension - }; - this.$.watcher.check(); - this.$http.patch('Sips', params).then(() => { - this.$.watcher.updateOriginalData(); - this.vnApp.showSuccess(this.$t('Data saved! User must access web')); - }); - } -} - -ngModule.vnComponent('vnWorkerPbx', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/pda/index.js b/modules/worker/front/pda/index.js deleted file mode 100644 index c3616b41e..000000000 --- a/modules/worker/front/pda/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - async $onInit() { - const url = await this.vnApp.getUrl(`worker/${this.$params.id}/pda`); - this.$state.go('worker.card.summary', {id: this.$params.id}); - window.location.href = url; - } -} - -ngModule.vnComponent('vnWorkerPda', { - controller: Controller -}); diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 489b4346a..9b3a50230 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -9,23 +9,6 @@ {"state": "worker.index", "icon": "icon-worker"}, {"state": "worker.department", "icon": "work"} ], - "card": [ - {"state": "worker.card.basicData", "icon": "settings"}, - {"state": "worker.card.note.index", "icon": "insert_drive_file"}, - {"state": "worker.card.timeControl", "icon": "access_time"}, - {"state": "worker.card.calendar", "icon": "icon-calendar"}, - {"state": "worker.card.pda", "icon": "phone_android"}, - {"state": "worker.card.notifications", "icon": "notifications"}, - {"state": "worker.card.pbx", "icon": "icon-pbx"}, - {"state": "worker.card.dms.index", "icon": "cloud_upload"}, - { - "icon": "icon-wiki", - "external":true, - "url": "http://wiki.verdnatura.es", - "description": "Wikipedia" - }, - {"state": "worker.card.workerLog", "icon": "history"} - ], "department": [ {"state": "worker.department.card.basicData", "icon": "settings"} ] @@ -43,12 +26,14 @@ "abstract": true, "component": "vn-worker", "description": "Workers" - }, { + }, + { "url": "/index?q", "state": "worker.index", "component": "vn-worker-index", "description": "Workers" - }, { + }, + { "url" : "/summary", "state": "worker.card.summary", "component": "vn-worker-summary", @@ -56,91 +41,14 @@ "params": { "worker": "$ctrl.worker" } - }, { - "url": "/:id", - "state": "worker.card", - "component": "vn-worker-card", - "abstract": true, - "description": "Detail" - }, { - "url": "/basic-data", - "state": "worker.card.basicData", - "component": "vn-worker-basic-data", - "description": "Basic data", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url" : "/log", - "state": "worker.card.workerLog", - "component": "vn-worker-log", - "description": "Log", - "acl": ["hr"] - }, { - "url": "/note", - "state": "worker.card.note", - "component": "ui-view", - "abstract": true - }, { - "url": "/index", - "state": "worker.card.note.index", - "component": "vn-worker-note", - "description": "Notes", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url": "/create", - "state": "worker.card.note.create", - "component": "vn-note-worker-create", - "description": "New note" - }, { - "url": "/pbx", - "state": "worker.card.pbx", - "component": "vn-worker-pbx", - "description": "Private Branch Exchange", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, { - "url": "/calendar", - "state": "worker.card.calendar", - "component": "vn-worker-calendar", - "description": "Calendar", - "params": { - "worker": "$ctrl.worker" - } - }, { - "url": "/notifications", - "state": "worker.card.notifications", - "component": "vn-worker-notifications", - "description": "Notifications", - "params": { - "worker": "$ctrl.worker" - } - }, { - "url": "/time-control?timestamp", - "state": "worker.card.timeControl", - "component": "vn-worker-time-control", - "description": "Time control", - "params": { - "worker": "$ctrl.worker" - } - }, { + }, + { "url": "/department?q", "state": "worker.department", "component": "vn-worker-department", "description":"Departments" - }, { - "url": "/:id", - "state": "worker.department.card", - "component": "vn-worker-department-card", - "abstract": true, - "description": "Detail" - }, { + }, + { "url" : "/summary", "state": "worker.department.card.summary", "component": "vn-worker-department-summary", @@ -148,62 +56,6 @@ "params": { "department": "$ctrl.department" } - }, - { - "url": "/basic-data", - "state": "worker.department.card.basicData", - "component": "vn-worker-department-basic-data", - "description": "Basic data", - "params": { - "department": "$ctrl.department" - } - }, - { - "url": "/dms", - "state": "worker.card.dms", - "abstract": true, - "component": "ui-view" - }, - { - "url": "/index", - "state": "worker.card.dms.index", - "component": "vn-worker-dms-index", - "description": "My documentation", - "acl": ["employee"] - }, - { - "url": "/create", - "state": "worker.card.dms.create", - "component": "vn-worker-dms-create", - "description": "Upload file", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, - { - "url": "/:dmsId/edit", - "state": "worker.card.dms.edit", - "component": "vn-worker-dms-edit", - "description": "Edit file", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, - { - "url": "/create", - "state": "worker.create", - "component": "vn-worker-create", - "description": "New worker", - "acl": ["hr"] - }, - { - "url": "/pda", - "state": "worker.card.pda", - "component": "vn-worker-pda", - "description": "PDA", - "acl": ["hr", "productionAssi"] } ] } diff --git a/modules/worker/front/search-panel/index.html b/modules/worker/front/search-panel/index.html deleted file mode 100644 index c93eef78b..000000000 --- a/modules/worker/front/search-panel/index.html +++ /dev/null @@ -1,67 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/worker/front/search-panel/index.js b/modules/worker/front/search-panel/index.js deleted file mode 100644 index ac7405e78..000000000 --- a/modules/worker/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnWorkerSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/worker/front/time-control/index.html b/modules/worker/front/time-control/index.html deleted file mode 100644 index c34a1e3ca..000000000 --- a/modules/worker/front/time-control/index.html +++ /dev/null @@ -1,219 +0,0 @@ - - -
- - - - - -
{{::$ctrl.weekdayNames[$index].name}}
-
- {{::weekday.dated | date: 'dd'}} - - {{::weekday.dated | date: 'MMMM'}} - -
- - - -
- {{::weekday.event.name}} -
-
-
-
-
- - - -
- - - - - - - - {{::hour.timed | date: 'HH:mm'}} - -
-
-
-
- - - - {{$ctrl.formatHours(weekday.workedHours)}} h. - - - - - - - - - -
-
- - -
- - - - - - -
- - -
-
- - -
-
-
Hours
- - - - -
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - -
-
- - - - -
- - - - Are you sure you want to send it? - - - - - - diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js deleted file mode 100644 index 2993e3986..000000000 --- a/modules/worker/front/time-control/index.js +++ /dev/null @@ -1,507 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $, vnWeekDays, moment) { - super($element, $); - this.weekDays = []; - this.weekdayNames = vnWeekDays.locales; - this.moment = moment; - this.entryDirections = [ - {code: 'in', description: this.$t('In')}, - {code: 'middle', description: this.$t('Intermediate')}, - {code: 'out', description: this.$t('Out')} - ]; - } - - $postLink() { - const timestamp = this.$params.timestamp; - let initialDate = Date.vnNew(); - - if (timestamp) { - initialDate = new Date(timestamp * 1000); - this.$.calendar.defaultDate = initialDate; - } - - this.date = initialDate; - - this.getMailStates(this.date); - } - - get isHr() { - return this.aclService.hasAny(['hr']); - } - - get isHimSelf() { - const userId = window.localStorage.currentUserWorkerId; - return userId == this.$params.id; - } - - get worker() { - return this._worker; - } - - get weekNumber() { - return this.getWeekNumber(this.date); - } - - set weekNumber(value) { - this._weekNumber = value; - } - - set worker(value) { - this._worker = value; - this.fetchHours(); - if (this.date) - this.getWeekData(); - } - - /** - * Worker hours data - */ - get hours() { - return this._hours; - } - - set hours(value) { - this._hours = value; - - for (const weekDay of this.weekDays) { - if (value) { - let day = weekDay.dated.getDay(); - weekDay.hours = value - .filter(hour => new Date(hour.timed).getDay() == day) - .sort((a, b) => new Date(a.timed) - new Date(b.timed)); - } else - weekDay.hours = null; - } - } - - /** - * The current selected date - */ - get date() { - return this._date; - } - - set date(value) { - this._date = value; - value.setHours(0, 0, 0, 0); - - let weekOffset = value.getDay() - 1; - if (weekOffset < 0) weekOffset = 6; - - let started = new Date(value.getTime()); - started.setDate(started.getDate() - weekOffset); - this.started = started; - - let ended = new Date(started.getTime()); - ended.setHours(23, 59, 59, 59); - ended.setDate(ended.getDate() + 6); - this.ended = ended; - - this.weekDays = []; - let dayIndex = new Date(started.getTime()); - - while (dayIndex < ended) { - this.weekDays.push({ - dated: new Date(dayIndex.getTime()) - }); - dayIndex.setDate(dayIndex.getDate() + 1); - } - - if (this.worker) { - this.fetchHours(); - this.getWeekData(); - } - } - - set weekTotalHours(totalHours) { - this._weekTotalHours = this.formatHours(totalHours); - } - - get weekTotalHours() { - return this._weekTotalHours; - } - - getWeekData() { - const filter = { - where: { - workerFk: this.$params.id, - year: this._date.getFullYear(), - week: this.getWeekNumber(this._date) - }, - }; - this.$http.get('WorkerTimeControlMails', {filter}) - .then(res => { - if (!res.data.length) { - this.state = null; - return; - } - const [mail] = res.data; - this.state = mail.state; - this.reason = mail.reason; - }); - this.canBeResend(); - } - - canBeResend() { - this.canResend = false; - const filter = { - where: { - year: this._date.getFullYear(), - week: this.getWeekNumber(this._date) - }, - limit: 1 - }; - this.$http.get('WorkerTimeControlMails', {filter}) - .then(res => { - if (res.data.length) - this.canResend = true; - }); - } - - fetchHours() { - if (!this.worker || !this.date) return; - - const params = {workerFk: this.$params.id}; - const filter = { - where: {and: [ - {timed: {gte: this.started}}, - {timed: {lte: this.ended}} - ]} - }; - this.$.model.applyFilter(filter, params).then(() => { - this.getWorkedHours(this.started, this.ended); - this.getAbsences(); - }); - } - - getWorkedHours(from, to) { - this.weekTotalHours = null; - let weekTotalHours = 0; - let params = { - id: this.$params.id, - from: from, - to: to - }; - const query = `Workers/${this.$params.id}/getWorkedHours`; - return this.$http.get(query, {params}).then(res => { - const workDays = res.data; - const map = new Map(); - - for (const workDay of workDays) { - workDay.dated = new Date(workDay.dated); - map.set(workDay.dated, workDay); - weekTotalHours += workDay.workedHours; - } - - for (const weekDay of this.weekDays) { - const workDay = workDays.find(day => { - let from = new Date(day.dated); - from.setHours(0, 0, 0, 0); - - let to = new Date(day.dated); - to.setHours(23, 59, 59, 59); - - return weekDay.dated >= from && weekDay.dated <= to; - }); - - if (workDay) { - weekDay.expectedHours = workDay.expectedHours; - weekDay.workedHours = workDay.workedHours; - } - } - this.weekTotalHours = weekTotalHours; - }); - } - - getAbsences() { - const fullYear = this.started.getFullYear(); - let params = { - workerFk: this.$params.id, - businessFk: null, - year: fullYear - }; - - return this.$http.get(`Calendars/absences`, {params}) - .then(res => this.onData(res.data)); - } - - hasEvents(day) { - return day >= this.started && day < this.ended; - } - - onData(data) { - const events = {}; - - const addEvent = (day, event) => { - events[new Date(day).getTime()] = event; - }; - - if (data.holidays) { - data.holidays.forEach(holiday => { - const holidayDetail = holiday.detail && holiday.detail.description; - const holidayType = holiday.type && holiday.type.name; - const holidayName = holidayDetail || holidayType; - - addEvent(holiday.dated, { - name: holidayName, - color: '#ff0' - }); - }); - } - if (data.absences) { - data.absences.forEach(absence => { - const type = absence.absenceType; - addEvent(absence.dated, { - name: type.name, - color: type.rgb - }); - }); - } - - this.weekDays.forEach(day => { - const timestamp = day.dated.getTime(); - if (events[timestamp]) - day.event = events[timestamp]; - }); - } - - getFinishTime() { - if (!this.weekDays) return; - - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - - let todayInWeek = this.weekDays.find(day => day.dated.getTime() === today.getTime()); - - if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) { - const remainingTime = todayInWeek.workedHours ? - ((todayInWeek.expectedHours - todayInWeek.workedHours) * 1000) : null; - const lastKnownEntry = todayInWeek.hours[todayInWeek.hours.length - 1]; - const lastKnownTime = new Date(lastKnownEntry.timed).getTime(); - const finishTimeStamp = lastKnownTime && remainingTime ? lastKnownTime + remainingTime : null; - - if (finishTimeStamp) { - let finishDate = new Date(finishTimeStamp); - let hour = finishDate.getHours(); - let minute = finishDate.getMinutes(); - - if (hour < 10) hour = `0${hour}`; - if (minute < 10) minute = `0${minute}`; - - return `${hour}:${minute} h.`; - } - } - } - - formatHours(timestamp = 0) { - let hour = Math.floor(timestamp / 3600); - let min = Math.floor(timestamp / 60 - 60 * hour); - - if (hour < 10) hour = `0${hour}`; - if (min < 10) min = `0${min}`; - - return `${hour}:${min}`; - } - - showAddTimeDialog(weekday) { - const timed = new Date(weekday.dated.getTime()); - timed.setHours(0, 0, 0, 0); - - this.newTimeEntry = { - workerFk: this.$params.id, - timed: timed - }; - this.selectedWeekday = weekday; - this.$.addTimeDialog.show(); - } - - addTime() { - try { - const entry = this.newTimeEntry; - if (!entry.direction) - throw new Error(`The entry type can't be empty`); - - const query = `WorkerTimeControls/${this.worker.id}/addTimeEntry`; - this.$http.post(query, entry) - .then(() => { - this.fetchHours(); - this.getMailStates(this.date); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - - return true; - } - - showDeleteDialog($event, hour) { - $event.preventDefault(); - - this.timeEntryToDelete = hour; - this.$.deleteEntryDialog.show(); - } - - deleteTimeEntry() { - const entryId = this.timeEntryToDelete.id; - - this.$http.post(`WorkerTimeControls/${entryId}/deleteTimeEntry`).then(() => { - this.fetchHours(); - this.getMailStates(this.date); - this.vnApp.showSuccess(this.$t('Entry removed')); - }); - } - - edit($event, hour) { - if ($event.defaultPrevented) return; - - this.selectedRow = hour; - this.$.editEntry.show($event); - } - - getWeekNumber(date) { - const tempDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())); - return this.moment(tempDate).isoWeek(); - } - - isSatisfied() { - this.updateWorkerTimeControlMail('CONFIRMED'); - } - - isUnsatisfied() { - if (!this.reason) throw new UserError(`You must indicate a reason`); - this.updateWorkerTimeControlMail('REVISE', this.reason); - } - - updateWorkerTimeControlMail(state, reason) { - const params = { - year: this.date.getFullYear(), - week: this.weekNumber, - state - }; - - if (reason) - params.reason = reason; - - const query = `WorkerTimeControls/${this.worker.id}/updateMailState`; - this.$http.post(query, params).then(() => { - this.getMailStates(this.date); - this.getWeekData(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - state(state, reason) { - this.state = state; - this.reason = reason; - this.repaint(); - } - - save() { - try { - const entry = this.selectedRow; - if (!entry.direction) - throw new Error(`The entry type can't be empty`); - - const query = `WorkerTimeControls/${entry.id}/updateTimeEntry`; - if (entry.direction !== entry.$orgRow.direction) { - this.$http.post(query, {direction: entry.direction}) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.$.editEntry.hide()) - .then(() => this.fetchHours()) - .then(() => this.getMailStates(this.date)); - } - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } - - resendEmail() { - const params = { - recipient: this.worker.user.emailUser.email, - week: this.weekNumber, - year: this.date.getFullYear(), - workerId: this.worker.id, - state: 'SENDED' - }; - this.$http.post(`WorkerTimeControls/weekly-hour-record-email`, params) - .then(() => { - this.getMailStates(this.date); - this.vnApp.showSuccess(this.$t('Email sended')); - }); - } - - getTime(timeString) { - const [hours, minutes, seconds] = timeString.split(':'); - return [parseInt(hours), parseInt(minutes), parseInt(seconds)]; - } - - getMailStates(date) { - const params = { - month: date.getMonth() + 1, - year: date.getFullYear() - }; - const query = `WorkerTimeControls/${this.$params.id}/getMailStates`; - this.$http.get(query, {params}) - .then(res => { - this.workerTimeControlMails = res.data; - this.repaint(); - }); - } - - formatWeek($element) { - const weekNumberHTML = $element.firstElementChild; - const weekNumberValue = weekNumberHTML.innerHTML; - - if (!this.workerTimeControlMails) return; - const workerTimeControlMail = this.workerTimeControlMails.find( - workerTimeControlMail => workerTimeControlMail.week == weekNumberValue - ); - - if (!workerTimeControlMail) return; - const state = workerTimeControlMail.state; - - if (state == 'CONFIRMED') { - weekNumberHTML.classList.remove('revise'); - weekNumberHTML.classList.remove('sended'); - - weekNumberHTML.classList.add('confirmed'); - weekNumberHTML.setAttribute('title', 'Conforme'); - } - if (state == 'REVISE') { - weekNumberHTML.classList.remove('confirmed'); - weekNumberHTML.classList.remove('sended'); - - weekNumberHTML.classList.add('revise'); - weekNumberHTML.setAttribute('title', 'No conforme'); - } - if (state == 'SENDED') { - weekNumberHTML.classList.add('sended'); - weekNumberHTML.setAttribute('title', 'Pendiente'); - } - } - - repaint() { - let calendars = this.element.querySelectorAll('vn-calendar'); - for (let calendar of calendars) - calendar.$ctrl.repaint(); - } -} - -Controller.$inject = ['$element', '$scope', 'vnWeekDays', 'moment']; - -ngModule.vnComponent('vnWorkerTimeControl', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - }, - require: { - card: '^vnWorkerCard' - } -}); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js deleted file mode 100644 index 3868ded75..000000000 --- a/modules/worker/front/time-control/index.spec.js +++ /dev/null @@ -1,286 +0,0 @@ -import './index.js'; - -describe('Component vnWorkerTimeControl', () => { - let $httpBackend; - let $scope; - let $element; - let controller; - let $httpParamSerializer; - - beforeEach(ngModule('worker')); - - beforeEach(inject(($componentController, $rootScope, $stateParams, _$httpBackend_, _$httpParamSerializer_) => { - $stateParams.id = 1; - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - $scope = $rootScope.$new(); - $element = angular.element(''); - controller = $componentController('vnWorkerTimeControl', {$element, $scope}); - controller.card = { - hasWorkCenter: true - }; - })); - - describe('date() setter', () => { - it(`should set the weekDays and the date in the controller`, () => { - let today = Date.vnNew(); - jest.spyOn(controller, 'fetchHours').mockReturnThis(); - - controller.date = today; - - expect(controller._date).toEqual(today); - expect(controller.started).toBeDefined(); - expect(controller.ended).toBeDefined(); - expect(controller.weekDays.length).toEqual(7); - }); - }); - - describe('hours() setter', () => { - it(`should set hours data at it's corresponding week day`, () => { - let today = Date.vnNew(); - jest.spyOn(controller, 'fetchHours').mockReturnThis(); - - controller.date = today; - - let hours = [ - { - id: 1, - timed: controller.started.toJSON(), - userFk: 1 - }, { - id: 2, - timed: controller.ended.toJSON(), - userFk: 1 - }, { - id: 3, - timed: controller.ended.toJSON(), - userFk: 1 - } - ]; - - controller.hours = hours; - - expect(controller.weekDays.length).toEqual(7); - expect(controller.weekDays[0].hours.length).toEqual(1); - expect(controller.weekDays[6].hours.length).toEqual(2); - }); - }); - - describe('getWorkedHours() ', () => { - it('should set the weekdays expected and worked hours plus the total worked hours', () => { - let today = Date.vnNew(); - jest.spyOn(controller, 'fetchHours').mockReturnThis(); - - controller.date = today; - - let sixHoursInSeconds = 6 * 60 * 60; - let tenHoursInSeconds = 10 * 60 * 60; - let response = [ - { - dated: today, - expectedHours: sixHoursInSeconds, - workedHours: tenHoursInSeconds, - - }, - ]; - $httpBackend.whenRoute('GET', 'Workers/:id/getWorkedHours') - .respond(response); - - $httpBackend.whenRoute('GET', 'WorkerTimeControlMails') - .respond([]); - - today.setHours(0, 0, 0, 0); - - let weekOffset = today.getDay() - 1; - if (weekOffset < 0) weekOffset = 6; - - let started = new Date(today.getTime()); - started.setDate(started.getDate() - weekOffset); - controller.started = started; - - let ended = new Date(started.getTime()); - ended.setHours(23, 59, 59, 59); - ended.setDate(ended.getDate() + 6); - controller.ended = ended; - - controller.getWorkedHours(controller.started, controller.ended); - $httpBackend.flush(); - - expect(controller.weekDays.length).toEqual(7); - expect(controller.weekDays[weekOffset].expectedHours).toEqual(response[0].expectedHours); - expect(controller.weekDays[weekOffset].workedHours).toEqual(response[0].workedHours); - expect(controller.weekTotalHours).toEqual('10:00'); - }); - - describe('formatHours() ', () => { - it(`should format a passed timestamp to hours and minutes`, () => { - const result = controller.formatHours(3600); - - expect(result).toEqual('01:00'); - }); - }); - - describe('save() ', () => { - it(`should make a query an then call to the fetchHours() method`, () => { - const today = Date.vnNew(); - - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.date = today; - controller.fetchHours = jest.fn(); - controller.selectedRow = {id: 1, timed: Date.vnNew(), direction: 'in', $orgRow: {direction: null}}; - controller.$.editEntry = { - hide: () => {} - }; - const expectedParams = {direction: 'in'}; - $httpBackend.expect('POST', 'WorkerTimeControls/1/updateTimeEntry', expectedParams).respond(200); - controller.save(); - $httpBackend.flush(); - - expect(controller.fetchHours).toHaveBeenCalledWith(); - }); - }); - - describe('$postLink() ', () => { - it(`should set the controller date as today if no timestamp is defined`, () => { - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.$params = {timestamp: undefined}; - controller.$postLink(); - - expect(controller.date).toEqual(jasmine.any(Date)); - }); - - it(`should set the controller date using the received timestamp`, () => { - const timestamp = 1; - const date = new Date(timestamp); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.$.calendar = {}; - controller.$params = {timestamp: timestamp}; - - controller.$postLink(); - - expect(controller.date.toDateString()).toEqual(date.toDateString()); - }); - }); - - describe('getWeekData() ', () => { - it(`should make a query an then update the state and reason`, () => { - const today = Date.vnNew(); - const response = [ - { - state: 'SENDED', - reason: null - } - ]; - - controller._date = today; - - $httpBackend.whenRoute('GET', 'WorkerTimeControlMails') - .respond(response); - - controller.getWeekData(); - $httpBackend.flush(); - - expect(controller.state).toBe('SENDED'); - expect(controller.reason).toBe(null); - }); - }); - - describe('isSatisfied() ', () => { - it(`should make a query an then call three methods`, () => { - const today = Date.vnNew(); - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.worker = {id: 1}; - controller.date = today; - controller.weekNumber = 1; - - $httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond(); - controller.isSatisfied(); - $httpBackend.flush(); - - expect(controller.getMailStates).toHaveBeenCalledWith(controller.date); - expect(controller.getWeekData).toHaveBeenCalled(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('isUnsatisfied() ', () => { - it(`should throw an error is reason is empty`, () => { - let error; - try { - controller.isUnsatisfied(); - } catch (e) { - error = e; - } - - expect(error).toBeDefined(); - expect(error.message).toBe(`You must indicate a reason`); - }); - - it(`should make a query an then call three methods`, () => { - const today = Date.vnNew(); - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.worker = {id: 1}; - controller.date = today; - controller.weekNumber = 1; - controller.reason = 'reason'; - - $httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond(); - controller.isSatisfied(); - $httpBackend.flush(); - - expect(controller.getMailStates).toHaveBeenCalledWith(controller.date); - expect(controller.getWeekData).toHaveBeenCalled(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('resendEmail() ', () => { - it(`should make a query an then call showSuccess method`, () => { - const today = Date.vnNew(); - - jest.spyOn(controller, 'getWeekData').mockReturnThis(); - jest.spyOn(controller, 'getMailStates').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.model = {applyFilter: jest.fn().mockReturnValue(Promise.resolve())}; - controller.worker = {id: 1}; - controller.worker = {user: {emailUser: {email: 'employee@verdnatura.es'}}}; - controller.date = today; - controller.weekNumber = 1; - - $httpBackend.expect('POST', 'WorkerTimeControls/weekly-hour-record-email').respond(); - controller.resendEmail(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('getMailStates() ', () => { - it(`should make a query an then call showSuccess method`, () => { - const today = Date.vnNew(); - jest.spyOn(controller, 'repaint').mockReturnThis(); - - controller.$params = {id: 1}; - - $httpBackend.expect('GET', `WorkerTimeControls/1/getMailStates?month=1&year=2001`).respond(); - controller.getMailStates(today); - $httpBackend.flush(); - - expect(controller.repaint).toHaveBeenCalled(); - }); - }); - }); -}); diff --git a/modules/worker/front/time-control/locale/es.yml b/modules/worker/front/time-control/locale/es.yml deleted file mode 100644 index 091c01baa..000000000 --- a/modules/worker/front/time-control/locale/es.yml +++ /dev/null @@ -1,22 +0,0 @@ -In: Entrada -Out: Salida -Intermediate: Intermedio -Hour: Hora -Hours: Horas -Add time: Añadir hora -Week total: Total semana -Current week: Semana actual -This time entry will be deleted: Se eliminará la hora fichada -Are you sure you want to delete this entry?: ¿Seguro que quieres eliminarla? -Finish at: Termina a las -Entry removed: Fichada borrada -The entry type can't be empty: El tipo de fichada no puede quedar vacía -Satisfied: Conforme -Not satisfied: No conforme -Reason: Motivo -Resend: Reenviar -Email sended: Email enviado -You must indicate a reason: Debes indicar un motivo -Send time control email: Enviar email control horario -Are you sure you want to send it?: ¿Seguro que quieres enviarlo? -Resend email of this week to the user: Reenviar email de esta semana al usuario diff --git a/modules/worker/front/time-control/style.scss b/modules/worker/front/time-control/style.scss deleted file mode 100644 index 9d7545aaf..000000000 --- a/modules/worker/front/time-control/style.scss +++ /dev/null @@ -1,52 +0,0 @@ -@import "variables"; - -vn-worker-time-control { - vn-thead > vn-tr > vn-td > div.weekday { - margin-bottom: 5px; - color: $color-main - } - vn-td.hours { - min-width: 100px; - vertical-align: top; - - & > section { - display: flex; - align-items: center; - justify-content: center; - padding: 4px 0; - - & > vn-icon { - color: $color-font-secondary; - padding-right: 1px; - } - } - } - .totalBox { - max-width: none - } - -} - -.reasonDialog{ - min-width: 500px; -} - -.edit-time-entry { - width: 200px -} - -.right { - float: right; - } - -.confirmed { - color: #97B92F; -} - -.revise { - color: #f61e1e; -} - -.sended { - color: #d19b25; -} From b56260af365a0a2097b6068a80340ec56c27b202 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 2 Aug 2024 07:58:45 +0200 Subject: [PATCH 069/145] feat: refs #6453 Requested changes --- .../procedures/order_confirmWithUser.sql | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 17798caf8..3acdaed5a 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -136,11 +136,11 @@ BEGIN FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id + LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd AND t.warehouseFk = vWarehouseFk AND o.date_send = t.landed - AND t.shipped BETWEEN vShipment AND vShipmentDayEnd WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL @@ -150,7 +150,9 @@ BEGIN -- Comprobamos si hay un ticket de previa disponible IF vTicketFk IS NULL THEN WITH tItemPackingTypeOrder AS ( - SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes, + SELECT GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes, o.address_id FROM vn.item i JOIN orderRow oro ON oro.itemFk = i.id @@ -159,16 +161,20 @@ BEGIN ), tItemPackingTypeTicket AS ( SELECT t.id, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes + GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'ON_PREVIOUS' + JOIN vn.ticketState tls ON tls.ticketFk = t.id + JOIN vn.alertLevel al ON al.id = tls.alertLevel JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk JOIN tItemPackingTypeOrder ipto - WHERE t.refFk IS NULL - AND t.shipped BETWEEN vShipment AND vShipmentDayEnd + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd + AND t.refFk IS NULL AND t.warehouseFk = vWarehouseFk AND t.addressFk = ipto.address_id + AND al.code = 'ON_PREVIOUS' GROUP BY t.id ) SELECT iptt.id INTO vTicketFk From d852d16ae4d19e97aafa562a8c9686b0e78c8742 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 2 Aug 2024 08:11:38 +0200 Subject: [PATCH 070/145] feat: refs #7382 Changes --- db/routines/vn/procedures/invoiceIn_booking.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index c728085b8..a5dd3a5f1 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -16,9 +16,11 @@ BEGIN DECLARE vHasRepeatedTransactions BOOL; SELECT TRUE INTO vHasRepeatedTransactions - FROM invoiceInTax - WHERE invoiceInFk = vSelf - HAVING COUNT(DISTINCT transactionTypeSageFk) > 1 + FROM invoiceInTax iit + JOIN invoiceIn ii ON ii.id = iit.invoiceInFk + WHERE ii.id = vSelf + AND ii.serial = 'E' + HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1 LIMIT 1; IF vHasRepeatedTransactions THEN From ddd5e4ffa491ce3b98a025659475e4d16b7b8d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 2 Aug 2024 10:28:50 +0200 Subject: [PATCH 071/145] fix: refs #7829 Error al calcular problemas de componentes --- .../vn/procedures/sale_getProblems.sql | 29 +++++++-------- .../ticket_setProblemRiskByClient.sql | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 db/routines/vn/procedures/ticket_setProblemRiskByClient.sql diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index ba4ff5857..730d84f38 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vComponentCount INT; + DECLARE vRequiredComponent INT; DECLARE vCursor CURSOR FOR SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) @@ -54,7 +54,7 @@ BEGIN SELECT ticketFk, clientFk FROM tmp.sale_getProblems; - SELECT COUNT(*) INTO vComponentCount + SELECT COUNT(*) INTO vRequiredComponent FROM component WHERE isRequired; @@ -96,20 +96,17 @@ BEGIN -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT ticketFk, (vComponentCount > nComp) hasComponentLack, saleFk - FROM ( - SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk - FROM tmp.ticket_list tl - JOIN sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - ) sub + SELECT t.id, COUNT(c.id) < vRequiredComponent hasComponentLack, s.id + FROM tmp.ticket_list tl + JOIN ticket t ON t.id = tl.ticketFk + JOIN sale s ON s.ticketFk = t.id + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired + WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') + AND s.quantity > 0 + GROUP BY s.id HAVING hasComponentLack; -- Cliente congelado diff --git a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql new file mode 100644 index 000000000..d652f5269 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql @@ -0,0 +1,35 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`( + vClientFk INT +) +BEGIN +/** + * Updates future ticket risk for a client + * + * @param vClientFk Id client + */ + DECLARE vDone INT DEFAULT FALSE; + DECLARE vTicketFk INT; + DECLARE vTickets CURSOR FOR + SELECT id + FROM ticket + WHERE clientFk = vClientFk + AND shipped >= util.VN_CURDATE(); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL vn.ticket_setProblemRisk(vTicketFk); + END LOOP; + + CLOSE vTickets; +END$$ +DELIMITER ; \ No newline at end of file From 29a50caaca99ec6024f13fa9780c67130ad72e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 2 Aug 2024 11:43:30 +0200 Subject: [PATCH 072/145] fix: refs #7829 Error al calcular problemas de componentes --- db/routines/vn/procedures/sale_getProblems.sql | 3 ++- db/routines/vn/procedures/ticket_setProblemRiskByClient.sql | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 730d84f38..979978f4a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -103,7 +103,8 @@ BEGIN JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired + LEFT JOIN component c ON c.id = sc.componentFk + AND c.isRequired WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') AND s.quantity > 0 GROUP BY s.id diff --git a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql index d652f5269..8479550de 100644 --- a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql +++ b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRi ) BEGIN /** - * Updates future ticket risk for a client + * Updates future ticket risk for a client. * * @param vClientFk Id client */ @@ -14,7 +14,8 @@ BEGIN SELECT id FROM ticket WHERE clientFk = vClientFk - AND shipped >= util.VN_CURDATE(); + AND shipped >= util.VN_CURDATE() + AND refFk IS NULL; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -29,7 +30,6 @@ BEGIN CALL vn.ticket_setProblemRisk(vTicketFk); END LOOP; - CLOSE vTickets; END$$ DELIMITER ; \ No newline at end of file From abd8bc96390eca32823c33e5d8e20574ca1b0d70 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 2 Aug 2024 12:20:50 +0200 Subject: [PATCH 073/145] fix: refs #6453 order_confirmWithUser --- db/routines/hedera/procedures/order_confirmWithUser.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 3acdaed5a..2b033b704 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -155,8 +155,8 @@ BEGIN ) distinctItemPackingTypes, o.address_id FROM vn.item i - JOIN orderRow oro ON oro.itemFk = i.id - JOIN `order` o ON o.id = oro.orderFk + JOIN hedera.orderRow oro ON oro.itemFk = i.id + JOIN hedera.`order` o ON o.id = oro.orderFk WHERE oro.orderFk = vSelf ), tItemPackingTypeTicket AS ( From f431d6c37f967ffedccee8f202faeb420b201d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 2 Aug 2024 13:45:58 +0200 Subject: [PATCH 074/145] Hotfix changes whit conficts merged incorrectly --- db/routines/vn/procedures/sale_setProblem.sql | 17 +++++++++++------ db/routines/vn/procedures/ticket_setProblem.sql | 14 +++++++++----- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblem.sql b/db/routines/vn/procedures/sale_setProblem.sql index b0870089f..b343c0b8c 100644 --- a/db/routines/vn/procedures/sale_setProblem.sql +++ b/db/routines/vn/procedures/sale_setProblem.sql @@ -11,24 +11,29 @@ BEGIN */ DECLARE vSaleFk INT; DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; DECLARE vDone BOOL; - DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale; + DECLARE vSaleList CURSOR FOR + SELECT saleFk, hasProblem, isProblemCalcNeeded + FROM tmp.sale; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; OPEN vSaleList; l: LOOP SET vDone = FALSE; - FETCH vSaleList INTO vSaleFk, vHasProblem; + FETCH vSaleList INTO vSaleFk, vHasProblem, vIsProblemCalcNeeded; IF vDone THEN LEAVE l; END IF; UPDATE sale - SET problem = CONCAT( - IF(vHasProblem, - CONCAT(problem, ',', vProblemCode), - REPLACE(problem, vProblemCode , ''))) + SET problem = IF (vIsProblemCalcNeeded, + CONCAT( + IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))), + NULL) WHERE id = vSaleFk; END LOOP; CLOSE vSaleList; diff --git a/db/routines/vn/procedures/ticket_setProblem.sql b/db/routines/vn/procedures/ticket_setProblem.sql index 66d244d5a..fea6d9b7d 100644 --- a/db/routines/vn/procedures/ticket_setProblem.sql +++ b/db/routines/vn/procedures/ticket_setProblem.sql @@ -12,24 +12,28 @@ BEGIN */ DECLARE vTicketFk INT; DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; DECLARE vDone BOOL; - DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket; + DECLARE vTicketList CURSOR FOR + SELECT ticketFk, hasProblem, isProblemCalcNeeded + FROM tmp.ticket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; OPEN vTicketList; l: LOOP SET vDone = FALSE; - FETCH vTicketList INTO vTicketFk, vHasProblem; + FETCH vTicketList INTO vTicketFk, vHasProblem, vIsProblemCalcNeeded; IF vDone THEN LEAVE l; END IF; UPDATE ticket - SET problem = CONCAT( - IF(vHasProblem, + SET problem = IF(vIsProblemCalcNeeded, + CONCAT(IF(vHasProblem, CONCAT(problem, ',', vProblemCode), - REPLACE(problem, vProblemCode , ''))) + REPLACE(problem, vProblemCode , ''))), + NULL) WHERE id = vTicketFk; END LOOP; CLOSE vTicketList; From bf7cd1530cc85645174217b7b845661f67e18073 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 2 Aug 2024 15:36:02 +0200 Subject: [PATCH 075/145] feat: refs #7283 order by desc date --- db/routines/vn/procedures/item_getBalance.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 3a594c81c..9c609b4c6 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -189,8 +189,8 @@ BEGIN SELECT * FROM sales UNION ALL SELECT * FROM orders - ORDER BY shipped, - (inventorySupplierFk = entityId) DESC, + ORDER BY shipped DESC, + (inventorySupplierFk = entityId) ASC, alertLevel DESC, isTicket, `order` DESC, From ab446b54ed2e015ebd947ba256dbe3801ee65b1c Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 11:29:35 +0200 Subject: [PATCH 076/145] feat: refs #7644 Optimized entry labels report --- loopback/locale/es.json | 3 +- modules/entry/back/methods/entry/buyLabel.js | 2 +- modules/entry/back/methods/entry/print.js | 58 +++++++++++++++++++ modules/entry/back/models/entry.js | 1 + package.json | 5 +- .../reports/buy-label/buy-label.html | 2 +- .../templates/reports/buy-label/buy-label.js | 5 +- print/templates/reports/buy-label/sql/buy.sql | 38 ++++++++++++ .../templates/reports/buy-label/sql/buys.sql | 33 ----------- 9 files changed, 107 insertions(+), 40 deletions(-) create mode 100644 modules/entry/back/methods/entry/print.js create mode 100644 print/templates/reports/buy-label/sql/buy.sql delete mode 100644 print/templates/reports/buy-label/sql/buys.sql diff --git a/loopback/locale/es.json b/loopback/locale/es.json index acc3d69f6..e1f7fd655 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -368,5 +368,6 @@ "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", - "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", + "The entry not have stickers": "La entrada no tiene etiquetas" } \ No newline at end of file diff --git a/modules/entry/back/methods/entry/buyLabel.js b/modules/entry/back/methods/entry/buyLabel.js index d9b0ebf1d..919f7c4d7 100644 --- a/modules/entry/back/methods/entry/buyLabel.js +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('buyLabel', { - description: 'Returns the entry buys labels', + description: 'Returns the entry buy labels', accessType: 'READ', accepts: [ { diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/print.js new file mode 100644 index 000000000..c155c3d8b --- /dev/null +++ b/modules/entry/back/methods/entry/print.js @@ -0,0 +1,58 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.remoteMethodCtx('print', { + description: 'Print stickers of all entries', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/print', + verb: 'GET' + }, + accessScopes: ['DEFAULT', 'read:multimedia'] + }); + + Self.print = async function(ctx, id, options) { + const models = Self.app.models; + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + // Importación dinámica porque no admite commonjs + const PDFMerger = ((await import('pdf-merger-js')).default); + const merger = new PDFMerger(); + const buys = await models.Buy.find({where: {entryFk: id}}, myOptions); + + for (const buy of buys) { + if (buy.stickers < 1) continue; + ctx.args.id = buy.id; + const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions); + await merger.add(new Uint8Array(pdfBuffer[0])); + } + + if (!merger._doc) throw new UserError('The entry not have stickers'); + return [await merger.saveAsBuffer(), 'application/pdf', `filename="entry-${id}.pdf"`]; + }; +}; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6e27e1ece..b11d64415 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -10,6 +10,7 @@ module.exports = Self => { require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); require('../methods/entry/buyLabel')(Self); + require('../methods/entry/print')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/package.json b/package.json index ea126bce3..32efa9ab2 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "mysql": "2.18.1", "node-ssh": "^11.0.0", "object.pick": "^1.3.0", + "pdf-merger-js": "^5.1.2", "puppeteer": "21.11.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", @@ -80,10 +81,10 @@ "gulp-merge-json": "^1.3.1", "gulp-nodemon": "^2.5.0", "gulp-print": "^2.0.1", - "gulp-wrap": "^0.15.0", - "gulp-yaml": "^1.0.1", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.4", + "gulp-wrap": "^0.15.0", + "gulp-yaml": "^1.0.1", "html-loader": "^0.4.5", "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^5.5.1", diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label/buy-label.html index 4a0d7f3fc..5777d34de 100644 --- a/print/templates/reports/buy-label/buy-label.html +++ b/print/templates/reports/buy-label/buy-label.html @@ -86,7 +86,7 @@
{{$t('boxNum')}} - {{`${buy.labelNum} / ${maxLabelNum}`}} + {{`${buy.labelNum} / ${buy.maxLabelNum}`}}
diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js index 48ffe336c..932c34453 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -7,8 +7,9 @@ module.exports = { name: 'buy-label', mixins: [vnReport], async serverPrefetch() { - this.buys = await this.rawSqlFromDef('buys', [this.id, this.id]); - this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); + const models = require('vn-loopback/server/server').models; + const buy = await models.Buy.findById(this.id, null); + this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); const date = new Date(); this.weekNum = moment(date).isoWeek(); this.dayNum = moment(date).day(); diff --git a/print/templates/reports/buy-label/sql/buy.sql b/print/templates/reports/buy-label/sql/buy.sql new file mode 100644 index 000000000..72765baa9 --- /dev/null +++ b/print/templates/reports/buy-label/sql/buy.sql @@ -0,0 +1,38 @@ +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ( + SELECT MAX(stickers) + FROM buy + WHERE entryFk = ? + ) +), +labels AS ( + SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, + i.name, + i.`size`, + i.category, + ink.id color, + o.code, + b.packing, + b.`grouping`, + i.stems, + b.id, + b.itemFk, + p.name producer, + IF(i2.id, i2.comment, i.comment) comment + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN producer p ON p.id = i.producerFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN item i2 ON i2.id = b.itemOriginalFk + JOIN numbers num + WHERE b.entryFk = ? + AND num.n <= b.stickers +) +SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum + FROM labels + WHERE id = ? \ No newline at end of file diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql deleted file mode 100644 index 44b1b4bad..000000000 --- a/print/templates/reports/buy-label/sql/buys.sql +++ /dev/null @@ -1,33 +0,0 @@ -WITH RECURSIVE numbers AS ( - SELECT 1 n - UNION ALL - SELECT n + 1 - FROM numbers - WHERE n < ( - SELECT MAX(stickers) - FROM buy - WHERE entryFk = ? - ) -) -SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, - i.name, - i.`size`, - i.category, - ink.id color, - o.code, - b.packing, - b.`grouping`, - i.stems, - b.id, - b.itemFk, - p.name producer, - IF(i2.id, i2.comment, i.comment) comment - FROM buy b - JOIN item i ON i.id = b.itemFk - LEFT JOIN producer p ON p.id = i.producerFk - LEFT JOIN ink ON ink.id = i.inkFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN item i2 ON i2.id = b.itemOriginalFk - JOIN numbers num - WHERE b.entryFk = ? - AND num.n <= b.stickers From 760a1debca18081dbc5ca48270fd64c30ffc5c4f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 11:44:20 +0200 Subject: [PATCH 077/145] feat: refs #7644 Requested changes --- print/templates/reports/buy-label/buy-label.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js index 932c34453..289483051 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -1,5 +1,6 @@ const vnReport = require('../../../core/mixins/vn-report.js'); const {DOMImplementation, XMLSerializer} = require('xmldom'); +const {models} = require('vn-loopback/server/server'); const jsBarcode = require('jsbarcode'); const moment = require('moment'); @@ -7,7 +8,6 @@ module.exports = { name: 'buy-label', mixins: [vnReport], async serverPrefetch() { - const models = require('vn-loopback/server/server').models; const buy = await models.Buy.findById(this.id, null); this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); const date = new Date(); From 32b48a7bb6fed8ff58de1a9af2f34660a669a83c Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 11:48:02 +0200 Subject: [PATCH 078/145] feat: refs #7644 Fix --- pnpm-lock.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 22d5b46f1..b4030d779 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -95,6 +95,9 @@ dependencies: object.pick: specifier: ^1.3.0 version: 1.3.0 + pdf-merger-js: + specifier: ^5.1.2 + version: 5.1.2 puppeteer: specifier: 21.11.0 version: 21.11.0(typescript@5.4.4) @@ -2090,6 +2093,18 @@ packages: rimraf: 3.0.2 dev: true + /@pdf-lib/standard-fonts@1.0.0: + resolution: {integrity: sha512-hU30BK9IUN/su0Mn9VdlVKsWBS6GyhVfqjwl1FjZN4TxP6cCw0jP2w7V3Hf5uX7M0AZJ16vey9yE0ny7Sa59ZA==} + dependencies: + pako: 1.0.11 + dev: false + + /@pdf-lib/upng@1.0.1: + resolution: {integrity: sha512-dQK2FUMQtowVP00mtIksrlZhdFXQZPC+taih1q4CvPZ5vqdxR/LKBaFg0oAfzd1GlHZXXSPdQfzQnt+ViGvEIQ==} + dependencies: + pako: 1.0.11 + dev: false + /@pkgjs/parseargs@0.11.0: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} @@ -4486,6 +4501,11 @@ packages: engines: {node: '>=14'} dev: true + /commander@11.1.0: + resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} + engines: {node: '>=16'} + dev: false + /commander@2.17.1: resolution: {integrity: sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==} dev: true @@ -11323,6 +11343,24 @@ packages: pinkie-promise: 2.0.1 dev: true + /pdf-lib@1.17.1: + resolution: {integrity: sha512-V/mpyJAoTsN4cnP31vc0wfNA1+p20evqqnap0KLoRUN0Yk/p3wN52DOEsL4oBFcLdb76hlpKPtzJIgo67j/XLw==} + dependencies: + '@pdf-lib/standard-fonts': 1.0.0 + '@pdf-lib/upng': 1.0.1 + pako: 1.0.11 + tslib: 1.14.1 + dev: false + + /pdf-merger-js@5.1.2: + resolution: {integrity: sha512-RCBjLQILZ8UA4keO/Ip2/gjUuxigMMoK7mO5eJg6zjlnyymboFnRTgzKwOs/FiU9ornS2m72Qr95oARX1C24fw==} + engines: {node: '>=14'} + hasBin: true + dependencies: + commander: 11.1.0 + pdf-lib: 1.17.1 + dev: false + /pend@1.2.0: resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} dev: false @@ -13836,6 +13874,10 @@ packages: resolution: {integrity: sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==} dev: false + /tslib@1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + dev: false + /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} From 967443b4278edb3ae0e99f23bd14421713a53e17 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 12:26:16 +0200 Subject: [PATCH 079/145] fix: refs #7834 expeditionScan_Put --- db/routines/vn/procedures/expeditionScan_Put.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 9744a7cd7..a5afc824f 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -1,11 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`(vPalletFk INT, vExpeditionFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put`( + vPalletFk INT, + vExpeditionFk INT +) BEGIN - - REPLACE vn.expeditionScan(expeditionFk, palletFk) + IF (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN + REPLACE expeditionScan(expeditionFk, palletFk) VALUES(vExpeditionFk, vPalletFk); - + SELECT LAST_INSERT_ID() INTO vPalletFk; - + END IF; END$$ DELIMITER ; From fa3a7aa9312a3ca591377cc6bb1b5ea5516765a6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 12:49:04 +0200 Subject: [PATCH 080/145] refactor: refs #7820 Deprecated silexACL --- db/versions/11179-whiteLaurel/00-firstScript.sql | 2 ++ myt.config.yml | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 db/versions/11179-whiteLaurel/00-firstScript.sql diff --git a/db/versions/11179-whiteLaurel/00-firstScript.sql b/db/versions/11179-whiteLaurel/00-firstScript.sql new file mode 100644 index 000000000..4a4e32c9d --- /dev/null +++ b/db/versions/11179-whiteLaurel/00-firstScript.sql @@ -0,0 +1,2 @@ +RENAME TABLE vn.silexACL TO vn.silexACL__; +ALTER TABLE vn.silexACL__ COMMENT='@deprecated 2024-08-05 refs #7820'; diff --git a/myt.config.yml b/myt.config.yml index 116e3668a..ffa4188b2 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -66,7 +66,6 @@ fixtures: - siiTrascendencyInvoiceIn - siiTypeInvoiceIn - siiTypeInvoiceOut - - silexACL - state - ticketUpdateAction - volumeConfig From 91253cc8070e16ae54c2bed1afda53edad5b11fe Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 5 Aug 2024 12:57:38 +0200 Subject: [PATCH 081/145] fix: refs #7835 transferSales --- modules/ticket/back/methods/ticket/transferSales.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/transferSales.js b/modules/ticket/back/methods/ticket/transferSales.js index 54306510c..5f5fdde67 100644 --- a/modules/ticket/back/methods/ticket/transferSales.js +++ b/modules/ticket/back/methods/ticket/transferSales.js @@ -83,12 +83,12 @@ module.exports = Self => { for (const sale of sales) { const originalSale = map.get(sale.id); - if (sale.quantity == originalSale.quantity) { + if (sale.quantity == originalSale?.quantity) { query = `UPDATE sale SET ticketFk = ? WHERE id = ?`; await Self.rawSql(query, [ticketId, sale.id], myOptions); - } else if (sale.quantity != originalSale.quantity) { + } else if (sale.quantity != originalSale?.quantity) { await transferPartialSale( ticketId, originalSale, sale, myOptions); } From be5859b8cfcf4116d77f204c8c1842a6d5bbc5b1 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 5 Aug 2024 14:28:29 +0200 Subject: [PATCH 082/145] prototipo --- .../supplier_statementWithEntries.sql | 166 ++++++++++++++++++ .../11180-navyGerbera/00-firstScript.sql | 2 + 2 files changed, 168 insertions(+) create mode 100644 db/routines/vn/procedures/supplier_statementWithEntries.sql create mode 100644 db/versions/11180-navyGerbera/00-firstScript.sql diff --git a/db/routines/vn/procedures/supplier_statementWithEntries.sql b/db/routines/vn/procedures/supplier_statementWithEntries.sql new file mode 100644 index 000000000..25a104af3 --- /dev/null +++ b/db/routines/vn/procedures/supplier_statementWithEntries.sql @@ -0,0 +1,166 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE vn.supplier_statementWithEntries( + vSupplierFk INT, + vCurrencyFk INT, + vCompanyFk INT, + vOrderBy VARCHAR(15), + vIsConciliated BOOL, + vHasEntries BOOL +) +BEGIN +/** +* Creates a supplier statement, calculating balances in euros and the specified currency. +* +* @param vSupplierFk Supplier ID +* @param vCurrencyFk Currency ID +* @param vCompanyFk Company ID +* @param vOrderBy Order by criteria +* @param vIsConciliated Indicates whether it is reconciled or not +* @param vHasEntries Indicates if future entries must be shown +* @return tmp.supplierStatement +*/ + SET @euroBalance:= 0; + SET @currencyBalance:= 0; + + CREATE OR REPLACE TEMPORARY TABLE tmp.supplierStatement + ENGINE = MEMORY + SELECT *, + @euroBalance:= ROUND( + @euroBalance + IFNULL(paymentEuros, 0) - + IFNULL(invoiceEuros, 0), 2 + ) euroBalance, + @currencyBalance:= ROUND( + @currencyBalance + IFNULL(paymentCurrency, 0) - + IFNULL(invoiceCurrency, 0), 2 + ) currencyBalance + FROM ( + SELECT * FROM + ( + SELECT NULL bankFk, + ii.companyFk, + ii.serial, + ii.id, + CASE + WHEN vOrderBy = 'issued' THEN ii.issued + WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried + WHEN vOrderBy = 'booked' THEN ii.booked + WHEN vOrderBy = 'dueDate' THEN iid.dueDated + END dated, + CONCAT('S/Fra ', ii.supplierRef) sref, + IF(ii.currencyFk > 1, + ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), + NULL + ) changeValue, + CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, + CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, + NULL paymentEuros, + NULL paymentCurrency, + ii.currencyFk, + ii.isBooked, + c.code, + 'invoiceIn' statementType + FROM invoiceIn ii + JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id + JOIN currency c ON c.id = ii.currencyFk + JOIN invoiceInConfig iic + WHERE ii.issued >= iic.balanceStartingDate + AND ii.supplierFk = vSupplierFk + AND vCurrencyFk IN (ii.currencyFk, 0) + AND vCompanyFk IN (ii.companyFk, 0) + AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) + GROUP BY iid.id + UNION ALL + SELECT p.bankFk, + p.companyFk, + NULL, + p.id, + CASE + WHEN vOrderBy = 'issued' THEN p.received + WHEN vOrderBy = 'bookEntried' THEN p.received + WHEN vOrderBy = 'booked' THEN p.received + WHEN vOrderBy = 'dueDate' THEN p.dueDated + END, + CONCAT(IFNULL(pm.name, ''), + IF(pn.concept <> '', + CONCAT(' : ', pn.concept), + '') + ), + IF(p.currencyFk > 1, p.divisa / p.amount, NULL), + NULL, + NULL, + p.amount, + p.divisa, + p.currencyFk, + p.isConciliated, + c.code, + 'payment' + FROM payment p + LEFT JOIN currency c ON c.id = p.currencyFk + LEFT JOIN accounting a ON a.id = p.bankFk + LEFT JOIN payMethod pm ON pm.id = p.payMethodFk + LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id + JOIN invoiceInConfig iic + WHERE p.received >= iic.balanceStartingDate + AND p.supplierFk = vSupplierFk + AND vCurrencyFk IN (p.currencyFk, 0) + AND vCompanyFk IN (p.companyFk, 0) + AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL, + companyFk, + NULL, + se.id, + CASE + WHEN vOrderBy = 'issued' THEN se.dated + WHEN vOrderBy = 'bookEntried' THEN se.dated + WHEN vOrderBy = 'booked' THEN se.dated + WHEN vOrderBy = 'dueDate' THEN se.dueDated + END, + se.description, + 1, + amount, + NULL, + NULL, + NULL, + currencyFk, + isConciliated, + c.`code`, + 'expense' + FROM supplierExpense se + JOIN currency c ON c.id = se.currencyFk + WHERE se.supplierFk = vSupplierFk + AND vCurrencyFk IN (se.currencyFk,0) + AND vCompanyFk IN (se.companyFk,0) + AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL bankFk, + e.companyFk, + 'E' serial, + e.invoiceNumber id, + tr.landed dated, + CONCAT('Ent. ',e.id) sref, + 1 / ((e.commission/100)+1) changeValue, + e.invoiceAmount * (1 + (e.commission/100)), + e.invoiceAmount, + NULL, + NULL, + e.currencyFk, + FALSE isBooked, + c.code, + 'order' + FROM vn.entry e + JOIN travel tr ON tr.id = e.travelFk + JOIN currency c ON c.id = e.currencyFk + WHERE e.supplierFk = vSupplierFk + AND tr.landed >= CURDATE() + AND e.invoiceInFk IS NULL + AND vHasEntries + ) sub + ORDER BY (dated IS NULL AND NOT isBooked), + dated, + IF(vOrderBy = 'dueDate', id, NULL) + LIMIT 10000000000000000000 + ) t; +END;$$ +DELIMITER ; diff --git a/db/versions/11180-navyGerbera/00-firstScript.sql b/db/versions/11180-navyGerbera/00-firstScript.sql new file mode 100644 index 000000000..8c5d79ce8 --- /dev/null +++ b/db/versions/11180-navyGerbera/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE vn.invoiceInConfig ADD balanceStartingDate DATE DEFAULT '2015-01-01' NOT NULL; From e95d722a7c9c1b7a2be0b1cee7a89cfa32095ff5 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 5 Aug 2024 14:52:09 +0200 Subject: [PATCH 083/145] add changelog --- CHANGELOG.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f59a3d4c6..6db79a40a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,61 @@ +# Version 24.32 - 2024-08-06 + +### Added 🆕 + +- chore: refs #7197 add supplierActivityFk filter by:jorgep +- feat checkExpeditionPrintOut refs #7751 by:sergiodt +- feat(defaulter_filter): add department by:alexm +- feat: redirect to lilium page not found by:alexm +- feat: refactor buyUltimate refs #7736 by:Carlos Andrés +- feat: refs #6403 add delete by:pablone +- feat: refs #7126 Added manaClaim calc by:guillermo +- feat: refs #7126 Refactor and added columns in bs.waste table & proc by:guillermo +- feat: refs #7197 filter by correcting by:jorgep +- feat: refs #7297 add new columns by:pablone +- feat: refs #7356 new parameters in sql for Weekly tickets front by:Jon +- feat: refs #7401 redirect lilium by:pablone +- feat: refs #7511 Fix tests by:guillermo +- feat: refs #7511 Rename to multiConfig tables by:guillermo +- feat: refs #7589 Added display (item_valuateInventory) by:guillermo +- feat: refs #7589 Added vItemTypeFk & vItemCategoryFk (item_valuateInventory) by:guillermo +- feat: refs #7681 Changes by:guillermo +- feat: refs #7681 Optimization and refactor by:guillermo +- feat: refs #7683 drop temporary table by:robert +- feat: refs #7683 productionControl by:robert +- feat: refs #7728 Added throw due date by:guillermo +- feat: refs #7740 Ticket before update added restriction by:guillermo +- feat(salix): #7648 Add field for endpoint as buyLabel report by:Javier Segarra +- feat(salix): #7648 remove white line by:Javier Segarra +- feat: tabla config dias margen vctos. refs #7728 by:Carlos Andrés + +### Changed 📦 + +- eat: refactor buyUltimate refs #7736 by:Carlos Andrés +- feat: refactor buyUltimate refs #7736 by:Carlos Andrés +- feat: refs #7681 Optimization and refactor by:guillermo +- refactor: refs #7126 Requested changes by:guillermo +- refactor: refs #7511 Minor change by:guillermo +- refactor: refs #7640 Multipleinventory available by:guillermo +- refactor: refs #7681 Changes by:guillermo +- refactor: refs #7681 Requested changes by:guillermo + +### Fixed 🛠️ + +- add prefix (hotFix_liliumRedirection) by:alexm +- fix(client_filter): add recovery by:alexm +- fix: defaulter filter correct sql (6943-fix_defaulter_filter) by:alexm +- fix(deletExpeditions): merge test → dev by:guillermo +- fix: refs #6403 fix mrw cancel shipment return type by:pablone +- fix: refs #7126 Added addressWaste type by:guillermo +- fix: refs #7126 Fix by:guillermo +- fix: refs #7126 Minor change by:guillermo +- fix: refs #7126 Primary key no unique data by:guillermo +- fix: refs #7126 Slow update by:guillermo +- fix: refs #7511 Minor change by:guillermo +- fix: refs #7546 Deleted insert util.binlogQueue by:guillermo +- fix: refs #7811 Variables pm2 by:guillermo +- fix: without path by:alexm + # Version 24.28 - 2024-07-09 ### Added 🆕 From e03a1914d94e1f0a9eea3bda1afbff38b5f79af8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 07:27:36 +0200 Subject: [PATCH 084/145] fix: refs #7834 Throw --- db/routines/vn/procedures/expeditionScan_Put.sql | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index a5afc824f..2a3e00df7 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -5,10 +5,16 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put` ) BEGIN IF (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN - REPLACE expeditionScan(expeditionFk, palletFk) - VALUES(vExpeditionFk, vPalletFk); - - SELECT LAST_INSERT_ID() INTO vPalletFk; + CALL util.throw('Expedition not exists'); END IF; + + IF (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN + CALL util.throw('Pallet not exists'); + END IF; + + REPLACE expeditionScan(expeditionFk, palletFk) + VALUES(vExpeditionFk, vPalletFk); + + SELECT LAST_INSERT_ID() INTO vPalletFk; END$$ DELIMITER ; From 54e6c63b8b246090686ed17511a1ca7c7a138a6f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 07:29:32 +0200 Subject: [PATCH 085/145] fix: refs #7834 SELECT --- db/routines/vn/procedures/expeditionScan_Put.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 2a3e00df7..68e124e4b 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -14,7 +14,5 @@ BEGIN REPLACE expeditionScan(expeditionFk, palletFk) VALUES(vExpeditionFk, vPalletFk); - - SELECT LAST_INSERT_ID() INTO vPalletFk; END$$ DELIMITER ; From 70a91da0ffdbdfb7e32743976155a1b1fefd8cfc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 6 Aug 2024 08:27:40 +0200 Subject: [PATCH 086/145] build: dump 2432 --- db/dump/.dump/data.sql | 28 +- db/dump/.dump/privileges.sql | 8 + db/dump/.dump/structure.sql | 2030 ++++++++++++++++++++-------------- db/dump/.dump/triggers.sql | 23 +- 4 files changed, 1212 insertions(+), 877 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 711524e4c..f6bc84db7 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -3,7 +3,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11154','04ff3e0cc79b00272d1ebbde7196292eab651c1d','2024-07-23 09:24:55','11163'); +INSERT INTO `version` VALUES ('vn-database','11161','36dee872d62ba2421c05503f374f6b208c40ecfa','2024-08-06 07:53:56','11180'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -822,6 +822,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11034','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11037','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11038','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:17',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11040','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11042','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11044','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:31',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11045','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-10 14:53:29',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11046','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-28 07:32:46',NULL,NULL); @@ -896,14 +897,22 @@ INSERT INTO `versionLog` VALUES ('vn-database','11138','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11139','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-08 10:58:01',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11140','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11145','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 13:55:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11146','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11149','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11150','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11152','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 09:06:11',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11154','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11155','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11156','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11157','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 13:11:00',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11158','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-17 17:06:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11159','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-18 17:23:32',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11160','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-18 13:46:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11161','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-08-06 07:53:54',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11164','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-23 11:03:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11168','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 08:58:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11169','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-25 12:38:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11177','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-30 12:42:28',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -2046,13 +2055,14 @@ INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (896,'Expedition_PrintOut','*','READ','ALLOW','ROLE','production'); INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system'); INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier'); INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier'); INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier'); INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier'); +INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2137,11 +2147,11 @@ INSERT INTO `module` VALUES ('wagon'); INSERT INTO `module` VALUES ('worker'); INSERT INTO `module` VALUES ('zone'); -INSERT INTO `defaultViewConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('ticketsMonitor','{\"id\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}'); -INSERT INTO `defaultViewConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('itemsIndex','{\"intrastat\":false,\"stemMultiplier\":false,\"landed\":false,\"producer\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('latestBuys','{\"intrastat\":false,\"description\":false,\"density\":false,\"isActive\":false,\n \"freightValue\":false,\"packageValue\":false,\"isIgnored\":false,\"price2\":false,\"ektFk\":false,\"weight\":false,\n \"size\":false,\"comissionValue\":false,\"landing\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('ticketsMonitor','{\"id\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('clientsDetail','{\"id\":true,\"phone\":true,\"city\":true,\"socialName\":true,\"salesPersonFk\":true,\"email\":true,\"name\":false,\"fi\":false,\"credit\":false,\"creditInsurance\":false,\"mobile\":false,\"street\":false,\"countryFk\":false,\"provinceFk\":false,\"postcode\":false,\"created\":false,\"businessTypeFk\":false,\"payMethodFk\":false,\"sageTaxTypeFk\":false,\"sageTransactionTypeFk\":false,\"isActive\":false,\"isVies\":false,\"isTaxDataChecked\":false,\"isEqualizated\":false,\"isFreezed\":false,\"hasToInvoice\":false,\"hasToInvoiceByAddress\":false,\"isToBeMailed\":false,\"hasLcr\":false,\"hasCoreVnl\":false,\"hasSepaVnl\":false}'); +INSERT INTO `defaultViewMultiConfig` VALUES ('routesList','{\"ID\":true,\"worker\":true,\"agency\":true,\"vehicle\":true,\"date\":true,\"volume\":true,\"description\":true,\"started\":true,\"finished\":true,\"actions\":true}'); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -2153,6 +2163,7 @@ USE `vn`; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; INSERT INTO `alertLevel` VALUES ('FREE',0,1); +INSERT INTO `alertLevel` VALUES ('ON_PREVIOUS',1,1); INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',2,1); INSERT INTO `alertLevel` VALUES ('PACKED',3,0); INSERT INTO `alertLevel` VALUES ('DELIVERED',4,0); @@ -2384,7 +2395,7 @@ INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1 INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (43,'VT','VENTAS',40,71,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (43,'VT','VENTAS',40,71,NULL,0,0,0,1,15,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (44,'management','GERENCIA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); @@ -2722,6 +2733,7 @@ INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1, INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning'); INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL); INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices'); INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana'); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index dc0549de4..7776e6d5a 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -1292,6 +1292,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','buffer','juan@db-p INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','greuge','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','item','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select,Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerBoss','itemShelving','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','agencyIncoming','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','addressObservation','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','negativeOrigin','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','Vehiculos_consumo','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','entryOrder','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); @@ -1357,6 +1359,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accounting', INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accounting','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketRequest','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','Vehiculos_consumo','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','budgetState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','vehicleState','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','expeditionState','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','specialPrice','jgallego@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); @@ -1379,6 +1383,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','professionalCategor INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','ticketObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','inventoryConfig','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','comparative','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceOutExpense','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','delivery','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1404,6 +1409,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','teamBoss','business','guiller INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketServiceType','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','business','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','','Select'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','supplierAgencyTerm','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemMinimumQuantity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientRate','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','entryEditor','Entradas','guillermo@10.5.1.3','0000-00-00 00:00:00','Insert','Update'); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','clientInforma','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1428,6 +1434,8 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessReasonEnd','guil INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buySource','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','claims_ratio','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','employee','shelfMultiConfig','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientConfig','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_gestdoc','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_state','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 174471895..4790e156c 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -4499,20 +4499,22 @@ DROP TABLE IF EXISTS `waste`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `waste` ( - `buyer` varchar(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `year` int(4) NOT NULL, `week` int(2) NOT NULL, - `family` varchar(30) NOT NULL, + `buyerFk` int(10) unsigned NOT NULL, + `itemTypeFk` smallint(5) unsigned NOT NULL, `itemFk` int(11) NOT NULL DEFAULT 0, - `itemTypeFk` smallint(5) unsigned DEFAULT NULL, - `saleTotal` decimal(16,0) DEFAULT NULL, - `saleWaste` decimal(16,0) DEFAULT NULL, - `rate` decimal(5,1) DEFAULT NULL, - PRIMARY KEY (`buyer`,`year`,`week`,`family`,`itemFk`), + `saleQuantity` decimal(10,2) DEFAULT NULL, + `saleTotal` decimal(10,2) DEFAULT NULL, + `saleInternalWaste` decimal(10,2) DEFAULT NULL, + `saleExternalWaste` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`year`,`week`,`buyerFk`,`itemTypeFk`,`itemFk`), KEY `waste_itemType_id` (`itemTypeFk`), KEY `waste_item_id` (`itemFk`), + KEY `waste_user_FK` (`buyerFk`), CONSTRAINT `waste_itemType_id` FOREIGN KEY (`itemTypeFk`) REFERENCES `vn`.`itemType` (`id`), - CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE + CONSTRAINT `waste_item_id` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON UPDATE CASCADE, + CONSTRAINT `waste_user_FK` FOREIGN KEY (`buyerFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -6525,32 +6527,51 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `waste_addSales`() BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; + DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(CURDATE()) DAY; + DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY; + + CALL cache.last_buy_refresh(FALSE); - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = util.VN_CURDATE(); - REPLACE bs.waste - SELECT *, 100 * mermas / total as porcentaje - FROM ( - SELECT buyer, - year, - week, - family, - itemFk, - itemTypeFk, - floor(sum(value)) as total, - floor(sum(IF(typeFk = 'loses', value, 0))) as mermas - FROM vn.saleValue - where year = vYear and week = vWeek - - GROUP BY family, itemFk - - ) sub - ORDER BY mermas DESC; + SELECT YEAR(t.shipped), + WEEK(t.shipped, 4), + it.workerFk, + it.id, + s.itemFk, + SUM(s.quantity), + SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) `value`, + SUM ( + IF( + aw.`type` = 'internal', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ) internalWaste, + SUM ( + IF( + aw.`type` = 'external', + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + IF(c.code = 'manaClaim', + sc.value * s.quantity, + 0 + ) + ) + ) externalWaste + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk + LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = w.id + JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id + LEFT JOIN vn.component c ON c.id = sc.componentFk + WHERE t.shipped BETWEEN vDateFrom AND vDateTo + AND w.isManaged + GROUP BY it.id, i.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -7745,7 +7766,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buyUltimateFromInterval(NULL, started, ended); + CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended); DELETE FROM last_buy; @@ -7889,9 +7910,12 @@ proc:BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, amount stock, amount visible - FROM cache.stock - WHERE warehouse_id = v_warehouse; + SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible + FROM stock s + JOIN vn.warehouse w ON w.id = s.warehouse_id + WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse) + AND w.isComparative + GROUP BY s.item_id; -- Calculamos los movimientos confirmados de hoy CALL vn.item_calcVisible(NULL, v_warehouse); @@ -7964,6 +7988,7 @@ CREATE TABLE `expedition_PrintOut` ( `longName` varchar(30) DEFAULT NULL, `shelvingFk` varchar(5) DEFAULT NULL, `comments` varchar(100) DEFAULT NULL, + `isChecked` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si la expedición ha sido revisada por un revisor', PRIMARY KEY (`expeditionFk`), KEY `expedition_PrintOut_FK` (`printerFk`), CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY (`printerFk`) REFERENCES `printer` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -8608,13 +8633,13 @@ CREATE TABLE `feature` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `fileConfig` +-- Table structure for table `fileMultiConfig` -- -DROP TABLE IF EXISTS `fileConfig`; +DROP TABLE IF EXISTS `fileMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `fileConfig` ( +CREATE TABLE `fileMultiConfig` ( `name` varchar(25) NOT NULL, `checksum` text DEFAULT NULL, `keyValue` tinyint(1) NOT NULL DEFAULT 1, @@ -8687,13 +8712,13 @@ CREATE TABLE `goodCharacteristic` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `imapConfig` +-- Table structure for table `imapMultiConfig` -- -DROP TABLE IF EXISTS `imapConfig`; +DROP TABLE IF EXISTS `imapMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `imapConfig` ( +CREATE TABLE `imapMultiConfig` ( `id` tinyint(3) unsigned NOT NULL, `environment` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, `host` varchar(150) NOT NULL DEFAULT 'localhost', @@ -9219,13 +9244,13 @@ CREATE TABLE `supplyResponseLog` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `tableConfig` +-- Table structure for table `tableMultiConfig` -- -DROP TABLE IF EXISTS `tableConfig`; +DROP TABLE IF EXISTS `tableMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `tableConfig` ( +CREATE TABLE `tableMultiConfig` ( `fileName` varchar(2) NOT NULL, `toTable` varchar(15) NOT NULL, `file` varchar(30) NOT NULL, @@ -12256,13 +12281,13 @@ CREATE TABLE `shelf` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `shelfConfig` +-- Table structure for table `shelfMultiConfig` -- -DROP TABLE IF EXISTS `shelfConfig`; +DROP TABLE IF EXISTS `shelfMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `shelfConfig` ( +CREATE TABLE `shelfMultiConfig` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(25) NOT NULL, `namePrefix` varchar(50) DEFAULT NULL, @@ -12276,9 +12301,9 @@ CREATE TABLE `shelfConfig` ( KEY `shelf_id` (`shelf`), KEY `family_id` (`family`), KEY `warehouse_id` (`warehouse`), - CONSTRAINT `shelfConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`), - CONSTRAINT `shelfConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, - CONSTRAINT `shelfConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `shelfMultiConfig_ibfk_1` FOREIGN KEY (`family`) REFERENCES `vn`.`itemType` (`id`), + CONSTRAINT `shelfMultiConfig_ibfk_2` FOREIGN KEY (`shelf`) REFERENCES `shelf` (`id`) ON UPDATE CASCADE, + CONSTRAINT `shelfMultiConfig_ibfk_3` FOREIGN KEY (`warehouse`) REFERENCES `vn`.`warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15834,7 +15859,7 @@ CREATE TABLE `queue` ( UNIQUE KEY `name` (`name`), UNIQUE KEY `description` (`description`), KEY `config` (`config`), - CONSTRAINT `queue_ibfk_1` FOREIGN KEY (`config`) REFERENCES `queueConfig` (`id`) ON UPDATE CASCADE + CONSTRAINT `queue_ibfk_1` FOREIGN KEY (`config`) REFERENCES `queueMultiConfig` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queues'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -15856,25 +15881,6 @@ SET character_set_client = utf8; 1 AS `ringinuse` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `queueConfig` --- - -DROP TABLE IF EXISTS `queueConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `queueConfig` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `strategy` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `timeout` int(10) unsigned NOT NULL, - `retry` int(10) unsigned NOT NULL, - `weight` int(10) unsigned NOT NULL, - `maxLen` int(10) unsigned NOT NULL, - `ringInUse` tinyint(4) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for queues configuration'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `queueMember` -- @@ -15909,6 +15915,25 @@ SET character_set_client = utf8; 1 AS `paused` */; SET character_set_client = @saved_cs_client; +-- +-- Table structure for table `queueMultiConfig` +-- + +DROP TABLE IF EXISTS `queueMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `queueMultiConfig` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `strategy` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + `timeout` int(10) unsigned NOT NULL, + `retry` int(10) unsigned NOT NULL, + `weight` int(10) unsigned NOT NULL, + `maxLen` int(10) unsigned NOT NULL, + `ringInUse` tinyint(4) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Default values for queues configuration'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `queuePhone` -- @@ -19090,13 +19115,13 @@ CREATE TABLE `authCode` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `defaultViewConfig` +-- Table structure for table `defaultViewMultiConfig` -- -DROP TABLE IF EXISTS `defaultViewConfig`; +DROP TABLE IF EXISTS `defaultViewMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `defaultViewConfig` ( +CREATE TABLE `defaultViewMultiConfig` ( `tableCode` varchar(25) NOT NULL, `columns` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='The default configuration of columns for views'; @@ -26523,6 +26548,7 @@ CREATE TABLE `agencyLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logAgencyUserFk` (`userFk`), KEY `agencyLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -27664,8 +27690,10 @@ CREATE TABLE `calendar` ( KEY `calendar_employee_business_labour_id_idx` (`businessFk`), KEY `calendar_employee_calendar_state_calendar_state_id_idx` (`dayOffTypeFk`), KEY `id_index` (`id`), + KEY `calendar_user_FK` (`editorFk`), CONSTRAINT `calendar_FK` FOREIGN KEY (`dayOffTypeFk`) REFERENCES `absenceType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `calendar_businessFk` FOREIGN KEY (`businessFk`) REFERENCES `business` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `calendar_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29332,24 +29360,6 @@ CREATE TABLE `conveyorBuildingClass` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de caja para el montaje de pallets'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `conveyorConfig` --- - -DROP TABLE IF EXISTS `conveyorConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `conveyorConfig` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `itemName` varchar(45) NOT NULL, - `length` int(11) DEFAULT NULL, - `width` int(11) DEFAULT NULL, - `height` int(11) DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `itemName_UNIQUE` (`itemName`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `conveyorExpedition` -- @@ -29398,6 +29408,24 @@ CREATE TABLE `conveyorMode` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `conveyorMultiConfig` +-- + +DROP TABLE IF EXISTS `conveyorMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `conveyorMultiConfig` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemName` varchar(45) NOT NULL, + `length` int(11) DEFAULT NULL, + `width` int(11) DEFAULT NULL, + `height` int(11) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemName_UNIQUE` (`itemName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `conveyorType` -- @@ -32085,6 +32113,7 @@ CREATE TABLE `invoiceInConfig` ( `sageFarmerWithholdingFk` smallint(6) NOT NULL, `daysAgo` int(10) unsigned DEFAULT 45 COMMENT 'Días en el pasado para mostrar facturas en invoiceIn series en salix', `taxRowLimit` int(11) DEFAULT 4 COMMENT 'Número máximo de líneas de IVA que puede tener una factura', + `dueDateMarginDays` int(10) unsigned DEFAULT 2, PRIMARY KEY (`id`), KEY `invoiceInConfig_sageWithholdingFk` (`sageFarmerWithholdingFk`), CONSTRAINT `invoiceInConfig_sageWithholdingFk` FOREIGN KEY (`sageFarmerWithholdingFk`) REFERENCES `sage`.`TiposRetencion` (`CodigoRetencion`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -32438,13 +32467,13 @@ CREATE TABLE `invoiceOutTax` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `invoiceOutTaxConfig` +-- Table structure for table `invoiceOutTaxMultiConfig` -- -DROP TABLE IF EXISTS `invoiceOutTaxConfig`; +DROP TABLE IF EXISTS `invoiceOutTaxMultiConfig`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `invoiceOutTaxConfig` ( +CREATE TABLE `invoiceOutTaxMultiConfig` ( `id` int(11) NOT NULL AUTO_INCREMENT, `taxClassCodeFk` varchar(1) DEFAULT NULL, `taxTypeSageFk` smallint(6) DEFAULT NULL, @@ -32534,6 +32563,12 @@ CREATE TABLE `item` ( `minQuantity__` int(10) unsigned DEFAULT NULL COMMENT '@deprecated 2024-07-11 refs #7704 Cantidad mínima para una línea de venta', `isBoxPickingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'FALSE: using item.packingOut TRUE: boxPicking using itemShelving.packing', `photoMotivation` varchar(255) DEFAULT NULL, + `tag11` varchar(20) DEFAULT NULL, + `value11` varchar(50) DEFAULT NULL, + `tag12` varchar(20) DEFAULT NULL, + `value12` varchar(50) DEFAULT NULL, + `tag13` varchar(20) DEFAULT NULL, + `value13` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -33070,7 +33105,7 @@ CREATE TABLE `itemShelving` ( `buyFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, `available` int(11) DEFAULT NULL, - `isSplit` tinyint(1) DEFAULT NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda', + `isSplit` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda', PRIMARY KEY (`id`), KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), @@ -33253,7 +33288,8 @@ CREATE TABLE `itemShelvingSaleReserve` ( `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`), - CONSTRAINT `itemShelvingSaleReserve_sector_FK` FOREIGN KEY (`id`) REFERENCES `sector` (`id`) ON UPDATE CASCADE + KEY `itemShelvingSaleReserve_sector_FK` (`sectorFk`), + CONSTRAINT `itemShelvingSaleReserve_sector_FK` FOREIGN KEY (`sectorFk`) REFERENCES `sector` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed itemShelvingSale to reserve'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -35741,6 +35777,7 @@ CREATE TABLE `productionConfigLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `productionConfigLog_userFk` (`userFk`), KEY `productionConfigLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -39958,27 +39995,6 @@ CREATE TABLE `trolley` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `userConfig` --- - -DROP TABLE IF EXISTS `userConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `userConfig` ( - `userFk` int(10) unsigned NOT NULL, - `warehouseFk` smallint(6) DEFAULT NULL, - `companyFk` smallint(5) unsigned DEFAULT NULL, - `created` timestamp NULL DEFAULT current_timestamp(), - `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), - `darkMode` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Salix interface dark mode', - `tabletFk` varchar(100) DEFAULT NULL, - PRIMARY KEY (`userFk`), - KEY `tabletFk` (`tabletFk`), - CONSTRAINT `userConfig_ibfk_1` FOREIGN KEY (`tabletFk`) REFERENCES `docuwareTablet` (`tablet`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de usuario en Salix'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `userLog` -- @@ -40006,6 +40022,27 @@ CREATE TABLE `userLog` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci `PAGE_COMPRESSED`=1; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `userMultiConfig` +-- + +DROP TABLE IF EXISTS `userMultiConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `userMultiConfig` ( + `userFk` int(10) unsigned NOT NULL, + `warehouseFk` smallint(6) DEFAULT NULL, + `companyFk` smallint(5) unsigned DEFAULT NULL, + `created` timestamp NULL DEFAULT current_timestamp(), + `updated` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `darkMode` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Salix interface dark mode', + `tabletFk` varchar(100) DEFAULT NULL, + PRIMARY KEY (`userFk`), + KEY `tabletFk` (`tabletFk`), + CONSTRAINT `userMultiConfig_ibfk_1` FOREIGN KEY (`tabletFk`) REFERENCES `docuwareTablet` (`tablet`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Configuración de usuario en Salix'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `userPhone` -- @@ -42152,6 +42189,28 @@ DELIMITER ;; /*!50003 SET character_set_client = @saved_cs_client */ ;; /*!50003 SET character_set_results = @saved_cs_results */ ;; /*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `travel_setDelivered` */;; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `travel_setDelivered` ON SCHEDULE EVERY 1 DAY STARTS '2024-07-12 00:10:00' ON COMPLETION PRESERVE ENABLE DO BEGIN + UPDATE travel t + SET t.isDelivered = TRUE + WHERE t.shipped < util.VN_CURDATE(); +END */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; /*!50106 DROP EVENT IF EXISTS `vehicle_notify` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; @@ -47452,7 +47511,7 @@ proc: BEGIN -- Tabla con el ultimo dia de last_buy para cada producto -- que hace un replace de la anterior. - CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); + CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE()); INSERT INTO tItemRange SELECT t.itemFk, tr.landed @@ -48118,40 +48177,15 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`( ) BEGIN /** - * Calcula las últimas compras realizadas hasta una fecha + * @deprecated Usar buy_getUltimate + * Calcula las últimas compras realizadas hasta una fecha. * + * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén * @param vDated Compras hasta fecha * @return tmp.buyUltimate */ - CALL cache.last_buy_refresh (FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(itemFk)) - ENGINE = MEMORY - SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing - FROM cache.last_buy - WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - - IF vDated >= util.VN_CURDATE() THEN - CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); - - REPLACE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed <= vDated - AND NOT isIgnored; - - INSERT IGNORE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed > vDated - ORDER BY isIgnored = FALSE DESC; - END IF; + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48175,6 +48209,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimateFromInterval`( ) BEGIN /** + * @deprecated Usar buy_getUltimateFromInterval * Calcula las últimas compras realizadas * desde un rango de fechas. * @@ -48183,154 +48218,7 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM - (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; + CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48716,6 +48604,254 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_getUltimate` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas hasta una fecha. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @param vDated Compras hasta fecha + * @return tmp.buyUltimate + */ + CALL cache.last_buy_refresh(FALSE); + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(itemFk)) + ENGINE = MEMORY + SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing + FROM cache.last_buy + WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL) + AND (item_id = vItemFk OR vItemFk IS NULL); + + IF vDated >= util.VN_CURDATE() THEN + CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + + REPLACE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed <= vDated + AND NOT isIgnored; + + INSERT IGNORE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed > vDated + ORDER BY isIgnored = FALSE DESC; + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `buy_getUltimateFromInterval` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_getUltimateFromInterval`( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = vEnded - INTERVAL 1 MONTH; + END IF; + + -- Item + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `buy_getVolume` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -49044,7 +49180,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `buy_updateGrouping`( + vWarehouseFk INT, + vItemFk INT, + vGrouping INT +) BEGIN /** * Actualiza el grouping de las últimas compras de un artículo @@ -49053,9 +49193,9 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); - UPDATE vn.buy b + UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk SET b.`grouping` = vGrouping WHERE bu.warehouseFk = vWarehouseFk @@ -49087,7 +49227,7 @@ BEGIN * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk @@ -49182,7 +49322,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); + CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot( @@ -49225,9 +49365,9 @@ BEGIN LEAVE l; END IF; - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buyUltimate(vWarehouseFk, vShipped); + CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, @@ -49239,17 +49379,17 @@ BEGIN LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id AND anr.calc_id = vAvailableNoRaidsCalc JOIN tmp.item i ON i.itemFk = a.item_id - JOIN vn.item it ON it.id = i.itemFk - JOIN vn.`zone` z ON z.id = vZoneFk + JOIN item it ON it.id = i.itemFk + JOIN `zone` z ON z.id = vZoneFk LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed - FROM vn.addressFilter af + FROM addressFilter af JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk + FROM address ad + JOIN province p ON p.id = ad.provinceFk WHERE ad.id = vAddressFk ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) @@ -49261,18 +49401,18 @@ BEGIN OR ISNULL(af.afterDated)) ) sub ON sub.isVNHSupplier = v.isVNHSupplier AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird)) - JOIN vn.agencyMode am ON am.id = vAgencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN vn.itemType itt ON itt.id = it.typeFk - JOIN vn.itemCategory itc on itc.id = itt.categoryFk - JOIN vn.address ad ON ad.id = vAddressFk - LEFT JOIN vn.clientItemType cit + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN agency ag ON ag.id = am.agencyFk + JOIN itemType itt ON itt.id = it.typeFk + JOIN itemCategory itc on itc.id = itt.categoryFk + JOIN address ad ON ad.id = vAddressFk + LEFT JOIN clientItemType cit ON cit.clientFk = ad.clientFk AND cit.itemTypeFk = itt.id - LEFT JOIN vn.zoneItemType zit + LEFT JOIN zoneItemType zit ON zit.zoneFk = vZoneFk AND zit.itemTypeFk = itt.id - LEFT JOIN vn.agencyModeItemType ait + LEFT JOIN agencyModeItemType ait ON ait.agencyModeFk = vAgencyModeFk AND ait.itemTypeFk = itt.id WHERE a.calc_id = vAvailableCalc @@ -49286,7 +49426,7 @@ BEGIN DROP TEMPORARY TABLE tmp.buyUltimate; - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); INSERT INTO tmp.ticketCalculateItem( itemFk, @@ -52853,7 +52993,7 @@ DECLARE vCompanyFk INT; SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) INTO vCompanyFk FROM vn.routeConfig rc - LEFT JOIN userConfig uc ON uc.userFk = workerFk; + LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk; SELECT @@ -54183,6 +54323,7 @@ BEGIN DECLARE vInvoiceFk INT; DECLARE vBookEntry INT; DECLARE vFiscalYear INT; + DECLARE vIncorrectInvoiceInDueDay INT; DECLARE vInvoicesIn CURSOR FOR SELECT DISTINCT e.invoiceInFk @@ -54195,6 +54336,19 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay + FROM invoiceInDueDay iidd + JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id + JOIN `entry` e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN invoiceInConfig iic + WHERE de.duaFk = vDuaFk + AND iidd.dueDated <= util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY; + + IF vIncorrectInvoiceInDueDay THEN + CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay)); + END IF; + UPDATE invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id JOIN duaEntry de ON de.entryFk = e.id @@ -55212,7 +55366,7 @@ BEGIN FROM tmp.itemList; END IF; - CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded); + CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded); CREATE OR REPLACE TEMPORARY TABLE tTransfer ENGINE = MEMORY @@ -55785,7 +55939,7 @@ BEGIN UPDATE itemShelving SET isSplit = TRUE - WHERE shelvingFk = vShelvingFk; + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; END LOOP; CLOSE cur; END ;; @@ -57642,7 +57796,9 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_calculate`(vInvoiceInFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `invoiceInDueDay_calculate`( +vInvoiceInFk INT +) BEGIN /** * Calcula los vctos. de una factura recibida @@ -57699,12 +57855,13 @@ BEGIN COUNT(DISTINCT(pdd.detail)) cont, s.payDay, ii.issued, - DATE(ii.created) + INTERVAL 2 DAY created + DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created FROM invoiceIn ii JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk JOIN supplier s ON s.id = ii.supplierFk - JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN invoiceInConfig iic WHERE ii.id = vInvoiceInFk GROUP BY ii.id )sub @@ -58038,9 +58195,11 @@ BEGIN DECLARE vHasRepeatedTransactions BOOL; SELECT TRUE INTO vHasRepeatedTransactions - FROM invoiceInTax - WHERE invoiceInFk = vSelf - HAVING COUNT(DISTINCT transactionTypeSageFk) > 1 + FROM invoiceInTax iit + JOIN invoiceIn ii ON ii.id = iit.invoiceInFk + WHERE ii.id = vSelf + AND ii.serial = 'E' + HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1 LIMIT 1; IF vHasRepeatedTransactions THEN @@ -59101,7 +59260,7 @@ BEGIN i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk FROM tmp.ticketServiceTax tst - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code WHERE i.isService HAVING taxableBase ) sub; @@ -59114,7 +59273,7 @@ BEGIN i.taxTypeSageFk , i.transactionTypeSageFk FROM tmp.ticketTax tt - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code WHERE !i.isService GROUP BY tt.pgcFk HAVING taxableBase @@ -60660,6 +60819,7 @@ proc: BEGIN itemShelvingFk, saleFk, quantity, + userFk, isPicked) SELECT vItemShelvingFk, vSaleFk, @@ -60684,6 +60844,65 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_addBySaleGroup` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_addBySaleGroup`( + vSaleGroupFk INT(11) +) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * a través del saleGroup + * + * @param vSaleGroupFk Identificador de saleGroup + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT s.id + FROM saleGroupDetail sgd + JOIN sale s ON sgd.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sgd.saleGroupFk = vSaleGroupFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingSale_addBySectorCollection` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60817,58 +61036,58 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_reallocate`( - vItemShelvingFk INT(10), - vItemFk INT(10), - vSectorFk INT +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_reallocate`( + vItemShelvingFk INT(10), + vItemFk INT(10), + vSectorFk INT ) -BEGIN -/** - * Elimina reservas de un itemShelving e intenta reservar en otra ubicación - * - * @param vItemShelvingFk Id itemShelving - * @param vItemFk Id del artículo - * @param vSectorFk Id del sector - */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - UPDATE itemShelving - SET visible = 0, - available = 0 - WHERE id = vItemShelvingFk - AND itemFk = vItemFk; - - SELECT iss.id - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND iss.itemFk = vItemFk - AND NOT iss.isPicked - FOR UPDATE; - - INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) - SELECT DISTINCT iss.saleFk - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - - DELETE iss - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - COMMIT; - - CALL itemShelvingSale_doReserve(); +BEGIN +/** + * Elimina reservas de un itemShelving e intenta reservar en otra ubicación + * + * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT DISTINCT iss.saleFk, vSectorFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -61036,7 +61255,7 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) SELECT vSaleFk, vSectorFk; CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; @@ -61231,7 +61450,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible @@ -61434,7 +61653,8 @@ BEGIN ish.id, s.priority, ish.isChecked, - ic.url + ic.url, + ish.available FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci @@ -61553,7 +61773,7 @@ BEGIN FROM operator WHERE workerFk = account.myUser_getId(); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE()); SELECT buyFk INTO vBuyFk FROM tmp.buyUltimate @@ -62397,6 +62617,7 @@ BEGIN FROM itemTicketOut i LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk JOIN `state` s ON s.id = ts.stateFk + JOIN warehouse w ON w.id = i.warehouseFk LEFT JOIN ( SELECT DISTINCT st.saleFk FROM saleTracking st @@ -62404,26 +62625,31 @@ BEGIN WHERE st.created > vDated AND (s.isPicked OR st.isChecked) ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk - WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk + WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk) AND (vSelf IS NULL OR i.itemFk = vSelf) AND (s.isPicked OR i.reserved OR stPrevious.saleFk) AND i.shipped >= vDated AND i.shipped < vTomorrow + AND w.isComparative UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE isReceived - AND landed >= vDated AND landed < vTomorrow - AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk - AND (vSelf IS NULL OR itemFk = vSelf) - AND NOT isVirtualStock + SELECT iei.itemFk, iei.quantity + FROM itemEntryIn iei + JOIN warehouse w ON w.id = iei.warehouseInFk + WHERE iei.isReceived + AND iei.landed >= vDated AND iei.landed < vTomorrow + AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk) + AND (vSelf IS NULL OR iei.itemFk = vSelf) + AND NOT iei.isVirtualStock + AND w.isComparative UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE isDelivered - AND shipped >= vDated - AND shipped < vTomorrow - AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk - AND (vSelf IS NULL OR itemFk = vSelf) + SELECT ieo.itemFk, ieo.quantity + FROM itemEntryOut ieo + JOIN warehouse w ON w.id = ieo.warehouseOutFk + WHERE ieo.isDelivered + AND ieo.shipped >= vDated + AND ieo.shipped < vTomorrow + AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk) + AND (vSelf IS NULL OR ieo.itemFk = vSelf) + AND w.isComparative ) t GROUP BY itemFk ON DUPLICATE KEY UPDATE @@ -62668,19 +62894,20 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `item_comparative`( ) proc: BEGIN /** - * Genera una tabla de comparativa de artículos por itemType/comprador/fecha. - * Los datos se calculan en función de los parámetros proporcionados. + * Generates a comparison table of items by itemType/buyer/date. + * The data is calculated based on the provided parameters. * - * @param vDate La fecha para la cual se generará la comparativa. - * @param vDayRange El rango de días a considerar para la comparativa. - * @param vWarehouseFk El identificador del almacén para filtrar los artículos. - * @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. - * @param vBuyerFk El identificador del comprador para filtrar los artículos. - * @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). - * @param vCountryFk El identificador del país. - * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) + * @param vDate The date for which the comparison will be generated. + * @param vDayRange The range of days to consider for the comparison. + * @param vWarehouseFk The warehouse identifier to filter the items. + * @param vAvailableSince The availability date from which the items are considered available. + * @param vBuyerFk The buyer identifier to filter the items. + * @param vIsFloramondo Indicates whether only Floramondo items should be included (optional). + * @param vCountryFk The country identifier. + * @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT) * @return tmp.comparative */ + DECLARE vDayRangeStart DATE; DECLARE vDayRangeEnd DATE; DECLARE w1, w2, w3, w4, w5, w6, w7 INT; @@ -63053,7 +63280,7 @@ BEGIN END IF; SELECT warehouseFk INTO vWarehouseFk - FROM userConfig + FROM userMultiConfig WHERE userFk = account.myUser_getId(); IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN @@ -63104,7 +63331,7 @@ BEGIN ORDER BY created DESC LIMIT 1; - CALL buyUltimate(vWarehouseFk, vCurdate); + CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate); SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal FROM tmp.buyUltimate bu @@ -63785,7 +64012,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getInfo`( + `vBarcode` VARCHAR(22), + `vWarehouseFk` INT +) BEGIN /** * Devuelve información relativa al item correspondiente del vBarcode pasado @@ -63797,12 +64027,14 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; + DECLARE vDated DATE; + + SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated; CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - - SELECT barcodeToItem(vBarcode) INTO vItemFk; + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); + SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock WHERE itemFk = vItemFk @@ -63940,39 +64172,42 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getMinacum`( + vWarehouseFk TINYINT, + vDated DATE, + vRange INT, + vItemFk INT +) BEGIN /** - * Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de - * NULL para todo. + * Cálculo del mínimo acumulado, para un item/almacén + * especificado, en caso de NULL para todos. * - * @param vWarehouseFk -> warehouseFk - * @param vDatedFrom -> fecha inicio - * @param vRange -> número de días a considerar - * @param vItemFk -> Identificador de item + * @param vWarehouseFk Id warehouse + * @param vDated Fecha inicio + * @param vRange Número de días a considerar + * @param vItemFk Id de artículo * @return tmp.itemMinacum */ - DECLARE vDatedTo DATETIME; + DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY); - SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc; - CREATE TEMPORARY TABLE tmp.itemCalc + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY SELECT sub.itemFk, sub.dated, CAST(SUM(sub.quantity) AS SIGNED) quantity, sub.warehouseFk - FROM (SELECT s.itemFk, + FROM ( + SELECT s.itemFk, DATE(t.shipped) dated, -s.quantity quantity, t.warehouseFk FROM sale s JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + WHERE t.shipped BETWEEN vDated AND vDatedTo AND t.warehouseFk - AND s.quantity != 0 + AND s.quantity <> 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) UNION ALL @@ -63983,10 +64218,10 @@ BEGIN FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDatedFrom AND vDatedTo + WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND NOT e.isExcludedFromAvailable + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL SELECT b.itemFk, @@ -63996,29 +64231,46 @@ BEGIN FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) - AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND NOT e.isExcludedFromAvailable + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND !e.isRaid + AND NOT e.isRaid + UNION ALL + SELECT r.itemFk, + r.shipment, + -r.amount, + r.warehouseFk + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN client c ON c.id = o.customer_id + WHERE r.shipment BETWEEN vDated AND vDatedTo + AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) + AND r.created >= ( + SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND (vItemFk IS NULL OR r.itemFk = vItemFk) + AND r.amount <> 0 ) sub GROUP BY sub.itemFk, sub.warehouseFk, sub.dated; - CALL item_getAtp(vDatedFrom); - DROP TEMPORARY TABLE tmp.itemCalc; + CALL item_getAtp(vDated); - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; - CREATE TEMPORARY TABLE tmp.itemMinacum + CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT i.itemFk, - i.warehouseFk, - i.quantity amount - FROM tmp.itemAtp i - HAVING amount != 0; + SELECT itemFk, + warehouseFk, + quantity amount + FROM tmp.itemAtp + WHERE quantity <> 0; - DROP TEMPORARY TABLE tmp.itemAtp; + DROP TEMPORARY TABLE + tmp.itemAtp, + tmp.itemCalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -64283,7 +64535,7 @@ BEGIN */ ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate (NULL, vWarehouseFk, vDate); CREATE OR REPLACE TEMPORARY TABLE tmp (KEY (itemFk)) @@ -64418,12 +64670,18 @@ BEGIN i.tag8 = JSON_VALUE(vTags, '$.8'), i.tag9 = JSON_VALUE(vTags, '$.9'), i.tag10 = JSON_VALUE(vTags, '$.10'), + i.tag11 = JSON_VALUE(vTags, '$.11'), + i.tag12 = JSON_VALUE(vTags, '$.12'), + i.tag13 = JSON_VALUE(vTags, '$.13'), i.value5 = JSON_VALUE(vValues, '$.5'), i.value6 = JSON_VALUE(vValues, '$.6'), i.value7 = JSON_VALUE(vValues, '$.7'), i.value8 = JSON_VALUE(vValues, '$.8'), i.value9 = JSON_VALUE(vValues, '$.9'), i.value10 = JSON_VALUE(vValues, '$.10'), + i.value11 = JSON_VALUE(vValues, '$.11'), + i.value12 = JSON_VALUE(vValues, '$.12'), + i.value13 = JSON_VALUE(vValues, '$.13'), i.producerFk = p.id, i.inkFk = k.id, i.originFk = IFNULL(o.id, i.originFk) @@ -64699,232 +64957,256 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_valuateInventory` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_valuateInventory`( -vDated DATE + vDated DATE, + vItemTypeFk INT, + vItemCategoryFk INT ) BEGIN -DECLARE vInventoried DATE; -DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; -DECLARE vInventoryClone DATE; -DECLARE vDateDayEnd DATETIME; -DECLARE vInventorySupplierFk INT; + DECLARE vInventoried DATE; + DECLARE vHasNotInventory BOOLEAN DEFAULT FALSE; + DECLARE vInventoryClone DATE; + DECLARE vDateDayEnd DATETIME; + DECLARE vInventorySupplierFk INT; -SELECT inventorySupplierFk INTO vInventorySupplierFk -FROM entryConfig; + SELECT inventorySupplierFk INTO vInventorySupplierFk + FROM entryConfig; -SET vDateDayEnd = util.dayEnd(vDated); + SET vDateDayEnd = util.dayEnd(vDated); -SELECT tr.landed INTO vInventoried -FROM travel tr -JOIN `entry` e ON e.travelFk = tr.id -WHERE tr.landed <= vDateDayEnd -AND e.supplierFk = vInventorySupplierFk -ORDER BY tr.landed DESC -LIMIT 1; + SELECT tr.landed INTO vInventoried + FROM travel tr + JOIN `entry` e ON e.travelFk = tr.id + WHERE tr.landed <= vDateDayEnd + AND e.supplierFk = vInventorySupplierFk + ORDER BY tr.landed DESC + LIMIT 1; -SET vHasNotInventory = (vInventoried IS NULL); + SET vHasNotInventory = (vInventoried IS NULL); + + IF vHasNotInventory THEN + SELECT landed INTO vInventoryClone + FROM travel tr + JOIN `entry` e ON e.travelFk = tr.id + WHERE tr.landed >= vDated + AND e.supplierFk = vInventorySupplierFk + ORDER BY landed ASC + LIMIT 1; -IF vHasNotInventory THEN -SELECT landed INTO vInventoryClone -FROM travel tr -JOIN `entry` e ON e.travelFk = tr.id -WHERE tr.landed >= vDated -AND e.supplierFk = vInventorySupplierFk -ORDER BY landed ASC -LIMIT 1; + SET vInventoried = vDated + INTERVAL 1 DAY; + SET vDateDayEnd = vInventoryClone; + END IF; -SET vInventoried = vDated + INTERVAL 1 DAY; -SET vDateDayEnd = vInventoryClone; -END IF; + CREATE OR REPLACE TEMPORARY TABLE tInventory( + warehouseFk SMALLINT, + itemFk BIGINT, + quantity INT, + volume DECIMAL(10,2), + cost DOUBLE DEFAULT 0, + total DOUBLE DEFAULT 0, + warehouseInventory VARCHAR(20), + PRIMARY KEY (warehouseInventory, itemFk) USING HASH + ) + ENGINE = MEMORY; + + -- Inventario inicial + IF vHasNotInventory THEN + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT tr.warehouseInFk, + b.itemFk, + SUM(b.quantity), + w.name + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN `entry` e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vDateDayEnd + AND e.supplierFk = vInventorySupplierFk + AND w.valuatedInventory + AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + GROUP BY tr.warehouseInFk, b.itemFk; + ELSE + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT tr.warehouseInFk, + b.itemFk, + SUM(b.quantity), + w.name + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN `entry` e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed = vInventoried + AND e.supplierFk = vInventorySupplierFk + AND w.valuatedInventory + AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + GROUP BY tr.warehouseInFk, b.itemFk; + END IF; -CREATE OR REPLACE TEMPORARY TABLE tInventory( -warehouseFk SMALLINT, -itemFk BIGINT, -quantity INT, -volume DECIMAL(10,2), -cost DOUBLE DEFAULT 0, -total DOUBLE DEFAULT 0, -warehouseInventory VARCHAR(20), -PRIMARY KEY (warehouseInventory, itemFk) USING HASH -) -ENGINE = MEMORY; + -- Añadimos las entradas + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT tr.warehouseInFk, + b.itemFk, + b.quantity * IF(vHasNotInventory, -1, 1), + w.name + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN `entry` e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseInFk + WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd + AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) + AND NOT e.isRaid + AND w.valuatedInventory + AND t.isInventory + AND e.supplierFk <> vInventorySupplierFk + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1)); + -- Descontamos las salidas + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT tr.warehouseOutFk, + b.itemFk, + b.quantity * IF(vHasNotInventory, 1, -1), + w.name + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN `entry` e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse w ON w.id = tr.warehouseOutFk + WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd + AND NOT e.isRaid + AND w.valuatedInventory + AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1)); -IF vHasNotInventory THEN -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT tr.warehouseInFk, -b.itemFk, -SUM(b.quantity), -w.name -FROM buy b -JOIN item i ON i.id = b.itemFk -JOIN `entry` e ON e.id = b.entryFk -JOIN travel tr ON tr.id = e.travelFk -JOIN itemType t ON t.id = i.typeFk -JOIN warehouse w ON w.id = tr.warehouseInFk -WHERE tr.landed = vDateDayEnd -AND e.supplierFk = vInventorySupplierFk -AND w.valuatedInventory -AND t.isInventory -GROUP BY tr.warehouseInFk, b.itemFk; -ELSE -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT tr.warehouseInFk, -b.itemFk, -SUM(b.quantity), -w.name -FROM buy b -JOIN item i ON i.id = b.itemFk -JOIN `entry` e ON e.id = b.entryFk -JOIN travel tr ON tr.id = e.travelFk -JOIN itemType t ON t.id = i.typeFk -JOIN warehouse w ON w.id = tr.warehouseInFk -WHERE tr.landed = vInventoried -AND e.supplierFk = vInventorySupplierFk -AND w.valuatedInventory -AND t.isInventory -GROUP BY tr.warehouseInFk, b.itemFk; -END IF; + -- Descontamos las lineas de venta + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT w.id, + s.itemFk, + s.quantity * IF(vHasNotInventory, 1, -1), + w.name + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN `client` c ON c.id = t.clientFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd + AND w.valuatedInventory + AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); + -- Volver a poner lo que esta aun en las estanterias + IF vDated = util.VN_CURDATE() THEN + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT w.id, + s.itemFk, + s.quantity * IF(vHasNotInventory, 0, 1), + w.name + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN `client` c ON c.id = t.clientFk + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse w ON w.id = t.warehouseFk + WHERE t.shipped BETWEEN vDated AND vDateDayEnd + AND NOT (s.isPicked OR t.isLabeled) + AND w.valuatedInventory + AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1); + END IF; -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT tr.warehouseInFk, -b.itemFk, -b.quantity * IF(vHasNotInventory, -1, 1), -w.name -FROM buy b -JOIN item i ON i.id = b.itemFk -JOIN `entry` e ON e.id = b.entryFk -JOIN travel tr ON tr.id = e.travelFk -JOIN itemType t ON t.id = i.typeFk -JOIN warehouse w ON w.id = tr.warehouseInFk -WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd -AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) -AND NOT e.isRaid -AND w.valuatedInventory -AND t.isInventory -AND e.supplierFk <> vInventorySupplierFk -ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1)); + -- Mercancia en transito + INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) + SELECT tr.warehouseInFk, + b.itemFk, + b.quantity, + CONCAT(wOut.`name`, ' - ', wIn.`name`) + FROM buy b + JOIN item i ON i.id = b.itemFk + JOIN `entry` e ON e.id = b.entryFk + JOIN travel tr ON tr.id = e.travelFk + JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk + JOIN warehouse wIn ON wIn.id = tr.warehouseInFk + JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk + WHERE vDated >= tr.shipped AND vDated < tr.landed + AND NOT isRaid + AND wIn.valuatedInventory + AND t.isInventory + AND e.isConfirmed + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) + ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); + + CALL buy_getUltimate (NULL, NULL, vDateDayEnd); + DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT tr.warehouseOutFk, -b.itemFk, -b.quantity * IF(vHasNotInventory, 1, -1), -w.name -FROM buy b -JOIN item i ON i.id = b.itemFk -JOIN `entry` e ON e.id = b.entryFk -JOIN travel tr ON tr.id = e.travelFk -JOIN itemType t ON t.id = i.typeFk -JOIN warehouse w ON w.id = tr.warehouseOutFk -WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd -AND NOT e.isRaid -AND w.valuatedInventory -AND t.isInventory -ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1)); + UPDATE tInventory i + JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk + JOIN buy b ON b.id = bu.buyFk + LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk + AND ic.warehouseFk = i.warehouseFk + SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), + i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0), + i.volume = i.quantity * ic.cm3delivery / 1000000; + SELECT ti.warehouseFk, + i.id, + i.longName, + i.size, + ti.quantity, + ti.volume, + tp.name itemTypeName, + ic.name itemCategoryName, + ti.cost, + ti.total, + ti.warehouseInventory, + ic.display + FROM tInventory ti + JOIN warehouse w ON w.id = warehouseFk + JOIN item i ON i.id = ti.itemFk + JOIN itemType tp ON tp.id = i.typeFk + JOIN itemCategory ic ON ic.id = tp.categoryFk + WHERE w.valuatedInventory + AND ti.total > 0; -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT w.id, -s.itemFk, -s.quantity * IF(vHasNotInventory, 1, -1), -w.name -FROM sale s -JOIN ticket t ON t.id = s.ticketFk -JOIN `client` c ON c.id = t.clientFk -JOIN item i ON i.id = s.itemFk -JOIN itemType it ON it.id = i.typeFk -JOIN warehouse w ON w.id = t.warehouseFk -WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd -AND w.valuatedInventory -AND it.isInventory -ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); - - -IF vDated = util.VN_CURDATE() THEN -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT w.id, -s.itemFk, -s.quantity * IF(vHasNotInventory, 0, 1), -w.name -FROM sale s -JOIN ticket t ON t.id = s.ticketFk -JOIN `client` c ON c.id = t.clientFk -JOIN item i ON i.id = s.itemFk -JOIN itemType it ON it.id = i.typeFk -JOIN warehouse w ON w.id = t.warehouseFk -WHERE t.shipped BETWEEN vDated AND vDateDayEnd -AND NOT (s.isPicked OR t.isLabeled) -AND w.valuatedInventory -AND it.isInventory -ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1); -END IF; - - -INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) -SELECT tr.warehouseInFk, -b.itemFk, -b.quantity, -CONCAT(wOut.`name`, ' - ', wIn.`name`) -FROM buy b -JOIN item i ON i.id = b.itemFk -JOIN `entry` e ON e.id = b.entryFk -JOIN travel tr ON tr.id = e.travelFk -JOIN itemType t ON t.id = i.typeFk -JOIN warehouse wIn ON wIn.id = tr.warehouseInFk -JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk -WHERE vDated >= tr.shipped AND vDated < tr.landed -AND NOT isRaid -AND wIn.valuatedInventory -AND t.isInventory -AND e.isConfirmed -ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - -CALL buyUltimate(NULL, vDateDayEnd); - -DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; - -UPDATE tInventory i -JOIN tmp.buyUltimate bu ON i.warehouseFk = bu.warehouseFk AND i.itemFk = bu.itemFk -JOIN buy b ON b.id = bu.buyFk -LEFT JOIN itemCost ic ON ic.itemFk = i.itemFk -AND ic.warehouseFk = i.warehouseFk -SET i.total = i.quantity * (IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0)), -i.cost = IFNULL(b.buyingValue, 0) + IFNULL(b.packageValue, 0) + IFNULL(b.freightValue, 0) + IFNULL(b.comissionValue, 0), -i.volume = i.quantity * ic.cm3delivery / 1000000; - -SELECT ti.warehouseFk, -i.id, -i.longName, -i.size, -ti.quantity, -ti.volume, -tp.name itemTypeName, -ic.name itemCategoryName, -ti.cost, -ti.total, -ti.warehouseInventory -FROM tInventory ti -JOIN warehouse w ON w.id = warehouseFk -JOIN item i ON i.id = ti.itemFk -JOIN itemType tp ON tp.id = i.typeFk -JOIN itemCategory ic ON ic.id = tp.categoryFk -WHERE w.valuatedInventory -AND ti.total > 0; - -DROP TEMPORARY TABLE -tmp.buyUltimate, -tInventory; + DROP TEMPORARY TABLE + tmp.buyUltimate, + tInventory; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -65679,13 +65961,6 @@ proc: BEGIN ) sub GROUP BY itemFk; - UPDATE tmp.itemInventory ai - JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id - SET ai.inventory = iic.quantity, - ai.visible = iic.quantity, - ai.avalaible = iic.quantity, - ai.sd = iic.quantity; - -- Cálculo del visible CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); @@ -65697,8 +65972,12 @@ proc: BEGIN WHERE calc_id = vCalcFk; UPDATE tmp.itemInventory it - JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id - SET it.visible = it.visible + ivc.visible; + LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.inventory = iic.quantity, + it.visible = ivc.visible, + it.avalaible = iic.quantity, + it.sd = iic.quantity; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc @@ -65746,32 +66025,36 @@ proc: BEGIN CALL item_getAtp(vDate); CALL travel_upcomingArrivals(vWarehouseFk, vDate); - UPDATE tmp.itemInventory ai - JOIN ( - SELECT it.itemFk, - SUM(it.quantity) quantity, - im.quantity minQuantity - FROM tmp.itemCalc it - JOIN tmp.itemAtp im ON im.itemFk = it.itemFk - JOIN item i ON i.id = it.itemFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk - WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, - t.landing, - vDateToTomorrow) - GROUP BY it.itemFk - ) sub ON sub.itemFk = ai.id - SET ai.avalaible = IF(sub.minQuantity > 0, - ai.avalaible, - ai.avalaible + sub.minQuantity), - ai.sd = ai.inventory + sub.quantity; + CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT it.itemFk, + SUM(it.quantity) quantity, + im.quantity minQuantity + FROM tmp.itemCalc it + JOIN tmp.itemAtp im ON im.itemFk = it.itemFk + JOIN item i ON i.id = it.itemFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk + WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, + t.landing, + vDateToTomorrow) + GROUP BY it.itemFk; + + UPDATE tmp.itemInventory it + JOIN tItemAvailableCalc iac ON iac.itemFk = it.id + SET it.avalaible = IF(iac.minQuantity > 0, + it.avalaible, + it.avalaible + iac.minQuantity), + it.sd = it.inventory + iac.quantity; DROP TEMPORARY TABLE tmp.itemTravel, tmp.itemCalc, tmp.itemAtp, tItemInventoryCalc, - tItemVisibleCalc; + tItemVisibleCalc, + tItemAvailableCalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66861,27 +67144,30 @@ proc: BEGIN WHERE NOT `lines`; -- Lineas por linea de encajado + CREATE OR REPLACE TEMPORARY TABLE tItemPackingType + (PRIMARY KEY(ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, + SUM(sub.H) H, + SUM(sub.V) V, + SUM(sub.N) N + FROM ( + SELECT t.ticketFk, + SUM(i.itemPackingTypeFk = 'H') H, + SUM(i.itemPackingTypeFk = 'V') V, + SUM(i.itemPackingTypeFk IS NULL) N + FROM tmp.productionTicket t + JOIN sale s ON s.ticketFk = t.ticketFk + JOIN item i ON i.id = s.itemFk + GROUP BY t.ticketFk, i.itemPackingTypeFk + ) sub + GROUP BY ticketFk; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT ticketFk, - SUM(sub.H) H, - SUM(sub.V) V, - SUM(sub.N) N - FROM ( - SELECT t.ticketFk, - SUM(i.itemPackingTypeFk = 'H') H, - SUM(i.itemPackingTypeFk = 'V') V, - SUM(i.itemPackingTypeFk IS NULL) N - FROM tmp.productionTicket t - JOIN sale s ON s.ticketFk = t.ticketFk - JOIN item i ON i.id = s.itemFk - GROUP BY t.ticketFk, i.itemPackingTypeFk - ) sub - GROUP BY ticketFk - ) sub2 ON sub2.ticketFk = pb.ticketFk - SET pb.H = sub2.H, - pb.V = sub2.V, - pb.N = sub2.N; + JOIN tItemPackingType ti ON ti.ticketFk = pb.ticketFk + SET pb.H = ti.H, + pb.V = ti.V, + pb.N = ti.N; -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb @@ -66960,7 +67246,8 @@ proc: BEGIN tmp.risk, tmp.ticket_problems, tmp.ticketWithPrevia, - tItemShelvingStock; + tItemShelvingStock, + tItemPackingType; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68339,17 +68626,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `route_updateM3`(vRoute INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `route_updateM3`( + vSelf INT +) BEGIN +/** + * Actualiza el volumen de la ruta. + * + * @param vSelf Id ruta + */ + DECLARE vVolume DECIMAL(10,1) + DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf); - UPDATE vn.route r - LEFT JOIN ( - SELECT routeFk, SUM(volume) AS m3 - FROM saleVolume - WHERE routeFk = vRoute - ) v ON v.routeFk = r.id - SET r.m3 = IFNULL(v.m3,0) - WHERE r.id =vRoute; + UPDATE `route` + SET m3 = IFNULL(vVolume, 0) + WHERE id = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68445,15 +68736,10 @@ BEGIN * @param vSaleGroupFk id de la preparación previa * @param vParkingFk id del parking */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - RESIGNAL; - END; - UPDATE saleGroup sg SET sg.parkingFk = vParkingFk - WHERE sg.id = vSaleGroupFk - AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; + WHERE sg.id = vSaleGroupFk + AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; CALL ticket_setNextState(ticket_get(vSaleGroupFk)); END ;; @@ -69496,7 +69782,7 @@ BEGIN DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vComponentCount INT; + DECLARE vRequiredComponent INT; DECLARE vCursor CURSOR FOR SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) @@ -69537,7 +69823,7 @@ BEGIN SELECT ticketFk, clientFk FROM tmp.sale_getProblems; - SELECT COUNT(*) INTO vComponentCount + SELECT COUNT(*) INTO vRequiredComponent FROM component WHERE isRequired; @@ -69579,20 +69865,18 @@ BEGIN -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT ticketFk, (vComponentCount > nComp) hasComponentLack, saleFk - FROM ( - SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk - FROM tmp.ticket_list tl - JOIN sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - ) sub + SELECT t.id, COUNT(c.id) < vRequiredComponent hasComponentLack, s.id + FROM tmp.ticket_list tl + JOIN ticket t ON t.id = tl.ticketFk + JOIN sale s ON s.ticketFk = t.id + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component c ON c.id = sc.componentFk + AND c.isRequired + WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') + AND s.quantity > 0 + GROUP BY s.id HAVING hasComponentLack; -- Cliente congelado @@ -69759,7 +70043,7 @@ BEGIN ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem ,saleFk FROM ( @@ -69872,14 +70156,14 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `sale_recalcComponent` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_recalcComponent`(vOption VARCHAR(25)) proc: BEGIN @@ -69960,7 +70244,7 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.zoneGetLanded; -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY @@ -70063,7 +70347,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSaleFk; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(vNewItemFk, vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing INTO vGrouping,vGroupingMode,vPacking @@ -70071,6 +70355,8 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; + DROP TEMPORARY TABLE tmp.buyUltimate; + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; @@ -70166,24 +70452,29 @@ BEGIN */ DECLARE vSaleFk INT; DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; DECLARE vDone BOOL; - DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale; + DECLARE vSaleList CURSOR FOR + SELECT saleFk, hasProblem, isProblemCalcNeeded + FROM tmp.sale; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; OPEN vSaleList; l: LOOP SET vDone = FALSE; - FETCH vSaleList INTO vSaleFk, vHasProblem; + FETCH vSaleList INTO vSaleFk, vHasProblem, vIsProblemCalcNeeded; IF vDone THEN LEAVE l; END IF; UPDATE sale - SET problem = CONCAT( - IF(vHasProblem, - CONCAT(problem, ',', vProblemCode), - REPLACE(problem, vProblemCode , ''))) + SET problem = IF (vIsProblemCalcNeeded, + CONCAT( + IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))), + NULL) WHERE id = vSaleFk; END LOOP; CLOSE vSaleList; @@ -70218,7 +70509,7 @@ BEGIN ENGINE = MEMORY SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem, - ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded FROM sale WHERE id = vSelf; @@ -70256,9 +70547,9 @@ BEGIN ENGINE = MEMORY SELECT saleFk, sale_hasComponentLack(saleFk) hasProblem, - ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded FROM ( - SELECT s.id saleFk, s.ticketFk + SELECT s.id saleFk, s.ticketFk, s.quantity FROM ticket t JOIN sale s ON s.ticketFk = t.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id @@ -70305,7 +70596,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSelf; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale SELECT vSelf saleFk, @@ -70681,12 +70972,6 @@ BEGIN DECLARE vParkingFk INT; DECLARE vLastWeek DATE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - SET vParkingCode = REPLACE(vParkingCode, ' ', ''); SELECT id INTO vParkingFk @@ -70697,8 +70982,6 @@ BEGIN CALL util.throw('parkingNotExist'); END IF; - START TRANSACTION; - SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK; -- Comprobamos si es una prep. previa, ticket, colección o shelving @@ -70713,8 +70996,6 @@ BEGIN ELSE CALL util.throw('paramNotExist'); END IF; - - COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -70991,21 +71272,21 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +BEGIN /** * Aparca una matrícula en un parking * * @param vShelvingCode code de la matrícula * @param vParkingFk id del parking */ - INSERT INTO vn.shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) + INSERT INTO shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) SELECT s.id, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", pNew.code),'Shelving',s.id FROM parking p JOIN shelving s ON s.parkingFk = p.id JOIN parking pNew ON pNew.id = vParkingFk WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci; - UPDATE vn.shelving + UPDATE shelving SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE @@ -71255,7 +71536,7 @@ BEGIN WHERE warehouse_id = vAuctionWarehouseFk ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); - CALL buyUltimate(vAuctionWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74392,13 +74673,12 @@ BEGIN FROM zone WHERE id = vZoneFk; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, + SELECT vWarehouseFk warehouseFk, + NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk @@ -75694,11 +75974,6 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - RESIGNAL; - END; - INSERT INTO vn.ticketParking(ticketFk, parkingFk) SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk FROM ticket t @@ -75793,24 +76068,28 @@ BEGIN */ DECLARE vTicketFk INT; DECLARE vHasProblem INT; + DECLARE vIsProblemCalcNeeded BOOL; DECLARE vDone BOOL; - DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket; + DECLARE vTicketList CURSOR FOR + SELECT ticketFk, hasProblem, isProblemCalcNeeded + FROM tmp.ticket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; OPEN vTicketList; l: LOOP SET vDone = FALSE; - FETCH vTicketList INTO vTicketFk, vHasProblem; + FETCH vTicketList INTO vTicketFk, vHasProblem, vIsProblemCalcNeeded; IF vDone THEN LEAVE l; END IF; UPDATE ticket - SET problem = CONCAT( - IF(vHasProblem, + SET problem = IF(vIsProblemCalcNeeded, + CONCAT(IF(vHasProblem, CONCAT(problem, ',', vProblemCode), - REPLACE(problem, vProblemCode , ''))) + REPLACE(problem, vProblemCode , ''))), + NULL) WHERE id = vTicketFk; END LOOP; CLOSE vTicketList; @@ -75964,6 +76243,54 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRiskByClient` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblemRiskByClient`( + vClientFk INT +) +BEGIN +/** + * Updates future ticket risk for a client. + * + * @param vClientFk Id client + */ + DECLARE vDone INT DEFAULT FALSE; + DECLARE vTicketFk INT; + DECLARE vTickets CURSOR FOR + SELECT id + FROM ticket + WHERE clientFk = vClientFk + AND shipped >= util.VN_CURDATE() + AND refFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL vn.ticket_setProblemRisk(vTicketFk); + END LOOP; + CLOSE vTickets; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setProblemRounding` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -75989,7 +76316,7 @@ BEGIN FROM ticket WHERE id = vSelf; - CALL buyUltimate(vWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk, isProblemCalcNeeded)) @@ -76142,96 +76469,85 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setRisk`( - vClientFk INT) + vClientFk INT +) BEGIN /** - * Update the risk for a client with pending tickets + * Update the risk for a client with pending tickets. * * @param vClientFk Id cliente */ - DECLARE vHasDebt BOOL; - DECLARE vStarted DATETIME; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` - WHERE id = vClientFk - AND typeFk = 'normal'; - - IF vHasDebt THEN - - SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted - FROM clientConfig; - + IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN CREATE OR REPLACE TEMPORARY TABLE tTicketRisk - (KEY (ticketFk)) + (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - WITH ticket AS( - SELECT id ticketFk, - companyFk, - DATE(shipped) dated, - totalWithVat, - ticket_isProblemCalcNeeded(id) isProblemCalcNeeded - FROM vn.ticket - WHERE clientFk = vClientFk - AND refFk IS NULL - AND NOT isDeleted - AND IFNULL(totalWithVat, 0) <> 0 - AND shipped > vStarted - ), balance AS( - SELECT SUM(amount)amount, companyFk - FROM ( - SELECT amount, companyFk - FROM vn.clientRisk - WHERE clientFk = vClientFk - UNION ALL - SELECT -(SUM(amount) / 100) amount, tm.companyFk - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk - WHERE clientFk = vClientFk - AND receiptFk IS NULL - AND status = 'ok' - ) sub - WHERE companyFk - GROUP BY companyFk - ), uninvoiced AS( + WITH ticket AS ( + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), uninvoiced AS ( SELECT companyFk, dated, SUM(totalWithVat) amount FROM ticket - GROUP BY companyFk, dated - ), receipt AS( - SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount - FROM vn.receipt - WHERE clientFk = vClientFk - AND payed > util.VN_CURDATE() - GROUP BY companyFk, DATE(payed) - ), risk AS( + GROUP BY companyFk, dated + ), companies AS ( + SELECT DISTINCT companyFk FROM uninvoiced + ), balance AS ( + SELECT SUM(IFNULL(amount, 0))amount, companyFk + FROM ( + SELECT cr.amount, c.companyFk + FROM companies c + LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk + AND cr.clientFk = vClientFk + UNION ALL + SELECT -(SUM(t.amount) / 100) amount, c.companyFk + FROM companies c + LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk + LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id + AND t.clientFk = vClientFk + AND t.receiptFk IS NULL + AND t.`status` = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), receipt AS ( + SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount + FROM vn.receipt r + JOIN companies c ON c.companyFk = r.companyFk + WHERE r.clientFk = vClientFk + AND r.payed > util.VN_CURDATE() + GROUP BY r.companyFk, DATE(r.payed) + ), risk AS ( SELECT b.companyFk, - ui.dated, - SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) + + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + b.amount + SUM(IFNULL(r.amount, 0)) amount FROM balance b JOIN uninvoiced ui ON ui.companyFk = b.companyFk - LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk GROUP BY b.companyFk, ui.dated - ) - SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded - FROM ticket ti - JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk; + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = tr.amount - WHERE tr.isProblemCalcNeeded - ORDER BY t.id; - - UPDATE ticket t - JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = NULL - WHERE tr.isProblemCalcNeeded - ORDER BY t.id; + SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL); DROP TEMPORARY TABLE tTicketRisk; - END IF; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -76408,7 +76724,7 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`( vSelf INT, - vItemPackingTypeFk VARCHAR(1) + vOriginalItemPackingTypeFk VARCHAR(1) ) BEGIN /** @@ -76416,7 +76732,7 @@ BEGIN * Respeta el id inicial para el tipo propuesto. * * @param vSelf Id ticket - * @param vItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; @@ -76430,7 +76746,7 @@ BEGIN SELECT itemPackingTypeFk FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vItemPackingTypeFk) DESC; + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -86309,7 +86625,7 @@ USE `pbx`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueConfig` `c` on(`q`.`config` = `c`.`id`)) */; +/*!50001 VIEW `queueConf` AS select `q`.`name` AS `name`,`c`.`strategy` AS `strategy`,`c`.`timeout` AS `timeout`,`c`.`retry` AS `retry`,`c`.`weight` AS `weight`,`c`.`maxLen` AS `maxlen`,`c`.`ringInUse` AS `ringinuse` from (`queue` `q` join `queueMultiConfig` `c` on(`q`.`config` = `c`.`id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91039,4 +91355,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-07-23 8:19:18 +-- Dump completed on 2024-08-06 6:02:57 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 1b92f0d43..014bce729 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -6325,10 +6325,6 @@ BEGIN SET NEW.userFk = account.myUser_getId(); END IF; - IF (NEW.visible <> OLD.visible) THEN - SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0); - END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -9224,13 +9220,16 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); IF NOT (NEW.routeFk <=> OLD.routeFk) THEN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id - FROM vn.route r - WHERE r.isOk = FALSE - AND r.id IN (OLD.routeFk,NEW.routeFk) - AND r.created >= util.VN_CURDATE() - GROUP BY r.id; + IF NEW.isSigned THEN + CALL util.throw('A signed ticket cannot be rerouted'); + END IF; + INSERT IGNORE INTO routeRecalc(routeFk) + SELECT id + FROM `route` + WHERE NOT isOk + AND id IN (OLD.routeFk, NEW.routeFk) + AND created >= util.VN_CURDATE() + GROUP BY id; END IF; IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN @@ -11143,4 +11142,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-07-23 8:19:41 +-- Dump completed on 2024-08-06 6:03:19 From 6fb78e15995efb5ad0972c8a9061cd53d9ee3bd2 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 6 Aug 2024 08:59:20 +0200 Subject: [PATCH 087/145] test: hotFix saveSign --- .../back/methods/ticket/specs/saveSign.spec.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index 53ab42364..e93408973 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -30,8 +30,6 @@ describe('Ticket saveSign()', () => { it('should change state for ticket', async() => { const tx = await models.Ticket.beginTransaction({}); const ticketWithPackedState = 7; - const ticketStateId = 16; - const ticketCode = 'PARTIAL_DELIVERED'; spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]); let ticketTrackingAfter; @@ -39,16 +37,11 @@ describe('Ticket saveSign()', () => { const options = {transaction: tx}; const tickets = [ticketWithPackedState]; - const state = await models.State.findById(ticketStateId, null, options); - await state.updateAttributes({ - code: ticketCode, - name: ticketCode - }, options); + const expedition = await models.Expedition.findById(3, null, options); + expedition.updateAttribute('ticketFk', ticketWithPackedState, options); await models.Ticket.saveSign(ctx, tickets, null, null, options); - ticketTrackingAfter = await models.TicketLastState.findOne({ - where: {ticketFk: ticketWithPackedState} - }, options); + ticketTrackingAfter = await models.TicketLastState.findById(ticketWithPackedState, null, options); await tx.rollback(); } catch (e) { @@ -56,6 +49,6 @@ describe('Ticket saveSign()', () => { throw e; } - expect(ticketTrackingAfter.name).toBe('PARTIAL_DELIVERED'); + expect(ticketTrackingAfter.name).toBe('Entregado en parte'); }); }); From 69c676d44b0678c8037c2d779c14c1a65ce001e7 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 6 Aug 2024 09:38:27 +0200 Subject: [PATCH 088/145] hotFix(route): fix getTicket use skip --- modules/route/back/methods/route/getTickets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index c0b952b70..5aa4fdf0f 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -90,7 +90,7 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeGroupBy('t.id')); - stmt.merge(conn.makeOrderBy(filter.order)); + stmt.merge(conn.makePagination(filter)); return conn.executeStmt(stmt, myOptions); }; From 0152fb8a982360aa7bf72bf4ae0746db44b4051d Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 6 Aug 2024 09:51:15 +0200 Subject: [PATCH 089/145] hotFix getTIckets --- modules/route/back/methods/route/getTickets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 5aa4fdf0f..c0b952b70 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -90,7 +90,7 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeGroupBy('t.id')); - stmt.merge(conn.makePagination(filter)); + stmt.merge(conn.makeOrderBy(filter.order)); return conn.executeStmt(stmt, myOptions); }; From c7c711ac1a4fb0f613827ccb6a8b0b4aa637ab69 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 12:43:51 +0200 Subject: [PATCH 090/145] fix: refs #7728 duaInvoiceInBooking --- db/routines/vn/procedures/duaInvoiceInBooking.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 80166db62..4570de332 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -32,7 +32,7 @@ BEGIN JOIN duaEntry de ON de.entryFk = e.id JOIN invoiceInConfig iic WHERE de.duaFk = vDuaFk - AND iidd.dueDated <= util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY; + AND iidd.dueDated < util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY; IF vIncorrectInvoiceInDueDay THEN CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay)); From d1bb77d6ed2222e149aa9442997693aa2a871eeb Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 12:51:55 +0200 Subject: [PATCH 091/145] fix: refs #7834 expeditionScan_Put --- db/routines/vn/procedures/expeditionScan_Put.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/expeditionScan_Put.sql b/db/routines/vn/procedures/expeditionScan_Put.sql index 68e124e4b..cbc76d317 100644 --- a/db/routines/vn/procedures/expeditionScan_Put.sql +++ b/db/routines/vn/procedures/expeditionScan_Put.sql @@ -4,11 +4,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionScan_Put` vExpeditionFk INT ) BEGIN - IF (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN + IF NOT (SELECT TRUE FROM expedition WHERE id = vExpeditionFk LIMIT 1) THEN CALL util.throw('Expedition not exists'); END IF; - IF (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN + IF NOT (SELECT TRUE FROM expeditionPallet WHERE id = vPalletFk LIMIT 1) THEN CALL util.throw('Pallet not exists'); END IF; From 03358170d3281404a694196cbbfb6fea2727ca81 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 14:10:16 +0200 Subject: [PATCH 092/145] fix: refs #7740 ticket route throw --- db/routines/vn/triggers/ticket_beforeUpdate.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql index 34b6711ff..6d5d7f908 100644 --- a/db/routines/vn/triggers/ticket_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql @@ -8,7 +8,13 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); IF NOT (NEW.routeFk <=> OLD.routeFk) THEN - IF NEW.isSigned THEN + IF NEW.isSigned AND NOT ( + SELECT (COUNT(s.id) = COUNT(cb.saleFk) + AND SUM(s.quantity) = SUM(cb.quantity)) + FROM sale s + LEFT JOIN claimBeginning cb ON cb.saleFk = s.id + WHERE s.ticketFk = NEW.id + ) THEN CALL util.throw('A signed ticket cannot be rerouted'); END IF; INSERT IGNORE INTO routeRecalc(routeFk) From 163faf983e326c2679c54d1993c0daeade61b7b4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 6 Aug 2024 16:34:46 +0200 Subject: [PATCH 093/145] feat workerActivity refs #6078 --- back/methods/workerActivity/add.js | 10 +++++--- back/methods/workerActivity/specs/add.spec.js | 25 +++++++------------ 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js index 587ebfae7..bba05dafd 100644 --- a/back/methods/workerActivity/add.js +++ b/back/methods/workerActivity/add.js @@ -24,8 +24,12 @@ module.exports = Self => { Self.add = async(ctx, code, model, options) => { const userId = ctx.req.accessToken.userId; + const myOptions = {}; - const result = await await Self.rawSql(` + if (typeof options == 'object') + Object.assign(myOptions, options); + + return await Self.rawSql(` INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) SELECT ?, ?, @@ -44,8 +48,6 @@ module.exports = Self => { WHERE sub.workerFk IS NULL OR sub.code <> ? OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` - , [userId, code, model, userId, code]); - - return result; + , [userId, code, model, userId, code], myOptions); }; }; diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js index 3f9657c67..67a85cb7d 100644 --- a/back/methods/workerActivity/specs/add.spec.js +++ b/back/methods/workerActivity/specs/add.spec.js @@ -1,36 +1,29 @@ const {models} = require('vn-loopback'); describe('workerActivity insert()', () => { - beforeAll(async() => { - ctx = { - req: { - accessToken: {}, - headers: {origin: 'http://localhost'}, - __: value => value - } - }; - }); + const ctx = beforeAll.getCtx(1106); it('should insert in workerActivity', async() => { const tx = await models.WorkerActivity.beginTransaction({}); + let count = 0; + const options = {transaction: tx}; try { await models.WorkerActivityType.create( - {'code': 'STOP', 'description': 'STOP'} + {'code': 'STOP', 'description': 'STOP'}, options ); - const options = {transaction: tx}; - ctx.req.accessToken.userId = 1106; - models.WorkerActivity.add(ctx, 'STOP', 'APP', options); + result = await models.WorkerActivity.add(ctx, 'STOP', 'APP', options); + + count = await models.WorkerActivity.count( + {'workerFK': 1106}, options + ); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } - const count = await models.WorkerActivity.count( - {'workerFK': 1106} - ); expect(count).toEqual(1); }); From b3b7e9c2135c114fe842359abe48029f7d6cd353 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 6 Aug 2024 17:08:27 +0200 Subject: [PATCH 094/145] fix: refs #7524 default limit select --- loopback/common/models/vn-model.js | 9 ++++----- loopback/server/boot/orm.js | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 loopback/server/boot/orm.js diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 0b16c6532..20c75ca8c 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -31,20 +31,19 @@ module.exports = function(Self) { /* * Intercept GET request for find */ - this.beforeRemote('find', async function(ctx) { + this.beforeRemote('find', async ctx => { isSelect = true; const filter = ctx.args.filter || {}; - // console.log(this.dataSource, Self.dataSource); undefined/null if (filter.limit === undefined) { - filter.limit = 1/* limit */; + filter.limit = this.app.orm.selectLimit; ctx.args.filter = filter; } }); - this.observe('loaded', async function({data}) { + this.observe('loaded', async({data}) => { if (!isSelect) return; const length = Array.isArray(data) ? data.length : data ? 1 : 0; - if (length >= 1) throw new UserError('Too many records'); + if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); }); // Register field ACL validation diff --git a/loopback/server/boot/orm.js b/loopback/server/boot/orm.js new file mode 100644 index 000000000..8bbd969e1 --- /dev/null +++ b/loopback/server/boot/orm.js @@ -0,0 +1,6 @@ +module.exports = async function(app) { + if (!app.orm) { + const ormConfig = await app.models.OrmConfig.findOne(); + app.orm = ormConfig; + } +}; From f385b9a8a3da9702998a7c7204212084b9fe6498 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Aug 2024 07:12:29 +0200 Subject: [PATCH 095/145] feat: refs #7818 entry_splitByShelving --- db/routines/vn/procedures/entry_splitByShelving.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index f46278e5a..9f09ed5be 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -15,7 +15,7 @@ BEGIN DECLARE cur CURSOR FOR SELECT bb.id buyFk, - FLOOR(ish.visible / ish.packing) ishStickers, + LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, bb.stickers buyStickers FROM itemShelving ish JOIN (SELECT b.id, b.itemFk, b.stickers @@ -23,7 +23,6 @@ BEGIN WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - AND bb.stickers >= FLOOR(ish.visible / ish.packing) WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci AND NOT ish.isSplit GROUP BY ish.id; From 849989afa87c5a80dcd025dc38e4dd746eca8984 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 7 Aug 2024 08:19:44 +0200 Subject: [PATCH 096/145] feat workerActivity refs #6078 --- back/methods/workerActivity/add.js | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js index bba05dafd..4592a0797 100644 --- a/back/methods/workerActivity/add.js +++ b/back/methods/workerActivity/add.js @@ -1,4 +1,3 @@ - module.exports = Self => { Self.remoteMethodCtx('add', { description: 'Add activity if the activity is different or is the same but have exceed time for break', @@ -31,23 +30,21 @@ module.exports = Self => { return await Self.rawSql(` INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) - SELECT ?, - ?, - ? - FROM workerTimeControlParams wtcp - LEFT JOIN ( - SELECT wa.workerFk, - wa.created, - wat.code - FROM workerActivity wa - LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk - WHERE wa.workerFk = ? - ORDER BY wa.created DESC - LIMIT 1 - ) sub ON TRUE - WHERE sub.workerFk IS NULL - OR sub.code <> ? - OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` + SELECT ?, ?, ? + FROM workerTimeControlParams wtcp + LEFT JOIN ( + SELECT wa.workerFk, + wa.created, + wat.code + FROM workerActivity wa + LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk + WHERE wa.workerFk = ? + ORDER BY wa.created DESC + LIMIT 1 + ) sub ON TRUE + WHERE sub.workerFk IS NULL + OR sub.code <> ? + OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` , [userId, code, model, userId, code], myOptions); }; }; From 41e44b747a7c02a00f0cd80ec8762a558d2acc7c Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Aug 2024 10:12:39 +0200 Subject: [PATCH 097/145] fix: refs #7685 hotFixAddress_updateCoordinates --- db/routines/vn/procedures/address_updateCoordinates.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/address_updateCoordinates.sql b/db/routines/vn/procedures/address_updateCoordinates.sql index bdeb886df..9d3ec963a 100644 --- a/db/routines/vn/procedures/address_updateCoordinates.sql +++ b/db/routines/vn/procedures/address_updateCoordinates.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_updateCoordinates`( vTicketFk INT, - vLongitude INT, - vLatitude INT) + vLongitude DECIMAL(11,7), + vLatitude DECIMAL(11,7)) BEGIN /** * Actualiza las coordenadas de una dirección. From b64b91e50fe9bbc3c1fb2f368d8a10a3f2f4a731 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 7 Aug 2024 10:12:54 +0200 Subject: [PATCH 098/145] feat: refs #7524 wip remote hooks --- loopback/common/models/vn-model.js | 32 ++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 20c75ca8c..56a4f4dd0 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -28,21 +28,33 @@ module.exports = function(Self) { }; }); - /* - * Intercept GET request for find - */ this.beforeRemote('find', async ctx => { - isSelect = true; - const filter = ctx.args.filter || {}; - if (filter.limit === undefined) { - filter.limit = this.app.orm.selectLimit; + const defaultLimit = this.app.orm.selectLimit; + const filter = ctx.args.filter || {limit: defaultLimit}; + + if (filter.limit > defaultLimit) { + filter.limit = defaultLimit; ctx.args.filter = filter; } }); - this.observe('loaded', async({data}) => { - if (!isSelect) return; - const length = Array.isArray(data) ? data.length : data ? 1 : 0; + this.afterRemote('find', async({result}) => { + const length = Array.isArray(result) ? result.length : result ? 1 : 0; + if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); + }); + + this.beforeRemote('filter', async ctx => { + const defaultLimit = this.app.orm.selectLimit; + const filter = ctx.args.filter || {limit: defaultLimit}; + + if (filter.limit > defaultLimit) { + filter.limit = defaultLimit; + ctx.args.filter = filter; + } + }); + + this.afterRemote('filter', async({result}) => { + const length = Array.isArray(result) ? result.length : result ? 1 : 0; if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); }); From 9b2cbcd5ccfef6c2efda734affbbe9b88a8e5f4b Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 7 Aug 2024 10:42:14 +0200 Subject: [PATCH 099/145] reviewed --- .../supplier_statementWithEntries.sql | 256 +++++++++--------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/db/routines/vn/procedures/supplier_statementWithEntries.sql b/db/routines/vn/procedures/supplier_statementWithEntries.sql index 25a104af3..df3b918a7 100644 --- a/db/routines/vn/procedures/supplier_statementWithEntries.sql +++ b/db/routines/vn/procedures/supplier_statementWithEntries.sql @@ -1,5 +1,4 @@ DELIMITER $$ -$$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE vn.supplier_statementWithEntries( vSupplierFk INT, vCurrencyFk INT, @@ -20,9 +19,15 @@ BEGIN * @param vHasEntries Indicates if future entries must be shown * @return tmp.supplierStatement */ + DECLARE vBalanceStartingDate DATETIME; + SET @euroBalance:= 0; SET @currencyBalance:= 0; + SELECT balanceStartingDate + INTO vBalanceStartingDate + FROM invoiceInConfig; + CREATE OR REPLACE TEMPORARY TABLE tmp.supplierStatement ENGINE = MEMORY SELECT *, @@ -35,132 +40,127 @@ BEGIN IFNULL(invoiceCurrency, 0), 2 ) currencyBalance FROM ( - SELECT * FROM - ( - SELECT NULL bankFk, - ii.companyFk, - ii.serial, - ii.id, - CASE - WHEN vOrderBy = 'issued' THEN ii.issued - WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried - WHEN vOrderBy = 'booked' THEN ii.booked - WHEN vOrderBy = 'dueDate' THEN iid.dueDated - END dated, - CONCAT('S/Fra ', ii.supplierRef) sref, - IF(ii.currencyFk > 1, - ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), - NULL - ) changeValue, - CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, - CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, - NULL paymentEuros, - NULL paymentCurrency, - ii.currencyFk, - ii.isBooked, - c.code, - 'invoiceIn' statementType - FROM invoiceIn ii - JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id - JOIN currency c ON c.id = ii.currencyFk - JOIN invoiceInConfig iic - WHERE ii.issued >= iic.balanceStartingDate - AND ii.supplierFk = vSupplierFk - AND vCurrencyFk IN (ii.currencyFk, 0) - AND vCompanyFk IN (ii.companyFk, 0) - AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) - GROUP BY iid.id - UNION ALL - SELECT p.bankFk, - p.companyFk, - NULL, - p.id, - CASE - WHEN vOrderBy = 'issued' THEN p.received - WHEN vOrderBy = 'bookEntried' THEN p.received - WHEN vOrderBy = 'booked' THEN p.received - WHEN vOrderBy = 'dueDate' THEN p.dueDated - END, - CONCAT(IFNULL(pm.name, ''), - IF(pn.concept <> '', - CONCAT(' : ', pn.concept), - '') - ), - IF(p.currencyFk > 1, p.divisa / p.amount, NULL), - NULL, - NULL, - p.amount, - p.divisa, - p.currencyFk, - p.isConciliated, - c.code, - 'payment' - FROM payment p - LEFT JOIN currency c ON c.id = p.currencyFk - LEFT JOIN accounting a ON a.id = p.bankFk - LEFT JOIN payMethod pm ON pm.id = p.payMethodFk - LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id - JOIN invoiceInConfig iic - WHERE p.received >= iic.balanceStartingDate - AND p.supplierFk = vSupplierFk - AND vCurrencyFk IN (p.currencyFk, 0) - AND vCompanyFk IN (p.companyFk, 0) - AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) - UNION ALL - SELECT NULL, - companyFk, - NULL, - se.id, - CASE - WHEN vOrderBy = 'issued' THEN se.dated - WHEN vOrderBy = 'bookEntried' THEN se.dated - WHEN vOrderBy = 'booked' THEN se.dated - WHEN vOrderBy = 'dueDate' THEN se.dueDated - END, - se.description, - 1, - amount, - NULL, - NULL, - NULL, - currencyFk, - isConciliated, - c.`code`, - 'expense' - FROM supplierExpense se - JOIN currency c ON c.id = se.currencyFk - WHERE se.supplierFk = vSupplierFk - AND vCurrencyFk IN (se.currencyFk,0) - AND vCompanyFk IN (se.companyFk,0) - AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) - UNION ALL - SELECT NULL bankFk, - e.companyFk, - 'E' serial, - e.invoiceNumber id, - tr.landed dated, - CONCAT('Ent. ',e.id) sref, - 1 / ((e.commission/100)+1) changeValue, - e.invoiceAmount * (1 + (e.commission/100)), - e.invoiceAmount, - NULL, - NULL, - e.currencyFk, - FALSE isBooked, - c.code, - 'order' - FROM vn.entry e - JOIN travel tr ON tr.id = e.travelFk - JOIN currency c ON c.id = e.currencyFk - WHERE e.supplierFk = vSupplierFk - AND tr.landed >= CURDATE() - AND e.invoiceInFk IS NULL - AND vHasEntries - ) sub - ORDER BY (dated IS NULL AND NOT isBooked), - dated, - IF(vOrderBy = 'dueDate', id, NULL) - LIMIT 10000000000000000000 + SELECT NULL bankFk, + ii.companyFk, + ii.serial, + ii.id, + CASE + WHEN vOrderBy = 'issued' THEN ii.issued + WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried + WHEN vOrderBy = 'booked' THEN ii.booked + WHEN vOrderBy = 'dueDate' THEN iid.dueDated + END dated, + CONCAT('S/Fra ', ii.supplierRef) sref, + IF(ii.currencyFk > 1, + ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), + NULL + ) changeValue, + CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, + CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, + NULL paymentEuros, + NULL paymentCurrency, + ii.currencyFk, + ii.isBooked, + c.code, + 'invoiceIn' statementType + FROM invoiceIn ii + JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id + JOIN currency c ON c.id = ii.currencyFk + WHERE ii.issued >= vBalanceStartingDate + AND ii.supplierFk = vSupplierFk + AND vCurrencyFk IN (ii.currencyFk, 0) + AND vCompanyFk IN (ii.companyFk, 0) + AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) + GROUP BY iid.id + UNION ALL + SELECT p.bankFk, + p.companyFk, + NULL, + p.id, + CASE + WHEN vOrderBy = 'issued' THEN p.received + WHEN vOrderBy = 'bookEntried' THEN p.received + WHEN vOrderBy = 'booked' THEN p.received + WHEN vOrderBy = 'dueDate' THEN p.dueDated + END, + CONCAT(IFNULL(pm.name, ''), + IF(pn.concept <> '', + CONCAT(' : ', pn.concept), + '') + ), + IF(p.currencyFk > 1, p.divisa / p.amount, NULL), + NULL, + NULL, + p.amount, + p.divisa, + p.currencyFk, + p.isConciliated, + c.code, + 'payment' + FROM payment p + LEFT JOIN currency c ON c.id = p.currencyFk + LEFT JOIN accounting a ON a.id = p.bankFk + LEFT JOIN payMethod pm ON pm.id = p.payMethodFk + LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id + WHERE p.received >= vBalanceStartingDate + AND p.supplierFk = vSupplierFk + AND vCurrencyFk IN (p.currencyFk, 0) + AND vCompanyFk IN (p.companyFk, 0) + AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL, + companyFk, + NULL, + se.id, + CASE + WHEN vOrderBy = 'issued' THEN se.dated + WHEN vOrderBy = 'bookEntried' THEN se.dated + WHEN vOrderBy = 'booked' THEN se.dated + WHEN vOrderBy = 'dueDate' THEN se.dueDated + END, + se.description, + 1, + amount, + NULL, + NULL, + NULL, + currencyFk, + isConciliated, + c.`code`, + 'expense' + FROM supplierExpense se + JOIN currency c ON c.id = se.currencyFk + WHERE se.supplierFk = vSupplierFk + AND vCurrencyFk IN (se.currencyFk,0) + AND vCompanyFk IN (se.companyFk,0) + AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) + UNION ALL + SELECT NULL bankFk, + e.companyFk, + 'E' serial, + e.invoiceNumber id, + tr.landed dated, + CONCAT('Ent. ',e.id) sref, + 1 / ((e.commission/100)+1) changeValue, + e.invoiceAmount * (1 + (e.commission/100)), + e.invoiceAmount, + NULL, + NULL, + e.currencyFk, + FALSE isBooked, + c.code, + 'order' + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + JOIN currency c ON c.id = e.currencyFk + WHERE e.supplierFk = vSupplierFk + AND tr.landed >= CURDATE() + AND e.invoiceInFk IS NULL + AND vHasEntries + ORDER BY (dated IS NULL AND NOT isBooked), + dated, + IF(vOrderBy = 'dueDate', id, NULL) + LIMIT 10000000000000000000 ) t; -END;$$ +END$$ DELIMITER ; From 22c3a632e2fd82560cb03ac318523ae26f6b8bf9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 7 Aug 2024 10:48:12 +0200 Subject: [PATCH 100/145] feat workerActivity refs #6078 --- back/methods/workerActivity/specs/add.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js index 67a85cb7d..352d67723 100644 --- a/back/methods/workerActivity/specs/add.spec.js +++ b/back/methods/workerActivity/specs/add.spec.js @@ -13,7 +13,7 @@ describe('workerActivity insert()', () => { {'code': 'STOP', 'description': 'STOP'}, options ); - result = await models.WorkerActivity.add(ctx, 'STOP', 'APP', options); + await models.WorkerActivity.add(ctx, 'STOP', 'APP', options); count = await models.WorkerActivity.count( {'workerFK': 1106}, options From c768fa113ed89c741e55f3384ac662bfae3a1b8f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Aug 2024 08:20:26 +0200 Subject: [PATCH 101/145] test: fix ticket redirect to lilium --- modules/ticket/front/sale/index.spec.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 8200d6b89..931776619 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -295,20 +295,26 @@ describe('Ticket', () => { describe('onCreateClaimAccepted()', () => { it('should perform a query and call window open', () => { jest.spyOn(controller, 'resetChanges').mockReturnThis(); - jest.spyOn(controller.$state, 'go').mockReturnThis(); + jest.spyOn(controller.vnApp, 'getUrl').mockReturnThis(); + Object.defineProperty(window, 'location', { + value: { + href: () => {} + }, + }); + jest.spyOn(controller.window.location, 'href'); const newEmptySale = {quantity: 10}; controller.sales.push(newEmptySale); const firstSale = controller.sales[0]; + const claimId = 1; firstSale.checked = true; const expectedParams = {ticketId: 1, sales: [firstSale]}; - $httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: 1}); + $httpBackend.expect('POST', `Claims/createFromSales`, expectedParams).respond(200, {id: claimId}); controller.onCreateClaimAccepted(); $httpBackend.flush(); expect(controller.resetChanges).toHaveBeenCalledWith(); - expect(controller.$state.go).toHaveBeenCalledWith('claim.card.basicData', {id: 1}); }); }); From 715439ae386c22afd513eb6e26f05e1b576ccb07 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Aug 2024 08:23:17 +0200 Subject: [PATCH 102/145] test: fix claim descriptor redirect to lilium --- modules/claim/front/descriptor/index.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index e6785d3d8..03710b479 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -53,14 +53,12 @@ describe('Item Component vnClaimDescriptor', () => { describe('deleteClaim()', () => { it('should perform a query and call showSuccess if the response is accept', () => { jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$state, 'go'); $httpBackend.expectDELETE(`Claims/${claim.id}`).respond(); controller.deleteClaim(); $httpBackend.flush(); expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$state.go).toHaveBeenCalledWith('claim.index'); }); }); }); From 41942783aa33b8bd3de5e15be87dfed49262948e Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 8 Aug 2024 08:27:50 +0200 Subject: [PATCH 103/145] dropOldProc --- db/versions/11180-navyGerbera/01-dropProc.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11180-navyGerbera/01-dropProc.sql diff --git a/db/versions/11180-navyGerbera/01-dropProc.sql b/db/versions/11180-navyGerbera/01-dropProc.sql new file mode 100644 index 000000000..9b9e37700 --- /dev/null +++ b/db/versions/11180-navyGerbera/01-dropProc.sql @@ -0,0 +1 @@ +DROP PROCEDURE IF EXISTS vn.supplier_statement; \ No newline at end of file From 4fb82dc9448b704af27c454841be1c13f136cca5 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Aug 2024 09:05:08 +0200 Subject: [PATCH 104/145] test: fix ticket sale e2e --- .../05-ticket/01-sale/02_edit_sale.spec.js | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js index e0f32fc3a..d9689e31a 100644 --- a/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js +++ b/e2e/paths/05-ticket/01-sale/02_edit_sale.spec.js @@ -19,7 +19,9 @@ describe('Ticket Edit sale path', () => { it(`should click on the first sale claim icon to navigate over there`, async() => { await page.waitToClick(selectors.ticketSales.firstSaleClaimIcon); - await page.waitForState('claim.card.basicData'); + await page.waitForNavigation(); + await page.goBack(); + await page.goBack(); }); it('should navigate to the tickets index', async() => { @@ -243,29 +245,13 @@ describe('Ticket Edit sale path', () => { await page.waitToClick(selectors.ticketSales.moreMenu); await page.waitToClick(selectors.ticketSales.moreMenuCreateClaim); await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForState('claim.card.basicData'); - }); - - it('should click on the Claims button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.claimsButton); - await page.waitForState('claim.index'); - }); - - it('should search for the claim with id 4', async() => { - await page.accessToSearchResult('4'); - await page.waitForState('claim.card.summary'); - }); - - it('should click the Tickets button of the top bar menu', async() => { - await page.waitToClick(selectors.globalItems.applicationsMenuButton); - await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); - await page.waitToClick(selectors.globalItems.ticketsButton); - await page.waitForState('ticket.index'); + await page.waitForNavigation(); }); it('should search for a ticket then access to the sales section', async() => { + await page.goBack(); + await page.goBack(); + await page.loginAndModule('salesPerson', 'ticket'); await page.accessToSearchResult('16'); await page.accessToSection('ticket.card.sale'); }); From 8580fa084903f1b3210010b0deb2512388f7d84f Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Aug 2024 10:07:03 +0200 Subject: [PATCH 105/145] hotFix(sendTwoFactor): fix code digits --- back/methods/vn-user/sign-in.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/back/methods/vn-user/sign-in.js b/back/methods/vn-user/sign-in.js index 782046641..775970d55 100644 --- a/back/methods/vn-user/sign-in.js +++ b/back/methods/vn-user/sign-in.js @@ -67,7 +67,9 @@ module.exports = Self => { if (vnUser.twoFactor === 'email') { const $ = Self.app.models; - const code = String(Math.floor(Math.random() * 999999)); + const min = 100000; + const max = 999999; + const code = String(Math.floor(Math.random() * (max - min + 1)) + min); const maxTTL = ((60 * 1000) * 5); // 5 min await $.AuthCode.upsertWithWhere({userFk: vnUser.id}, { userFk: vnUser.id, From c8f1b7c5ff57391c927984c83e1d6eb7e98343ab Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Aug 2024 11:51:46 +0200 Subject: [PATCH 106/145] hotFix(validateCode): username comparation --- back/methods/vn-user/validate-auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/validate-auth.js b/back/methods/vn-user/validate-auth.js index beab43417..8fb8b4923 100644 --- a/back/methods/vn-user/validate-auth.js +++ b/back/methods/vn-user/validate-auth.js @@ -58,7 +58,7 @@ module.exports = Self => { fields: ['name', 'twoFactor'] }, myOptions); - if (user.name !== username) + if (user.name.toLowerCase() !== username.toLowerCase()) throw new UserError('Authentication failed'); await authCode.destroy(myOptions); From afc56151401f8a020a977ee612084bb4f93a8412 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 8 Aug 2024 12:14:44 +0200 Subject: [PATCH 107/145] #6900 fix: #6900 rectificative filter --- modules/invoiceIn/back/methods/invoice-in/filter.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index d72d7fc63..a8ffb5f97 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -154,9 +154,10 @@ module.exports = Self => { case 'awbCode': return {'sub.code': value}; case 'correctingFk': + if (!correcteds.length && !args.correctingFk) return; return args.correctingFk - ? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}} - : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; + ? {['ii.id']: {inq: correcteds.map(x => x.correctingFk)}} + : {['ii.id']: {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; case 'supplierActivityFk': From 1ccfd8731fb8cb31ab0f7a4c32692e5f1f642aa4 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 8 Aug 2024 12:17:56 +0200 Subject: [PATCH 108/145] #6900 feat: empty commit --- modules/invoiceIn/back/methods/invoice-in/filter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index a8ffb5f97..05e038a61 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -119,6 +119,7 @@ module.exports = Self => { } let correctings; + let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ From b4ea7819f8da46f9586095994b2c9779e977be16 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 8 Aug 2024 12:18:42 +0200 Subject: [PATCH 109/145] #6900 feat: clear empty --- modules/invoiceIn/back/methods/invoice-in/filter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 05e038a61..a8ffb5f97 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -119,7 +119,6 @@ module.exports = Self => { } let correctings; - let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ From 4af881a8d9473f99a7e191b1193941265fcc6aa4 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 8 Aug 2024 12:35:11 +0200 Subject: [PATCH 110/145] #6900 feat: clear empty --- modules/invoiceIn/back/methods/invoice-in/filter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index a8ffb5f97..05e038a61 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -119,6 +119,7 @@ module.exports = Self => { } let correctings; + let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ From 660ebfbe15078ef630a29bf032f2e66d41409da8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 8 Aug 2024 12:36:06 +0200 Subject: [PATCH 111/145] #6900 feat: empty commit --- modules/invoiceIn/back/methods/invoice-in/filter.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 05e038a61..a8ffb5f97 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -119,7 +119,6 @@ module.exports = Self => { } let correctings; - let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ From 853a57ec63ffb20a7040bc7b36d4143cc7f3fc43 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 8 Aug 2024 12:37:29 +0200 Subject: [PATCH 112/145] #6900 fix: empty commit --- modules/invoiceIn/back/methods/invoice-in/filter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index a8ffb5f97..05e038a61 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -119,6 +119,7 @@ module.exports = Self => { } let correctings; + let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ From 62cee3a07ab185038b5be7131080a8d0d3b6693d Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 8 Aug 2024 12:49:36 +0200 Subject: [PATCH 113/145] fix: refs #6130 commit lint --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e7040f36..887f20522 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,10 @@ "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", - "watch:db": "node ./db/dbWatcher.js" + "watch:db": "node ./db/dbWatcher.js", + "commitlint": "commitlint --edit", + "prepare": "husky install", + "addReferenceTag": "node .husky/addReferenceTag.js" }, "jest": { "projects": [ From 1c75c429cc721ade14867058c88a730785787403 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 8 Aug 2024 13:29:02 +0200 Subject: [PATCH 114/145] test: husky --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 887f20522..61a9cf46c 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "lint": "eslint ./ --cache --ignore-pattern .gitignore", "watch:db": "node ./db/dbWatcher.js", "commitlint": "commitlint --edit", - "prepare": "husky install", + "prepare": "npx husky install", "addReferenceTag": "node .husky/addReferenceTag.js" }, "jest": { From 98f4cb1de5505f0f35925faaec44a9419d0af6cf Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 9 Aug 2024 08:04:36 +0200 Subject: [PATCH 115/145] dropping proc --- .../vn/procedures/supplier_statement.sql | 139 ------------------ db/versions/11180-navyGerbera/01-dropProc.sql | 1 - 2 files changed, 140 deletions(-) delete mode 100644 db/routines/vn/procedures/supplier_statement.sql delete mode 100644 db/versions/11180-navyGerbera/01-dropProc.sql diff --git a/db/routines/vn/procedures/supplier_statement.sql b/db/routines/vn/procedures/supplier_statement.sql deleted file mode 100644 index a03a7770c..000000000 --- a/db/routines/vn/procedures/supplier_statement.sql +++ /dev/null @@ -1,139 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplier_statement`( - vSupplierFk INT, - vCurrencyFk INT, - vCompanyFk INT, - vOrderBy VARCHAR(15), - vIsConciliated BOOL -) -BEGIN -/** - * Crea un estado de cuenta de proveedores calculando - * los saldos en euros y en la moneda especificada. - * - * @param vSupplierFk Id del proveedor - * @param vCurrencyFk Id de la moneda - * @param vCompanyFk Id de la empresa - * @param vOrderBy Criterio de ordenación - * @param vIsConciliated Indica si está conciliado o no - * @return tmp.supplierStatement - */ - SET @euroBalance:= 0; - SET @currencyBalance:= 0; - - CREATE OR REPLACE TEMPORARY TABLE tmp.supplierStatement - ENGINE = MEMORY - SELECT *, - @euroBalance:= ROUND( - @euroBalance + IFNULL(paymentEuros, 0) - - IFNULL(invoiceEuros, 0), 2 - ) euroBalance, - @currencyBalance:= ROUND( - @currencyBalance + IFNULL(paymentCurrency, 0) - - IFNULL(invoiceCurrency, 0), 2 - ) currencyBalance - FROM ( - SELECT * FROM - ( - SELECT NULL bankFk, - ii.companyFk, - ii.serial, - ii.id, - CASE - WHEN vOrderBy = 'issued' THEN ii.issued - WHEN vOrderBy = 'bookEntried' THEN ii.bookEntried - WHEN vOrderBy = 'booked' THEN ii.booked - WHEN vOrderBy = 'dueDate' THEN iid.dueDated - END dated, - CONCAT('S/Fra ', ii.supplierRef) sref, - IF(ii.currencyFk > 1, - ROUND(SUM(iid.foreignValue) / SUM(iid.amount), 3), - NULL - ) changeValue, - CAST(SUM(iid.amount) AS DECIMAL(10,2)) invoiceEuros, - CAST(SUM(iid.foreignValue) AS DECIMAL(10,2)) invoiceCurrency, - NULL paymentEuros, - NULL paymentCurrency, - ii.currencyFk, - ii.isBooked, - c.code, - 'invoiceIn' statementType - FROM invoiceIn ii - JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id - JOIN currency c ON c.id = ii.currencyFk - WHERE ii.issued > '2014-12-31' - AND ii.supplierFk = vSupplierFk - AND vCurrencyFk IN (ii.currencyFk, 0) - AND vCompanyFk IN (ii.companyFk, 0) - AND (vIsConciliated = ii.isBooked OR NOT vIsConciliated) - GROUP BY iid.id - UNION ALL - SELECT p.bankFk, - p.companyFk, - NULL, - p.id, - CASE - WHEN vOrderBy = 'issued' THEN p.received - WHEN vOrderBy = 'bookEntried' THEN p.received - WHEN vOrderBy = 'booked' THEN p.received - WHEN vOrderBy = 'dueDate' THEN p.dueDated - END, - CONCAT(IFNULL(pm.name, ''), - IF(pn.concept <> '', - CONCAT(' : ', pn.concept), - '') - ), - IF(p.currencyFk > 1, p.divisa / p.amount, NULL), - NULL, - NULL, - p.amount, - p.divisa, - p.currencyFk, - p.isConciliated, - c.code, - 'payment' - FROM payment p - LEFT JOIN currency c ON c.id = p.currencyFk - LEFT JOIN accounting a ON a.id = p.bankFk - LEFT JOIN payMethod pm ON pm.id = p.payMethodFk - LEFT JOIN promissoryNote pn ON pn.paymentFk = p.id - WHERE p.received > '2014-12-31' - AND p.supplierFk = vSupplierFk - AND vCurrencyFk IN (p.currencyFk, 0) - AND vCompanyFk IN (p.companyFk, 0) - AND (vIsConciliated = p.isConciliated OR NOT vIsConciliated) - UNION ALL - SELECT NULL, - companyFk, - NULL, - se.id, - CASE - WHEN vOrderBy = 'issued' THEN se.dated - WHEN vOrderBy = 'bookEntried' THEN se.dated - WHEN vOrderBy = 'booked' THEN se.dated - WHEN vOrderBy = 'dueDate' THEN se.dueDated - END, - se.description, - 1, - amount, - NULL, - NULL, - NULL, - currencyFk, - isConciliated, - c.`code`, - 'expense' - FROM supplierExpense se - JOIN currency c ON c.id = se.currencyFk - WHERE se.supplierFk = vSupplierFk - AND vCurrencyFk IN (se.currencyFk,0) - AND vCompanyFk IN (se.companyFk,0) - AND (vIsConciliated = se.isConciliated OR NOT vIsConciliated) - ) sub - ORDER BY (dated IS NULL AND NOT isBooked), - dated, - IF(vOrderBy = 'dueDate', id, NULL) - LIMIT 10000000000000000000 - ) t; -END$$ -DELIMITER ; diff --git a/db/versions/11180-navyGerbera/01-dropProc.sql b/db/versions/11180-navyGerbera/01-dropProc.sql deleted file mode 100644 index 9b9e37700..000000000 --- a/db/versions/11180-navyGerbera/01-dropProc.sql +++ /dev/null @@ -1 +0,0 @@ -DROP PROCEDURE IF EXISTS vn.supplier_statement; \ No newline at end of file From cf13aa917ef8198a491633bd802b99185d9ed524 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 9 Aug 2024 08:18:30 +0200 Subject: [PATCH 116/145] feat: refs #7126 saleQuantity to saleWasteQuantity --- db/dump/fixtures.before.sql | 2 +- db/routines/bs/procedures/waste_addSales.sql | 14 +++++++------- db/versions/11182-redAralia/00-firstScript.sql | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 db/versions/11182-redAralia/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 60c96abb4..6563292dd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1516,7 +1516,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''); -INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`) +INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWasteQuantity`, `saleInternalWaste`, `saleExternalWaste`) VALUES ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'), ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69'), diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 3e189d2e6..b855e8b0d 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`() BEGIN - DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(CURDATE()) DAY; + DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY; CALL cache.last_buy_refresh(FALSE); @@ -12,16 +12,16 @@ BEGIN it.workerFk, it.id, s.itemFk, - SUM(s.quantity), - SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) `value`, - SUM ( + SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity), + SUM(IF(aw.`type`, s.quantity, 0)), + SUM( IF( aw.`type` = 'internal', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, 0 ) - ) internalWaste, - SUM ( + ), + SUM( IF( aw.`type` = 'external', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, @@ -30,7 +30,7 @@ BEGIN 0 ) ) - ) externalWaste + ) FROM vn.sale s JOIN vn.item i ON i.id = s.itemFk JOIN vn.itemType it ON it.id = i.typeFk diff --git a/db/versions/11182-redAralia/00-firstScript.sql b/db/versions/11182-redAralia/00-firstScript.sql new file mode 100644 index 000000000..72c06de65 --- /dev/null +++ b/db/versions/11182-redAralia/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE bs.waste CHANGE saleQuantity saleWasteQuantity decimal(10,2) DEFAULT NULL NULL AFTER saleTotal; +ALTER TABLE bs.waste MODIFY COLUMN saleTotal decimal(10,2) DEFAULT NULL NULL COMMENT 'Coste'; From 8ab049be0d741a9cac1c4ced0120ea1249c27a9d Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 9 Aug 2024 11:48:22 +0200 Subject: [PATCH 117/145] chore: refs #6900 beautify code --- modules/invoiceIn/back/methods/invoice-in/filter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 05e038a61..8a884e211 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -157,8 +157,8 @@ module.exports = Self => { case 'correctingFk': if (!correcteds.length && !args.correctingFk) return; return args.correctingFk - ? {['ii.id']: {inq: correcteds.map(x => x.correctingFk)}} - : {['ii.id']: {nin: correcteds.map(x => x.correctingFk)}}; + ? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}} + : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; case 'supplierActivityFk': From af65ef25365de75fd91ab3c815e64f220218b2c2 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 9 Aug 2024 12:54:33 +0200 Subject: [PATCH 118/145] fix(orders_filter): add sourceApp accepts --- modules/order/back/methods/order/filter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/order/back/methods/order/filter.js b/modules/order/back/methods/order/filter.js index 592ed11e6..758e8065c 100644 --- a/modules/order/back/methods/order/filter.js +++ b/modules/order/back/methods/order/filter.js @@ -59,6 +59,10 @@ module.exports = Self => { arg: 'showEmpty', type: 'boolean', description: 'Show empty orders' + }, { + arg: 'sourceApp', + type: 'string', + description: 'Application' } ], returns: { From 38dbe6e966953fa5dac469b377ddca2a5edc04f4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 9 Aug 2024 13:53:28 +0200 Subject: [PATCH 119/145] fix: #7126 waste_addSales --- db/routines/bs/procedures/waste_addSales.sql | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index b855e8b0d..20eee5d49 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -25,10 +25,7 @@ BEGIN IF( aw.`type` = 'external', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, - IF(c.code = 'manaClaim', - sc.value * s.quantity, - 0 - ) + 0 ) ) FROM vn.sale s @@ -41,10 +38,8 @@ BEGIN JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = w.id JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id - LEFT JOIN vn.component c ON c.id = sc.componentFk WHERE t.shipped BETWEEN vDateFrom AND vDateTo AND w.isManaged - GROUP BY it.id, i.id; + GROUP BY i.id; END$$ DELIMITER ; From 00845c0534afc25f1a4a3fa1032b76ff6c591b7d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 12 Aug 2024 08:03:49 +0200 Subject: [PATCH 120/145] refactor: refs #7646 #7646 Deleted scannable* variables productionConfig --- db/versions/11165-grayAralia/00-firstScript.sql | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/db/versions/11165-grayAralia/00-firstScript.sql b/db/versions/11165-grayAralia/00-firstScript.sql index 2e0e2a329..652b2343a 100644 --- a/db/versions/11165-grayAralia/00-firstScript.sql +++ b/db/versions/11165-grayAralia/00-firstScript.sql @@ -1,7 +1,3 @@ --- Place your SQL code here -ALTER TABLE IF EXISTS vn.productionConfig -CHANGE COLUMN IF EXISTS scannableCodeType scannableCodeType__ enum('qr','barcode') - CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'barcode' NOT NULL, -CHANGE COLUMN IF EXISTS scannablePreviusCodeType scannablePreviusCodeType__ enum('qr','barcode') - CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'barcode' NOT NULL; - +ALTER TABLE vn.productionConfig + DROP COLUMN scannableCodeType, + DROP COLUMN scannablePreviusCodeType; From c4e82022611fecada029cfa8614e4c4eceb0f8bf Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 12 Aug 2024 08:53:24 +0200 Subject: [PATCH 121/145] feat: refs #7774 #7774 Changes ticket_cloneWeekly --- .../vn/procedures/ticket_cloneWeekly.sql | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index f689f2600..be19a40bf 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -17,35 +17,33 @@ BEGIN DECLARE vYear INT; DECLARE vSalesPersonFK INT; DECLARE vItemPicker INT; - DECLARE vTicketfailed INT; + DECLARE vEmail VARCHAR(150); + DECLARE vIsDuplicateMail BOOL; + DECLARE vSubject VARCHAR(150); + DECLARE vMessage TEXT; - DECLARE rsTicket CURSOR FOR - SELECT tt.ticketFk, - t.clientFk, - t.warehouseFk, - t.companyFk, - t.addressFk, - tt.agencyModeFk, - ti.dated - FROM ticketWeekly tt - JOIN ticket t ON tt.ticketFk = t.id - JOIN tmp.time ti - WHERE WEEKDAY(ti.dated) = tt.weekDay; + DECLARE vTickets CURSOR FOR + SELECT tt.ticketFk, + t.clientFk, + t.warehouseFk, + t.companyFk, + t.addressFk, + tt.agencyModeFk, + ti.dated + FROM ticketWeekly tt + JOIN ticket t ON tt.ticketFk = t.id + JOIN tmp.time ti + WHERE WEEKDAY(ti.dated) = tt.weekDay; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; - - CALL `util`.`time_generate`(vDateFrom,vDateTo); - - OPEN rsTicket; - myLoop: LOOP - BEGIN - DECLARE vSalesPersonEmail VARCHAR(150); - DECLARE vIsDuplicateMail BOOL; - DECLARE vSubject VARCHAR(150); - DECLARE vMessage TEXT; + + CALL `util`.`time_generate`(vDateFrom, vDateTo); + + OPEN vTickets; + l: LOOP SET vIsDone = FALSE; - FETCH rsTicket INTO + FETCH vTickets INTO vTicketFk, vClientFk, vWarehouseFk, @@ -55,10 +53,10 @@ BEGIN vShipment; IF vIsDone THEN - LEAVE myLoop; + LEAVE l; END IF; - -- busca si el ticket ya ha sido clonado + -- Busca si el ticket ya ha sido clonado IF EXISTS (SELECT TRUE FROM ticket tOrig JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id @@ -68,7 +66,7 @@ BEGIN AND tClon.isDeleted = FALSE AND DATE(tClon.shipped) = vShipment) THEN - ITERATE myLoop; + ITERATE l; END IF; IF vAgencyModeFk IS NULL THEN @@ -184,9 +182,9 @@ BEGIN ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - IF (vLanding IS NULL) THEN + IF vLanding IS NULL THEN - SELECT IFNULL(d.notificationEmail,e.email) INTO vSalesPersonEmail + SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail FROM client c JOIN worker w ON w.id = c.salesPersonFk JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk @@ -203,21 +201,21 @@ BEGIN SELECT COUNT(*) INTO vIsDuplicateMail FROM mail - WHERE receiver = vSalesPersonEmail + WHERE receiver = vEmail AND subject = vSubject; IF NOT vIsDuplicateMail THEN - CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); + CALL mail_insert(vEmail, NULL, vSubject, vMessage); END IF; CALL ticket_setState(vNewTicket, 'FIXING'); ELSE CALL ticketCalculateClon(vNewTicket, vTicketFk); END IF; - - END; END LOOP; - CLOSE rsTicket; + CLOSE vTickets; - DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded; + DROP TEMPORARY TABLE IF EXISTS + tmp.time, + tmp.zoneGetLanded; END$$ DELIMITER ; From 3cf2cec94604a4e6e422db029bd58e0576962be3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 12 Aug 2024 09:02:38 +0200 Subject: [PATCH 122/145] feat: refs #7774 #7774 Changes ticket_cloneWeekly --- .../vn/procedures/ticket_cloneWeekly.sql | 52 ++++++++----------- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index be19a40bf..d5c9939df 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneWeekly` vDateTo DATE ) BEGIN - DECLARE vIsDone BOOL; DECLARE vLanding DATE; DECLARE vShipment DATE; DECLARE vWarehouseFk INT; @@ -15,12 +14,15 @@ BEGIN DECLARE vAgencyModeFk INT; DECLARE vNewTicket INT; DECLARE vYear INT; - DECLARE vSalesPersonFK INT; - DECLARE vItemPicker INT; - DECLARE vEmail VARCHAR(150); + DECLARE vObservationSalesPersonFk INT + DEFAULT (SELECT id FROM observationType WHERE code = 'salesPerson'); + DECLARE vObservationItemPickerFk INT + DEFAULT (SELECT id FROM observationType WHERE code = 'itemPicker'); + DECLARE vEmail VARCHAR(255); DECLARE vIsDuplicateMail BOOL; - DECLARE vSubject VARCHAR(150); + DECLARE vSubject VARCHAR(100); DECLARE vMessage TEXT; + DECLARE vDone BOOL; DECLARE vTickets CURSOR FOR SELECT tt.ticketFk, @@ -35,14 +37,13 @@ BEGIN JOIN tmp.time ti WHERE WEEKDAY(ti.dated) = tt.weekDay; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; CALL `util`.`time_generate`(vDateFrom, vDateTo); OPEN vTickets; l: LOOP - - SET vIsDone = FALSE; + SET vDone = FALSE; FETCH vTickets INTO vTicketFk, vClientFk, @@ -52,7 +53,7 @@ BEGIN vAgencyModeFk, vShipment; - IF vIsDone THEN + IF vDone THEN LEAVE l; END IF; @@ -106,15 +107,15 @@ BEGIN priceFixed, isPriceFixed) SELECT vNewTicket, - saleOrig.itemFk, - saleOrig.concept, - saleOrig.quantity, - saleOrig.price, - saleOrig.discount, - saleOrig.priceFixed, - saleOrig.isPriceFixed - FROM sale saleOrig - WHERE saleOrig.ticketFk = vTicketFk; + itemFk, + concept, + quantity, + price, + discount, + priceFixed, + isPriceFixed + FROM sale + WHERE ticketFk = vTicketFk; INSERT IGNORE INTO saleCloned(saleOriginalFk, saleClonedFk) SELECT saleOriginal.id, saleClon.id @@ -151,15 +152,7 @@ BEGIN attenderFk, vNewTicket FROM ticketRequest - WHERE ticketFk =vTicketFk; - - SELECT id INTO vSalesPersonFK - FROM observationType - WHERE code = 'salesPerson'; - - SELECT id INTO vItemPicker - FROM observationType - WHERE code = 'itemPicker'; + WHERE ticketFk = vTicketFk; INSERT INTO ticketObservation( ticketFk, @@ -167,7 +160,7 @@ BEGIN description) VALUES( vNewTicket, - vSalesPersonFK, + vObservationSalesPersonFk, CONCAT('turno desde ticket: ',vTicketFk)) ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); @@ -177,13 +170,12 @@ BEGIN description) VALUES( vNewTicket, - vItemPicker, + vObservationItemPickerFk, 'ATENCION: Contiene lineas de TURNO') ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); IF vLanding IS NULL THEN - SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail FROM client c JOIN worker w ON w.id = c.salesPersonFk From 931c13d8ab1fddfd517568b3f5a456f8de6527a0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 12 Aug 2024 09:06:24 +0200 Subject: [PATCH 123/145] feat: refs #7774 #7774 Changes ticket_cloneWeekly --- db/routines/vn/procedures/ticket_cloneWeekly.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/ticket_cloneWeekly.sql b/db/routines/vn/procedures/ticket_cloneWeekly.sql index d5c9939df..e13e7e677 100644 --- a/db/routines/vn/procedures/ticket_cloneWeekly.sql +++ b/db/routines/vn/procedures/ticket_cloneWeekly.sql @@ -178,10 +178,9 @@ BEGIN IF vLanding IS NULL THEN SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail FROM client c - JOIN worker w ON w.id = c.salesPersonFk - JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk - JOIN department d ON d.id = wd.departmentFk JOIN account.emailUser e ON e.userFk = c.salesPersonFk + LEFT JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk + LEFT JOIN department d ON d.id = wd.departmentFk WHERE c.id = vClientFk; SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', From 1602c12200ac71e132aebf1c2c9e7b97b9ac06b1 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 12 Aug 2024 09:13:30 +0200 Subject: [PATCH 124/145] fix: refs #7283 sql --- db/routines/vn/procedures/item_getBalance.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 9c609b4c6..46e4bafcc 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -190,7 +190,7 @@ BEGIN UNION ALL SELECT * FROM orders ORDER BY shipped DESC, - (inventorySupplierFk = entityId) ASC, + (inventorySupplierFk = entityId) DESC, alertLevel DESC, isTicket, `order` DESC, From 46abf2f57bafaca090d77e86ede873d40bc027c0 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 12 Aug 2024 10:27:26 +0200 Subject: [PATCH 125/145] fix(defaulter_filter): recovery subquery --- modules/client/back/methods/defaulter/filter.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 40756b236..9f19dee0a 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -83,9 +83,14 @@ module.exports = Self => { LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user uw ON uw.id = co.workerFk LEFT JOIN ( - SELECT MAX(started), clientFk, finished - FROM recovery - GROUP BY clientFk + SELECT r1.started, r1.clientFk, r1.finished + FROM recovery r1 + JOIN ( + SELECT MAX(started) AS maxStarted, clientFk + FROM recovery + GROUP BY clientFk + ) r2 ON r1.clientFk = r2.clientFk + AND r1.started = r2.maxStarted ) r ON r.clientFk = c.id LEFT JOIN workerDepartment wd ON wd.workerFk = u.id JOIN department dp ON dp.id = wd.departmentFk From 3ee9833a701b8e6c270d554b60d84eae3bec2534 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 12 Aug 2024 14:06:02 +0200 Subject: [PATCH 126/145] fix: refs #7355 remove and tests accounts --- .../01_create_and_basic_data.spec.js | 164 ------------ .../02_alias_create_and_basic_data.spec.js | 66 ----- .../03_role_create_and_basic_data.spec.js | 86 ------- e2e/paths/14-account/04_acl.spec.js | 60 ----- e2e/paths/14-account/05_connections.spec.js | 25 -- e2e/paths/14-account/06_accounts.spec.js | 37 --- e2e/paths/14-account/07_ldap.spec.js | 41 --- e2e/paths/14-account/08_samba.spec.js | 42 --- e2e/paths/14-account/09_privileges.spec.js | 112 -------- modules/account/front/accounts/index.html | 75 ------ modules/account/front/accounts/index.js | 19 -- modules/account/front/accounts/locale/es.yml | 14 - modules/account/front/acl/create/index.html | 70 ----- modules/account/front/acl/create/index.js | 33 --- modules/account/front/acl/index.js | 4 - modules/account/front/acl/index/index.html | 51 ---- modules/account/front/acl/index/index.js | 15 -- modules/account/front/acl/index/locale/es.yml | 4 - modules/account/front/acl/locale/es.yml | 4 - modules/account/front/acl/main/index.html | 20 -- modules/account/front/acl/main/index.js | 18 -- .../account/front/acl/search-panel/index.html | 39 --- .../account/front/acl/search-panel/index.js | 26 -- .../account/front/alias/basic-data/index.html | 43 ---- .../account/front/alias/basic-data/index.js | 12 - modules/account/front/alias/card/index.html | 5 - modules/account/front/alias/card/index.js | 14 - modules/account/front/alias/create/index.html | 38 --- modules/account/front/alias/create/index.js | 15 -- .../account/front/alias/descriptor/index.html | 27 -- .../account/front/alias/descriptor/index.js | 26 -- .../front/alias/descriptor/locale/es.yml | 2 - modules/account/front/alias/index.js | 9 - modules/account/front/alias/index/index.html | 39 --- modules/account/front/alias/index/index.js | 14 - .../account/front/alias/index/locale/es.yml | 2 - modules/account/front/alias/locale/es.yml | 1 - modules/account/front/alias/main/index.html | 17 -- modules/account/front/alias/main/index.js | 18 -- .../account/front/alias/summary/index.html | 16 -- modules/account/front/alias/summary/index.js | 25 -- modules/account/front/alias/users/index.html | 26 -- modules/account/front/alias/users/index.js | 31 --- .../account/front/alias/users/index.spec.js | 42 --- .../account/front/alias/users/locale/es.yml | 2 - modules/account/front/aliases/index.html | 64 ----- modules/account/front/aliases/index.js | 51 ---- modules/account/front/aliases/index.spec.js | 53 ---- modules/account/front/aliases/locale/es.yml | 3 - modules/account/front/basic-data/index.html | 51 ---- modules/account/front/basic-data/index.js | 25 -- .../account/front/basic-data/locale/es.yml | 1 - modules/account/front/card/index.html | 8 - modules/account/front/card/index.js | 32 --- modules/account/front/card/index.spec.js | 27 -- modules/account/front/card/style.scss | 10 - modules/account/front/connections/index.html | 45 ---- modules/account/front/connections/index.js | 29 --- .../account/front/connections/locale/es.yml | 5 - modules/account/front/create/index.html | 57 ---- modules/account/front/create/index.js | 20 -- .../front/descriptor-popover/index.html | 4 - .../account/front/descriptor-popover/index.js | 9 - .../__snapshots__/index.spec.js.snap | 5 - modules/account/front/descriptor/index.html | 192 -------------- modules/account/front/descriptor/index.js | 145 ----------- .../account/front/descriptor/index.spec.js | 97 ------- .../account/front/descriptor/locale/es.yml | 35 --- modules/account/front/index.js | 21 -- modules/account/front/index/index.html | 47 ---- modules/account/front/index/index.js | 14 - modules/account/front/index/locale/es.yml | 2 - modules/account/front/ldap/index.html | 66 ----- modules/account/front/ldap/index.js | 14 - modules/account/front/ldap/locale/es.yml | 8 - .../account/front/mail-forwarding/index.html | 49 ---- .../account/front/mail-forwarding/index.js | 12 - .../front/mail-forwarding/locale/es.yml | 7 - modules/account/front/main/index.html | 19 -- modules/account/front/main/index.js | 28 +- modules/account/front/main/index.spec.js | 28 -- modules/account/front/privileges/index.html | 41 --- modules/account/front/privileges/index.js | 21 -- .../account/front/privileges/locale/es.yml | 2 - modules/account/front/role-log/index.html | 1 - modules/account/front/role-log/index.js | 7 - .../account/front/role/basic-data/index.html | 40 --- .../account/front/role/basic-data/index.js | 12 - modules/account/front/role/card/index.html | 5 - modules/account/front/role/card/index.js | 14 - modules/account/front/role/card/index.spec.js | 25 -- modules/account/front/role/create/index.html | 38 --- modules/account/front/role/create/index.js | 15 -- .../account/front/role/descriptor/index.html | 27 -- .../account/front/role/descriptor/index.js | 26 -- .../front/role/descriptor/index.spec.js | 29 --- .../front/role/descriptor/locale/es.yml | 2 - modules/account/front/role/index.js | 10 - modules/account/front/role/index/index.html | 42 --- modules/account/front/role/index/index.js | 14 - .../account/front/role/index/locale/es.yml | 2 - .../account/front/role/inherited/index.html | 21 -- modules/account/front/role/inherited/index.js | 23 -- .../front/role/inherited/index.spec.js | 23 -- modules/account/front/role/locale/es.yml | 1 - modules/account/front/role/main/index.html | 18 -- modules/account/front/role/main/index.js | 24 -- .../front/role/search-panel/index.html | 21 -- .../account/front/role/search-panel/index.js | 7 - .../account/front/role/subroles/index.html | 57 ---- modules/account/front/role/subroles/index.js | 51 ---- .../account/front/role/subroles/index.spec.js | 53 ---- .../account/front/role/subroles/locale/es.yml | 4 - modules/account/front/role/summary/index.html | 20 -- modules/account/front/role/summary/index.js | 24 -- modules/account/front/roles/index.html | 21 -- modules/account/front/roles/index.js | 26 -- modules/account/front/routes.json | 243 ------------------ modules/account/front/samba/index.html | 71 ----- modules/account/front/samba/index.js | 14 - modules/account/front/samba/locale/es.yml | 9 - modules/account/front/search-panel/index.html | 31 --- modules/account/front/search-panel/index.js | 7 - modules/account/front/summary/index.html | 40 --- modules/account/front/summary/index.js | 40 --- modules/account/front/user-log/index.html | 1 - modules/account/front/user-log/index.js | 7 - 127 files changed, 3 insertions(+), 3959 deletions(-) delete mode 100644 e2e/paths/14-account/01_create_and_basic_data.spec.js delete mode 100644 e2e/paths/14-account/02_alias_create_and_basic_data.spec.js delete mode 100644 e2e/paths/14-account/03_role_create_and_basic_data.spec.js delete mode 100644 e2e/paths/14-account/04_acl.spec.js delete mode 100644 e2e/paths/14-account/05_connections.spec.js delete mode 100644 e2e/paths/14-account/06_accounts.spec.js delete mode 100644 e2e/paths/14-account/07_ldap.spec.js delete mode 100644 e2e/paths/14-account/08_samba.spec.js delete mode 100644 e2e/paths/14-account/09_privileges.spec.js delete mode 100644 modules/account/front/accounts/index.html delete mode 100644 modules/account/front/accounts/index.js delete mode 100644 modules/account/front/accounts/locale/es.yml delete mode 100644 modules/account/front/acl/create/index.html delete mode 100644 modules/account/front/acl/create/index.js delete mode 100644 modules/account/front/acl/index.js delete mode 100644 modules/account/front/acl/index/index.html delete mode 100644 modules/account/front/acl/index/index.js delete mode 100644 modules/account/front/acl/index/locale/es.yml delete mode 100644 modules/account/front/acl/locale/es.yml delete mode 100644 modules/account/front/acl/main/index.html delete mode 100644 modules/account/front/acl/main/index.js delete mode 100644 modules/account/front/acl/search-panel/index.html delete mode 100644 modules/account/front/acl/search-panel/index.js delete mode 100644 modules/account/front/alias/basic-data/index.html delete mode 100644 modules/account/front/alias/basic-data/index.js delete mode 100644 modules/account/front/alias/card/index.html delete mode 100644 modules/account/front/alias/card/index.js delete mode 100644 modules/account/front/alias/create/index.html delete mode 100644 modules/account/front/alias/create/index.js delete mode 100644 modules/account/front/alias/descriptor/index.html delete mode 100644 modules/account/front/alias/descriptor/index.js delete mode 100644 modules/account/front/alias/descriptor/locale/es.yml delete mode 100644 modules/account/front/alias/index.js delete mode 100644 modules/account/front/alias/index/index.html delete mode 100644 modules/account/front/alias/index/index.js delete mode 100644 modules/account/front/alias/index/locale/es.yml delete mode 100644 modules/account/front/alias/locale/es.yml delete mode 100644 modules/account/front/alias/main/index.html delete mode 100644 modules/account/front/alias/main/index.js delete mode 100644 modules/account/front/alias/summary/index.html delete mode 100644 modules/account/front/alias/summary/index.js delete mode 100644 modules/account/front/alias/users/index.html delete mode 100644 modules/account/front/alias/users/index.js delete mode 100644 modules/account/front/alias/users/index.spec.js delete mode 100644 modules/account/front/alias/users/locale/es.yml delete mode 100644 modules/account/front/aliases/index.html delete mode 100644 modules/account/front/aliases/index.js delete mode 100644 modules/account/front/aliases/index.spec.js delete mode 100644 modules/account/front/aliases/locale/es.yml delete mode 100644 modules/account/front/basic-data/index.html delete mode 100644 modules/account/front/basic-data/index.js delete mode 100644 modules/account/front/basic-data/locale/es.yml delete mode 100644 modules/account/front/card/index.html delete mode 100644 modules/account/front/card/index.js delete mode 100644 modules/account/front/card/index.spec.js delete mode 100644 modules/account/front/card/style.scss delete mode 100644 modules/account/front/connections/index.html delete mode 100644 modules/account/front/connections/index.js delete mode 100644 modules/account/front/connections/locale/es.yml delete mode 100644 modules/account/front/create/index.html delete mode 100644 modules/account/front/create/index.js delete mode 100644 modules/account/front/descriptor-popover/index.html delete mode 100644 modules/account/front/descriptor-popover/index.js delete mode 100644 modules/account/front/descriptor/__snapshots__/index.spec.js.snap delete mode 100644 modules/account/front/descriptor/index.html delete mode 100644 modules/account/front/descriptor/index.js delete mode 100644 modules/account/front/descriptor/index.spec.js delete mode 100644 modules/account/front/descriptor/locale/es.yml delete mode 100644 modules/account/front/index/index.html delete mode 100644 modules/account/front/index/index.js delete mode 100644 modules/account/front/index/locale/es.yml delete mode 100644 modules/account/front/ldap/index.html delete mode 100644 modules/account/front/ldap/index.js delete mode 100644 modules/account/front/ldap/locale/es.yml delete mode 100644 modules/account/front/mail-forwarding/index.html delete mode 100644 modules/account/front/mail-forwarding/index.js delete mode 100644 modules/account/front/mail-forwarding/locale/es.yml delete mode 100644 modules/account/front/main/index.spec.js delete mode 100644 modules/account/front/privileges/index.html delete mode 100644 modules/account/front/privileges/index.js delete mode 100644 modules/account/front/privileges/locale/es.yml delete mode 100644 modules/account/front/role-log/index.html delete mode 100644 modules/account/front/role-log/index.js delete mode 100644 modules/account/front/role/basic-data/index.html delete mode 100644 modules/account/front/role/basic-data/index.js delete mode 100644 modules/account/front/role/card/index.html delete mode 100644 modules/account/front/role/card/index.js delete mode 100644 modules/account/front/role/card/index.spec.js delete mode 100644 modules/account/front/role/create/index.html delete mode 100644 modules/account/front/role/create/index.js delete mode 100644 modules/account/front/role/descriptor/index.html delete mode 100644 modules/account/front/role/descriptor/index.js delete mode 100644 modules/account/front/role/descriptor/index.spec.js delete mode 100644 modules/account/front/role/descriptor/locale/es.yml delete mode 100644 modules/account/front/role/index.js delete mode 100644 modules/account/front/role/index/index.html delete mode 100644 modules/account/front/role/index/index.js delete mode 100644 modules/account/front/role/index/locale/es.yml delete mode 100644 modules/account/front/role/inherited/index.html delete mode 100644 modules/account/front/role/inherited/index.js delete mode 100644 modules/account/front/role/inherited/index.spec.js delete mode 100644 modules/account/front/role/locale/es.yml delete mode 100644 modules/account/front/role/main/index.html delete mode 100644 modules/account/front/role/main/index.js delete mode 100644 modules/account/front/role/search-panel/index.html delete mode 100644 modules/account/front/role/search-panel/index.js delete mode 100644 modules/account/front/role/subroles/index.html delete mode 100644 modules/account/front/role/subroles/index.js delete mode 100644 modules/account/front/role/subroles/index.spec.js delete mode 100644 modules/account/front/role/subroles/locale/es.yml delete mode 100644 modules/account/front/role/summary/index.html delete mode 100644 modules/account/front/role/summary/index.js delete mode 100644 modules/account/front/roles/index.html delete mode 100644 modules/account/front/roles/index.js delete mode 100644 modules/account/front/samba/index.html delete mode 100644 modules/account/front/samba/index.js delete mode 100644 modules/account/front/samba/locale/es.yml delete mode 100644 modules/account/front/search-panel/index.html delete mode 100644 modules/account/front/search-panel/index.js delete mode 100644 modules/account/front/summary/index.html delete mode 100644 modules/account/front/summary/index.js delete mode 100644 modules/account/front/user-log/index.html delete mode 100644 modules/account/front/user-log/index.js diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js deleted file mode 100644 index e2c069d80..000000000 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ /dev/null @@ -1,164 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('itManagement', 'account'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account form by clicking the add button', async() => { - await page.waitToClick(selectors.accountIndex.addAccount); - await page.waitForState('account.create'); - }); - - it('should fill the form and then save it by clicking the create button', async() => { - await page.write(selectors.accountIndex.newName, 'remy'); - await page.write(selectors.accountIndex.newNickname, 'Gambit'); - await page.write(selectors.accountIndex.newEmail, 'RemyEtienneLeBeau@verdnatura.es'); - await page.autocompleteSearch(selectors.accountIndex.newRole, 'Trainee'); - await page.write(selectors.accountIndex.newPassword, 'cestlavie'); - await page.waitToClick(selectors.accountIndex.createAccountButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created account basic data section', async() => { - await page.waitForState('account.card.basicData'); - }); - - it('should check the name is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value'); - - expect(result).toEqual('remy'); - }); - - it('should check the nickname is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.nickname, 'value'); - - expect(result).toEqual('Gambit'); - }); - - it('should check the email is as expected', async() => { - const result = await page.waitToGetProperty(selectors.accountBasicData.email, 'value'); - - expect(result).toEqual('RemyEtienneLeBeau@verdnatura.es'); - }); - - it('should navigate to the roles section to check the roles are correct', async() => { - await page.accessToSection('account.card.roles'); - const rolesCount = await page.countElement(selectors.accountRoles.anyResult); - - expect(rolesCount).toEqual(3); - }); - - describe('Descriptor option', () => { - describe('activate account', () => { - it(`should check the active account icon isn't present in the descriptor`, async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeAccountIcon, 0); - }); - - it('should activate the account using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.activateAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Account enabled!'); - }); - - it('should check the active account icon is now present in the descriptor', async() => { - await page.waitForSelector(selectors.accountDescriptor.activeAccountIcon, {visible: false}); - }); - }); - - describe('deactivate user', () => { - it(`should check the inactive user icon isn't present in the descriptor just yet`, async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - }); - - it('should deactivate the user using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deactivateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User deactivated!'); - }); - - it('should check the inactive user icon is now present', async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 1); - }); - }); - - describe('activate user', () => { - it('should activate the user using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.activateUser); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User activated!'); - }); - - it('should check the inactive user icon is not present anymore', async() => { - await page.waitForNumberOfElements(selectors.accountDescriptor.activeUserIcon, 0); - }); - }); - - describe('mail forwarding', () => { - it('should activate the mail forwarding and set the recipent email', async() => { - await page.accessToSection('account.card.mailForwarding'); - await page.waitToClick(selectors.accountMailForwarding.mailForwardingCheckbox); - await page.write(selectors.accountMailForwarding.email, 'someEmail@someDomain.es'); - await page.waitToClick(selectors.accountMailForwarding.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - }); - - describe('Set password', () => { - it('should set the password using the descriptor menu', async() => { - const newPassword = 'quantum.12345'; - - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.setPassword); - await page.write(selectors.accountDescriptor.newPassword, newPassword); - await page.write(selectors.accountDescriptor.repeatPassword, newPassword); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Password changed succesfully!'); - }); - - // cant log into created account for unknown reasons - // it('should login into the created account with the new password', async() => { - // await page.loginAndModule('Remy', 'quantum.crypt0graphy'); - // }); - }); - - describe('delete account', () => { - // it('should navigate to the account basic data section', async() => { - // }); - - it('should delete the account using the descriptor menu', async() => { - await page.waitToClick(selectors.accountDescriptor.menuButton); - await page.waitToClick(selectors.accountDescriptor.deleteAccount); - await page.waitToClick(selectors.accountDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('User removed'); - }); - }); - }); -}); diff --git a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js b/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js deleted file mode 100644 index 840fb8afe..000000000 --- a/e2e/paths/14-account/02_alias_create_and_basic_data.spec.js +++ /dev/null @@ -1,66 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Alias create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('itManagement', 'account'); - await page.accessToSection('account.alias'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account alias form by clicking the add button', async() => { - await page.waitToClick(selectors.accountAliasIndex.addAlias); - await page.waitForState('account.alias.create'); - }); - - it('should fill the form and then save it by clicking the create alias button', async() => { - await page.write(selectors.accountAliasIndex.newName, 'Boring alias'); - await page.write(selectors.accountAliasIndex.newDescription, 'Boring description'); - await page.waitToClick(selectors.accountAliasIndex.createAliasButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created account alias basic data section', async() => { - await page.waitForState('account.alias.card.basicData'); - }); - - it('should edit the alias basic data', async() => { - await page.overwrite(selectors.accountAliasBasicData.name, 'Psykers'); - await page.overwrite(selectors.accountAliasBasicData.description, 'Email group for psykers'); - await page.waitToClick(selectors.accountAliasBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the basicData section and check the name was edited successfully', async() => { - await page.reloadSection('account.alias.card.basicData'); - const result = await page.waitToGetProperty(selectors.accountAliasBasicData.name, 'value'); - - expect(result).toEqual('Psykers'); - }); - - it('should check the alias description was edited successfully', async() => { - const result = await page.waitToGetProperty(selectors.accountAliasBasicData.description, 'value'); - - expect(result).toContain('psykers'); - }); - - it('should search IT alias then access the user section to check the role listed is the expected one', async() => { - await page.accessToSearchResult('IT'); - await page.accessToSection('account.alias.card.users'); - const rolesCount = await page.countElement(selectors.accountAliasUsers.anyResult); - - expect(rolesCount).toEqual(1); - }); -}); diff --git a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js b/e2e/paths/14-account/03_role_create_and_basic_data.spec.js deleted file mode 100644 index 6acf82318..000000000 --- a/e2e/paths/14-account/03_role_create_and_basic_data.spec.js +++ /dev/null @@ -1,86 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Role create and basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('it', 'account'); - await page.accessToSection('account.role'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should open the new account role form by clicking the add button', async() => { - await page.waitToClick(selectors.accountRoleIndex.addRole); - await page.waitForState('account.role.create'); - }); - - it('should fill the form and then save it by clicking the create role button', async() => { - await page.write(selectors.accountRoleIndex.newName, 'boringRole'); - await page.write(selectors.accountRoleIndex.newDescription, 'Boring description'); - await page.waitToClick(selectors.accountRoleIndex.createRoleButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should redirect the user to the created role basic data section', async() => { - await page.waitForState('account.role.card.basicData'); - }); - - it('should edit the role basic data', async() => { - await page.overwrite(selectors.accountRoleBasicData.name, 'psyker'); - await page.overwrite(selectors.accountRoleBasicData.description, 'A role just for psykers'); - await page.waitToClick(selectors.accountRoleBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the role basicData section and check the name was edited successfully', async() => { - await page.reloadSection('account.role.card.basicData'); - const result = await page.waitToGetProperty(selectors.accountRoleBasicData.name, 'value'); - - expect(result).toEqual('psyker'); - }); - - it('should check the role description was edited successfully', async() => { - const result = await page.waitToGetProperty(selectors.accountRoleBasicData.description, 'value'); - - expect(result).toContain('psykers'); - }); - - it('should navigate to the subroles section', async() => { - await page.accessToSection('account.role.card.subroles'); - }); - - it('should asign a subrole', async() => { - await page.waitToClick(selectors.accountSubroles.addSubrole); - await page.autocompleteSearch(selectors.accountSubroles.role, 'teamManager'); - await page.waitToClick(selectors.accountSubroles.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Role added!'); - }); - - it('should reload the subroles section and check a role was added', async() => { - await page.reloadSection('account.role.card.subroles'); - const subrolesCount = await page.countElement(selectors.accountSubroles.anyResult); - - expect(subrolesCount).toEqual(1); - }); - - it('should access the employee roles inheritance then check the roles listed are the expected ones', async() => { - await page.accessToSearchResult('employee'); - await page.accessToSection('account.role.card.inherited'); - const rolesCount = await page.countElement(selectors.accountRoleInheritance.anyResult); - - expect(rolesCount).toEqual(7); - }); -}); diff --git a/e2e/paths/14-account/04_acl.spec.js b/e2e/paths/14-account/04_acl.spec.js deleted file mode 100644 index ce2a63b14..000000000 --- a/e2e/paths/14-account/04_acl.spec.js +++ /dev/null @@ -1,60 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account ACL path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'account'); - await page.accessToSection('account.acl'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should go to create new acl', async() => { - await page.waitToClick(selectors.accountAcl.addAcl); - await page.waitForState('account.acl.create'); - }); - - it('should create new acl', async() => { - await page.autocompleteSearch(selectors.accountAcl.role, 'sysadmin'); - await page.autocompleteSearch(selectors.accountAcl.model, 'Account'); - await page.autocompleteSearch(selectors.accountAcl.accessType, '*'); - await page.autocompleteSearch(selectors.accountAcl.permission, 'ALLOW'); - await page.waitToClick(selectors.accountAcl.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should navigate to edit', async() => { - await page.doSearch(); - await page.waitToClick(selectors.accountAcl.thirdAcl); - await page.waitForState('account.acl.edit'); - }); - - it('should edit the third acl', async() => { - await page.autocompleteSearch(selectors.accountAcl.model, 'Supplier'); - await page.autocompleteSearch(selectors.accountAcl.accessType, 'READ'); - await page.waitToClick(selectors.accountAcl.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should delete the third result', async() => { - const result = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); - await page.waitToClick(selectors.accountAcl.deleteThirdAcl); - await page.waitToClick(selectors.globalItems.acceptButton); - const message = await page.waitForSnackbar(); - const newResult = await page.waitToGetProperty(selectors.accountAcl.thirdAcl, 'innerText'); - - expect(message.text).toContain('ACL removed'); - expect(result).not.toEqual(newResult); - }); -}); diff --git a/e2e/paths/14-account/05_connections.spec.js b/e2e/paths/14-account/05_connections.spec.js deleted file mode 100644 index 49d5f612d..000000000 --- a/e2e/paths/14-account/05_connections.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Connections path', () => { - let browser; - let page; - const account = 'sysadmin'; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule(account, 'account'); - await page.accessToSection('account.connections'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check this is the last connection', async() => { - const firstResult = await page.waitToGetProperty(selectors.accountConnections.firstConnection, 'innerText'); - - expect(firstResult).toContain(account); - }); -}); diff --git a/e2e/paths/14-account/06_accounts.spec.js b/e2e/paths/14-account/06_accounts.spec.js deleted file mode 100644 index 8bd6ea7d5..000000000 --- a/e2e/paths/14-account/06_accounts.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Accounts path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.accounts'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should sync roles', async() => { - await page.waitToClick(selectors.accountAccounts.syncRoles); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Roles synchronized!'); - }); - - it('should relogin', async() => { - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.accounts'); - }); - - it('should sync all', async() => { - await page.waitToClick(selectors.accountAccounts.syncAll); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Synchronizing in the background'); - }); -}); diff --git a/e2e/paths/14-account/07_ldap.spec.js b/e2e/paths/14-account/07_ldap.spec.js deleted file mode 100644 index eb22f695c..000000000 --- a/e2e/paths/14-account/07_ldap.spec.js +++ /dev/null @@ -1,41 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account LDAP path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.ldap'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set data and save', async() => { - await page.waitToClick(selectors.accountLdap.checkEnable); - await page.write(selectors.accountLdap.server, '1234'); - await page.write(selectors.accountLdap.rdn, '1234'); - await page.write(selectors.accountLdap.password, 'nightmare'); - await page.write(selectors.accountLdap.userDn, 'sysadmin'); - await page.write(selectors.accountLdap.groupDn, '1234'); - await page.waitToClick(selectors.accountLdap.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reset data', async() => { - await page.waitToClick(selectors.accountLdap.checkEnable); - await page.waitToClick(selectors.accountLdap.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/14-account/08_samba.spec.js b/e2e/paths/14-account/08_samba.spec.js deleted file mode 100644 index a92344acb..000000000 --- a/e2e/paths/14-account/08_samba.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account Samba path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSection('account.samba'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should set data and save', async() => { - await page.waitToClick(selectors.accountSamba.checkEnable); - await page.write(selectors.accountSamba.adDomain, '1234'); - await page.write(selectors.accountSamba.adController, '1234'); - await page.write(selectors.accountSamba.adUser, 'sysadmin'); - await page.write(selectors.accountSamba.adPassword, 'nightmare'); - await page.write(selectors.accountSamba.userDn, 'testDn'); - await page.waitToClick(selectors.accountSamba.verifyCert); - await page.waitToClick(selectors.accountSamba.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reset data', async() => { - await page.waitToClick(selectors.accountSamba.checkEnable); - await page.waitToClick(selectors.accountSamba.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/14-account/09_privileges.spec.js b/e2e/paths/14-account/09_privileges.spec.js deleted file mode 100644 index e4b8fb24c..000000000 --- a/e2e/paths/14-account/09_privileges.spec.js +++ /dev/null @@ -1,112 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Account privileges path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'account'); - await page.accessToSearchResult('1101'); - await page.accessToSection('account.card.privileges'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as developer', () => { - it('should throw error when give privileges', async() => { - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have grant privilege`); - }); - - it('should throw error when change role', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't have grant privilege`); - }); - }); - - describe('as sysadmin', () => { - beforeAll(async() => { - await page.loginAndModule('sysadmin', 'account'); - await page.accessToSearchResult('9'); - await page.accessToSection('account.card.privileges'); - }); - - it('should give privileges', async() => { - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); - - expect(message.text).toContain(`Data saved!`); - expect(result).toBe('checked'); - }); - - it('should throw error when change role and not own role', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'itBoss'); - await page.waitToClick(selectors.accountPrivileges.save); - - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`You don't own the role and you can't assign it to another user`); - }); - - it('should change role to employee', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); - - expect(message.text).toContain(`Data saved!`); - expect(result).toContain('employee'); - }); - - it('should return role to developer', async() => { - await page.autocompleteSearch(selectors.accountPrivileges.role, 'developer'); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('account.card.privileges'); - const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); - - expect(message.text).toContain(`Data saved!`); - expect(result).toContain('developer'); - }); - }); - - describe('as developer again', () => { - it('should remove privileges', async() => { - await page.accessToSearchResult('9'); - await page.accessToSection('account.card.privileges'); - - await page.waitToClick(selectors.accountPrivileges.checkHasGrant); - await page.waitToClick(selectors.accountPrivileges.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`Data saved!`); - }); - - it('should logIn in developer', async() => { - await page.reloadSection('account.card.privileges'); - const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); - - expect(result).toBe('unchecked'); - }); - }); -}); diff --git a/modules/account/front/accounts/index.html b/modules/account/front/accounts/index.html deleted file mode 100644 index 6847e68d1..000000000 --- a/modules/account/front/accounts/index.html +++ /dev/null @@ -1,75 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/accounts/index.js b/modules/account/front/accounts/index.js deleted file mode 100644 index ab19126a1..000000000 --- a/modules/account/front/accounts/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSynchronizeAll() { - this.vnApp.showSuccess(this.$t('Synchronizing in the background')); - this.$http.patch(`Accounts/syncAll`); - } - - onSynchronizeRoles() { - this.$http.patch(`RoleInherits/sync`) - .then(() => this.vnApp.showSuccess(this.$t('Roles synchronized!'))); - } -} - -ngModule.component('vnAccountAccounts', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/accounts/locale/es.yml b/modules/account/front/accounts/locale/es.yml deleted file mode 100644 index 614ade3eb..000000000 --- a/modules/account/front/accounts/locale/es.yml +++ /dev/null @@ -1,14 +0,0 @@ -Accounts: Cuentas -Homedir base: Directorio base para carpetas de usuario -Shell: Intérprete de línea de comandos -User and role base id: Id base usuarios y roles -Synchronize all: Sincronizar todo -Synchronize roles: Sincronizar roles -If password is not specified, just user attributes are synchronized: >- - Si la contraseña no se especifica solo se sincronizarán lo atributos del usuario -Synchronizing in the background: Sincronizando en segundo plano -Users synchronized!: ¡Usuarios sincronizados! -Username: Nombre de usuario -Synchronize: Sincronizar -Please enter the username: Por favor introduce el nombre de usuario -Roles synchronized!: ¡Roles sincronizados! diff --git a/modules/account/front/acl/create/index.html b/modules/account/front/acl/create/index.html deleted file mode 100644 index 14332f737..000000000 --- a/modules/account/front/acl/create/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/acl/create/index.js b/modules/account/front/acl/create/index.js deleted file mode 100644 index fea71991f..000000000 --- a/modules/account/front/acl/create/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor(...args) { - super(...args); - this.accessTypes = [ - {name: '*'}, - {name: 'READ'}, - {name: 'WRITE'} - ]; - this.permissions = [ - {name: 'ALLOW'}, - {name: 'DENY'} - ]; - - this.models = []; - for (let model in window.validations) - this.models.push({name: model}); - - this.acl = { - property: '*', - principalType: 'ROLE', - accessType: 'READ', - permission: 'ALLOW' - }; - } -} - -ngModule.component('vnAclCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/acl/index.js b/modules/account/front/acl/index.js deleted file mode 100644 index 8393859a5..000000000 --- a/modules/account/front/acl/index.js +++ /dev/null @@ -1,4 +0,0 @@ -import './main'; -import './index/'; -import './create'; -import './search-panel'; diff --git a/modules/account/front/acl/index/index.html b/modules/account/front/acl/index/index.html deleted file mode 100644 index af06ec481..000000000 --- a/modules/account/front/acl/index/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - -
{{::row.model}}.{{::row.property}}
- - - - - - -
- - - - -
-
-
-
- - - - - \ No newline at end of file diff --git a/modules/account/front/acl/index/index.js b/modules/account/front/acl/index/index.js deleted file mode 100644 index a2aec534a..000000000 --- a/modules/account/front/acl/index/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onDelete(row) { - return this.$http.delete(`ACLs/${row.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('ACL removed'))); - } -} - -ngModule.component('vnAclIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/acl/index/locale/es.yml b/modules/account/front/acl/index/locale/es.yml deleted file mode 100644 index 8024f804c..000000000 --- a/modules/account/front/acl/index/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -New ACL: Nuevo ACL -Edit ACL: Editar ACL -ACL will be removed: El ACL será eliminado -ACL removed: ACL eliminado diff --git a/modules/account/front/acl/locale/es.yml b/modules/account/front/acl/locale/es.yml deleted file mode 100644 index ff6a1b41c..000000000 --- a/modules/account/front/acl/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Model: Modelo -Property: Propiedad -Access type: Tipo de acceso -Permission: Permiso \ No newline at end of file diff --git a/modules/account/front/acl/main/index.html b/modules/account/front/acl/main/index.html deleted file mode 100644 index 7767768d9..000000000 --- a/modules/account/front/acl/main/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/acl/main/index.js b/modules/account/front/acl/main/index.js deleted file mode 100644 index a91a71cb7..000000000 --- a/modules/account/front/acl/main/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class ACL extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return {model: {like: `%${value}%`}}; - default: - return {[param]: value}; - } - } -} - -ngModule.vnComponent('vnAclComponent', { - controller: ACL, - template: require('./index.html') -}); diff --git a/modules/account/front/acl/search-panel/index.html b/modules/account/front/acl/search-panel/index.html deleted file mode 100644 index a3efab440..000000000 --- a/modules/account/front/acl/search-panel/index.html +++ /dev/null @@ -1,39 +0,0 @@ -
-
- - - - - - - - - - - - - - -
-
diff --git a/modules/account/front/acl/search-panel/index.js b/modules/account/front/acl/search-panel/index.js deleted file mode 100644 index 4f571059e..000000000 --- a/modules/account/front/acl/search-panel/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -export default class Controller extends SearchPanel { - constructor(...args) { - super(...args); - this.accessTypes = [ - {name: '*'}, - {name: 'READ'}, - {name: 'WRITE'} - ]; - this.permissions = [ - {name: 'ALLOW'}, - {name: 'DENY'} - ]; - - this.models = []; - for (let model in window.validations) - this.models.push({name: model}); - } -} - -ngModule.component('vnAclSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/basic-data/index.html b/modules/account/front/alias/basic-data/index.html deleted file mode 100644 index 523c9297a..000000000 --- a/modules/account/front/alias/basic-data/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - -
- - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/account/front/alias/basic-data/index.js b/modules/account/front/alias/basic-data/index.js deleted file mode 100644 index b7c2db089..000000000 --- a/modules/account/front/alias/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnAliasBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/card/index.html b/modules/account/front/alias/card/index.html deleted file mode 100644 index 712147a24..000000000 --- a/modules/account/front/alias/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/account/front/alias/card/index.js b/modules/account/front/alias/card/index.js deleted file mode 100644 index fd1a18f6a..000000000 --- a/modules/account/front/alias/card/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`MailAliases/${this.$params.id}`) - .then(res => this.alias = res.data); - } -} - -ngModule.vnComponent('vnAliasCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/create/index.html b/modules/account/front/alias/create/index.html deleted file mode 100644 index 4dad1b870..000000000 --- a/modules/account/front/alias/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/account/front/alias/create/index.js b/modules/account/front/alias/create/index.js deleted file mode 100644 index c058c3adf..000000000 --- a/modules/account/front/alias/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -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.alias.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.component('vnAliasCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/descriptor/index.html b/modules/account/front/alias/descriptor/index.html deleted file mode 100644 index 71b98c6a3..000000000 --- a/modules/account/front/alias/descriptor/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Delete - - - -
- - -
-
-
- - \ No newline at end of file diff --git a/modules/account/front/alias/descriptor/index.js b/modules/account/front/alias/descriptor/index.js deleted file mode 100644 index a21baae5a..000000000 --- a/modules/account/front/alias/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get alias() { - return this.entity; - } - - set alias(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`MailAliases/${this.id}`) - .then(() => this.$state.go('account.alias')) - .then(() => this.vnApp.showSuccess(this.$t('Alias removed'))); - } -} - -ngModule.component('vnAliasDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/descriptor/locale/es.yml b/modules/account/front/alias/descriptor/locale/es.yml deleted file mode 100644 index 9c6fa0e73..000000000 --- a/modules/account/front/alias/descriptor/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Alias will be removed: El alias será eliminado -Alias removed: Alias eliminado \ No newline at end of file diff --git a/modules/account/front/alias/index.js b/modules/account/front/alias/index.js deleted file mode 100644 index 8eed3a3d3..000000000 --- a/modules/account/front/alias/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import './main'; -import './index/'; -import './create'; -import './summary'; -import './card'; -import './descriptor'; -import './create'; -import './basic-data'; -import './users'; diff --git a/modules/account/front/alias/index/index.html b/modules/account/front/alias/index/index.html deleted file mode 100644 index 7343cb9bd..000000000 --- a/modules/account/front/alias/index/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - -
{{::alias.alias}}
-
{{::alias.description}}
-
- - - - -
-
-
-
- - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/index/index.js b/modules/account/front/alias/index/index.js deleted file mode 100644 index 44e146fb4..000000000 --- a/modules/account/front/alias/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(alias) { - this.selectedAlias = alias; - this.$.summary.show(); - } -} - -ngModule.component('vnAliasIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/index/locale/es.yml b/modules/account/front/alias/index/locale/es.yml deleted file mode 100644 index 4df41c0be..000000000 --- a/modules/account/front/alias/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New alias: Nuevo alias -View alias: Ver alias \ No newline at end of file diff --git a/modules/account/front/alias/locale/es.yml b/modules/account/front/alias/locale/es.yml deleted file mode 100644 index ecc856fcf..000000000 --- a/modules/account/front/alias/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Public: Público \ No newline at end of file diff --git a/modules/account/front/alias/main/index.html b/modules/account/front/alias/main/index.html deleted file mode 100644 index 43f6e2f51..000000000 --- a/modules/account/front/alias/main/index.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/alias/main/index.js b/modules/account/front/alias/main/index.js deleted file mode 100644 index 21eed3d85..000000000 --- a/modules/account/front/alias/main/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Alias extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {alias: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnAlias', { - controller: Alias, - template: require('./index.html') -}); diff --git a/modules/account/front/alias/summary/index.html b/modules/account/front/alias/summary/index.html deleted file mode 100644 index 52ee2813d..000000000 --- a/modules/account/front/alias/summary/index.html +++ /dev/null @@ -1,16 +0,0 @@ - -
{{summary.alias}}
- - -

Basic data

- - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/alias/summary/index.js b/modules/account/front/alias/summary/index.js deleted file mode 100644 index 21bc8d9ba..000000000 --- a/modules/account/front/alias/summary/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set alias(value) { - this._alias = value; - this.$.summary = null; - if (!value) return; - - this.$http.get(`MailAliases/${value.id}`) - .then(res => this.$.summary = res.data); - } - - get alias() { - return this._alias; - } -} - -ngModule.component('vnAliasSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - alias: '<' - } -}); diff --git a/modules/account/front/alias/users/index.html b/modules/account/front/alias/users/index.html deleted file mode 100644 index 048a702ea..000000000 --- a/modules/account/front/alias/users/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - {{::row.user.name}} - - - - - - - - - - - diff --git a/modules/account/front/alias/users/index.js b/modules/account/front/alias/users/index.js deleted file mode 100644 index b2446d71b..000000000 --- a/modules/account/front/alias/users/index.js +++ /dev/null @@ -1,31 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - include: { - relation: 'user', - scope: { - fields: ['id', 'name'] - } - } - }; - this.$http.get(`MailAliases/${this.$params.id}/accounts`, {filter}) - .then(res => this.$.data = res.data); - } - - onRemove(row) { - return this.$http.delete(`MailAliases/${this.$params.id}/accounts/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.vnApp.showSuccess(this.$t('User removed')); - }); - } -} - -ngModule.component('vnAliasUsers', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/alias/users/index.spec.js b/modules/account/front/alias/users/index.spec.js deleted file mode 100644 index d618f1de1..000000000 --- a/modules/account/front/alias/users/index.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import './index'; - -describe('component vnAliasUsers', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnAliasUsers', {$element: null}); - controller.$params.id = 1; - })); - - describe('$onInit()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('MailAliases/1/accounts').respond('foo'); - controller.$onInit(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onRemove()', () => { - it('should call backend method to change role', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - controller.$.data = [ - {id: 1, alias: 'foo'}, - {id: 2, alias: 'bar'} - ]; - - $httpBackend.expectDELETE('MailAliases/1/accounts/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/alias/users/locale/es.yml b/modules/account/front/alias/users/locale/es.yml deleted file mode 100644 index dc24eb318..000000000 --- a/modules/account/front/alias/users/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -User will be removed from alias: El usuario será borrado del alias -User removed: Usuario borrado \ No newline at end of file diff --git a/modules/account/front/aliases/index.html b/modules/account/front/aliases/index.html deleted file mode 100644 index 4a73ec873..000000000 --- a/modules/account/front/aliases/index.html +++ /dev/null @@ -1,64 +0,0 @@ -
- - - - - -
- {{::row.alias.alias}} -
-
- {{::row.alias.description}} -
-
- - - - -
-
- -
-
- - - - - - - - - - - - - - -
-
- Account not enabled -
diff --git a/modules/account/front/aliases/index.js b/modules/account/front/aliases/index.js deleted file mode 100644 index 0fc806a71..000000000 --- a/modules/account/front/aliases/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.refresh(); - } - - refresh() { - let filter = { - where: {account: this.$params.id}, - include: { - relation: 'alias', - scope: { - fields: ['id', 'alias', 'description'] - } - } - }; - return this.$http.get(`MailAliasAccounts`, {filter}) - .then(res => this.$.data = res.data); - } - - onAddClick() { - this.addData = {account: this.$params.id}; - this.$.dialog.show(); - } - - onAddSave() { - return this.$http.post(`MailAliasAccounts`, this.addData) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess( - this.$t('Subscribed to alias!')) - ); - } - - onRemove(row) { - return this.$http.delete(`MailAliasAccounts/${row.id}`) - .then(() => { - this.$.data.splice(this.$.data.indexOf(row), 1); - this.vnApp.showSuccess(this.$t('Unsubscribed from alias!')); - }); - } -} - -ngModule.component('vnUserAliases', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - } -}); diff --git a/modules/account/front/aliases/index.spec.js b/modules/account/front/aliases/index.spec.js deleted file mode 100644 index 466f1e1e9..000000000 --- a/modules/account/front/aliases/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index'; - -describe('component vnUserAliases', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnUserAliases', {$element: null}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('refresh()', () => { - it('should refresh the controller data', () => { - $httpBackend.expectGET('MailAliasAccounts').respond('foo'); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onAddSave()', () => { - it('should add the new row', () => { - controller.addData = {account: 1}; - - $httpBackend.expectPOST('MailAliasAccounts').respond(); - $httpBackend.expectGET('MailAliasAccounts').respond('foo'); - controller.onAddSave(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onRemove()', () => { - it('shoud remove the passed row remote and locally', () => { - controller.$.data = [ - {id: 1, alias: 'foo'}, - {id: 2, alias: 'bar'} - ]; - - $httpBackend.expectDELETE('MailAliasAccounts/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, alias: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/aliases/locale/es.yml b/modules/account/front/aliases/locale/es.yml deleted file mode 100644 index 4d1ad76a7..000000000 --- a/modules/account/front/aliases/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Unsubscribe: Desuscribir -Subscribed to alias!: ¡Suscrito al alias! -Unsubscribed from alias!: ¡Desuscrito del alias! \ No newline at end of file diff --git a/modules/account/front/basic-data/index.html b/modules/account/front/basic-data/index.html deleted file mode 100644 index 9fd3506fe..000000000 --- a/modules/account/front/basic-data/index.html +++ /dev/null @@ -1,51 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/basic-data/index.js b/modules/account/front/basic-data/index.js deleted file mode 100644 index f6b266bbc..000000000 --- a/modules/account/front/basic-data/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - if (this.$params.emailConfirmed) - this.vnApp.showSuccess(this.$t('Email verified successfully!')); - } - - onSubmit() { - this.$.watcher.submit() - .then(() => this.card.reload()); - } -} - -ngModule.component('vnUserBasicData', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - }, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/basic-data/locale/es.yml b/modules/account/front/basic-data/locale/es.yml deleted file mode 100644 index 2ca7bf698..000000000 --- a/modules/account/front/basic-data/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Email verified successfully!: Correo verificado correctamente! diff --git a/modules/account/front/card/index.html b/modules/account/front/card/index.html deleted file mode 100644 index cba6b93c6..000000000 --- a/modules/account/front/card/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/modules/account/front/card/index.js b/modules/account/front/card/index.js deleted file mode 100644 index 2c8cc7637..000000000 --- a/modules/account/front/card/index.js +++ /dev/null @@ -1,32 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; -import './style.scss'; - -class Controller extends ModuleCard { - reload() { - const filter = { - where: {id: this.$params.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - - return Promise.all([ - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [user] = res.data; - this.user = user; - }), - this.$http.get(`Accounts/${this.$params.id}/exists`) - .then(res => this.hasAccount = res.data.exists) - ]); - } -} - -ngModule.vnComponent('vnUserCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/card/index.spec.js b/modules/account/front/card/index.spec.js deleted file mode 100644 index 712d3c1d8..000000000 --- a/modules/account/front/card/index.spec.js +++ /dev/null @@ -1,27 +0,0 @@ -import './index'; - -describe('component vnUserCard', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnUserCard', {$element: null}); - })); - - describe('reload()', () => { - it('should reload the controller data', () => { - controller.$params.id = 1; - - $httpBackend.expectGET('VnUsers/preview').respond('foo'); - $httpBackend.expectGET('Accounts/1/exists').respond({exists: true}); - controller.reload(); - $httpBackend.flush(); - - expect(controller.user).toBe('f'); - expect(controller.hasAccount).toBeTruthy(); - }); - }); -}); diff --git a/modules/account/front/card/style.scss b/modules/account/front/card/style.scss deleted file mode 100644 index 4d9d108a0..000000000 --- a/modules/account/front/card/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -@import "variables"; - -.bg-title { - display: block; - text-align: center; - padding: 24px; - box-sizing: border-box; - color: $color-font-secondary; - font-size: 1.375rem; -} diff --git a/modules/account/front/connections/index.html b/modules/account/front/connections/index.html deleted file mode 100644 index d634b7a9f..000000000 --- a/modules/account/front/connections/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - -
{{::row.user.username}}
-
{{::row.created | date:'dd/MM HH:mm'}}
-
- - - - -
-
-
-
- - - - \ No newline at end of file diff --git a/modules/account/front/connections/index.js b/modules/account/front/connections/index.js deleted file mode 100644 index c4ddd5615..000000000 --- a/modules/account/front/connections/index.js +++ /dev/null @@ -1,29 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor(...args) { - super(...args); - this.filter = { - fields: ['id', 'created', 'userId'], - include: { - relation: 'user', - scope: { - fields: ['username'] - } - }, - order: 'created DESC' - }; - } - - onDisconnect(row) { - return this.$http.delete(`AccessTokens/${row.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Session killed'))); - } -} - -ngModule.component('vnConnections', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/connections/locale/es.yml b/modules/account/front/connections/locale/es.yml deleted file mode 100644 index 41ef18b45..000000000 --- a/modules/account/front/connections/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Go to user: Ir al usuario -Refresh: Actualizar -Session will be killed: Se va a matar la sesión -Kill session: Matar sesión -Session killed: Sesión matada \ No newline at end of file diff --git a/modules/account/front/create/index.html b/modules/account/front/create/index.html deleted file mode 100644 index 70a518885..000000000 --- a/modules/account/front/create/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/create/index.js b/modules/account/front/create/index.js deleted file mode 100644 index 01ba7905b..000000000 --- a/modules/account/front/create/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.user = {active: true}; - } - - onSubmit() { - return this.$.watcher.submit().then(res => { - this.$state.go('account.card.basicData', {id: res.data.id}); - }); - } -} - -ngModule.component('vnUserCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/descriptor-popover/index.html b/modules/account/front/descriptor-popover/index.html deleted file mode 100644 index f3131a84b..000000000 --- a/modules/account/front/descriptor-popover/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/modules/account/front/descriptor-popover/index.js b/modules/account/front/descriptor-popover/index.js deleted file mode 100644 index d7b052473..000000000 --- a/modules/account/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnAccountDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/descriptor/__snapshots__/index.spec.js.snap b/modules/account/front/descriptor/__snapshots__/index.spec.js.snap deleted file mode 100644 index de5f8e8c2..000000000 --- a/modules/account/front/descriptor/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,5 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`component vnUserDescriptor onPassChange() should throw an error when password is empty 1`] = `"You must enter a new password"`; - -exports[`component vnUserDescriptor onPassChange() should throw an error when repeat password not matches new password 1`] = `"Passwords don't match"`; diff --git a/modules/account/front/descriptor/index.html b/modules/account/front/descriptor/index.html deleted file mode 100644 index 86e78dfce..000000000 --- a/modules/account/front/descriptor/index.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - Delete - - - Change password - - - Set password - - - Enable account - - - Disable account - - - Activate user - - - Deactivate user - - - Synchronize - - - -
- - - - -
-
- - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - Do you want to synchronize user? - - - - - - - - - - - - - - - diff --git a/modules/account/front/descriptor/index.js b/modules/account/front/descriptor/index.js deleted file mode 100644 index de41d619d..000000000 --- a/modules/account/front/descriptor/index.js +++ /dev/null @@ -1,145 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; -import UserError from 'core/lib/user-error'; - -class Controller extends Descriptor { - get user() { - return this.entity; - } - - set user(value) { - this.entity = value; - } - - get entity() { - return super.entity; - } - - set entity(value) { - super.entity = value; - this.hasAccount = null; - if (!value) return; - - this.$http.get(`Accounts/${value.id}/exists`) - .then(res => this.hasAccount = res.data.exists); - } - - loadData() { - const filter = { - where: {id: this.$params.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - - return Promise.all([ - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [user] = res.data; - this.user = user; - }), - this.$http.get(`Accounts/${this.$params.id}/exists`) - .then(res => this.hasAccount = res.data.exists) - ]); - } - - onDelete() { - return this.$http.delete(`VnUsers/${this.id}`) - .then(() => this.$state.go('account.index')) - .then(() => this.vnApp.showSuccess(this.$t('User removed'))); - } - - onChangePassClick(askOldPass) { - this.$http.get('UserPasswords/findOne') - .then(res => { - this.passRequirements = res.data; - this.askOldPass = askOldPass; - this.$.changePass.show(); - }); - } - - onPassChange() { - if (!this.newPassword) - throw new UserError(`You must enter a new password`); - if (this.newPassword != this.repeatPassword) - throw new UserError(`Passwords don't match`); - - let method; - const params = {newPassword: this.newPassword}; - - if (this.askOldPass) { - method = 'change-password'; - params.oldPassword = this.oldPassword; - } else - method = 'setPassword'; - - return this.$http.patch(`Accounts/${this.id}/${method}`, params) - .then(() => { - this.emit('change'); - this.vnApp.showSuccess(this.$t('Password changed succesfully!')); - }); - } - - onPassClose() { - this.oldPassword = ''; - this.newPassword = ''; - this.repeatPassword = ''; - this.$.$apply(); - } - - onEnableAccount() { - return this.$http.post(`Accounts`, {id: this.id}) - .then(() => this.onSwitchAccount(true)); - } - - onDisableAccount() { - return this.$http.delete(`Accounts/${this.id}`) - .then(() => this.onSwitchAccount(false)); - } - - onSwitchAccount(enable) { - this.hasAccount = enable; - const message = enable - ? 'Account enabled!' - : 'Account disabled!'; - this.emit('change'); - this.vnApp.showSuccess(this.$t(message)); - } - - onSetActive(active) { - return this.$http.patch(`VnUsers/${this.id}`, {active}) - .then(() => { - this.user.active = active; - const message = active - ? 'User activated!' - : 'User deactivated!'; - this.emit('change'); - this.vnApp.showSuccess(this.$t(message)); - }); - } - - onSync() { - const params = {force: true}; - if (this.shouldSyncPassword) - params.password = this.syncPassword; - - return this.$http.patch(`Accounts/${this.user.name}/sync`, params) - .then(() => this.vnApp.showSuccess(this.$t('User synchronized!'))); - } - - onSyncClose() { - this.shouldSyncPassword = false; - this.syncPassword = undefined; - } -} - -ngModule.component('vnUserDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/descriptor/index.spec.js b/modules/account/front/descriptor/index.spec.js deleted file mode 100644 index 46c7e376c..000000000 --- a/modules/account/front/descriptor/index.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import './index'; - -describe('component vnUserDescriptor', () => { - let controller; - let $httpBackend; - - let user = {id: 1, name: 'foo'}; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $httpBackend.whenGET('Accounts/1/exists').respond({exists: true}); - - controller = $componentController('vnUserDescriptor', {$element: null}, {user}); - jest.spyOn(controller, 'emit'); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('onDelete()', () => { - it('should delete entity and go to index', () => { - controller.$state.go = jest.fn(); - - $httpBackend.expectDELETE('VnUsers/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('account.index'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onPassChange()', () => { - it('should throw an error when password is empty', () => { - expect(() => { - controller.onPassChange(); - }).toThrowErrorMatchingSnapshot(); - }); - - it('should throw an error when repeat password not matches new password', () => { - controller.newPassword = 'foo'; - controller.repeatPassword = 'bar'; - - expect(() => { - controller.onPassChange(); - }).toThrowErrorMatchingSnapshot(); - }); - - it('should make a request when password checks passes', () => { - controller.newPassword = 'foo'; - controller.repeatPassword = 'foo'; - - $httpBackend.expectPATCH('Accounts/1/setPassword').respond(); - controller.onPassChange(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onEnableAccount()', () => { - it('should make request to enable account', () => { - $httpBackend.expectPOST('Accounts', {id: 1}).respond(); - controller.onEnableAccount(); - $httpBackend.flush(); - - expect(controller.hasAccount).toBeTruthy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onDisableAccount()', () => { - it('should make request to disable account', () => { - $httpBackend.expectDELETE('Accounts/1').respond(); - controller.onDisableAccount(); - $httpBackend.flush(); - - expect(controller.hasAccount).toBeFalsy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); - - describe('onSetActive()', () => { - it('should make request to activate/deactivate the user', () => { - $httpBackend.expectPATCH('VnUsers/1', {active: true}).respond(); - controller.onSetActive(true); - $httpBackend.flush(); - - expect(controller.user.active).toBeTruthy(); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.emit).toHaveBeenCalledWith('change'); - }); - }); -}); diff --git a/modules/account/front/descriptor/locale/es.yml b/modules/account/front/descriptor/locale/es.yml deleted file mode 100644 index 98ced7694..000000000 --- a/modules/account/front/descriptor/locale/es.yml +++ /dev/null @@ -1,35 +0,0 @@ -User will be removed: El usuario será eliminado -User removed: Usuario eliminado -Are you sure you want to continue?: ¿Seguro que quieres continuar? -Account will be enabled: La cuenta será habilitada -Account will be disabled: La cuenta será deshabilitada -Account enabled!: ¡Cuenta habilitada! -Account disabled!: ¡Cuenta deshabilitada! -User will activated: El usuario será activado -User will be deactivated: El usuario será desactivado -User activated!: ¡Usuario activado! -User deactivated!: ¡Usuario desactivado! -Account enabled: Cuenta habilitada -User deactivated: Usuario desactivado -Change role: Modificar rol -Change password: Cambiar contraseña -Set password: Establecer contraseña -Enable account: Habilitar cuenta -Disable account: Deshabilitar cuenta -Activate user: Activar usuario -Deactivate user: Desactivar usuario -Old password: Contraseña antigua -New password: Nueva contraseña -Repeat password: Repetir contraseña -Password changed succesfully!: ¡Contraseña modificada correctamente! -Synchronize: Sincronizar -Do you want to synchronize user?: ¿Quieres sincronizar el usuario? -Synchronize password: Sincronizar contraseña -User synchronized!: ¡Usuario sincronizado! -Role changed succesfully!: ¡Rol modificado correctamente! -Password requirements: > - La contraseña debe tener al menos {{ length }} caracteres de longitud, - {{nAlpha}} caracteres alfabéticos, {{nUpper}} letras mayúsculas, {{nDigits}} - dígitos y {{nPunct}} símbolos (Ej: $%&.) -You must enter a new password: Debes introducir la nueva contraseña -Passwords don't match: Las contraseñas no coinciden diff --git a/modules/account/front/index.js b/modules/account/front/index.js index 4d6aedcae..a7209a0bd 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -1,24 +1,3 @@ export * from './module'; import './main'; -import './index/'; -import './role'; -import './alias'; -import './connections'; -import './acl'; -import './summary'; -import './card'; -import './descriptor'; -import './descriptor-popover'; -import './search-panel'; -import './create'; -import './basic-data'; -import './mail-forwarding'; -import './aliases'; -import './roles'; -import './ldap'; -import './samba'; -import './accounts'; -import './privileges'; -import './user-log'; -import './role-log'; diff --git a/modules/account/front/index/index.html b/modules/account/front/index/index.html deleted file mode 100644 index 7502c8b3d..000000000 --- a/modules/account/front/index/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - diff --git a/modules/account/front/index/index.js b/modules/account/front/index/index.js deleted file mode 100644 index 9324ca740..000000000 --- a/modules/account/front/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(user) { - this.selectedUser = user; - this.$.summary.show(); - } -} - -ngModule.component('vnUserIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/index/locale/es.yml b/modules/account/front/index/locale/es.yml deleted file mode 100644 index 074fb054e..000000000 --- a/modules/account/front/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New user: Nuevo usuario -View user: Ver usuario \ No newline at end of file diff --git a/modules/account/front/ldap/index.html b/modules/account/front/ldap/index.html deleted file mode 100644 index 23356452a..000000000 --- a/modules/account/front/ldap/index.html +++ /dev/null @@ -1,66 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/ldap/index.js b/modules/account/front/ldap/index.js deleted file mode 100644 index 40e1e8db1..000000000 --- a/modules/account/front/ldap/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onTestConection() { - this.$http.get(`LdapConfigs/test`) - .then(() => this.vnApp.showSuccess(this.$t('LDAP connection established!'))); - } -} - -ngModule.component('vnAccountLdap', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/ldap/locale/es.yml b/modules/account/front/ldap/locale/es.yml deleted file mode 100644 index 0353d6b72..000000000 --- a/modules/account/front/ldap/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Enable synchronization: Habilitar sincronización -Server: Servidor -RDN: RDN -User DN: DN usuarios -Filter: Filtro -Group DN: DN grupos -Test connection: Probar conexión -LDAP connection established!: ¡Conexión con LDAP establecida! diff --git a/modules/account/front/mail-forwarding/index.html b/modules/account/front/mail-forwarding/index.html deleted file mode 100644 index df5cd80bf..000000000 --- a/modules/account/front/mail-forwarding/index.html +++ /dev/null @@ -1,49 +0,0 @@ -
- - -
- - - - - - - - - - - - - - -
-
-
- Account not enabled -
diff --git a/modules/account/front/mail-forwarding/index.js b/modules/account/front/mail-forwarding/index.js deleted file mode 100644 index 5118e8eab..000000000 --- a/modules/account/front/mail-forwarding/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnUserMailForwarding', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnUserCard' - }, -}); diff --git a/modules/account/front/mail-forwarding/locale/es.yml b/modules/account/front/mail-forwarding/locale/es.yml deleted file mode 100644 index 688ace6b5..000000000 --- a/modules/account/front/mail-forwarding/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Mail forwarding: Reenvío de correo -Forward email: Dirección de reenvío -Enable mail forwarding: Habilitar redirección de correo -All emails will be forwarded to the specified address.: > - Todos los correos serán reenviados a la dirección especificada, no se - mantendrá copia de los mismos en el buzón del usuario. -You don't have enough privileges: No tienes suficientes permisos diff --git a/modules/account/front/main/index.html b/modules/account/front/main/index.html index 36b493ec4..e69de29bb 100644 --- a/modules/account/front/main/index.html +++ b/modules/account/front/main/index.html @@ -1,19 +0,0 @@ - - - - - - - - - - diff --git a/modules/account/front/main/index.js b/modules/account/front/main/index.js index a43ffb76b..335d71b42 100644 --- a/modules/account/front/main/index.js +++ b/modules/account/front/main/index.js @@ -4,32 +4,10 @@ import ModuleMain from 'salix/components/module-main'; export default class User extends ModuleMain { constructor($element, $) { super($element, $); - this.filter = { - fields: ['id', 'nickname', 'name', 'role'], - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {nickname: {like: `%${value}%`}} - ]}; - case 'name': - case 'nickname': - return {[param]: {like: `%${value}%`}}; - case 'roleFk': - return {[param]: value}; - } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`account/`); } } diff --git a/modules/account/front/main/index.spec.js b/modules/account/front/main/index.spec.js deleted file mode 100644 index c232aa849..000000000 --- a/modules/account/front/main/index.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import './index'; - -describe('component vnUser', () => { - let controller; - - beforeEach(ngModule('account')); - - beforeEach(inject($componentController => { - controller = $componentController('vnUser', {$element: null}); - })); - - describe('exprBuilder()', () => { - it('should search by id when only digits string is passed', () => { - let expr = controller.exprBuilder('search', '1'); - - expect(expr).toEqual({id: '1'}); - }); - - it('should search by name when non-only digits string is passed', () => { - let expr = controller.exprBuilder('search', '1foo'); - - expect(expr).toEqual({or: [ - {name: {like: '%1foo%'}}, - {nickname: {like: '%1foo%'}} - ]}); - }); - }); -}); diff --git a/modules/account/front/privileges/index.html b/modules/account/front/privileges/index.html deleted file mode 100644 index 343c179e3..000000000 --- a/modules/account/front/privileges/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/privileges/index.js b/modules/account/front/privileges/index.js deleted file mode 100644 index f69428666..000000000 --- a/modules/account/front/privileges/index.js +++ /dev/null @@ -1,21 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - get user() { - return this._user; - } - - set user(value) { - this._user = value; - if (!value) return; - } -} - -ngModule.component('vnUserPrivileges', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/privileges/locale/es.yml b/modules/account/front/privileges/locale/es.yml deleted file mode 100644 index d66a7a6cf..000000000 --- a/modules/account/front/privileges/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Privileges: Privilegios -Has grant: Puede delegar privilegios diff --git a/modules/account/front/role-log/index.html b/modules/account/front/role-log/index.html deleted file mode 100644 index 9e2b151b5..000000000 --- a/modules/account/front/role-log/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/account/front/role-log/index.js b/modules/account/front/role-log/index.js deleted file mode 100644 index 02448ccaa..000000000 --- a/modules/account/front/role-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnRoleLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/account/front/role/basic-data/index.html b/modules/account/front/role/basic-data/index.html deleted file mode 100644 index 846f8b455..000000000 --- a/modules/account/front/role/basic-data/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/account/front/role/basic-data/index.js b/modules/account/front/role/basic-data/index.js deleted file mode 100644 index 4e26906ee..000000000 --- a/modules/account/front/role/basic-data/index.js +++ /dev/null @@ -1,12 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section {} - -ngModule.component('vnRoleBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/role/card/index.html b/modules/account/front/role/card/index.html deleted file mode 100644 index 2f51f88b5..000000000 --- a/modules/account/front/role/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/account/front/role/card/index.js b/modules/account/front/role/card/index.js deleted file mode 100644 index 3c7c758ef..000000000 --- a/modules/account/front/role/card/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - this.$http.get(`VnRoles/${this.$params.id}`) - .then(res => this.role = res.data); - } -} - -ngModule.vnComponent('vnRoleCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/card/index.spec.js b/modules/account/front/role/card/index.spec.js deleted file mode 100644 index 569fe487d..000000000 --- a/modules/account/front/role/card/index.spec.js +++ /dev/null @@ -1,25 +0,0 @@ -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('VnRoles/1').respond('foo'); - controller.reload(); - $httpBackend.flush(); - - expect(controller.role).toBe('foo'); - }); - }); -}); diff --git a/modules/account/front/role/create/index.html b/modules/account/front/role/create/index.html deleted file mode 100644 index 77d6fc2c1..000000000 --- a/modules/account/front/role/create/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - -
- - - - - - - - - - - - - - -
diff --git a/modules/account/front/role/create/index.js b/modules/account/front/role/create/index.js deleted file mode 100644 index 3f7fcc9cf..000000000 --- a/modules/account/front/role/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -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('vnRoleCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/descriptor/index.html b/modules/account/front/role/descriptor/index.html deleted file mode 100644 index d8bf4857a..000000000 --- a/modules/account/front/role/descriptor/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - Delete - - - -
- - -
-
-
- - diff --git a/modules/account/front/role/descriptor/index.js b/modules/account/front/role/descriptor/index.js deleted file mode 100644 index 17b585cb7..000000000 --- a/modules/account/front/role/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get role() { - return this.entity; - } - - set role(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`VnRoles/${this.id}`) - .then(() => this.$state.go('account.role')) - .then(() => this.vnApp.showSuccess(this.$t('Role removed'))); - } -} - -ngModule.component('vnRoleDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/role/descriptor/index.spec.js b/modules/account/front/role/descriptor/index.spec.js deleted file mode 100644 index f3b2e4763..000000000 --- a/modules/account/front/role/descriptor/index.spec.js +++ /dev/null @@ -1,29 +0,0 @@ -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('VnRoles/1').respond(); - controller.onDelete(); - $httpBackend.flush(); - - expect(controller.$state.go).toHaveBeenCalledWith('account.role'); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/role/descriptor/locale/es.yml b/modules/account/front/role/descriptor/locale/es.yml deleted file mode 100644 index 1ca512e4f..000000000 --- a/modules/account/front/role/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/account/front/role/index.js b/modules/account/front/role/index.js deleted file mode 100644 index 97a20d3bc..000000000 --- a/modules/account/front/role/index.js +++ /dev/null @@ -1,10 +0,0 @@ -import './main'; -import './index/'; -import './summary'; -import './card'; -import './descriptor'; -import './search-panel'; -import './create'; -import './basic-data'; -import './subroles'; -import './inherited'; diff --git a/modules/account/front/role/index/index.html b/modules/account/front/role/index/index.html deleted file mode 100644 index 4c4c6b0ad..000000000 --- a/modules/account/front/role/index/index.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/account/front/role/index/index.js b/modules/account/front/role/index/index.js deleted file mode 100644 index 40773b23b..000000000 --- a/modules/account/front/role/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(role) { - this.selectedRole = role; - this.$.summary.show(); - } -} - -ngModule.component('vnRoleIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/index/locale/es.yml b/modules/account/front/role/index/locale/es.yml deleted file mode 100644 index 70932e983..000000000 --- a/modules/account/front/role/index/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New role: Nuevo rol -View role: Ver rol \ No newline at end of file diff --git a/modules/account/front/role/inherited/index.html b/modules/account/front/role/inherited/index.html deleted file mode 100644 index 83ecbbff4..000000000 --- a/modules/account/front/role/inherited/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -
- {{::row.inherits.name}} -
-
- {{::row.inherits.description}} -
-
-
-
-
-
diff --git a/modules/account/front/role/inherited/index.js b/modules/account/front/role/inherited/index.js deleted file mode 100644 index 5927493ee..000000000 --- a/modules/account/front/role/inherited/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - where: {role: this.$params.id}, - include: { - relation: 'inherits', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get('RoleRoles', {filter}) - .then(res => this.$.data = res.data); - } -} - -ngModule.component('vnRoleInherited', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/inherited/index.spec.js b/modules/account/front/role/inherited/index.spec.js deleted file mode 100644 index 16b0c53b2..000000000 --- a/modules/account/front/role/inherited/index.spec.js +++ /dev/null @@ -1,23 +0,0 @@ -import './index'; - -describe('component vnRoleInherited', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleInherited', {$element: null}); - })); - - describe('$onInit()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('RoleRoles').respond('foo'); - controller.$onInit(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); -}); diff --git a/modules/account/front/role/locale/es.yml b/modules/account/front/role/locale/es.yml deleted file mode 100644 index 159fc7f16..000000000 --- a/modules/account/front/role/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Subroles: Subroles diff --git a/modules/account/front/role/main/index.html b/modules/account/front/role/main/index.html deleted file mode 100644 index cfef28e57..000000000 --- a/modules/account/front/role/main/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/modules/account/front/role/main/index.js b/modules/account/front/role/main/index.js deleted file mode 100644 index 77d15cf17..000000000 --- a/modules/account/front/role/main/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Role extends ModuleMain { - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {or: [ - {name: {like: `%${value}%`}}, - {nickname: {like: `%${value}%`}} - ]}; - case 'name': - case 'description': - return {[param]: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnRole', { - controller: Role, - template: require('./index.html') -}); diff --git a/modules/account/front/role/search-panel/index.html b/modules/account/front/role/search-panel/index.html deleted file mode 100644 index dfea9f01c..000000000 --- a/modules/account/front/role/search-panel/index.html +++ /dev/null @@ -1,21 +0,0 @@ -
-
- - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/account/front/role/search-panel/index.js b/modules/account/front/role/search-panel/index.js deleted file mode 100644 index 35da591ad..000000000 --- a/modules/account/front/role/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnRoleSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/account/front/role/subroles/index.html b/modules/account/front/role/subroles/index.html deleted file mode 100644 index eba1002b0..000000000 --- a/modules/account/front/role/subroles/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - -
- {{::row.inherits.name}} -
-
- {{::row.inherits.description}} -
-
- - - - -
-
-
-
- - - - - - - - - - - - - - diff --git a/modules/account/front/role/subroles/index.js b/modules/account/front/role/subroles/index.js deleted file mode 100644 index b7e1caaa4..000000000 --- a/modules/account/front/role/subroles/index.js +++ /dev/null @@ -1,51 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - this.refresh(); - } - - get path() { - return `RoleInherits`; - } - - refresh() { - let filter = { - where: {role: this.$params.id}, - include: { - relation: 'inherits', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get(this.path, {filter}) - .then(res => this.$.data = res.data); - } - - onAddClick() { - this.addData = {role: this.$params.id}; - this.$.dialog.show(); - } - - onAddSave() { - return this.$http.post(this.path, this.addData) - .then(() => this.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Role added! Changes will take a while to fully propagate.'))); - } - - onRemove(row) { - return this.$http.delete(`${this.path}/${row.id}`) - .then(() => { - let index = this.$.data.indexOf(row); - if (index !== -1) this.$.data.splice(index, 1); - this.vnApp.showSuccess(this.$t('Role removed. Changes will take a while to fully propagate.')); - }); - } -} - -ngModule.component('vnRoleSubroles', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/role/subroles/index.spec.js b/modules/account/front/role/subroles/index.spec.js deleted file mode 100644 index e7d9a4d0e..000000000 --- a/modules/account/front/role/subroles/index.spec.js +++ /dev/null @@ -1,53 +0,0 @@ -import './index'; - -describe('component vnRoleSubroles', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('account')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnRoleSubroles', {$element: null}); - jest.spyOn(controller.vnApp, 'showSuccess'); - })); - - describe('refresh()', () => { - it('should delete entity and go to index', () => { - $httpBackend.expectGET('RoleInherits').respond('foo'); - controller.refresh(); - $httpBackend.flush(); - - expect(controller.$.data).toBe('foo'); - }); - }); - - describe('onAddSave()', () => { - it('should add a subrole', () => { - controller.addData = {role: 'foo'}; - - $httpBackend.expectPOST('RoleInherits', {role: 'foo'}).respond(); - $httpBackend.expectGET('RoleInherits').respond(); - controller.onAddSave(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onRemove()', () => { - it('should remove a subrole', () => { - controller.$.data = [ - {id: 1, name: 'foo'}, - {id: 2, name: 'bar'} - ]; - - $httpBackend.expectDELETE('RoleInherits/1').respond(); - controller.onRemove(controller.$.data[0]); - $httpBackend.flush(); - - expect(controller.$.data).toEqual([{id: 2, name: 'bar'}]); - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); -}); diff --git a/modules/account/front/role/subroles/locale/es.yml b/modules/account/front/role/subroles/locale/es.yml deleted file mode 100644 index 170882405..000000000 --- a/modules/account/front/role/subroles/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Role added! Changes will take a while to fully propagate.: > - ¡Rol añadido! Los cambios tardaran un tiempo en propagarse completamente. -Role removed. Changes will take a while to fully propagate.: > - Rol eliminado. Los cambios tardaran un tiempo en propagarse completamente. diff --git a/modules/account/front/role/summary/index.html b/modules/account/front/role/summary/index.html deleted file mode 100644 index f7971190c..000000000 --- a/modules/account/front/role/summary/index.html +++ /dev/null @@ -1,20 +0,0 @@ - -
{{summary.name}}
- - -

Basic data

- - - - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/role/summary/index.js b/modules/account/front/role/summary/index.js deleted file mode 100644 index 6c649a68f..000000000 --- a/modules/account/front/role/summary/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; - -class Controller extends Component { - set role(value) { - this._role = value; - this.$.summary = null; - if (!value) return; - this.$http.get(`VnRoles/${value.id}`) - .then(res => this.$.summary = res.data); - } - - get role() { - return this._role; - } -} - -ngModule.component('vnRoleSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - role: '<' - } -}); diff --git a/modules/account/front/roles/index.html b/modules/account/front/roles/index.html deleted file mode 100644 index 8c8583929..000000000 --- a/modules/account/front/roles/index.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - -
- {{::row.role.name}} -
-
- {{::row.role.description}} -
-
-
-
-
-
diff --git a/modules/account/front/roles/index.js b/modules/account/front/roles/index.js deleted file mode 100644 index 0982dcf10..000000000 --- a/modules/account/front/roles/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - $onInit() { - let filter = { - where: { - prindicpalType: 'USER', - principalId: this.$params.id - }, - include: { - relation: 'role', - scope: { - fields: ['id', 'name', 'description'] - } - } - }; - this.$http.get('RoleMappings', {filter}) - .then(res => this.$.data = res.data); - } -} - -ngModule.component('vnUserRoles', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/routes.json b/modules/account/front/routes.json index d7845090b..9eadf2af2 100644 --- a/modules/account/front/routes.json +++ b/modules/account/front/routes.json @@ -7,31 +7,6 @@ "menus": { "main": [ {"state": "account.index", "icon": "face"}, - {"state": "account.role", "icon": "group"}, - {"state": "account.alias", "icon": "email"}, - {"state": "account.accounts", "icon": "accessibility"}, - {"state": "account.ldap", "icon": "account_tree"}, - {"state": "account.samba", "icon": "preview"}, - {"state": "account.acl", "icon": "check"}, - {"state": "account.connections", "icon": "share"} - ], - "card": [ - {"state": "account.card.basicData", "icon": "settings"}, - {"state": "account.card.roles", "icon": "group"}, - {"state": "account.card.mailForwarding", "icon": "forward"}, - {"state": "account.card.aliases", "icon": "email"}, - {"state": "account.card.privileges", "icon": "badge"}, - {"state": "account.card.log", "icon": "history"} - ], - "role": [ - {"state": "account.role.card.basicData", "icon": "settings"}, - {"state": "account.role.card.subroles", "icon": "groups"}, - {"state": "account.role.card.inherited", "icon": "account_tree"}, - {"state": "account.role.card.log", "icon": "history"} - ], - "alias": [ - {"state": "account.alias.card.basicData", "icon": "settings"}, - {"state": "account.alias.card.users", "icon": "groups"} ] }, "keybindings": [ @@ -50,224 +25,6 @@ "state": "account.index", "component": "vn-user-index", "description": "Users" - }, - { - "url": "/create", - "state": "account.create", - "component": "vn-user-create", - "description": "New user" - }, - { - "url": "/:id", - "state": "account.card", - "component": "vn-user-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.card.summary", - "component": "vn-user-summary", - "description": "Summary", - "params": { - "user": "$ctrl.user" - } - }, - { - "url": "/basic-data?emailConfirmed", - "state": "account.card.basicData", - "component": "vn-user-basic-data", - "description": "Basic data", - "params": { - "user": "$ctrl.user" - } - }, - { - "url" : "/log", - "state": "account.card.log", - "component": "vn-user-log", - "description": "Log" - }, - { - "url" : "/log", - "state": "account.role.card.log", - "component": "vn-role-log", - "description": "Log" - }, - { - "url": "/roles", - "state": "account.card.roles", - "component": "vn-user-roles", - "description": "Inherited roles" - }, - { - "url": "/mail-forwarding", - "state": "account.card.mailForwarding", - "component": "vn-user-mail-forwarding", - "description": "Mail forwarding" - }, - { - "url": "/aliases", - "state": "account.card.aliases", - "component": "vn-user-aliases", - "description": "Mail aliases" - }, - { - "url": "/privileges", - "state": "account.card.privileges", - "component": "vn-user-privileges", - "description": "Privileges", - "params": { - "user": "$ctrl.user" - } - }, - { - "url": "/role?q", - "state": "account.role", - "component": "vn-role", - "description": "Roles", - "acl": ["it"] - }, - { - "url": "/create", - "state": "account.role.create", - "component": "vn-role-create", - "description": "New role", - "acl": ["it"] - }, - { - "url": "/:id", - "state": "account.role.card", - "component": "vn-role-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.role.card.summary", - "component": "vn-role-summary", - "description": "Summary", - "params": { - "role": "$ctrl.role" - }, - "acl": ["it"] - }, - { - "url": "/basic-data", - "state": "account.role.card.basicData", - "component": "vn-role-basic-data", - "description": "Basic data", - "params": { - "role": "$ctrl.role" - }, - "acl": ["it"] - }, - { - "url": "/subroles", - "state": "account.role.card.subroles", - "component": "vn-role-subroles", - "description": "Subroles", - "acl": ["it"] - }, - { - "url": "/inherited", - "state": "account.role.card.inherited", - "component": "vn-role-inherited", - "description": "Inherited roles", - "acl": ["it"] - }, - { - "url": "/alias?q", - "state": "account.alias", - "component": "vn-alias", - "description": "Mail aliases" - }, - { - "url": "/create", - "state": "account.alias.create", - "component": "vn-alias-create", - "description": "New alias" - }, - { - "url": "/:id", - "state": "account.alias.card", - "component": "vn-alias-card", - "abstract": true, - "description": "Detail" - }, - { - "url": "/summary", - "state": "account.alias.card.summary", - "component": "vn-alias-summary", - "description": "Summary", - "params": { - "alias": "$ctrl.alias" - } - }, - { - "url": "/basic-data", - "state": "account.alias.card.basicData", - "component": "vn-alias-basic-data", - "description": "Basic data", - "params": { - "alias": "$ctrl.alias" - } - }, - { - "url": "/users", - "state": "account.alias.card.users", - "component": "vn-alias-users", - "description": "Users", - "acl": ["it"] - }, - { - "url": "/accounts", - "state": "account.accounts", - "component": "vn-account-accounts", - "description": "Accounts", - "acl": ["sysadmin"] - }, - { - "url": "/ldap", - "state": "account.ldap", - "component": "vn-account-ldap", - "description": "LDAP", - "acl": ["sysadmin"] - }, - { - "url": "/samba", - "state": "account.samba", - "component": "vn-account-samba", - "description": "Samba", - "acl": ["sysadmin"] - }, - { - "url": "/acl?q", - "state": "account.acl", - "component": "vn-acl-component", - "description": "ACLs", - "acl": ["developer"] - }, - { - "url": "/create", - "state": "account.acl.create", - "component": "vn-acl-create", - "description": "New ACL", - "acl": ["developer"] - }, - { - "url": "/:id/edit", - "state": "account.acl.edit", - "component": "vn-acl-create", - "description": "Edit ACL", - "acl": ["developer"] - }, - { - "url": "/connections", - "state": "account.connections", - "component": "vn-connections", - "description": "Connections", - "acl": ["developer"] } ] } diff --git a/modules/account/front/samba/index.html b/modules/account/front/samba/index.html deleted file mode 100644 index 0186cac7c..000000000 --- a/modules/account/front/samba/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/account/front/samba/index.js b/modules/account/front/samba/index.js deleted file mode 100644 index 6a4969893..000000000 --- a/modules/account/front/samba/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onTestConection() { - this.$http.get(`SambaConfigs/test`) - .then(() => this.vnApp.showSuccess(this.$t('Samba connection established!'))); - } -} - -ngModule.component('vnAccountSamba', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/account/front/samba/locale/es.yml b/modules/account/front/samba/locale/es.yml deleted file mode 100644 index efa3b1597..000000000 --- a/modules/account/front/samba/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Enable synchronization: Habilitar sincronización -Domain controller: Controlador de dominio -AD domain: Dominio AD -AD user: Usuario AD -AD password: Contraseña AD -User DN (without domain part): DN usuarios (sin la parte del dominio) -Verify certificate: Verificar certificado -Test connection: Probar conexión -Samba connection established!: ¡Conexión con Samba establecida! diff --git a/modules/account/front/search-panel/index.html b/modules/account/front/search-panel/index.html deleted file mode 100644 index a539d9657..000000000 --- a/modules/account/front/search-panel/index.html +++ /dev/null @@ -1,31 +0,0 @@ -
-
- - - - - - - - - - - - - - - -
-
diff --git a/modules/account/front/search-panel/index.js b/modules/account/front/search-panel/index.js deleted file mode 100644 index fff3bf7b9..000000000 --- a/modules/account/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnUserSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/account/front/summary/index.html b/modules/account/front/summary/index.html deleted file mode 100644 index 41632aef6..000000000 --- a/modules/account/front/summary/index.html +++ /dev/null @@ -1,40 +0,0 @@ - -
- - - - {{summary.id}} - {{summary.nickname}} -
- - -

- - Basic Data - -

-

- Basic Data -

- - - - - - -
-
-
\ No newline at end of file diff --git a/modules/account/front/summary/index.js b/modules/account/front/summary/index.js deleted file mode 100644 index 53b66dbe2..000000000 --- a/modules/account/front/summary/index.js +++ /dev/null @@ -1,40 +0,0 @@ -import ngModule from '../module'; -import Summary from 'salix/components/summary'; - -class Controller extends Summary { - set user(value) { - this._user = value; - this.$.summary = null; - if (!value) return; - - const filter = { - where: {id: value.id}, - include: { - relation: 'role', - scope: { - fields: ['id', 'name'] - } - } - }; - this.$http.get(`VnUsers/preview`, {filter}) - .then(res => { - const [summary] = res.data; - this.$.summary = summary; - }); - } - get isHr() { - return this.aclService.hasAny(['hr']); - } - - get user() { - return this._user; - } -} - -ngModule.component('vnUserSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - user: '<' - } -}); diff --git a/modules/account/front/user-log/index.html b/modules/account/front/user-log/index.html deleted file mode 100644 index 5a77ed7b9..000000000 --- a/modules/account/front/user-log/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/modules/account/front/user-log/index.js b/modules/account/front/user-log/index.js deleted file mode 100644 index 7cd0bb378..000000000 --- a/modules/account/front/user-log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnUserLog', { - template: require('./index.html'), - controller: Section, -}); From bbe53060886a9f935159f68bee0db0ffb99cf269 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 12 Aug 2024 16:36:43 +0200 Subject: [PATCH 127/145] feat: refs #7524 add default limit --- loopback/common/models/vn-model.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/loopback/common/models/vn-model.js b/loopback/common/models/vn-model.js index 56a4f4dd0..a11bed11d 100644 --- a/loopback/common/models/vn-model.js +++ b/loopback/common/models/vn-model.js @@ -5,7 +5,6 @@ const utils = require('loopback/lib/utils'); module.exports = function(Self) { Self.ParameterizedSQL = ParameterizedSQL; - let isSelect; require('../methods/vn-model/getSetValues')(Self); require('../methods/vn-model/getEnumValues')(Self); @@ -28,7 +27,9 @@ module.exports = function(Self) { }; }); - this.beforeRemote('find', async ctx => { + this.beforeRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; + const defaultLimit = this.app.orm.selectLimit; const filter = ctx.args.filter || {limit: defaultLimit}; @@ -38,22 +39,10 @@ module.exports = function(Self) { } }); - this.afterRemote('find', async({result}) => { - const length = Array.isArray(result) ? result.length : result ? 1 : 0; - if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); - }); + this.afterRemote('**', async ctx => { + if (!this.hasFilter(ctx)) return; - this.beforeRemote('filter', async ctx => { - const defaultLimit = this.app.orm.selectLimit; - const filter = ctx.args.filter || {limit: defaultLimit}; - - if (filter.limit > defaultLimit) { - filter.limit = defaultLimit; - ctx.args.filter = filter; - } - }); - - this.afterRemote('filter', async({result}) => { + const {result} = ctx; const length = Array.isArray(result) ? result.length : result ? 1 : 0; if (length >= this.app.orm.selectLimit) throw new UserError('Too many records'); }); @@ -357,6 +346,12 @@ module.exports = function(Self) { checkInsertAcls(ctx) { return this.checkAcls(ctx, 'insert'); + }, + + hasFilter(ctx) { + return ctx.req.method.toUpperCase() === 'GET' && + ctx.method.accepts.some(x => x.arg === 'filter' && x.type.toLowerCase() === 'object'); } + }); }; From 61d6efaea7f7b261b58b7a0ec7642877715c9ba7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 09:53:05 +0200 Subject: [PATCH 128/145] refactor: refs #7798 Drop bi.Greuges_comercial_detail --- db/versions/11185-maroonArborvitae/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11185-maroonArborvitae/00-firstScript.sql diff --git a/db/versions/11185-maroonArborvitae/00-firstScript.sql b/db/versions/11185-maroonArborvitae/00-firstScript.sql new file mode 100644 index 000000000..b07126e71 --- /dev/null +++ b/db/versions/11185-maroonArborvitae/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE bi.Greuges_comercial_detail; \ No newline at end of file From a733560649668beb014784dbbeb98d7639bb1b84 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Aug 2024 10:26:36 +0200 Subject: [PATCH 129/145] feat: refs #7323 add locale --- modules/worker/back/locale/worker-time-control/en.yml | 7 +++++++ modules/worker/back/locale/worker-time-control/es.yml | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 modules/worker/back/locale/worker-time-control/en.yml create mode 100644 modules/worker/back/locale/worker-time-control/es.yml diff --git a/modules/worker/back/locale/worker-time-control/en.yml b/modules/worker/back/locale/worker-time-control/en.yml new file mode 100644 index 000000000..f1de66474 --- /dev/null +++ b/modules/worker/back/locale/worker-time-control/en.yml @@ -0,0 +1,7 @@ +name: time control +columns: + direction: direction + isSendMail: sent mail + logExclude: excluded log + manual: manual + timed: timed diff --git a/modules/worker/back/locale/worker-time-control/es.yml b/modules/worker/back/locale/worker-time-control/es.yml new file mode 100644 index 000000000..1739c487c --- /dev/null +++ b/modules/worker/back/locale/worker-time-control/es.yml @@ -0,0 +1,7 @@ +name: control horario +columns: + direction: dirección + isSendMail: correo enviado + logExclude: registro excluido + manual: manual + timed: fichada \ No newline at end of file From 32d5ca0d5c3324d0e779239555ec5418f230962e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 13 Aug 2024 11:37:08 +0200 Subject: [PATCH 130/145] fix: refs #6861 refs#6861 bySectorCollection --- .../vn/procedures/itemShelvingSale_addBySectorCollection.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql index c359c7c8d..26e661d9a 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -12,7 +12,7 @@ BEGIN DECLARE vSaleFk INT; DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR - SELECT s.id + SELECT DISTINCT s.id FROM sectorCollectionSaleGroup sc JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk JOIN sale s ON sg.saleFk = s.id From d9f64dea086e56a5b897b16738a46b09646cbd69 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:15:30 +0200 Subject: [PATCH 131/145] fix: refs #7713 ACL Log --- db/routines/salix/triggers/ACL_afterDelete.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/salix/triggers/ACL_afterDelete.sql b/db/routines/salix/triggers/ACL_afterDelete.sql index 18689dfb0..b7e6071fc 100644 --- a/db/routines/salix/triggers/ACL_afterDelete.sql +++ b/db/routines/salix/triggers/ACL_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `salix`.`ACL_afterDelete` AFTER DELETE ON `ACL` FOR EACH ROW BEGIN - INSERT INTO ACL + INSERT INTO ACLLog SET `action` = 'delete', `changedModel` = 'Acl', `changedModelId` = OLD.id, From 38cf5af23ee3061f0fe935e065aa469ea46388bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:21:03 +0200 Subject: [PATCH 132/145] feat: refs #7842 Added editorFk in vn.host --- db/routines/vn/triggers/host_beforeInsert.sql | 8 ++++++++ db/routines/vn/triggers/host_beforeUpdate.sql | 1 + db/versions/11187-yellowErica/00-firstScript.sql | 1 + 3 files changed, 10 insertions(+) create mode 100644 db/routines/vn/triggers/host_beforeInsert.sql create mode 100644 db/versions/11187-yellowErica/00-firstScript.sql diff --git a/db/routines/vn/triggers/host_beforeInsert.sql b/db/routines/vn/triggers/host_beforeInsert.sql new file mode 100644 index 000000000..c2cb82334 --- /dev/null +++ b/db/routines/vn/triggers/host_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`host_beforeInsert` + BEFORE INSERT ON `host` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/host_beforeUpdate.sql b/db/routines/vn/triggers/host_beforeUpdate.sql index 0b0962e86..dc5a18f3c 100644 --- a/db/routines/vn/triggers/host_beforeUpdate.sql +++ b/db/routines/vn/triggers/host_beforeUpdate.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`host_beforeUpdate` FOR EACH ROW BEGIN SET new.updated = util.VN_NOW(); + SET NEW.editorFk = account.myUser_getId(); END$$ DELIMITER ; diff --git a/db/versions/11187-yellowErica/00-firstScript.sql b/db/versions/11187-yellowErica/00-firstScript.sql new file mode 100644 index 000000000..fb75b1f2f --- /dev/null +++ b/db/versions/11187-yellowErica/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.host ADD editorFk int(10) unsigned DEFAULT NULL NULL; From 360e20545ae927f67b1d6a7e62e2e7d081bf7a9d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:26:01 +0200 Subject: [PATCH 133/145] feat: refs #7799 Added Fk in vn.item.itemPackingTypeFk --- db/versions/11189-purplePaniculata/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11189-purplePaniculata/00-firstScript.sql diff --git a/db/versions/11189-purplePaniculata/00-firstScript.sql b/db/versions/11189-purplePaniculata/00-firstScript.sql new file mode 100644 index 000000000..3319bd154 --- /dev/null +++ b/db/versions/11189-purplePaniculata/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.item + ADD CONSTRAINT item_itemPackingType_FK FOREIGN KEY (itemPackingTypeFk) + REFERENCES vn.itemPackingType(code) ON DELETE RESTRICT ON UPDATE CASCADE; From 22ee4f18539bd5af31c5a1da49396ec5266472d7 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 13 Aug 2024 12:30:12 +0200 Subject: [PATCH 134/145] refactor: refs #7848 adapt to lilium --- back/models/vn-user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 6ec5642a2..531561e04 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -101,9 +101,10 @@ module.exports = function(Self) { const headers = httpRequest.headers; const origin = headers.origin; - const defaultHash = '/reset-password?access_token=$token$'; + const defaultHash = '!/reset-password?access_token=$token$'; const recoverHashes = { - hedera: 'verificationToken=$token$' + hedera: '!verificationToken=$token$', + lilium: '/resetPassword?access_token=$token$' }; const app = info.options?.app; @@ -115,7 +116,7 @@ module.exports = function(Self) { const params = { recipient: info.email, lang: user.lang, - url: origin + '/#!' + recoverHash + url: origin + '/#' + recoverHash }; const options = Object.assign({}, info.options); From ef1b4ef0a4a01558fc9047edd475f732fe426b24 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 13 Aug 2024 12:30:37 +0200 Subject: [PATCH 135/145] feat(update-user): refs #7848 add twoFactor --- back/methods/vn-user/update-user.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/back/methods/vn-user/update-user.js b/back/methods/vn-user/update-user.js index ddaae8548..202b01c65 100644 --- a/back/methods/vn-user/update-user.js +++ b/back/methods/vn-user/update-user.js @@ -24,6 +24,10 @@ module.exports = Self => { arg: 'lang', type: 'string', description: 'The user lang' + }, { + arg: 'twoFactor', + type: 'string', + description: 'The user twoFactor' } ], http: { @@ -32,8 +36,8 @@ module.exports = Self => { } }); - Self.updateUser = async(ctx, id, name, nickname, email, lang) => { + Self.updateUser = async(ctx, id, name, nickname, email, lang, twoFactor) => { await Self.userSecurity(ctx, id); - await Self.upsertWithWhere({id}, {name, nickname, email, lang}); + await Self.upsertWithWhere({id}, {name, nickname, email, lang, twoFactor}); }; }; From a178c285c06f154ee3c0698f0a2e4d6db54eb09c Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 13 Aug 2024 10:44:54 +0000 Subject: [PATCH 136/145] fix(salix): #7867 avoid deactivate user when is supplier --- db/routines/vn/procedures/client_userDisable.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/vn/procedures/client_userDisable.sql b/db/routines/vn/procedures/client_userDisable.sql index f2ba65c1c..da3c0efa1 100644 --- a/db/routines/vn/procedures/client_userDisable.sql +++ b/db/routines/vn/procedures/client_userDisable.sql @@ -21,6 +21,9 @@ BEGIN AND a.id IS NULL AND u.active AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND u.role NOT IN ( + SELECT id FROM `role` r WHERE r.name = 'supplier' + ) AND u.id NOT IN ( SELECT DISTINCT c.id FROM client c From dd5845abae6557774cc70a015e3e67ef23579006 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:49:56 +0200 Subject: [PATCH 137/145] fix: refs #7800 tpvMerchantEnable PRIMARY KEY --- db/versions/11190-blueLaurel/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11190-blueLaurel/00-firstScript.sql diff --git a/db/versions/11190-blueLaurel/00-firstScript.sql b/db/versions/11190-blueLaurel/00-firstScript.sql new file mode 100644 index 000000000..484b77ad8 --- /dev/null +++ b/db/versions/11190-blueLaurel/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE hedera.tpvMerchantEnable DROP FOREIGN KEY tpvMerchantEnable_ibfk_1; +ALTER TABLE hedera.tpvMerchantEnable DROP PRIMARY KEY; +ALTER TABLE hedera.tpvMerchantEnable + ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk); +ALTER TABLE hedera.tpvMerchantEnable + ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK FOREIGN KEY (merchantFk) REFERENCES hedera.tpvMerchant(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 68ee5e3549a55b7ec8d48a859d9533ef3377631b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Aug 2024 12:52:39 +0200 Subject: [PATCH 138/145] fix: refs #7800 tpvMerchantEnable PRIMARY KEY --- db/versions/11190-blueLaurel/00-firstScript.sql | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/db/versions/11190-blueLaurel/00-firstScript.sql b/db/versions/11190-blueLaurel/00-firstScript.sql index 484b77ad8..75e3f8e59 100644 --- a/db/versions/11190-blueLaurel/00-firstScript.sql +++ b/db/versions/11190-blueLaurel/00-firstScript.sql @@ -1,6 +1,9 @@ -ALTER TABLE hedera.tpvMerchantEnable DROP FOREIGN KEY tpvMerchantEnable_ibfk_1; -ALTER TABLE hedera.tpvMerchantEnable DROP PRIMARY KEY; ALTER TABLE hedera.tpvMerchantEnable - ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk); -ALTER TABLE hedera.tpvMerchantEnable - ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK FOREIGN KEY (merchantFk) REFERENCES hedera.tpvMerchant(id) ON DELETE RESTRICT ON UPDATE CASCADE; + DROP FOREIGN KEY tpvMerchantEnable_ibfk_1, + DROP PRIMARY KEY, + ADD CONSTRAINT tpvMerchantEnable_pk PRIMARY KEY (merchantFk), + ADD CONSTRAINT tpvMerchantEnable_tpvMerchant_FK + FOREIGN KEY (merchantFk) + REFERENCES hedera.tpvMerchant(id) + ON DELETE RESTRICT + ON UPDATE CASCADE; From befcf895342d6d8f57eb3bda53f0d2af9434e9ce Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 13 Aug 2024 11:18:23 +0000 Subject: [PATCH 139/145] fix(salix): #7867 apply SQL conventions --- db/routines/vn/procedures/client_userDisable.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/client_userDisable.sql b/db/routines/vn/procedures/client_userDisable.sql index da3c0efa1..779ffd688 100644 --- a/db/routines/vn/procedures/client_userDisable.sql +++ b/db/routines/vn/procedures/client_userDisable.sql @@ -21,9 +21,7 @@ BEGIN AND a.id IS NULL AND u.active AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH - AND u.role NOT IN ( - SELECT id FROM `role` r WHERE r.name = 'supplier' - ) + AND NOT u.role = (SELECT id FROM `role` WHERE name = 'supplier') AND u.id NOT IN ( SELECT DISTINCT c.id FROM client c From cf39e944f0802b3d5db5bc2e8ad8fad35b595a11 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 14 Aug 2024 11:00:17 +0200 Subject: [PATCH 140/145] feat: refs #7323 redirect to lilium --- front/salix/components/user-popover/index.html | 2 +- front/salix/components/user-popover/index.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/front/salix/components/user-popover/index.html b/front/salix/components/user-popover/index.html index 06a4af1e0..cedb3383b 100644 --- a/front/salix/components/user-popover/index.html +++ b/front/salix/components/user-popover/index.html @@ -38,7 +38,7 @@ My account diff --git a/front/salix/components/user-popover/index.js b/front/salix/components/user-popover/index.js index 1d88137ff..72cb734e9 100644 --- a/front/salix/components/user-popover/index.js +++ b/front/salix/components/user-popover/index.js @@ -82,6 +82,9 @@ class Controller { ? {id: $search} : {bank: {like: '%' + $search + '%'}}; } + async redirect(id) { + window.location.href = await this.vnConfig.vnApp.getUrl(`worker/${id}`); + } } Controller.$inject = ['$scope', '$translate', 'vnConfig', 'vnAuth', 'vnToken']; From 79923cc1d380592a56f9f5ee1fec8da80135a5c6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 14 Aug 2024 12:20:02 +0200 Subject: [PATCH 141/145] feat: refs #6900 drop section --- e2e/paths/09-invoice-in/01_summary.spec.js | 28 -- e2e/paths/09-invoice-in/02_descriptor.spec.js | 52 --- e2e/paths/09-invoice-in/03_basic_data.spec.js | 196 ----------- e2e/paths/09-invoice-in/04_tax.spec.js | 59 ---- e2e/paths/09-invoice-in/05_serial.spec.js | 48 --- modules/invoiceIn/front/basic-data/index.html | 315 ------------------ modules/invoiceIn/front/basic-data/index.js | 187 ----------- .../invoiceIn/front/basic-data/index.spec.js | 102 ------ .../invoiceIn/front/basic-data/locale/en.yml | 1 - .../invoiceIn/front/basic-data/locale/es.yml | 15 - modules/invoiceIn/front/create/index.html | 55 --- modules/invoiceIn/front/create/index.js | 30 -- modules/invoiceIn/front/create/locale/es.yml | 1 - modules/invoiceIn/front/dueDay/index.html | 71 ---- modules/invoiceIn/front/dueDay/index.js | 37 -- modules/invoiceIn/front/dueDay/index.spec.js | 44 --- modules/invoiceIn/front/index.js | 10 - modules/invoiceIn/front/index/index.html | 82 ----- modules/invoiceIn/front/index/index.js | 58 ---- modules/invoiceIn/front/index/locale/es.yml | 6 - modules/invoiceIn/front/intrastat/index.html | 100 ------ modules/invoiceIn/front/intrastat/index.js | 60 ---- .../invoiceIn/front/intrastat/index.spec.js | 85 ----- modules/invoiceIn/front/log/index.html | 1 - modules/invoiceIn/front/log/index.js | 7 - modules/invoiceIn/front/main/index.html | 18 - modules/invoiceIn/front/main/index.js | 11 +- .../invoiceIn/front/search-panel/index.html | 97 ------ modules/invoiceIn/front/search-panel/index.js | 7 - .../front/search-panel/locale/es.yml | 2 - .../front/serial-search-panel/index.html | 27 -- .../front/serial-search-panel/index.js | 44 --- .../front/serial-search-panel/index.spec.js | 43 --- .../front/serial-search-panel/style.scss | 24 -- modules/invoiceIn/front/serial/index.html | 40 --- modules/invoiceIn/front/serial/index.js | 22 -- modules/invoiceIn/front/serial/locale/es.yml | 3 - modules/invoiceIn/front/tax/index.html | 149 --------- modules/invoiceIn/front/tax/index.js | 66 ---- modules/invoiceIn/front/tax/index.spec.js | 113 ------- modules/invoiceIn/front/tax/locale/es.yml | 7 - 41 files changed, 10 insertions(+), 2313 deletions(-) delete mode 100644 e2e/paths/09-invoice-in/01_summary.spec.js delete mode 100644 e2e/paths/09-invoice-in/02_descriptor.spec.js delete mode 100644 e2e/paths/09-invoice-in/03_basic_data.spec.js delete mode 100644 e2e/paths/09-invoice-in/04_tax.spec.js delete mode 100644 e2e/paths/09-invoice-in/05_serial.spec.js delete mode 100644 modules/invoiceIn/front/basic-data/index.html delete mode 100644 modules/invoiceIn/front/basic-data/index.js delete mode 100644 modules/invoiceIn/front/basic-data/index.spec.js delete mode 100644 modules/invoiceIn/front/basic-data/locale/en.yml delete mode 100644 modules/invoiceIn/front/basic-data/locale/es.yml delete mode 100644 modules/invoiceIn/front/create/index.html delete mode 100644 modules/invoiceIn/front/create/index.js delete mode 100644 modules/invoiceIn/front/create/locale/es.yml delete mode 100644 modules/invoiceIn/front/dueDay/index.html delete mode 100644 modules/invoiceIn/front/dueDay/index.js delete mode 100644 modules/invoiceIn/front/dueDay/index.spec.js delete mode 100644 modules/invoiceIn/front/index/index.html delete mode 100644 modules/invoiceIn/front/index/index.js delete mode 100644 modules/invoiceIn/front/index/locale/es.yml delete mode 100644 modules/invoiceIn/front/intrastat/index.html delete mode 100644 modules/invoiceIn/front/intrastat/index.js delete mode 100644 modules/invoiceIn/front/intrastat/index.spec.js delete mode 100644 modules/invoiceIn/front/log/index.html delete mode 100644 modules/invoiceIn/front/log/index.js delete mode 100644 modules/invoiceIn/front/search-panel/index.html delete mode 100644 modules/invoiceIn/front/search-panel/index.js delete mode 100644 modules/invoiceIn/front/search-panel/locale/es.yml delete mode 100644 modules/invoiceIn/front/serial-search-panel/index.html delete mode 100644 modules/invoiceIn/front/serial-search-panel/index.js delete mode 100644 modules/invoiceIn/front/serial-search-panel/index.spec.js delete mode 100644 modules/invoiceIn/front/serial-search-panel/style.scss delete mode 100644 modules/invoiceIn/front/serial/index.html delete mode 100644 modules/invoiceIn/front/serial/index.js delete mode 100644 modules/invoiceIn/front/serial/locale/es.yml delete mode 100644 modules/invoiceIn/front/tax/index.html delete mode 100644 modules/invoiceIn/front/tax/index.js delete mode 100644 modules/invoiceIn/front/tax/index.spec.js delete mode 100644 modules/invoiceIn/front/tax/locale/es.yml diff --git a/e2e/paths/09-invoice-in/01_summary.spec.js b/e2e/paths/09-invoice-in/01_summary.spec.js deleted file mode 100644 index d5932efd0..000000000 --- a/e2e/paths/09-invoice-in/01_summary.spec.js +++ /dev/null @@ -1,28 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSearchResult('1'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the summary section', async() => { - await page.waitForState('invoiceIn.card.summary'); - }); - - it('should contain some basic data from the invoice', async() => { - const result = await page.waitToGetProperty(selectors.invoiceInSummary.supplierRef, 'innerText'); - - expect(result).toEqual('1234'); - }); -}); diff --git a/e2e/paths/09-invoice-in/02_descriptor.spec.js b/e2e/paths/09-invoice-in/02_descriptor.spec.js deleted file mode 100644 index 02bbce7ac..000000000 --- a/e2e/paths/09-invoice-in/02_descriptor.spec.js +++ /dev/null @@ -1,52 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSearchResult('10'); - await page.accessToSection('invoiceIn.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should clone the invoiceIn using the descriptor more menu', async() => { - await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); - await page.waitToClick(selectors.invoiceInDescriptor.moreMenuCloneInvoiceIn); - await page.waitToClick(selectors.invoiceInDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('InvoiceIn cloned'); - }); - - it('should have been redirected to the created invoiceIn summary', async() => { - await page.waitForState('invoiceIn.card.summary'); - }); - - it('should delete the cloned invoiceIn using the descriptor more menu', async() => { - await page.waitToClick(selectors.invoiceInDescriptor.moreMenu); - await page.waitToClick(selectors.invoiceInDescriptor.moreMenuDeleteInvoiceIn); - await page.waitToClick(selectors.invoiceInDescriptor.acceptButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('InvoiceIn deleted'); - }); - - it('should have been relocated to the invoiceOut index', async() => { - await page.waitForState('invoiceIn.index'); - }); - - it(`should search for the deleted invouceOut to find no results`, async() => { - await page.doSearch('10'); - const nResults = await page.countElement(selectors.invoiceOutIndex.searchResult); - - expect(nResults).toEqual(0); - }); -}); diff --git a/e2e/paths/09-invoice-in/03_basic_data.spec.js b/e2e/paths/09-invoice-in/03_basic_data.spec.js deleted file mode 100644 index 50fe18830..000000000 --- a/e2e/paths/09-invoice-in/03_basic_data.spec.js +++ /dev/null @@ -1,196 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn basic data path', () => { - let browser; - let page; - let newDms; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSearchResult('1'); - await page.accessToSection('invoiceIn.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should edit the invoiceIn basic data`, async() => { - const now = Date.vnNew(); - await page.pickDate(selectors.invoiceInBasicData.issued, now); - await page.pickDate(selectors.invoiceInBasicData.operated, now); - await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura'); - await page.clearInput(selectors.invoiceInBasicData.supplierRef); - await page.write(selectors.invoiceInBasicData.supplierRef, '9999'); - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.write(selectors.invoiceInBasicData.dms, '2'); - await page.pickDate(selectors.invoiceInBasicData.bookEntried, now); - await page.pickDate(selectors.invoiceInBasicData.booked, now); - await page.autocompleteSearch(selectors.invoiceInBasicData.currency, 'USD'); - await page.autocompleteSearch(selectors.invoiceInBasicData.company, 'ORN'); - await page.waitToClick(selectors.invoiceInBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the invoiceIn supplier was edited`, async() => { - await page.reloadSection('invoiceIn.card.basicData'); - const result = await page.waitToGetProperty(selectors.invoiceInBasicData.supplier, 'value'); - - expect(result).toContain('Verdnatura'); - }); - - it(`should confirm the invoiceIn supplierRef was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.supplierRef, 'value'); - - expect(result).toEqual('9999'); - }); - - it(`should confirm the invoiceIn currency was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.currency, 'value'); - - expect(result).toEqual('USD'); - }); - - it(`should confirm the invoiceIn company was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.company, 'value'); - - expect(result).toEqual('ORN'); - }); - - it(`should confirm the invoiceIn dms was edited`, async() => { - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.dms, 'value'); - - expect(result).toEqual('2'); - }); - - it(`should create a new invoiceIn dms and save the changes`, async() => { - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.waitToClick(selectors.invoiceInBasicData.create); - - await page.clearInput(selectors.invoiceInBasicData.reference); - await page.write(selectors.invoiceInBasicData.reference, 'New Dms'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - let message = await page.waitForSnackbar(); - - await page.clearInput(selectors.invoiceInBasicData.companyId); - await page.autocompleteSearch(selectors.invoiceInBasicData.companyId, 'VNL'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - await page.clearInput(selectors.invoiceInBasicData.warehouseId); - await page.autocompleteSearch(selectors.invoiceInBasicData.warehouseId, 'Warehouse One'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - await page.clearInput(selectors.invoiceInBasicData.dmsTypeId); - await page.autocompleteSearch(selectors.invoiceInBasicData.dmsTypeId, 'Ticket'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - await page.waitToClick(selectors.invoiceInBasicData.description); - await page.write(selectors.invoiceInBasicData.description, 'Dms without edition.'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('The files can\'t be empty'); - - let currentDir = process.cwd(); - let filePath = `${currentDir}/e2e/assets/thermograph.jpeg`; - - const [fileChooser] = await Promise.all([ - page.waitForFileChooser(), - page.waitToClick(selectors.invoiceInBasicData.inputFile) - ]); - await fileChooser.accept([filePath]); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - - newDms = await page - .waitToGetProperty(selectors.invoiceInBasicData.dms, 'value'); - }); - - it(`should confirm the invoiceIn was edited with the new dms`, async() => { - await page.reloadSection('invoiceIn.card.basicData'); - const result = await page - .waitToGetProperty(selectors.invoiceInBasicData.dms, 'value'); - - expect(result).toEqual(newDms); - }); - - it(`should edit the invoiceIn`, async() => { - await page.waitToClick(selectors.invoiceInBasicData.edit); - - await page.clearInput(selectors.invoiceInBasicData.reference); - await page.write(selectors.invoiceInBasicData.reference, 'Dms Edited'); - await page.clearInput(selectors.invoiceInBasicData.companyId); - await page.autocompleteSearch(selectors.invoiceInBasicData.companyId, 'CCs'); - await page.clearInput(selectors.invoiceInBasicData.warehouseId); - await page.autocompleteSearch(selectors.invoiceInBasicData.warehouseId, 'Algemesi'); - await page.clearInput(selectors.invoiceInBasicData.dmsTypeId); - await page.autocompleteSearch(selectors.invoiceInBasicData.dmsTypeId, 'Basura'); - await page.waitToClick(selectors.invoiceInBasicData.description); - await page.write(selectors.invoiceInBasicData.description, ' Nevermind, now is edited.'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - let message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the new dms has been edited`, async() => { - await page.reloadSection('invoiceIn.card.basicData'); - await page.waitToClick(selectors.invoiceInBasicData.edit); - - const reference = await page - .waitToGetProperty(selectors.invoiceInBasicData.reference, 'value'); - const companyId = await page - .waitToGetProperty(selectors.invoiceInBasicData.companyId, 'value'); - const warehouseId = await page - .waitToGetProperty(selectors.invoiceInBasicData.warehouseId, 'value'); - const dmsTypeId = await page - .waitToGetProperty(selectors.invoiceInBasicData.dmsTypeId, 'value'); - const description = await page - .waitToGetProperty(selectors.invoiceInBasicData.description, 'value'); - - expect(reference).toEqual('Dms Edited'); - expect(companyId).toEqual('CCs'); - expect(warehouseId).toEqual('Algemesi'); - expect(dmsTypeId).toEqual('Basura'); - expect(description).toEqual('Dms without edition. Nevermind, now is edited.'); - - await page.waitToClick(selectors.invoiceInBasicData.confirm); - }); - - it(`should disable edit and download if dms doesn't exists, and set back the original dms`, async() => { - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.write(selectors.invoiceInBasicData.dms, '9999'); - - await page.waitForSelector(`${selectors.invoiceInBasicData.download}.disabled`); - await page.waitForSelector(`${selectors.invoiceInBasicData.edit}.disabled`); - - await page.clearInput(selectors.invoiceInBasicData.dms); - await page.write(selectors.invoiceInBasicData.dms, '1'); - - await page.waitToClick(selectors.invoiceInBasicData.save); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/09-invoice-in/04_tax.spec.js b/e2e/paths/09-invoice-in/04_tax.spec.js deleted file mode 100644 index d51c39048..000000000 --- a/e2e/paths/09-invoice-in/04_tax.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn tax path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('developer', 'invoiceIn'); - await page.accessToSearchResult('2'); - await page.accessToSection('invoiceIn.card.tax'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should add a new tax and check it', async() => { - await page.waitToClick(selectors.invoiceInTax.addTaxButton); - await page.autocompleteSearch(selectors.invoiceInTax.thirdExpense, '6210000567'); - await page.write(selectors.invoiceInTax.thirdTaxableBase, '100'); - await page.autocompleteSearch(selectors.invoiceInTax.thirdTaxType, 'H.P. IVA'); - await page.autocompleteSearch(selectors.invoiceInTax.thirdTransactionType, 'Operaciones exentas'); - await page.waitToClick(selectors.invoiceInTax.saveButton); - const message = await page.waitForSnackbar(); - - await page.waitToClick(selectors.invoiceInDescriptor.summaryIcon); - await page.waitForState('invoiceIn.card.summary'); - const total = await page.waitToGetProperty(selectors.invoiceInSummary.totalTaxableBase, 'innerText'); - - await page.accessToSection('invoiceIn.card.tax'); - - const thirdExpense = await page.waitToGetProperty(selectors.invoiceInTax.thirdExpense, 'value'); - const thirdTaxableBase = await page.waitToGetProperty(selectors.invoiceInTax.thirdTaxableBase, 'value'); - const thirdTaxType = await page.waitToGetProperty(selectors.invoiceInTax.thirdTaxType, 'value'); - const thirdTransactionType = await page.waitToGetProperty(selectors.invoiceInTax.thirdTransactionType, 'value'); - const thirdRate = await page.waitToGetProperty(selectors.invoiceInTax.thirdRate, 'value'); - - expect(message.text).toContain('Data saved!'); - - expect(total).toEqual('Taxable base €1,323.16'); - - expect(thirdExpense).toEqual('6210000567'); - expect(thirdTaxableBase).toEqual('100'); - expect(thirdTaxType).toEqual('H.P. IVA 4% CEE'); - expect(thirdTransactionType).toEqual('Operaciones exentas'); - expect(thirdRate).toEqual('€4.00'); - }); - - it('should delete the added line', async() => { - await page.waitToClick(selectors.invoiceInTax.thirdDeleteButton); - await page.waitToClick(selectors.invoiceInTax.saveButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); -}); diff --git a/e2e/paths/09-invoice-in/05_serial.spec.js b/e2e/paths/09-invoice-in/05_serial.spec.js deleted file mode 100644 index 8be5660da..000000000 --- a/e2e/paths/09-invoice-in/05_serial.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('InvoiceIn serial path', () => { - let browser; - let page; - let httpRequest; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('administrative', 'invoiceIn'); - await page.accessToSection('invoiceIn.serial'); - page.on('request', req => { - if (req.url().includes(`InvoiceIns/getSerial`)) - httpRequest = req.url(); - }); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should check that passes the correct params to back', async() => { - await page.overwrite(selectors.invoiceInSerial.daysAgo, '30'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('daysAgo=30'); - - await page.overwrite(selectors.invoiceInSerial.serial, 'R'); - await page.keyboard.press('Enter'); - - expect(httpRequest).toContain('serial=R'); - await page.click(selectors.invoiceInSerial.chip); - }); - - it('should go to index and check if the search-panel has the correct params', async() => { - await page.waitToClick(selectors.invoiceInSerial.goToIndex); - const params = await page.$$(selectors.invoiceInIndex.topbarSearchParams); - const serial = await params[0].getProperty('title'); - const isBooked = await params[1].getProperty('title'); - const from = await params[2].getProperty('title'); - - expect(await serial.jsonValue()).toContain('serial'); - expect(await isBooked.jsonValue()).toContain('not isBooked'); - expect(await from.jsonValue()).toContain('from'); - }); -}); diff --git a/modules/invoiceIn/front/basic-data/index.html b/modules/invoiceIn/front/basic-data/index.html deleted file mode 100644 index fbb9b05a2..000000000 --- a/modules/invoiceIn/front/basic-data/index.html +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - -
- - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - - {{id}} - {{name}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/invoiceIn/front/basic-data/index.js b/modules/invoiceIn/front/basic-data/index.js deleted file mode 100644 index 246f1b16f..000000000 --- a/modules/invoiceIn/front/basic-data/index.js +++ /dev/null @@ -1,187 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $, vnFile) { - super($element, $, vnFile); - this.dms = { - files: [], - hasFile: false, - hasFileAttached: false - }; - this.vnFile = vnFile; - this.getAllowedContentTypes(); - this._editDownloadDisabled = false; - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - get editDownloadDisabled() { - return this._editDownloadDisabled; - } - - async checkFileExists(dmsId) { - if (!dmsId) return; - let filter = { - fields: ['id'] - }; - await this.$http.get(`Dms/${dmsId}`, {filter}) - .then(() => this._editDownloadDisabled = false) - .catch(() => this._editDownloadDisabled = true); - } - - async getFile(dmsId) { - const path = `Dms/${dmsId}`; - await this.$http.get(path).then(res => { - const dms = res.data && res.data; - this.dms = { - dmsId: dms.id, - reference: dms.reference, - warehouseId: dms.warehouseFk, - companyId: dms.companyFk, - dmsTypeId: dms.dmsTypeFk, - description: dms.description, - hasFile: dms.hasFile, - hasFileAttached: false, - files: [] - }; - }); - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - if (res.data.length > 0) { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - } - }); - } - - openEditDialog(dmsId) { - this.getFile(dmsId).then(() => this.$.dmsEditDialog.show()); - } - - openCreateDialog() { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - this.dms = { - reference: this.invoiceIn.supplierRef, - warehouseId: this.vnConfig.warehouseFk, - companyId: this.vnConfig.companyFk, - dmsTypeId: res.data.id, - description: this.invoiceIn.supplier.name, - hasFile: true, - hasFileAttached: true, - files: null - }; - this.$.dmsCreateDialog.show(); - }); - } - - downloadFile(dmsId) { - this.vnFile.download(`api/dms/${dmsId}/downloadFile`); - } - - onFileChange(files) { - let hasFileAttached = false; - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } - - onEdit() { - if (!this.dms.companyId) - throw new UserError(`The company can't be empty`); - if (!this.dms.warehouseId) - throw new UserError(`The warehouse can't be empty`); - if (!this.dms.dmsTypeId) - throw new UserError(`The DMS Type can't be empty`); - if (!this.dms.description) - throw new UserError(`The description can't be empty`); - - const query = `dms/${this.dms.dmsId}/updateFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - if (res.data.length > 0) this.invoiceIn.dmsFk = res.data[0].id; - } - }); - } - - onCreate() { - if (!this.dms.companyId) - throw new UserError(`The company can't be empty`); - if (!this.dms.warehouseId) - throw new UserError(`The warehouse can't be empty`); - if (!this.dms.dmsTypeId) - throw new UserError(`The DMS Type can't be empty`); - if (!this.dms.description) - throw new UserError(`The description can't be empty`); - if (!this.dms.files) - throw new UserError(`The files can't be empty`); - - const query = `Dms/uploadFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - - for (let i = 0; i < files.length; i++) - formData.append(files[i].name, files[i]); - - return formData; - }, - data: this.dms.files - }; - - this.$http(options).then(res => { - if (res) { - this.vnApp.showSuccess(this.$t('Data saved!')); - if (res.data.length > 0) this.invoiceIn.dmsFk = res.data[0].id; - } - }); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnInvoiceInBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/basic-data/index.spec.js b/modules/invoiceIn/front/basic-data/index.spec.js deleted file mode 100644 index 98710ac35..000000000 --- a/modules/invoiceIn/front/basic-data/index.spec.js +++ /dev/null @@ -1,102 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; - -describe('InvoiceIn', () => { - describe('Component vnInvoiceInBasicData', () => { - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnInvoiceInBasicData', {$element, $scope}); - controller.$.watcher = watcher; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond({}); - })); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - - describe('checkFileExists()', () => { - it(`should return false if a file exists`, () => { - const fileIdExists = 1; - controller.checkFileExists(fileIdExists); - - expect(controller.editDownloadDisabled).toBe(false); - }); - }); - - describe('onEdit()', () => { - it(`should perform a POST query to edit the dms properties`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const dms = { - dmsId: 1, - reference: 'Ref1', - warehouseId: 1, - companyId: 442, - dmsTypeId: 20, - description: 'This is a description', - files: [] - }; - - controller.dms = dms; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `dms/${controller.dms.dmsId}/updateFile?${serializedParams}`; - - $httpBackend.expectPOST(query).respond({}); - controller.onEdit(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('onCreate()', () => { - it(`should perform a POST query to create a new dms`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - - const dms = { - reference: 'Ref1', - warehouseId: 1, - companyId: 442, - dmsTypeId: 20, - description: 'This is a description', - files: [{ - lastModified: 1668673957761, - lastModifiedDate: Date.vnNew(), - name: 'file-example.png', - size: 19653, - type: 'image/png', - webkitRelativePath: '' - }] - }; - - controller.dms = dms; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `Dms/uploadFile?${serializedParams}`; - - $httpBackend.expectPOST(query).respond({}); - controller.onCreate(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - }); -}); - diff --git a/modules/invoiceIn/front/basic-data/locale/en.yml b/modules/invoiceIn/front/basic-data/locale/en.yml deleted file mode 100644 index 19f4dc8c2..000000000 --- a/modules/invoiceIn/front/basic-data/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -ContentTypesInfo: Allowed file types {{allowedContentTypes}} diff --git a/modules/invoiceIn/front/basic-data/locale/es.yml b/modules/invoiceIn/front/basic-data/locale/es.yml deleted file mode 100644 index e2e494fa5..000000000 --- a/modules/invoiceIn/front/basic-data/locale/es.yml +++ /dev/null @@ -1,15 +0,0 @@ -Upload file: Subir fichero -Edit file: Editar fichero -Upload: Subir -Document: Documento -ContentTypesInfo: "Tipos de archivo permitidos: {{allowedContentTypes}}" -Generate identifier for original file: Generar identificador para archivo original -File management: Gestión documental -Hard copy: Copia -This file will be deleted: Este fichero va a ser borrado -Are you sure?: Estas seguro? -File deleted: Fichero eliminado -Remove file: Eliminar fichero -Download file: Descargar fichero -Edit document: Editar documento -Create document: Crear documento diff --git a/modules/invoiceIn/front/create/index.html b/modules/invoiceIn/front/create/index.html deleted file mode 100644 index 16ecf26cf..000000000 --- a/modules/invoiceIn/front/create/index.html +++ /dev/null @@ -1,55 +0,0 @@ - - -
-
- - - {{id}}: {{nif}}: {{name}} - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/invoiceIn/front/create/index.js b/modules/invoiceIn/front/create/index.js deleted file mode 100644 index 885d55359..000000000 --- a/modules/invoiceIn/front/create/index.js +++ /dev/null @@ -1,30 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - $onInit() { - this.invoiceIn = {}; - if (this.$params && this.$params.supplierFk) - this.invoiceIn.supplierFk = this.$params.supplierFk; - this.invoiceIn.issued = Date.vnNew(); - } - - get companyFk() { - return this.invoiceIn.companyFk || this.vnConfig.companyFk; - } - - set companyFk(value) { - this.invoiceIn.companyFk = value; - } - - onSubmit() { - this.$.watcher.submit().then( - res => this.$state.go('invoiceIn.card.basicData', {id: res.data.id}) - ); - } -} - -ngModule.vnComponent('vnInvoiceInCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceIn/front/create/locale/es.yml b/modules/invoiceIn/front/create/locale/es.yml deleted file mode 100644 index 35bfe3ca4..000000000 --- a/modules/invoiceIn/front/create/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -a:a \ No newline at end of file diff --git a/modules/invoiceIn/front/dueDay/index.html b/modules/invoiceIn/front/dueDay/index.html deleted file mode 100644 index abc91312d..000000000 --- a/modules/invoiceIn/front/dueDay/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - -
- - - - - - {{id}}: {{bank}} - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js deleted file mode 100644 index ee9b13e5c..000000000 --- a/modules/invoiceIn/front/dueDay/index.js +++ /dev/null @@ -1,37 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - add() { - this.$.model.insert({ - dueDated: Date.vnNew(), - bankFk: this.vnConfig.local.bankFk - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.card.reload(); - }); - } - - bankSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {bank: {like: '%' + $search + '%'}}; - } -} - -ngModule.vnComponent('vnInvoiceInDueDay', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnInvoiceInCard' - }, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/dueDay/index.spec.js b/modules/invoiceIn/front/dueDay/index.spec.js deleted file mode 100644 index 7dddd3bb0..000000000 --- a/modules/invoiceIn/front/dueDay/index.spec.js +++ /dev/null @@ -1,44 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('InvoiceIn', () => { - describe('Component due day', () => { - let controller; - let $scope; - let vnApp; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _vnApp_) => { - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - const $element = angular.element(''); - controller = $componentController('vnInvoiceInDueDay', {$element, $scope}); - controller.invoiceIn = {id: 1}; - })); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save due day values', () => { - controller.card = {reload: () => {}}; - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn(controller.card, 'reload'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/invoiceIn/front/index.js b/modules/invoiceIn/front/index.js index e257cfee3..8155e7089 100644 --- a/modules/invoiceIn/front/index.js +++ b/modules/invoiceIn/front/index.js @@ -1,17 +1,7 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; import './card'; import './descriptor'; import './descriptor-popover'; import './summary'; -import './basic-data'; -import './tax'; -import './dueDay'; -import './intrastat'; -import './create'; -import './log'; -import './serial'; -import './serial-search-panel'; diff --git a/modules/invoiceIn/front/index/index.html b/modules/invoiceIn/front/index/index.html deleted file mode 100644 index 008d615b1..000000000 --- a/modules/invoiceIn/front/index/index.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - ID - Supplier - Supplier ref. - Serial number - Serial - File - Issued - Is booked - AWB - Amount - - - - -
- {{::invoiceIn.id}} - - - {{::invoiceIn.supplierName}} - - - {{::invoiceIn.supplierRef | dashIfEmpty}} - {{::invoiceIn.serialNumber}} - {{::invoiceIn.serial}} - - - {{::invoiceIn.file}} - - - {{::invoiceIn.issued | date:'dd/MM/yyyy' | dashIfEmpty}} - - - - - {{::invoiceIn.awbCode}} - {{::invoiceIn.amount | currency:'EUR'}} - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/modules/invoiceIn/front/index/index.js b/modules/invoiceIn/front/index/index.js deleted file mode 100644 index 254e6d3bf..000000000 --- a/modules/invoiceIn/front/index/index.js +++ /dev/null @@ -1,58 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $, vnFile) { - super($element, $, vnFile); - this.vnFile = vnFile; - } - - exprBuilder(param, value) { - switch (param) { - case 'issued': - return {'ii.issued': { - between: this.dateRange(value)} - }; - case 'id': - case 'supplierFk': - case 'supplierRef': - case 'serialNumber': - case 'serial': - case 'created': - case 'isBooked': - return {[`ii.${param}`]: value}; - case 'account': - case 'fi': - return {[`s.${param}`]: value}; - case 'awbCode': - return {'awb.code': value}; - default: - return {[param]: value}; - } - } - - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - - preview(invoiceIn) { - this.selectedInvoiceIn = invoiceIn; - this.$.summary.show(); - } - - downloadFile(dmsId) { - this.vnFile.download(`api/dms/${dmsId}/downloadFile`); - } -} - -Controller.$inject = ['$element', '$scope', 'vnFile']; - -ngModule.vnComponent('vnInvoiceInIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceIn/front/index/locale/es.yml b/modules/invoiceIn/front/index/locale/es.yml deleted file mode 100644 index e1b354316..000000000 --- a/modules/invoiceIn/front/index/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -Created: Fecha creación -Issued: Fecha emisión -Supplier ref.: Ref. proveedor -Serial number: Num. serie -Serial: Serie -Is booked: Conciliada \ No newline at end of file diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html deleted file mode 100644 index b15fdf543..000000000 --- a/modules/invoiceIn/front/intrastat/index.html +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - -
- - - - {{id}}: {{description}} - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/invoiceIn/front/intrastat/index.js b/modules/invoiceIn/front/intrastat/index.js deleted file mode 100644 index 659929513..000000000 --- a/modules/invoiceIn/front/intrastat/index.js +++ /dev/null @@ -1,60 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - set invoceInIntrastat(value) { - this._invoceInIntrastat = value; - - if (value) this.calculateTotals(); - } - - get invoceInIntrastat() { - return this._invoceInIntrastat; - } - - calculateTotals() { - this.amountTotal = 0.0; - this.netTotal = 0.0; - this.stemsTotal = 0.0; - if (!this.invoceInIntrastat) return; - - this.invoceInIntrastat.forEach(intrastat => { - this.amountTotal += intrastat.amount; - this.netTotal += intrastat.net; - this.stemsTotal += intrastat.stems; - }); - } - - add() { - this.$.model.insert({}); - } - - deleteIntrastat($index) { - this.$.model.remove($index); - this.$.model.save().then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.calculateTotals(); - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.calculateTotals(); - this.card.reload(); - }); - } -} - -ngModule.vnComponent('vnInvoiceInIntrastat', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnInvoiceInCard' - }, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/intrastat/index.spec.js b/modules/invoiceIn/front/intrastat/index.spec.js deleted file mode 100644 index d7d50ac5b..000000000 --- a/modules/invoiceIn/front/intrastat/index.spec.js +++ /dev/null @@ -1,85 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('InvoiceIn', () => { - describe('Component intrastat', () => { - let controller; - let $scope; - let vnApp; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _vnApp_) => { - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - const $element = angular.element(''); - controller = $componentController('vnInvoiceInIntrastat', {$element, $scope}); - controller.invoiceIn = {id: 1}; - })); - - describe('calculateTotals()', () => { - it('should set amountTotal, netTotal and stemsTotal to 0 if salesClaimed has no data', () => { - controller.invoceInIntrastat = []; - controller.calculateTotals(); - - expect(controller.amountTotal).toEqual(0); - expect(controller.netTotal).toEqual(0); - expect(controller.stemsTotal).toEqual(0); - }); - - it('should set amountTotal, netTotal and stemsTotal', () => { - controller.invoceInIntrastat = [ - { - id: 1, - invoiceInFk: 1, - net: 30.5, - intrastatFk: 5080000, - amount: 10, - stems: 162, - countryFk: 5, - statisticalValue: 0 - }, - { - id: 2, - invoiceInFk: 1, - net: 10, - intrastatFk: 6021010, - amount: 20, - stems: 205, - countryFk: 5, - statisticalValue: 0 - } - ]; - controller.calculateTotals(); - - expect(controller.amountTotal).toEqual(30); - expect(controller.netTotal).toEqual(40.5); - expect(controller.stemsTotal).toEqual(367); - }); - }); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save intrastat values', () => { - controller.card = {reload: () => {}}; - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn(controller.card, 'reload'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - }); -}); diff --git a/modules/invoiceIn/front/log/index.html b/modules/invoiceIn/front/log/index.html deleted file mode 100644 index 2cfc9dfb1..000000000 --- a/modules/invoiceIn/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/invoiceIn/front/log/index.js b/modules/invoiceIn/front/log/index.js deleted file mode 100644 index 7a018de0f..000000000 --- a/modules/invoiceIn/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnInvoiceInLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/invoiceIn/front/main/index.html b/modules/invoiceIn/front/main/index.html index 2dc87b2ee..e69de29bb 100644 --- a/modules/invoiceIn/front/main/index.html +++ b/modules/invoiceIn/front/main/index.html @@ -1,18 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/modules/invoiceIn/front/main/index.js b/modules/invoiceIn/front/main/index.js index f7b767458..c22b37924 100644 --- a/modules/invoiceIn/front/main/index.js +++ b/modules/invoiceIn/front/main/index.js @@ -1,7 +1,16 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class InvoiceIn extends ModuleMain {} +export default class InvoiceIn extends ModuleMain { + constructor($element, $) { + super($element, $); + } + + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`invoice-in/`); + } +} ngModule.vnComponent('vnInvoiceIn', { controller: InvoiceIn, diff --git a/modules/invoiceIn/front/search-panel/index.html b/modules/invoiceIn/front/search-panel/index.html deleted file mode 100644 index 609fa56d8..000000000 --- a/modules/invoiceIn/front/search-panel/index.html +++ /dev/null @@ -1,97 +0,0 @@ -
-
- - - - - - - - - - - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/invoiceIn/front/search-panel/index.js b/modules/invoiceIn/front/search-panel/index.js deleted file mode 100644 index a8e41b7ef..000000000 --- a/modules/invoiceIn/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnInvoiceInSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/invoiceIn/front/search-panel/locale/es.yml b/modules/invoiceIn/front/search-panel/locale/es.yml deleted file mode 100644 index 57e2944ea..000000000 --- a/modules/invoiceIn/front/search-panel/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Supplier fiscal id: CIF proveedor -Search invoices in by id or supplier fiscal name: Buscar facturas recibidas por id o por nombre fiscal del proveedor \ No newline at end of file diff --git a/modules/invoiceIn/front/serial-search-panel/index.html b/modules/invoiceIn/front/serial-search-panel/index.html deleted file mode 100644 index 0dda54852..000000000 --- a/modules/invoiceIn/front/serial-search-panel/index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - -
- - {{$ctrl.$t('Serial')}}: {{$ctrl.filter.serial}} - -
-
diff --git a/modules/invoiceIn/front/serial-search-panel/index.js b/modules/invoiceIn/front/serial-search-panel/index.js deleted file mode 100644 index b11911ee3..000000000 --- a/modules/invoiceIn/front/serial-search-panel/index.js +++ /dev/null @@ -1,44 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; -import './style.scss'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - this.filter = {}; - const filter = { - fields: ['daysAgo'] - }; - this.$http.get('InvoiceInConfigs', {filter}).then(res => { - if (res.data) { - this.invoiceInConfig = res.data[0]; - this.addFilters(); - } - }); - } - - removeItemFilter(param) { - this.filter[param] = null; - this.addFilters(); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.addFilters(); - } - - addFilters() { - if (!this.filter.daysAgo) - this.filter.daysAgo = this.invoiceInConfig.daysAgo; - - return this.model.addFilter({}, this.filter); - } -} - -ngModule.component('vnInvoiceInSerialSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - model: '<' - } -}); diff --git a/modules/invoiceIn/front/serial-search-panel/index.spec.js b/modules/invoiceIn/front/serial-search-panel/index.spec.js deleted file mode 100644 index b5228e126..000000000 --- a/modules/invoiceIn/front/serial-search-panel/index.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import './index.js'; - -describe('InvoiceIn', () => { - describe('Component serial-search-panel', () => { - let controller; - let $scope; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnInvoiceInSerialSearchPanel', {$element, $scope}); - controller.model = { - addFilter: jest.fn(), - }; - controller.invoiceInConfig = { - daysAgo: 45, - }; - })); - - describe('addFilters()', () => { - it('should add default daysAgo if it is not already set', () => { - controller.filter = { - serial: 'R', - }; - controller.addFilters(); - - expect(controller.filter.daysAgo).toEqual(controller.invoiceInConfig.daysAgo); - }); - - it('should not add default daysAgo if it is already set', () => { - controller.filter = { - daysAgo: 1, - serial: 'R', - }; - controller.addFilters(); - - expect(controller.filter.daysAgo).toEqual(1); - }); - }); - }); -}); diff --git a/modules/invoiceIn/front/serial-search-panel/style.scss b/modules/invoiceIn/front/serial-search-panel/style.scss deleted file mode 100644 index 4abfcbfa2..000000000 --- a/modules/invoiceIn/front/serial-search-panel/style.scss +++ /dev/null @@ -1,24 +0,0 @@ -@import "variables"; - -vn-invoice-in-serial-search-panel vn-side-menu div { - & > .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - & > .horizontal { - grid-auto-flow: column; - grid-column-gap: $spacing-sm; - align-items: center; - } - & > .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - border-color: $color-spacer; - border-top: $border-thin; - } -} diff --git a/modules/invoiceIn/front/serial/index.html b/modules/invoiceIn/front/serial/index.html deleted file mode 100644 index 1649ec7d7..000000000 --- a/modules/invoiceIn/front/serial/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - Serial - Pending - Total - - - - - - {{::invoiceIn.serial}} - {{::invoiceIn.pending}} - {{::invoiceIn.total}} - - - - - - - - - diff --git a/modules/invoiceIn/front/serial/index.js b/modules/invoiceIn/front/serial/index.js deleted file mode 100644 index 193a57492..000000000 --- a/modules/invoiceIn/front/serial/index.js +++ /dev/null @@ -1,22 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - } - - goToIndex(daysAgo, serial) { - const issued = Date.vnNew(); - issued.setDate(issued.getDate() - daysAgo); - this.$state.go('invoiceIn.index', - {q: `{"serial": "${serial}", "isBooked": false, "from": ${issued.getTime()}}`}); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnInvoiceInSerial', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/invoiceIn/front/serial/locale/es.yml b/modules/invoiceIn/front/serial/locale/es.yml deleted file mode 100644 index 92a49cc82..000000000 --- a/modules/invoiceIn/front/serial/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Serial: Serie -Pending: Pendientes -Go to InvoiceIn: Ir al listado de facturas recibidas diff --git a/modules/invoiceIn/front/tax/index.html b/modules/invoiceIn/front/tax/index.html deleted file mode 100644 index e13f769ce..000000000 --- a/modules/invoiceIn/front/tax/index.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - -
- - - - {{id}}: {{name}} - - - - - - - - - -
{{::vat}}
-
#{{::id}}
-
-
- - -
{{::transaction}}
-
#{{::id}}
-
-
- - - - - - - - -
- - - - -
- - - - -
- - - - -
-
{{$ctrl.$t('New expense')}}
- - - - - - - - - - -
-
- - - - -
diff --git a/modules/invoiceIn/front/tax/index.js b/modules/invoiceIn/front/tax/index.js deleted file mode 100644 index d05a77f29..000000000 --- a/modules/invoiceIn/front/tax/index.js +++ /dev/null @@ -1,66 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $, vnWeekDays) { - super($element, $); - this.expense = {}; - } - taxRate(invoiceInTax, taxRateSelection) { - const taxTypeSage = taxRateSelection && taxRateSelection.rate; - const taxableBase = invoiceInTax && invoiceInTax.taxableBase; - - if (taxTypeSage && taxableBase) - return (taxTypeSage / 100) * taxableBase; - - return 0; - } - - add() { - this.$.model.insert({ - invoiceIn: this.$params.id - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.card.reload(); - }); - } - - onResponse() { - try { - if (!this.expense.code) - throw new Error(`The code can't be empty`); - if (!this.expense.description) - throw new UserError(`The description can't be empty`); - - const data = [{ - id: this.expense.code, - isWithheld: this.expense.isWithheld, - name: this.expense.description - }]; - - this.$http.post(`Expenses`, data) .then(() => { - this.vnApp.showSuccess(this.$t('Expense saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } -} - -ngModule.vnComponent('vnInvoiceInTax', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnInvoiceInCard' - }, - bindings: { - invoiceIn: '<' - } -}); diff --git a/modules/invoiceIn/front/tax/index.spec.js b/modules/invoiceIn/front/tax/index.spec.js deleted file mode 100644 index 52114afe5..000000000 --- a/modules/invoiceIn/front/tax/index.spec.js +++ /dev/null @@ -1,113 +0,0 @@ -import './index.js'; -import watcher from 'core/mocks/watcher'; -import crudModel from 'core/mocks/crud-model'; - -describe('InvoiceIn', () => { - describe('Component tax', () => { - let controller; - let $scope; - let vnApp; - let $httpBackend; - - beforeEach(ngModule('invoiceIn')); - - beforeEach(inject(($componentController, $rootScope, _vnApp_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - vnApp = _vnApp_; - jest.spyOn(vnApp, 'showError'); - $scope = $rootScope.$new(); - $scope.model = crudModel; - $scope.watcher = watcher; - - const $element = angular.element(''); - controller = $componentController('vnInvoiceInTax', {$element, $scope}); - controller.$.model = crudModel; - controller.invoiceIn = {id: 1}; - })); - - describe('taxRate()', () => { - it('should set tax rate with the Sage tax type value', () => { - const taxRateSelection = { - rate: 21 - }; - const invoiceInTax = { - taxableBase: 200 - }; - - const taxRate = controller.taxRate(invoiceInTax, taxRateSelection); - - expect(taxRate).toEqual(42); - }); - }); - - describe('onSubmit()', () => { - it('should make HTTP POST request to save tax values', () => { - controller.card = {reload: () => {}}; - jest.spyOn($scope.watcher, 'check'); - jest.spyOn($scope.watcher, 'notifySaved'); - jest.spyOn($scope.watcher, 'updateOriginalData'); - jest.spyOn(controller.card, 'reload'); - jest.spyOn($scope.model, 'save'); - - controller.onSubmit(); - - expect($scope.model.save).toHaveBeenCalledWith(); - expect($scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect($scope.watcher.check).toHaveBeenCalledWith(); - expect($scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - - describe('onResponse()', () => { - it('should return success message', () => { - controller.expense = { - code: 7050000005, - isWithheld: 0, - description: 'Test' - }; - - const data = [{ - id: controller.expense.code, - isWithheld: controller.expense.isWithheld, - name: controller.expense.description - }]; - - jest.spyOn(controller.vnApp, 'showSuccess'); - $httpBackend.expect('POST', `Expenses`, data).respond(); - - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Expense saved!'); - }); - - it('should return an error if code is empty', () => { - controller.expense = { - code: null, - isWithheld: 0, - description: 'Test' - }; - - jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The code can't be empty`); - }); - - it('should return an error if description is empty', () => { - controller.expense = { - code: 7050000005, - isWithheld: 0, - description: null - }; - - jest.spyOn(controller.vnApp, 'showError'); - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The description can't be empty`); - }); - }); - }); -}); - diff --git a/modules/invoiceIn/front/tax/locale/es.yml b/modules/invoiceIn/front/tax/locale/es.yml deleted file mode 100644 index 3ff68ea40..000000000 --- a/modules/invoiceIn/front/tax/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Create expense: Crear gasto -New expense: Nuevo gasto -It's a withholding: Es una retención -The fields can't be empty: Los campos no pueden estar vacíos -The code can't be empty: El código no puede estar vacío -The description can't be empty: La descripción no puede estar vacía -Expense saved!: Gasto guardado! \ No newline at end of file From 3ee377156b173b6f41d19c9519a12c64d853b165 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 14 Aug 2024 12:38:38 +0200 Subject: [PATCH 142/145] fix: refs #7355 remove and tests accounts --- .../front/descriptor-popover/index.html | 4 + .../account/front/descriptor-popover/index.js | 9 + modules/account/front/descriptor/index.html | 192 ++++++++++++++++++ modules/account/front/descriptor/index.js | 145 +++++++++++++ .../account/front/descriptor/locale/es.yml | 35 ++++ modules/account/front/index.js | 3 + modules/account/front/summary/index.html | 40 ++++ modules/account/front/summary/index.js | 40 ++++ 8 files changed, 468 insertions(+) create mode 100644 modules/account/front/descriptor-popover/index.html create mode 100644 modules/account/front/descriptor-popover/index.js create mode 100644 modules/account/front/descriptor/index.html create mode 100644 modules/account/front/descriptor/index.js create mode 100644 modules/account/front/descriptor/locale/es.yml create mode 100644 modules/account/front/summary/index.html create mode 100644 modules/account/front/summary/index.js diff --git a/modules/account/front/descriptor-popover/index.html b/modules/account/front/descriptor-popover/index.html new file mode 100644 index 000000000..f3131a84b --- /dev/null +++ b/modules/account/front/descriptor-popover/index.html @@ -0,0 +1,4 @@ + + + + diff --git a/modules/account/front/descriptor-popover/index.js b/modules/account/front/descriptor-popover/index.js new file mode 100644 index 000000000..d7b052473 --- /dev/null +++ b/modules/account/front/descriptor-popover/index.js @@ -0,0 +1,9 @@ +import ngModule from '../module'; +import DescriptorPopover from 'salix/components/descriptor-popover'; + +class Controller extends DescriptorPopover {} + +ngModule.vnComponent('vnAccountDescriptorPopover', { + slotTemplate: require('./index.html'), + controller: Controller +}); diff --git a/modules/account/front/descriptor/index.html b/modules/account/front/descriptor/index.html new file mode 100644 index 000000000..86e78dfce --- /dev/null +++ b/modules/account/front/descriptor/index.html @@ -0,0 +1,192 @@ + + + + + + + Delete + + + Change password + + + Set password + + + Enable account + + + Disable account + + + Activate user + + + Deactivate user + + + Synchronize + + + +
+ + + + +
+
+ + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + Do you want to synchronize user? + + + + + + + + + + + + + + + diff --git a/modules/account/front/descriptor/index.js b/modules/account/front/descriptor/index.js new file mode 100644 index 000000000..de41d619d --- /dev/null +++ b/modules/account/front/descriptor/index.js @@ -0,0 +1,145 @@ +import ngModule from '../module'; +import Descriptor from 'salix/components/descriptor'; +import UserError from 'core/lib/user-error'; + +class Controller extends Descriptor { + get user() { + return this.entity; + } + + set user(value) { + this.entity = value; + } + + get entity() { + return super.entity; + } + + set entity(value) { + super.entity = value; + this.hasAccount = null; + if (!value) return; + + this.$http.get(`Accounts/${value.id}/exists`) + .then(res => this.hasAccount = res.data.exists); + } + + loadData() { + const filter = { + where: {id: this.$params.id}, + include: { + relation: 'role', + scope: { + fields: ['id', 'name'] + } + } + }; + + return Promise.all([ + this.$http.get(`VnUsers/preview`, {filter}) + .then(res => { + const [user] = res.data; + this.user = user; + }), + this.$http.get(`Accounts/${this.$params.id}/exists`) + .then(res => this.hasAccount = res.data.exists) + ]); + } + + onDelete() { + return this.$http.delete(`VnUsers/${this.id}`) + .then(() => this.$state.go('account.index')) + .then(() => this.vnApp.showSuccess(this.$t('User removed'))); + } + + onChangePassClick(askOldPass) { + this.$http.get('UserPasswords/findOne') + .then(res => { + this.passRequirements = res.data; + this.askOldPass = askOldPass; + this.$.changePass.show(); + }); + } + + onPassChange() { + if (!this.newPassword) + throw new UserError(`You must enter a new password`); + if (this.newPassword != this.repeatPassword) + throw new UserError(`Passwords don't match`); + + let method; + const params = {newPassword: this.newPassword}; + + if (this.askOldPass) { + method = 'change-password'; + params.oldPassword = this.oldPassword; + } else + method = 'setPassword'; + + return this.$http.patch(`Accounts/${this.id}/${method}`, params) + .then(() => { + this.emit('change'); + this.vnApp.showSuccess(this.$t('Password changed succesfully!')); + }); + } + + onPassClose() { + this.oldPassword = ''; + this.newPassword = ''; + this.repeatPassword = ''; + this.$.$apply(); + } + + onEnableAccount() { + return this.$http.post(`Accounts`, {id: this.id}) + .then(() => this.onSwitchAccount(true)); + } + + onDisableAccount() { + return this.$http.delete(`Accounts/${this.id}`) + .then(() => this.onSwitchAccount(false)); + } + + onSwitchAccount(enable) { + this.hasAccount = enable; + const message = enable + ? 'Account enabled!' + : 'Account disabled!'; + this.emit('change'); + this.vnApp.showSuccess(this.$t(message)); + } + + onSetActive(active) { + return this.$http.patch(`VnUsers/${this.id}`, {active}) + .then(() => { + this.user.active = active; + const message = active + ? 'User activated!' + : 'User deactivated!'; + this.emit('change'); + this.vnApp.showSuccess(this.$t(message)); + }); + } + + onSync() { + const params = {force: true}; + if (this.shouldSyncPassword) + params.password = this.syncPassword; + + return this.$http.patch(`Accounts/${this.user.name}/sync`, params) + .then(() => this.vnApp.showSuccess(this.$t('User synchronized!'))); + } + + onSyncClose() { + this.shouldSyncPassword = false; + this.syncPassword = undefined; + } +} + +ngModule.component('vnUserDescriptor', { + template: require('./index.html'), + controller: Controller, + bindings: { + user: '<' + } +}); diff --git a/modules/account/front/descriptor/locale/es.yml b/modules/account/front/descriptor/locale/es.yml new file mode 100644 index 000000000..98ced7694 --- /dev/null +++ b/modules/account/front/descriptor/locale/es.yml @@ -0,0 +1,35 @@ +User will be removed: El usuario será eliminado +User removed: Usuario eliminado +Are you sure you want to continue?: ¿Seguro que quieres continuar? +Account will be enabled: La cuenta será habilitada +Account will be disabled: La cuenta será deshabilitada +Account enabled!: ¡Cuenta habilitada! +Account disabled!: ¡Cuenta deshabilitada! +User will activated: El usuario será activado +User will be deactivated: El usuario será desactivado +User activated!: ¡Usuario activado! +User deactivated!: ¡Usuario desactivado! +Account enabled: Cuenta habilitada +User deactivated: Usuario desactivado +Change role: Modificar rol +Change password: Cambiar contraseña +Set password: Establecer contraseña +Enable account: Habilitar cuenta +Disable account: Deshabilitar cuenta +Activate user: Activar usuario +Deactivate user: Desactivar usuario +Old password: Contraseña antigua +New password: Nueva contraseña +Repeat password: Repetir contraseña +Password changed succesfully!: ¡Contraseña modificada correctamente! +Synchronize: Sincronizar +Do you want to synchronize user?: ¿Quieres sincronizar el usuario? +Synchronize password: Sincronizar contraseña +User synchronized!: ¡Usuario sincronizado! +Role changed succesfully!: ¡Rol modificado correctamente! +Password requirements: > + La contraseña debe tener al menos {{ length }} caracteres de longitud, + {{nAlpha}} caracteres alfabéticos, {{nUpper}} letras mayúsculas, {{nDigits}} + dígitos y {{nPunct}} símbolos (Ej: $%&.) +You must enter a new password: Debes introducir la nueva contraseña +Passwords don't match: Las contraseñas no coinciden diff --git a/modules/account/front/index.js b/modules/account/front/index.js index a7209a0bd..0f2208862 100644 --- a/modules/account/front/index.js +++ b/modules/account/front/index.js @@ -1,3 +1,6 @@ export * from './module'; import './main'; +import './descriptor'; +import './descriptor-popover'; +import './summary'; diff --git a/modules/account/front/summary/index.html b/modules/account/front/summary/index.html new file mode 100644 index 000000000..f3c11f25f --- /dev/null +++ b/modules/account/front/summary/index.html @@ -0,0 +1,40 @@ + +
+ + + + {{summary.id}} - {{summary.nickname}} +
+ + +

+ + Basic Data + +

+

+ Basic Data +

+ + + + + + +
+
+
diff --git a/modules/account/front/summary/index.js b/modules/account/front/summary/index.js new file mode 100644 index 000000000..53b66dbe2 --- /dev/null +++ b/modules/account/front/summary/index.js @@ -0,0 +1,40 @@ +import ngModule from '../module'; +import Summary from 'salix/components/summary'; + +class Controller extends Summary { + set user(value) { + this._user = value; + this.$.summary = null; + if (!value) return; + + const filter = { + where: {id: value.id}, + include: { + relation: 'role', + scope: { + fields: ['id', 'name'] + } + } + }; + this.$http.get(`VnUsers/preview`, {filter}) + .then(res => { + const [summary] = res.data; + this.$.summary = summary; + }); + } + get isHr() { + return this.aclService.hasAny(['hr']); + } + + get user() { + return this._user; + } +} + +ngModule.component('vnUserSummary', { + template: require('./index.html'), + controller: Controller, + bindings: { + user: '<' + } +}); From b268bf5eb76ef9bd4681ca5a1985194aa4929d59 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 14 Aug 2024 12:47:44 +0200 Subject: [PATCH 143/145] feat: refs #7811 Added autorestart param pm2 --- back/process.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/back/process.yml b/back/process.yml index 08fee7a93..94072b57d 100644 --- a/back/process.yml +++ b/back/process.yml @@ -3,4 +3,5 @@ apps: name: salix-back instances: 1 max_restarts: 0 + autorestart: false node_args: --tls-min-v1.0 --openssl-legacy-provider From fc1767cab4e8c832ee1e2baadb0b17e00a77dc79 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 08:45:04 +0200 Subject: [PATCH 144/145] refactor: refs #7756 Fix tests --- db/versions/11172-blueFern/15-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11172-blueFern/15-firstScript.sql diff --git a/db/versions/11172-blueFern/15-firstScript.sql b/db/versions/11172-blueFern/15-firstScript.sql new file mode 100644 index 000000000..5d34f1025 --- /dev/null +++ b/db/versions/11172-blueFern/15-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file From 0fcff01433db61f8af6fe21d601c51682820a47b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 09:11:30 +0200 Subject: [PATCH 145/145] refactor: refs #7756 Fix tests --- db/versions/11172-blueFern/10-firstScript.sql | 3 +-- db/versions/11172-blueFern/11-firstScript.sql | 4 ++-- db/versions/11172-blueFern/12-firstScript.sql | 4 ++-- db/versions/11172-blueFern/13-firstScript.sql | 4 ++-- db/versions/11172-blueFern/14-firstScript.sql | 2 +- db/versions/11172-blueFern/15-firstScript.sql | 3 ++- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/versions/11172-blueFern/10-firstScript.sql b/db/versions/11172-blueFern/10-firstScript.sql index e1847a877..5d34f1025 100644 --- a/db/versions/11172-blueFern/10-firstScript.sql +++ b/db/versions/11172-blueFern/10-firstScript.sql @@ -1,2 +1 @@ -ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK - FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file diff --git a/db/versions/11172-blueFern/11-firstScript.sql b/db/versions/11172-blueFern/11-firstScript.sql index 720b7962e..e1847a877 100644 --- a/db/versions/11172-blueFern/11-firstScript.sql +++ b/db/versions/11172-blueFern/11-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK - FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.ticket ADD CONSTRAINT ticket_invoiceOut_FK + FOREIGN KEY (refFk) REFERENCES vn.invoiceOut(`ref`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/12-firstScript.sql b/db/versions/11172-blueFern/12-firstScript.sql index 35099bd5d..720b7962e 100644 --- a/db/versions/11172-blueFern/12-firstScript.sql +++ b/db/versions/11172-blueFern/12-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 - FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK + FOREIGN KEY (correctingFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/13-firstScript.sql b/db/versions/11172-blueFern/13-firstScript.sql index f1aa0a216..35099bd5d 100644 --- a/db/versions/11172-blueFern/13-firstScript.sql +++ b/db/versions/11172-blueFern/13-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK - FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.invoiceCorrection ADD CONSTRAINT invoiceCorrection_invoiceOut_FK_1 + FOREIGN KEY (correctedFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file diff --git a/db/versions/11172-blueFern/14-firstScript.sql b/db/versions/11172-blueFern/14-firstScript.sql index ba570e20c..f1aa0a216 100644 --- a/db/versions/11172-blueFern/14-firstScript.sql +++ b/db/versions/11172-blueFern/14-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK +ALTER TABLE vn.invoiceOutExpense ADD CONSTRAINT invoiceOutExpense_invoiceOut_FK FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/11172-blueFern/15-firstScript.sql b/db/versions/11172-blueFern/15-firstScript.sql index 5d34f1025..ba570e20c 100644 --- a/db/versions/11172-blueFern/15-firstScript.sql +++ b/db/versions/11172-blueFern/15-firstScript.sql @@ -1 +1,2 @@ -ALTER TABLE vn.invoiceOut MODIFY COLUMN id int(10) unsigned auto_increment NOT NULL; \ No newline at end of file +ALTER TABLE vn.invoiceOutTax ADD CONSTRAINT invoiceOutTax_invoiceOut_FK + FOREIGN KEY (invoiceOutFk) REFERENCES vn.invoiceOut(id) ON DELETE CASCADE ON UPDATE CASCADE;