Merge branch 'dev' into 8227-roadmap
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Guillermo Bonet 2025-02-03 09:59:03 +00:00
commit 247bdc7295
31 changed files with 434 additions and 345 deletions

View File

@ -3205,7 +3205,7 @@ UPDATE vn.department
SET workerFk = null; SET workerFk = null;
INSERT INTO vn.packaging 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 INSERT IGNORE INTO vn.intrastat

View File

@ -9,7 +9,7 @@ BEGIN
DECLARE vCalc INT; DECLARE vCalc INT;
DECLARE vWarehouseFk INT; DECLARE vWarehouseFk INT;
DECLARE cWarehouses CURSOR FOR DECLARE cWarehouses CURSOR FOR
SELECT id SELECT id
FROM vn.warehouse FROM vn.warehouse
WHERE isInventory; WHERE isInventory;
@ -22,13 +22,13 @@ BEGIN
read_loop: LOOP read_loop: LOOP
SET vDone = FALSE; SET vDone = FALSE;
FETCH cWarehouses INTO vWarehouseFk; FETCH cWarehouses INTO vWarehouseFk;
IF vDone THEN IF vDone THEN
LEAVE read_loop; LEAVE read_loop;
END IF; END IF;
CALL cache.visible_refresh(vCalc, FALSE, vWarehouseFk); CALL cache.visible_refresh(vCalc, FALSE, vWarehouseFk);
CREATE OR REPLACE TEMPORARY TABLE tVisible CREATE OR REPLACE TEMPORARY TABLE tVisible
SELECT itemFk, SUM(visible) totalVisible SELECT itemFk, SUM(visible) totalVisible
FROM vn.itemShelving ish FROM vn.itemShelving ish
@ -37,7 +37,7 @@ BEGIN
JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.sector sc ON sc.id = p.sectorFk
WHERE sc.warehouseFk = vWarehouseFk WHERE sc.warehouseFk = vWarehouseFk
GROUP BY itemFk; GROUP BY itemFk;
INSERT INTO inventoryDiscrepancyDetail( INSERT INTO inventoryDiscrepancyDetail(
warehouseFk, warehouseFk,
itemFk, itemFk,
@ -65,7 +65,7 @@ BEGIN
JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.ticketState ts ON ts.ticketFk = t.id
JOIN vn.alertLevel al ON al.id = ts.alertLevel JOIN vn.alertLevel al ON al.id = ts.alertLevel
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) 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 al.code = 'FREE'
AND t.warehouseFk = vWarehouseFk AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk GROUP BY s.itemFk
@ -73,7 +73,6 @@ BEGIN
) s ON s.itemFk = v.item_id ) s ON s.itemFk = v.item_id
WHERE v.calc_id = vCalc WHERE v.calc_id = vCalc
AND NOT v.visible <=> tv.totalVisible; AND NOT v.visible <=> tv.totalVisible;
END LOOP; END LOOP;
CLOSE cWarehouses; CLOSE cWarehouses;

View File

@ -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 ;

View File

@ -266,14 +266,14 @@ proc: BEGIN
UPDATE tmp.productionBuffer pb UPDATE tmp.productionBuffer pb
JOIN sale s ON s.ticketFk = pb.ticketFk JOIN sale s ON s.ticketFk = pb.ticketFk
JOIN item i ON i.id = s.itemFk 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 AND lb.item_id = s.itemFk
JOIN buy b ON b.id = lb.buy_id JOIN buy b ON b.id = lb.buy_id
JOIN packaging p ON p.id = b.packagingFk JOIN packaging p ON p.id = b.packagingFk
SET pb.hasPlantTray = TRUE SET pb.hasPlantTray = TRUE
WHERE p.isPlantTray WHERE p.isPlantTray
AND s.quantity >= b.packing AND s.quantity >= b.packing
AND pb.isOwn; AND pb.isOwn;
DROP TEMPORARY TABLE DROP TEMPORARY TABLE
tmp.productionTicket, tmp.productionTicket,

View File

@ -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 ;

View File

