diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index a00bce940..5e23178ec 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3205,7 +3205,7 @@ UPDATE vn.department SET workerFk = null; INSERT INTO vn.packaging - VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1); + VALUES('--', 2745600.00, 100.00, 120.00, 220.00, 0.00, 1, '2001-01-01 00:00:00.000', NULL, NULL, NULL, 0.00, 16, 0.00, 0, NULL, 0.00, NULL, NULL, 0, NULL, 0, 0,0,1,0); INSERT IGNORE INTO vn.intrastat diff --git a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql index b698f0e3e..6894b2928 100644 --- a/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql +++ b/db/routines/bs/procedures/inventoryDiscrepancyDetail_replace.sql @@ -9,7 +9,7 @@ BEGIN DECLARE vCalc INT; DECLARE vWarehouseFk INT; - DECLARE cWarehouses CURSOR FOR + DECLARE cWarehouses CURSOR FOR SELECT id FROM vn.warehouse WHERE isInventory; @@ -22,13 +22,13 @@ BEGIN read_loop: LOOP SET vDone = FALSE; FETCH cWarehouses INTO vWarehouseFk; - + IF vDone THEN LEAVE read_loop; END IF; - + CALL cache.visible_refresh(vCalc, FALSE, vWarehouseFk); - + CREATE OR REPLACE TEMPORARY TABLE tVisible SELECT itemFk, SUM(visible) totalVisible FROM vn.itemShelving ish @@ -37,7 +37,7 @@ BEGIN JOIN vn.sector sc ON sc.id = p.sectorFk WHERE sc.warehouseFk = vWarehouseFk GROUP BY itemFk; - + INSERT INTO inventoryDiscrepancyDetail( warehouseFk, itemFk, @@ -65,7 +65,7 @@ BEGIN JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.alertLevel al ON al.id = ts.alertLevel WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND s.isPicked = FALSE + AND NOT s.isPicked AND al.code = 'FREE' AND t.warehouseFk = vWarehouseFk GROUP BY s.itemFk @@ -73,7 +73,6 @@ BEGIN ) s ON s.itemFk = v.item_id WHERE v.calc_id = vCalc AND NOT v.visible <=> tv.totalVisible; - END LOOP; CLOSE cWarehouses; diff --git a/db/routines/vn/procedures/itemShelvingRadar.sql b/db/routines/vn/procedures/itemShelvingRadar.sql deleted file mode 100644 index 4bdd0873e..000000000 --- a/db/routines/vn/procedures/itemShelvingRadar.sql +++ /dev/null @@ -1,207 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingRadar`( - vSectorFk INT -) -BEGIN -/** - * Calcula la información detallada respecto un sector. - * - * @param vSectorFk Id de sector - */ - DECLARE vCalcVisibleFk INT; - DECLARE vCalcAvailableFk INT; - DECLARE hasFatherSector BOOLEAN; - DECLARE vBuyerFk INT DEFAULT 0; - DECLARE vWarehouseFk INT DEFAULT 0; - DECLARE vSonSectorFk INT; - DECLARE vWorkerFk INT; - - SELECT s.workerFk INTO vWorkerFk - FROM sector s - WHERE s.id = vSectorFk; - - SELECT COUNT(*) INTO hasFatherSector - FROM sector - WHERE sonFk = vSectorFk; - - SELECT warehouseFk, sonFk INTO vWarehouseFk, vSonSectorFk - FROM sector - WHERE id = vSectorFk; - - CALL cache.visible_refresh(vCalcVisibleFk, TRUE, vWarehouseFk); - CALL cache.available_refresh(vCalcAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - - IF hasFatherSector THEN - CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT * - FROM ( - SELECT iss.itemFk, - i.longName, - i.size, - i.subName producer, - IFNULL(a.available, 0) available, - SUM(IF(s.sonFk = vSectorFk, IFNULL(iss.visible, 0), 0)) upstairs, - SUM(IF(iss.sectorFk = vSectorFk, IFNULL(iss.visible, 0), 0)) downstairs, - IF(it.isPackaging, NULL, IFNULL(v.visible, 0)) visible, - vSectorFk sectorFk, - ish.isChecked, - sub.isAllChecked - FROM itemShelvingStock iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN ( - SELECT itemFk, - IF( - COUNT(*) = SUM(IF(isChecked >= 0, 1, 0)), - TRUE, - FALSE - ) isAllChecked - FROM itemShelving is2 - GROUP BY itemFk - ) sub ON sub.itemFk = ish.itemFk - JOIN sector s ON s.id = iss.sectorFk - JOIN item i ON i.id = iss.itemFk - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN cache.available a ON a.item_id = iss.itemFk - AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk - AND v.calc_id = vCalcVisibleFk - WHERE vSectorFk IN (iss.sectorFk, s.sonFk) - GROUP BY iss.itemFk - UNION ALL - SELECT v.item_id, - i.longName, - i.size, - i.subName, - IFNULL(a.available, 0), - 0, - 0, - IF(it.isPackaging, NULL, v.visible), - vSectorFk, - NULL, - NULL - FROM cache.visible v - JOIN item i ON i.id = v.item_id - JOIN itemType it ON it.id = i.typeFk - LEFT JOIN itemShelvingStock iss ON iss.itemFk = v.item_id - AND iss.warehouseFk = vWarehouseFk - LEFT JOIN cache.available a ON a.item_id = v.item_id - AND a.calc_id = vCalcAvailableFk - WHERE v.calc_id = vCalcVisibleFk - AND iss.itemFk IS NULL - AND it.isInventory - ) sub - GROUP BY itemFk; - - SELECT ishr.*, - CAST(visible - upstairs - downstairs AS DECIMAL(10, 0)) nicho, - CAST(downstairs - IFNULL(notPickedYed, 0) AS DECIMAL(10, 0)) pendiente - FROM tItemShelvingRadar ishr - JOIN item i ON i.id = ishr.itemFk - LEFT JOIN ( - SELECT s.itemFk, SUM(s.quantity) notPickedYed - FROM ticket t - JOIN ticketStateToday tst ON tst.ticketFk = t.id - JOIN alertLevel al ON al.id = tst.alertLevel - JOIN sale s ON s.ticketFk = t.id - WHERE t.warehouseFk = vWarehouseFk - AND al.code = 'FREE' - GROUP BY s.itemFk - ) sub ON sub.itemFk = ishr.itemFk - ORDER BY i.typeFk, i.longName; - ELSE - CREATE OR REPLACE TEMPORARY TABLE tItemShelvingRadar - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT iss.itemFk, - 0 `hour`, - 0 `minute`, - '--' itemPlacementCode, - i.longName, - i.size, - i.subName producer, - i.upToDown, - IFNULL(a.available, 0) available, - IFNULL(v.visible - iss.visible, 0) dayEndVisible, - IFNULL(v.visible - iss.visible, 0) firstNegative, - IFNULL(v.visible - iss.visible, 0) itemPlacementVisible, - IFNULL(i.minimum * b.packing, 0) itemPlacementSize, - ips.onTheWay, - iss.visible itemShelvingStock, - IFNULL(v.visible, 0) visible, - b.isPickedOff, - iss.sectorFk - FROM itemShelvingStock iss - JOIN item i ON i.id = iss.itemFk - LEFT JOIN cache.last_buy lb ON lb.item_id = iss.itemFk - AND lb.warehouse_id = vWarehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id - LEFT JOIN cache.available a ON a.item_id = iss.itemFk - AND a.calc_id = vCalcAvailableFk - LEFT JOIN cache.visible v ON v.item_id = iss.itemFk - AND v.calc_id = vCalcVisibleFk - LEFT JOIN ( - SELECT itemFk, SUM(saldo) onTheWay - FROM itemPlacementSupplyList - WHERE saldo > 0 - GROUP BY itemFk - ) ips ON ips.itemFk = i.id - WHERE iss.sectorFk = vSectorFk - OR iss.sectorFk IS NULL; - - CREATE OR REPLACE TEMPORARY TABLE tmp.itemOutTime - SELECT *, SUM(amount) quantity - FROM ( - SELECT io.itemFk, - io.quantity amount, - IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) `hours`, - IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) `minutes` - FROM itemTicketOut `io` - JOIN tItemShelvingRadar isr ON isr.itemFk = io.itemFk - JOIN ticket t ON t.id= io.ticketFk - JOIN ticketState ts ON ts.ticketFk = io.ticketFk - JOIN `state` s ON s.id = ts.stateFk - LEFT JOIN `zone` z ON z.id = t.zoneFk - LEFT JOIN ( - SELECT DISTINCT saleFk - FROM saleTracking st - WHERE st.created > util.VN_CURDATE() - AND st.isChecked - ) stPrevious ON stPrevious.saleFk = io.saleFk - WHERE t.warehouseFk = vWarehouseFk - AND NOT s.isPicked - AND NOT io.reserved - AND stPrevious.saleFk IS NULL - AND io.shipped >= util.VN_CURDATE() - AND io.shipped < util.VN_CURDATE() + INTERVAL 1 DAY - ) sub - GROUP BY itemFk, `hours`, `minutes`; - - INSERT INTO tItemShelvingRadar (itemFk) - SELECT itemFk FROM tmp.itemOutTime - ON DUPLICATE KEY UPDATE dayEndVisible = dayEndVisible + quantity, - firstNegative = IF(firstNegative < 0, firstNegative, firstNegative + quantity), - `hour` = IFNULL(IF(firstNegative > 0 , `hour`, `hours`), 0), - `minute` = IFNULL(IF(firstNegative > 0, `minute`, `minutes`), 0); - - UPDATE tItemShelvingRadar isr - JOIN ( - SELECT s.itemFk, SUM(s.quantity) amount - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN ticketState ts ON ts.ticketFk = t.id - WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - AND ts.code = 'COOLER_PREPARATION' - GROUP BY s.itemFk - ) sub ON sub.itemFk = isr.itemFk - SET isr.dayEndVisible = dayEndVisible + sub.amount, - firstNegative = firstNegative + sub.amount; - - SELECT * FROM tItemShelvingRadar; - END IF; - - DROP TEMPORARY TABLE tItemShelvingRadar; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 813c65ab2..aa52a52c5 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -266,14 +266,14 @@ proc: BEGIN UPDATE tmp.productionBuffer pb JOIN sale s ON s.ticketFk = pb.ticketFk JOIN item i ON i.id = s.itemFk - JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk JOIN buy b ON b.id = lb.buy_id JOIN packaging p ON p.id = b.packagingFk SET pb.hasPlantTray = TRUE WHERE p.isPlantTray AND s.quantity >= b.packing - AND pb.isOwn; + AND pb.isOwn; DROP TEMPORARY TABLE tmp.productionTicket, diff --git a/db/routines/vn/procedures/ticket_DelayTruck.sql b/db/routines/vn/procedures/ticket_DelayTruck.sql deleted file mode 100644 index ebd0e5baf..000000000 --- a/db/routines/vn/procedures/ticket_DelayTruck.sql +++ /dev/null @@ -1,36 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_DelayTruck`(vWarehouserFk INT, vHour INT, vMinute INT) -BEGIN - DECLARE done INT DEFAULT FALSE; - DECLARE vTicketFk INT; - DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tTicket; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - - CALL vn.productionControl(vWarehouserFk,0) ; - - DROP TEMPORARY TABLE IF EXISTS tTicket; - CREATE TEMPORARY TABLE tTicket - SELECT ticketFk - FROM tmp.productionBuffer - JOIN alertLevel al ON al.code = 'FREE' - WHERE shipped = util.VN_CURDATE() - AND problem LIKE '%I:%' - AND (HH <= vHour OR HH = vHour AND mm < vMinute) - AND alertLevel = al.id; - - OPEN cur1; - - read_loop: LOOP - FETCH cur1 INTO vTicketFk; - IF done THEN - LEAVE read_loop; - END IF; - - CALL vn.ticket_DelayTruckSplit(vTicketFk); - END LOOP; - - CLOSE cur1; - DROP TEMPORARY TABLE tTicket, tmp.productionBuffer; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql b/db/routines/vn/procedures/ticket_DelayTruckSplit.sql deleted file mode 100644 index 3d22207f3..000000000 --- a/db/routines/vn/procedures/ticket_DelayTruckSplit.sql +++ /dev/null @@ -1,59 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_DelayTruckSplit`( - vTicketFk INT -) -BEGIN -/** - * Splita las lineas de ticket que no estan ubicadas - * - * @param vTicketFk Id ticket - */ - DECLARE vNewTicketFk INT; - DECLARE vTotalLines INT; - DECLARE vLinesToSplit INT; - - DROP TEMPORARY TABLE IF EXISTS tmp.SalesToSplit; - - SELECT COUNT(*) INTO vTotalLines - FROM sale - WHERE ticketFk = vTicketFk; - - CREATE TEMPORARY TABLE tmp.SalesToSplit - SELECT s.id saleFk - FROM ticket t - JOIN sale s ON t.id = s.ticketFk - LEFT JOIN ( - SELECT ish.itemFk itemFk, - SUM(ish.visible) visible, - s.warehouseFk warehouseFk - FROM itemShelving ish - JOIN shelving sh ON sh.id = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector s ON s.id = p.sectorFk - GROUP BY ish.itemFk, - s.warehouseFk - ) issw ON issw.itemFk = s.itemFk - AND issw.warehouseFk = t.warehouseFk - WHERE s.quantity > IFNULL(issw.visible, 0) - AND s.quantity > 0 - AND NOT s.isPicked - AND NOT s.reserved - AND t.id = vTicketFk; - - SELECT COUNT(*) INTO vLinesToSplit - FROM tmp.SalesToSplit; - - IF vLinesToSplit = vTotalLines AND vLinesToSplit > 0 THEN - SET vNewTicketFk = vTicketFk; - ELSE - CALL ticket_Clone(vTicketFk, vNewTicketFk); - UPDATE sale s - JOIN tmp.SalesToSplit sts ON sts.saleFk = s.id - SET s.ticketFk = vNewTicketFk; - END IF; - - CALL ticket_setState(vNewTicketFk, 'FIXING'); - - DROP TEMPORARY TABLE tmp.SalesToSplit; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_canMerge.sql b/db/routines/vn/procedures/ticket_canMerge.sql index ce90551db..d0737f00f 100644 --- a/db/routines/vn/procedures/ticket_canMerge.sql +++ b/db/routines/vn/procedures/ticket_canMerge.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canMerge`(vDat BEGIN /** * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro - * + * * @param vDated Fecha en cuestión * @param vScopeDays Dias en el futuro a sondear * @param vLitersMax Volumen máximo de los tickets a catapultar diff --git a/db/routines/vn2008/views/Cubos.sql b/db/routines/vn2008/views/Cubos.sql index 1b23af4fc..7ca82e66e 100644 --- a/db/routines/vn2008/views/Cubos.sql +++ b/db/routines/vn2008/views/Cubos.sql @@ -18,5 +18,6 @@ AS SELECT `p`.`id` AS `Id_Cubo`, `p`.`base` AS `Base`, `p`.`isBox` AS `box`, `p`.`returnCost` AS `costeRetorno`, - `p`.`isActive` AS `isActive` + `p`.`isActive` AS `isActive`, + `p`.`flippingCost` AS `flippingCost` FROM `vn`.`packaging` `p` diff --git a/db/routines/vn2008/views/awb.sql b/db/routines/vn2008/views/awb.sql index 010596288..a32571888 100644 --- a/db/routines/vn2008/views/awb.sql +++ b/db/routines/vn2008/views/awb.sql @@ -29,5 +29,6 @@ AS SELECT `a`.`id` AS `id`, `a`.`invoiceInPaletizedFk` AS `invoiceInPaletizedFk`, `a`.`observation` AS `observation`, `a`.`hasFreightPrepaid` AS `hasFreightPrepaid`, - `a`.`propertyNumber` AS `propertyNumber` + `a`.`propertyNumber` AS `propertyNumber`, + `a`.`costPerKg` AS `costPerKg` FROM `vn`.`awb` `a` diff --git a/db/versions/11076-blueChico/00-firstScript.sql b/db/versions/11076-blueChico/00-firstScript.sql new file mode 100644 index 000000000..75fdc0c56 --- /dev/null +++ b/db/versions/11076-blueChico/00-firstScript.sql @@ -0,0 +1,27 @@ +ALTER TABLE vn.business +ADD CONSTRAINT `business_companyCodeFk` FOREIGN KEY (`companyCodeFk`) REFERENCES `company` (`code`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values. +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('BusinessReasonEnd','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('CalendarType','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('OccupationCode','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('BusinessReasonEnd','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('WorkerBusinessProfessionalCategory','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('WorkerBusinessAgreement','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('WorkerBusinessType','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('PayrollCategory','find','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','__get__business','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','__create__business','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Business','crud','*','ALLOW','ROLE','hr'); + diff --git a/db/versions/11202-limeRuscus/01-updateStateAlertLevel.sql b/db/versions/11202-limeRuscus/01-updateStateAlertLevel.sql new file mode 100644 index 000000000..c49ad71ed --- /dev/null +++ b/db/versions/11202-limeRuscus/01-updateStateAlertLevel.sql @@ -0,0 +1,14 @@ +UPDATE vn.state + SET alertLevel = 1 -- ON_PREVIOUS + WHERE id IN ( + 36, -- Previa Revisando + 37, -- Previa Revisado + 26, -- Prep Previa + 28, -- Previa OK + 29, -- Previa Impreso + 31, -- Polizon Impreso + 32, -- Polizon OK + 20, -- Asignado + 23, -- URGENTE + 33 -- Auto_Impreso + ); diff --git a/db/versions/11427-azureChico/00-firstScript.sql b/db/versions/11427-azureChico/00-firstScript.sql new file mode 100644 index 000000000..34a8c8d14 --- /dev/null +++ b/db/versions/11427-azureChico/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.packaging + ADD COLUMN flippingCost decimal(10, 2) NOT NULL DEFAULT 0.00 \ No newline at end of file diff --git a/db/versions/11428-blackArborvitae/00-firstScript.sql b/db/versions/11428-blackArborvitae/00-firstScript.sql new file mode 100644 index 000000000..4e9aecafa --- /dev/null +++ b/db/versions/11428-blackArborvitae/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.travel CHANGE appointment appointment__ datetime DEFAULT NULL COMMENT '@deprecated 2025-01-28'; \ No newline at end of file diff --git a/db/versions/11429-brownBamboo/00-firstScript.sql b/db/versions/11429-brownBamboo/00-firstScript.sql new file mode 100644 index 000000000..726856e76 --- /dev/null +++ b/db/versions/11429-brownBamboo/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE `vn`.`awb` + ADD COLUMN `costPerKg` DECIMAL(10, 2) UNSIGNED DEFAULT NULL COMMENT 'Tarifa que indica a cuanto cuesta el kilo en ese vuelo'; \ No newline at end of file diff --git a/modules/client/back/methods/client/filter.js b/modules/client/back/methods/client/filter.js index 7df973f19..c217b2a86 100644 --- a/modules/client/back/methods/client/filter.js +++ b/modules/client/back/methods/client/filter.js @@ -158,10 +158,12 @@ module.exports = Self => { a.provinceFk AS provinceAddressFk, p.name AS province, u.id AS salesPersonFk, - u.name AS salesPerson + u.name AS salesPerson, + co.name AS country FROM client c LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN province p ON p.id = c.provinceFk + LEFT JOIN country co ON co.id = c.countryFk JOIN address a ON a.clientFk = c.id ` ); diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index e6690ee5f..67a61b8b5 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -139,5 +139,23 @@ }, "Xdiario": { "dataSource": "vn" + }, + "BusinessReasonEnd": { + "dataSource": "vn" + }, + "OccupationCode": { + "dataSource": "vn" + }, + "WorkerBusinessProfessionalCategory": { + "dataSource": "vn" + }, + "CalendarType": { + "dataSource": "vn" + }, + "WorkerBusinessType": { + "dataSource": "vn" + }, + "PayrollCategory": { + "dataSource": "vn" } } diff --git a/modules/client/back/models/business-reason-end.json b/modules/client/back/models/business-reason-end.json new file mode 100644 index 000000000..54a632bea --- /dev/null +++ b/modules/client/back/models/business-reason-end.json @@ -0,0 +1,17 @@ +{ + "name": "BusinessReasonEnd", + "base": "VnModel", + "options": { + "mysql": { + "table": "businessReasonEnd" + } + }, + "properties": { + "id": { + "type": "number" + }, + "reason": { + "type": "string" + } + } +} diff --git a/modules/client/back/models/business.json b/modules/client/back/models/business.json index 58e989ae0..dc6cd0bcd 100644 --- a/modules/client/back/models/business.json +++ b/modules/client/back/models/business.json @@ -13,6 +13,63 @@ }, "workcenterFk" : { "type": "number" + }, + "companyCodeFk" : { + "type": "string" + }, + "started" : { + "type": "date" + }, + "ended" : { + "type": "date" + }, + "workerBusiness" : { + "type": "string" + }, + "reasonEndFk" : { + "type": "number" + }, + "payedHolidays" : { + "type": "number" + }, + "occupationCodeFk" : { + "type": "string" + }, + "workerFk" : { + "type": "number" + }, + "notes" : { + "type": "string" + }, + "departmentFk": { + "type": "string" + }, + "workerBusinessProfessionalCategoryFk": { + "type": "number" + }, + "calendarTypeFk": { + "type": "string" + }, + "isHourlyLabor": { + "type": "boolean" + }, + "rate": { + "type": "number" + }, + "workerBusinessCategoryFk": { + "type": "number" + }, + "workerBusinessTypeFk": { + "type": "number" + }, + "amount": { + "type": "number" + }, + "workerBusinessAgreementFk": { + "type": "number" + }, + "basicSalary": { + "type": "number" } }, "relations": { @@ -25,6 +82,59 @@ "type": "belongsTo", "model": "Department", "foreignKey": "departmentFk" + }, + "workCenter": { + "type": "belongsTo", + "model": "WorkCenter", + "foreignKey": "workcenterFk" + }, + "companyCode": { + "type": "belongsTo", + "model": "Company", + "foreignKey": "companyCodeFk", + "primaryKey": "code" + }, + "reasonEnd": { + "type": "belongsTo", + "model": "BusinessReasonEnd", + "foreignKey": "reasonEndFk" + }, + "occupationCode": { + "type": "belongsTo", + "model": "OccupationCode", + "foreignKey":"occupationCodeFk", + "primaryKey": "code" + }, + "payrollCategory": { + "type": "belongsTo", + "model": "PayrollCategory", + "foreignKey":"workerBusinessCategoryFk" + }, + "workerBusinessProfessionalCategory": { + "type": "belongsTo", + "model": "WorkerBusinessProfessionalCategory", + "foreignKey": "workerBusinessProfessionalCategoryFk" + }, + "calendarType": { + "type": "belongsTo", + "model": "CalendarType", + "foreignKey": "calendarTypeFk" + }, + "workerBusinessCategory": { + "type": "belongsTo", + "model": "WorkerBusinessCategory", + "foreignKey": "workerBusinessCategoryFk" + }, + "workerBusinessType": { + "type": "belongsTo", + "model": "WorkerBusinessType", + "foreignKey": "workerBusinessTypeFk" + }, + "workerBusinessAgreement": { + "type": "belongsTo", + "model": "WorkerBusinessAgreement", + "foreignKey": "workerBusinessAgreementFk" } + } } diff --git a/modules/client/back/models/calendar-type.json b/modules/client/back/models/calendar-type.json new file mode 100644 index 000000000..742aaed94 --- /dev/null +++ b/modules/client/back/models/calendar-type.json @@ -0,0 +1,21 @@ +{ + "name": "CalendarType", + "base": "VnModel", + "options": { + "mysql": { + "table": "calendarType" + } + }, + "properties": { + "id": { + "type": "number" + }, + "description": { + "type": "string" + }, + "hoursWeek": { + "type": "number" + }, + "isPartial": "number" + } +} diff --git a/modules/client/back/models/occupation-code.json b/modules/client/back/models/occupation-code.json new file mode 100644 index 000000000..e40eaf2fe --- /dev/null +++ b/modules/client/back/models/occupation-code.json @@ -0,0 +1,18 @@ +{ + "name": "OccupationCode", + "base": "VnModel", + "options": { + "mysql": { + "table": "occupationCode" + } + }, + "properties": { + "code": { + "type": "string", + "id": true + }, + "name": { + "type": "string" + } + } +} diff --git a/modules/client/back/models/payroll-categories.json b/modules/client/back/models/payroll-categories.json new file mode 100644 index 000000000..ca3431ba9 --- /dev/null +++ b/modules/client/back/models/payroll-categories.json @@ -0,0 +1,20 @@ +{ + "name": "PayrollCategory", + "base": "VnModel", + "options": { + "mysql": { + "table": "payrollCategories" + } + }, + "properties": { + "id": { + "type": "number" + }, + "description": { + "type": "string" + }, + "rate": { + "type": "number" + } + } +} diff --git a/modules/client/back/models/professional-category.json b/modules/client/back/models/professional-category.json new file mode 100644 index 000000000..5f812a704 --- /dev/null +++ b/modules/client/back/models/professional-category.json @@ -0,0 +1,20 @@ +{ + "name": "WorkerBusinessProfessionalCategory", + "base": "VnModel", + "options": { + "mysql": { + "table": "professionalCategory" + } + }, + "properties": { + "id": { + "type": "number" + }, + "description": { + "type": "string" + }, + "code": { + "type": "string" + } + } +} diff --git a/modules/client/back/models/worker-business-agreement.json b/modules/client/back/models/worker-business-agreement.json new file mode 100644 index 000000000..bd62b2aa3 --- /dev/null +++ b/modules/client/back/models/worker-business-agreement.json @@ -0,0 +1,29 @@ +{ + "name": "WorkerBusinessAgreement", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerBusinessAgreement" + } + }, + "properties": { + "id": { + "type": "number" + }, + "name": { + "type": "string" + }, + "monthHolidays": { + "type": "number" + }, + "yearsHours": { + "type": "number" + }, + "started": { + "type": "date" + }, + "ended": { + "type": "date" + } + } +} diff --git a/modules/client/back/models/worker-business-type.json b/modules/client/back/models/worker-business-type.json new file mode 100644 index 000000000..648ce3fd2 --- /dev/null +++ b/modules/client/back/models/worker-business-type.json @@ -0,0 +1,27 @@ +{ + "name": "WorkerBusinessType", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerBusinessType" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "name": { + "type": "string" + }, + "isFullTime": { + "type": "number" + }, + "isPermanent": { + "type": "number" + }, + "hasHolidayEntitlement": { + "type": "number" + } + } +} diff --git a/modules/mdb/back/methods/mdbVersion/upload.js b/modules/mdb/back/methods/mdbVersion/upload.js index 64de72679..ee67e35d0 100644 --- a/modules/mdb/back/methods/mdbVersion/upload.js +++ b/modules/mdb/back/methods/mdbVersion/upload.js @@ -146,7 +146,7 @@ module.exports = Self => { await fs.symlink(rootRelative, destinationRoot); } } - if (description) { + if (description && branch == 'master') { let formatDesc; const mainBranches = new Set(['master', 'test', 'dev']); if (mainBranches.has(branch)) diff --git a/modules/ticket/back/locale/sale/es.yml b/modules/ticket/back/locale/sale/es.yml index e6a984a5d..eefd05d83 100644 --- a/modules/ticket/back/locale/sale/es.yml +++ b/modules/ticket/back/locale/sale/es.yml @@ -15,4 +15,4 @@ columns: priceFixed: precio fijado isPriceFixed: tiene precio fijado isAdded: añadida - total: total + total: importe diff --git a/modules/ticket/back/methods/state/isEditable.js b/modules/ticket/back/methods/state/isEditable.js index ec246c61f..696183827 100644 --- a/modules/ticket/back/methods/state/isEditable.js +++ b/modules/ticket/back/methods/state/isEditable.js @@ -34,8 +34,8 @@ module.exports = Self => { state.code == 'PICKER_DESIGNED' || state.code == 'PRINTED' ) ); - - const isAllowed = isAllEditable || isSomeEditable || state.alertLevel == 0; + const alertLevel = await models.AlertLevel.findOne({where: {code: 'FREE'}}, myOptions); + const isAllowed = isAllEditable || isSomeEditable || state.alertLevel == alertLevel.id; return isAllowed; }; }; diff --git a/modules/ticket/back/methods/state/specs/editableState.spec.js b/modules/ticket/back/methods/state/specs/editableState.spec.js index 2e1ce0c19..0c4024bbc 100644 --- a/modules/ticket/back/methods/state/specs/editableState.spec.js +++ b/modules/ticket/back/methods/state/specs/editableState.spec.js @@ -35,9 +35,9 @@ describe('ticket editableStates()', () => { const editableStates = await models.State.editableStates(ctx, filter, options); - const pickerDesignedState = editableStates.some(state => state.code == 'PICKER_DESIGNED'); + const okState = editableStates.some(state => state.code == 'OK'); - expect(pickerDesignedState).toBeTruthy(); + expect(okState).toBeTruthy(); await tx.rollback(); } catch (e) { @@ -54,11 +54,11 @@ describe('ticket editableStates()', () => { const employeeRole = 1; const ctx = {req: {accessToken: {userId: employeeRole}}}; - const filter = {where: {name: {like: '%Previa OK%'}}}; + const filter = {where: {name: {like: '%Bloqueado%'}}}; const [editableStates] = await models.State.editableStates(ctx, filter, options); - expect(editableStates.name).toBe('Previa OK'); + expect(editableStates.name).toBe('Bloqueado'); await tx.rollback(); } catch (e) { diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 97e6a283c..4895a6107 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -1,5 +1,4 @@ module.exports = Self => { - const validateTin = require('vn-loopback/util/validateTin'); require('../methods/worker/filter')(Self); require('../methods/worker/mySubordinates')(Self); require('../methods/worker/isSubordinate')(Self); @@ -23,26 +22,10 @@ module.exports = Self => { require('../methods/worker/getAvailablePda')(Self); require('../methods/worker/myTeam')(Self); - Self.validateAsync('fi', tinIsValid, { - message: 'Invalid TIN' - }); - Self.canModifyAbsenceInPast = async(ctx, time) => { const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); const today = Date.vnNew(); today.setHours(0, 0, 0, 0); return hasPrivs || today.getTime() < time; }; - - async function tinIsValid(err, done) { - const country = await Self.app.models.Country.findOne({ - fields: ['code'], - where: {id: this.originCountryFk} - }); - const code = country ? country.code.toLowerCase() : null; - - if (!this.fi || !validateTin(this.fi, code)) - err(); - done(); - } }; diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 705851963..346c70d56 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -75,6 +75,9 @@ }, "isSsDiscounted": { "type": "boolean" + }, + "businessFk": { + "type": "number" } }, "relations": { @@ -103,6 +106,11 @@ "model": "WorkerDepartment", "foreignKey": "id" }, + "currentBusiness": { + "type": "belongsTo", + "model": "Business", + "foreignKey": "businessFk" + }, "collegues": { "type": "hasMany", "model": "WorkerTeamCollegues", @@ -113,6 +121,11 @@ "model": "Locker", "foreignKey": "workerFk" }, + "business": { + "type": "hasMany", + "model": "Business", + "foreignKey": "workerFk" + }, "medicalReview": { "type": "hasMany", "model": "MedicalReview", @@ -259,12 +272,36 @@ "relation": "department", "scope": { "fields": [ - "name" + "id" ] } } } }, + { + "relation": "business", + "scope": { + "fields": [ + "id", + "started", + "ended", + "reasonEndFk", + "departmentFk", + "workerBusinessProfessionalCategoryFk" + ], + "include": [ + { + "relation": "reasonEnd", + "scope": { + "fields": [ + "id", + "reason" + ] + } + } + ] + } + }, { "relation": "boss", "scope": { @@ -312,7 +349,8 @@ "educationLevelFk", "originCountryFk", "maritalStatus", - "SSN" + "SSN", + "businessFk" ], "include": [ { @@ -323,6 +361,48 @@ "phone" ] } + }, + { + "relation": "currentBusiness", + "scope": { + "fields": [ + "id", + "started", + "ended", + "reasonEndFk", + "departmentFk", + "workerBusinessProfessionalCategoryFk" + ], + "include": [ + { + "relation": "reasonEnd", + "scope": { + "fields": [ + "id", + "reason" + ] + } + }, + { + "relation": "department", + "scope": { + "fields": [ + "id", + "name" + ] + } + }, + { + "relation": "workerBusinessProfessionalCategory", + "scope": { + "fields": [ + "id", + "description" + ] + } + } + ] + } } ] } diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index e3a206656..8e69d6c65 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -90,8 +90,7 @@ {{ticket.id}} {{ticket.clientFk}} {{ticket.addressName}} - {{ticket.addressFk.toString().substr(0, ticket.addressFk.toString().length - 3)}} - {{ticket.addressFk.toString().substr(-3, 3)}} + {{ticket.addressFk.toString()}} {{ticket.packages}} {{ticket.itemPackingTypes}}