@ -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 ;

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_canMerge`(vDat
BEGIN BEGIN
/** /**
* Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro * Devuelve un listado de tickets susceptibles de fusionarse con otros tickets en el futuro
* *
* @param vDated Fecha en cuestión * @param vDated Fecha en cuestión
* @param vScopeDays Dias en el futuro a sondear * @param vScopeDays Dias en el futuro a sondear
* @param vLitersMax Volumen máximo de los tickets a catapultar * @param vLitersMax Volumen máximo de los tickets a catapultar

View File

@ -18,5 +18,6 @@ AS SELECT `p`.`id` AS `Id_Cubo`,
`p`.`base` AS `Base`, `p`.`base` AS `Base`,
`p`.`isBox` AS `box`, `p`.`isBox` AS `box`,
`p`.`returnCost` AS `costeRetorno`, `p`.`returnCost` AS `costeRetorno`,
`p`.`isActive` AS `isActive` `p`.`isActive` AS `isActive`,
`p`.`flippingCost` AS `flippingCost`
FROM `vn`.`packaging` `p` FROM `vn`.`packaging` `p`

View File

@ -29,5 +29,6 @@ AS SELECT `a`.`id` AS `id`,
`a`.`invoiceInPaletizedFk` AS `invoiceInPaletizedFk`, `a`.`invoiceInPaletizedFk` AS `invoiceInPaletizedFk`,
`a`.`observation` AS `observation`, `a`.`observation` AS `observation`,
`a`.`hasFreightPrepaid` AS `hasFreightPrepaid`, `a`.`hasFreightPrepaid` AS `hasFreightPrepaid`,
`a`.`propertyNumber` AS `propertyNumber` `a`.`propertyNumber` AS `propertyNumber`,
`a`.`costPerKg` AS `costPerKg`
FROM `vn`.`awb` `a` FROM `vn`.`awb` `a`

View File

@ -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');

View File

@ -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
);

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.packaging
ADD COLUMN flippingCost decimal(10, 2) NOT NULL DEFAULT 0.00

View File

@ -0,0 +1 @@
ALTER TABLE vn.travel CHANGE appointment appointment__ datetime DEFAULT NULL COMMENT '@deprecated 2025-01-28';

View File

@ -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';

View File

@ -158,10 +158,12 @@ module.exports = Self => {
a.provinceFk AS provinceAddressFk, a.provinceFk AS provinceAddressFk,
p.name AS province, p.name AS province,
u.id AS salesPersonFk, u.id AS salesPersonFk,
u.name AS salesPerson u.name AS salesPerson,
co.name AS country
FROM client c FROM client c
LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = c.salesPersonFk
LEFT JOIN province p ON p.id = c.provinceFk 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 JOIN address a ON a.clientFk = c.id
` `
); );

View File

@ -139,5 +139,23 @@
}, },
"Xdiario": { "Xdiario": {
"dataSource": "vn" "dataSource": "vn"
},
"BusinessReasonEnd": {
"dataSource": "vn"
},
"OccupationCode": {
"dataSource": "vn"
},
"WorkerBusinessProfessionalCategory": {
"dataSource": "vn"
},
"CalendarType": {
"dataSource": "vn"
},
"WorkerBusinessType": {
"dataSource": "vn"
},
"PayrollCategory": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,17 @@
{
"name": "BusinessReasonEnd",
"base": "VnModel",
"options": {
"mysql": {
"table": "businessReasonEnd"
}
},
"properties": {
"id": {
"type": "number"
},
"reason": {
"type": "string"
}
}
}

View File

@ -13,6 +13,63 @@
}, },
"workcenterFk" : { "workcenterFk" : {
"type": "number" "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": { "relations": {
@ -25,6 +82,59 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Department", "model": "Department",
"foreignKey": "departmentFk" "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"
} }
} }
} }

View File

@ -0,0 +1,21 @@
{
"name": "CalendarType",
"base": "VnModel",
"options": {
"mysql": {
"table": "calendarType"
}
},
"properties": {
"id": {
"type": "number"
},
"description": {
"type": "string"
},
"hoursWeek": {
"type": "number"
},
"isPartial": "number"
}
}

View File

@ -0,0 +1,18 @@
{
"name": "OccupationCode",
"base": "VnModel",
"options": {
"mysql": {
"table": "occupationCode"
}
},
"properties": {
"code": {
"type": "string",
"id": true
},
"name": {
"type": "string"
}
}
}

View File

@ -0,0 +1,20 @@
{
"name": "PayrollCategory",
"base": "VnModel",
"options": {
"mysql": {
"table": "payrollCategories"
}
},
"properties": {
"id": {
"type": "number"
},
"description": {
"type": "string"
},
"rate": {
"type": "number"
}
}
}

View File

@ -0,0 +1,20 @@
{
"name": "WorkerBusinessProfessionalCategory",
"base": "VnModel",
"options": {
"mysql": {
"table": "professionalCategory"
}
},
"properties": {
"id": {
"type": "number"
},
"description": {
"type": "string"
},
"code": {
"type": "string"
}
}
}

View File

@ -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"
}
}
}

View File

@ -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"
}
}
}

View File

@ -146,7 +146,7 @@ module.exports = Self => {
await fs.symlink(rootRelative, destinationRoot); await fs.symlink(rootRelative, destinationRoot);
} }
} }
if (description) { if (description && branch == 'master') {
let formatDesc; let formatDesc;
const mainBranches = new Set(['master', 'test', 'dev']); const mainBranches = new Set(['master', 'test', 'dev']);
if (mainBranches.has(branch)) if (mainBranches.has(branch))

View File

@ -15,4 +15,4 @@ columns:
priceFixed: precio fijado priceFixed: precio fijado
isPriceFixed: tiene precio fijado isPriceFixed: tiene precio fijado
isAdded: añadida isAdded: añadida
total: total total: importe

View File

@ -34,8 +34,8 @@ module.exports = Self => {
state.code == 'PICKER_DESIGNED' || state.code == 'PRINTED' state.code == 'PICKER_DESIGNED' || state.code == 'PRINTED'
) )
); );
const alertLevel = await models.AlertLevel.findOne({where: {code: 'FREE'}}, myOptions);
const isAllowed = isAllEditable || isSomeEditable || state.alertLevel == 0; const isAllowed = isAllEditable || isSomeEditable || state.alertLevel == alertLevel.id;
return isAllowed; return isAllowed;
}; };
}; };

View File

@ -35,9 +35,9 @@ describe('ticket editableStates()', () => {
const editableStates = await models.State.editableStates(ctx, filter, options); 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(); await tx.rollback();
} catch (e) { } catch (e) {
@ -54,11 +54,11 @@ describe('ticket editableStates()', () => {
const employeeRole = 1; const employeeRole = 1;
const ctx = {req: {accessToken: {userId: employeeRole}}}; 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); const [editableStates] = await models.State.editableStates(ctx, filter, options);
expect(editableStates.name).toBe('Previa OK'); expect(editableStates.name).toBe('Bloqueado');
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {

View File

@ -1,5 +1,4 @@
module.exports = Self => { module.exports = Self => {
const validateTin = require('vn-loopback/util/validateTin');
require('../methods/worker/filter')(Self); require('../methods/worker/filter')(Self);
require('../methods/worker/mySubordinates')(Self); require('../methods/worker/mySubordinates')(Self);
require('../methods/worker/isSubordinate')(Self); require('../methods/worker/isSubordinate')(Self);
@ -23,26 +22,10 @@ module.exports = Self => {
require('../methods/worker/getAvailablePda')(Self); require('../methods/worker/getAvailablePda')(Self);
require('../methods/worker/myTeam')(Self); require('../methods/worker/myTeam')(Self);
Self.validateAsync('fi', tinIsValid, {
message: 'Invalid TIN'
});
Self.canModifyAbsenceInPast = async(ctx, time) => { Self.canModifyAbsenceInPast = async(ctx, time) => {
const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE');
const today = Date.vnNew(); const today = Date.vnNew();
today.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0);
return hasPrivs || today.getTime() < time; 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();
}
}; };

View File

@ -75,6 +75,9 @@
}, },
"isSsDiscounted": { "isSsDiscounted": {
"type": "boolean" "type": "boolean"
},
"businessFk": {
"type": "number"
} }
}, },
"relations": { "relations": {
@ -103,6 +106,11 @@
"model": "WorkerDepartment", "model": "WorkerDepartment",
"foreignKey": "id" "foreignKey": "id"
}, },
"currentBusiness": {
"type": "belongsTo",
"model": "Business",
"foreignKey": "businessFk"
},
"collegues": { "collegues": {
"type": "hasMany", "type": "hasMany",
"model": "WorkerTeamCollegues", "model": "WorkerTeamCollegues",
@ -113,6 +121,11 @@
"model": "Locker", "model": "Locker",
"foreignKey": "workerFk" "foreignKey": "workerFk"
}, },
"business": {
"type": "hasMany",
"model": "Business",
"foreignKey": "workerFk"
},
"medicalReview": { "medicalReview": {
"type": "hasMany", "type": "hasMany",
"model": "MedicalReview", "model": "MedicalReview",
@ -259,12 +272,36 @@
"relation": "department", "relation": "department",
"scope": { "scope": {
"fields": [ "fields": [
"name" "id"
] ]
} }
} }
} }
}, },
{
"relation": "business",
"scope": {
"fields": [
"id",
"started",
"ended",
"reasonEndFk",
"departmentFk",
"workerBusinessProfessionalCategoryFk"
],
"include": [
{
"relation": "reasonEnd",
"scope": {
"fields": [
"id",
"reason"
]
}
}
]
}
},
{ {
"relation": "boss", "relation": "boss",
"scope": { "scope": {
@ -312,7 +349,8 @@
"educationLevelFk", "educationLevelFk",
"originCountryFk", "originCountryFk",
"maritalStatus", "maritalStatus",
"SSN" "SSN",
"businessFk"
], ],
"include": [ "include": [
{ {
@ -323,6 +361,48 @@
"phone" "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"
]
}
}
]
}
} }
] ]
} }

View File

@ -90,8 +90,7 @@
<td class="number">{{ticket.id}}</td> <td class="number">{{ticket.id}}</td>
<td width="50%">{{ticket.clientFk}} {{ticket.addressName}}</td> <td width="50%">{{ticket.clientFk}} {{ticket.addressName}}</td>
<td v-if="ticket.addressFk" class="number"> <td v-if="ticket.addressFk" class="number">
{{ticket.addressFk.toString().substr(0, ticket.addressFk.toString().length - 3)}} <span class="black-container"> {{ticket.addressFk.toString()}} </span>
<span class="black-container"> {{ticket.addressFk.toString().substr(-3, 3)}} </span>
</td> </td>
<td class="number">{{ticket.packages}}</td> <td class="number">{{ticket.packages}}</td>
<td>{{ticket.itemPackingTypes}}</td> <td>{{ticket.itemPackingTypes}}</td>