Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6273-registerFreelance
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-06-10 15:21:59 +02:00
commit 8e3cc574ac
30 changed files with 126 additions and 145 deletions

View File

@ -1772,8 +1772,8 @@ INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','emplo
INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss');
INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (692,'ExpeditionTruck','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (693,'ExpeditionTruck','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (692,'RoadmapStop','*','*','ALLOW','ROLE','production');
INSERT INTO `ACL` VALUES (693,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss');
INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee');
INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative');

View File

@ -2687,13 +2687,20 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`)
(3, 6, 5),
(4, 7, 1);
INSERT INTO `vn`.`roadmapAddress` (`addressFk`)
VALUES
(1),
(2),
(3),
(4);
INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`)
VALUES
(1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
(2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
(3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
(1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
(2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
(3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`)
INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `userFk`)
VALUES
(1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1),
(2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1),

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`midnight`()
RETURNS datetime
NOT DETERMINISTIC
DETERMINISTIC
READS SQL DATA
BEGIN

View File

@ -14,7 +14,7 @@ BEGIN
DECLARE vIsTooLittle TINYINT(1);
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
AND IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
FROM ticket t
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
JOIN volumeConfig vc

View File

@ -1,5 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT)
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(
vSelf INT
)
BEGIN
/**
* Triggered actions when a buy is updated or inserted.
@ -16,7 +18,7 @@ BEGIN
DECLARE vIsFeedStock BOOL;
DECLARE vWeight DECIMAL(10,2);
DECLARE vPacking INT;
SELECT b.entryFk,
b.itemFk,
i.packingOut,
@ -47,8 +49,11 @@ BEGIN
WHERE e.id = vEntryFk;
IF vIsMerchandise THEN
IF vWarehouse IS NULL THEN
CALL util.throw('The entry does not have travel');
END IF;
REPLACE itemCost SET
REPLACE itemCost SET
itemFk = vItemFk,
warehouseFk = vWarehouse,
cm3 = buy_getUnitVolume(vSelf),
@ -74,7 +79,7 @@ BEGIN
WHERE b.id = vSelf;
END IF;
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
SELECT vSelf id;
CALL buy_checkItem();
END$$

View File

@ -49,7 +49,10 @@ BEGIN
BEGIN
IF vLockName IS NOT NULL THEN
DO RELEASE_LOCK(vLockName);
CALL util.debugAdd('releaseLock', vLockName); -- Tmp
CALL util.debugAdd(JSON_OBJECT(
'type', 'releaseLock',
'userFk', vUserFk
), vLockName); -- Tmp
END IF;
RESIGNAL;

View File

@ -1,9 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45))
BEGIN
INSERT INTO vn.roadmapStop(eta,description)
VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription);
END$$
DELIMITER ;

View File

@ -1,12 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_List`()
BEGIN
SELECT id truckFk,
eta,
description Destino
FROM roadmapStop
WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE())
ORDER BY eta;
END$$
DELIMITER ;

View File

@ -146,13 +146,19 @@ proc: BEGIN
-- Líneas y volumen por ticket
UPDATE tmp.productionBuffer pb
JOIN (
SELECT tt.ticketFk,
COUNT(*) `lines`,
SUM(sv.volume) m3,
IFNULL(SUM(IF(sv.isPicked, sv.volume, 0)) / SUM(sv.volume), 0) rate
FROM tmp.productionTicket tt
JOIN saleVolume sv ON sv.ticketFk = tt.ticketFk
GROUP BY tt.ticketFk
SELECT tt.ticketFk,
COUNT(*) `lines`,
SUM(s.quantity * ic.cm3delivery / 1000000) m3,
IFNULL(SUM(IF(s.isPicked,
(s.quantity * ic.cm3delivery / 1000000),
0)) / SUM(s.quantity * ic.cm3delivery / 1000000),
0) rate
FROM tmp.productionTicket tt
JOIN sale s ON s.ticketFk = tt.ticketFk
AND s.quantity > 0
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = vWarehouseFk
GROUP BY tt.ticketFk
) m ON m.ticketFk = pb.ticketFk
SET pb.`lines` = m.`lines`,
pb.m3 = m.m3,
@ -219,6 +225,8 @@ proc: BEGIN
AND ish.visible
GROUP BY ish.itemFk, p.sectorFk;
CREATE INDEX idxItem ON tItemShelvingStock (itemFk);
INSERT INTO tmp.ticketWithPrevia(ticketFk, salesCount)
SELECT pb.ticketFk, COUNT(DISTINCT s.id)
FROM tmp.productionBuffer pb

View File

@ -64,10 +64,15 @@ BEGIN
FROM tmp.sale_getProblems tp
JOIN ticket t ON t.id = tp.ticketFk
JOIN (
SELECT t.addressFk, SUM(sv.litros) litros, t.totalWithoutVat
SELECT t.addressFk,
SUM(ROUND(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0)) litros,
t.totalWithoutVat
FROM tmp.ticket_list tl
JOIN saleVolume sv ON sv.ticketFk = tl.ticketFk
JOIN ticket t ON t.id = tl.ticketFk
JOIN sale s ON s.ticketFk = t.id
AND s.quantity > 0
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
AND zc.dated = util.VN_CURDATE()
JOIN agencyMode am ON am.id = t.agencyModeFk
@ -95,12 +100,12 @@ BEGIN
FROM (
SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk
FROM tmp.ticket_list tl
JOIN vn.sale s ON s.ticketFk = tl.ticketFk
LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id
LEFT JOIN vn.component c ON c.id = sc.componentFk AND c.isRequired
JOIN vn.ticket t ON t.id = tl.ticketFk
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.deliveryMethod dm ON dm.id = am.deliveryMethodFk
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

View File

@ -18,7 +18,7 @@ BEGIN
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE t.shipped >= util.midnight()
WHERE t.shipped >= util.VN_CURDATE()
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk)
GROUP BY s.id) sub;

View File

@ -13,7 +13,7 @@ BEGIN
ENGINE = MEMORY
SELECT t.id ticketFk, FALSE hasProblem
FROM ticket t
WHERE t.shipped >= util.midnight()
WHERE t.shipped >= util.VN_CURDATE()
AND (vClientFk IS NULL OR t.clientFk = vClientFk);
UPDATE tmp.ticket t

View File

@ -13,7 +13,7 @@ BEGIN
ENGINE = MEMORY
SELECT t.id ticketFk, FALSE hasProblem
FROM ticket t
WHERE t.shipped >= util.midnight()
WHERE t.shipped >= util.VN_CURDATE()
AND (vSelf IS NULL OR t.id = vSelf);
UPDATE tmp.ticket t

View File

@ -14,7 +14,7 @@ BEGIN
SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem
FROM ticket t
JOIN client c ON c.id = t.clientFk
WHERE t.shipped >= util.midnight()
WHERE t.shipped >= util.VN_CURDATE()
AND (c.id = vClientFk OR vClientFk IS NULL);
CALL ticket_setProblem('isTaxDataChecked');

View File

@ -16,7 +16,7 @@ BEGIN
SELECT t.id ticketFk
FROM vn.ticket t
LEFT JOIN vn.sale s ON s.ticketFk = t.id
WHERE t.shipped >= util.midnight()
WHERE t.shipped >= util.VN_CURDATE()
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
GROUP BY t.id
)SELECT ticketFk, ticket_isTooLittle(ticketFk) hasProblem

View File

@ -1,19 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionTruck_Control`
AS SELECT `e`.`truckFk` AS `id`,
`e`.`eta` AS `ETD`,
`e`.`description` AS `description`,
COUNT(
DISTINCT IF(`e`.`expeditionFk` IS NULL, `e`.`ticketFk`, NULL)
) AS `ticketsSinBultos`,
COUNT(DISTINCT `e`.`palletFk`) AS `pallets`,
COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`,
sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
max(`e`.`lastPacked`) AS `lastPacked`
FROM `vn`.`expeditionCommon` `e`
GROUP BY `e`.`truckFk`
ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
`e`.`eta`

View File

@ -1,18 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionTruck_Control_Detail`
AS SELECT `e`.`truckFk` AS `id`,
`e`.`eta` AS `eta`,
`e`.`description` AS `destino`,
`e`.`palletFk` AS `pallet`,
COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`,
sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
max(`e`.`lastPacked`) AS `lastPacked`
FROM `vn`.`expeditionCommon` `e`
GROUP BY `e`.`truckFk`,
`e`.`palletFk`
ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
`e`.`eta`,
`e`.`truckFk`

View File

@ -1,22 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`expeditionTruck_Control_Detail_Pallet`
AS SELECT `e`.`truckFk` AS `id`,
`e`.`eta` AS `eta`,
`e`.`description` AS `destino`,
`e`.`palletFk` AS `pallet`,
`e`.`routeFk` AS `route`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
`rs`.`description` AS `destinos`,
SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
`e`.`roadmapStopFk` AS `roadmapStopFk`,
MAX(`e`.`lastPacked`) AS `lastPacked`
FROM (
`vn`.`expeditionCommon` `e`
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`roadmapStopFk`)
)
GROUP BY `e`.`truckFk`,
`e`.`palletFk`,
`e`.`routeFk`
ORDER BY SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
`e`.`palletFk`

View File

@ -20,7 +20,7 @@ FROM (
`vn`.`saleGroup` `sg`
JOIN `vn`.`saleGroupDetail` `sgd` ON(`sgd`.`saleGroupFk` = `sg`.`id`)
)
JOIN `vn`.`sale` `s` ON(`s`.`id` = `sgd`.`saleFk`)
JOIN `vn`.`sale` `s` FORCE INDEX (PRIMARY) ON(`s`.`id` = `sgd`.`saleFk`)
)
JOIN `vn`.`ticketState` `tls` ON(`tls`.`ticketFk` = `s`.`ticketFk`)
)

View File

@ -0,0 +1,8 @@
CREATE TABLE `vn`.`roadmapAddress` (
addressFk int(11) NULL,
isActive TINYINT DEFAULT 1 NULL,
PRIMARY KEY (addressFk)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Direcciones de los troncales';
ALTER TABLE vn.roadmapAddress
ADD CONSTRAINT roadmapAddress_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,7 @@
ALTER TABLE vn.roadmapStop DROP FOREIGN KEY expeditionTruck_FK_1;
ALTER TABLE vn.roadmapStop DROP COLUMN warehouseFk;
ALTER TABLE vn.roadmapStop ADD addressFk int(11) NULL;
ALTER TABLE vn.roadmapStop CHANGE addressFk addressFk int(11) DEFAULT NULL NULL AFTER roadmapFk;
ALTER TABLE vn.roadmapStop
ADD CONSTRAINT roadmapStop_roadmapAddress_FK FOREIGN KEY (addressFk) REFERENCES vn.roadmapAddress(addressFk) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,11 @@
DELETE FROM salix.ACL
WHERE model in ('expeditionTruck', 'Roadmap', 'roadmapStop', 'roadmapAddress');
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES
('RoadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'),
('RoadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
('Roadmap', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'),
('Roadmap', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
('RoadmapStop', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'),
('RoadmapStop', '*', 'READ', 'ALLOW', 'ROLE', 'production');

View File

@ -13,7 +13,6 @@ columns:
m3: m3
priority: priority
etd: etd
expeditionTruckFk: truck
m3boxes: m3 boxes
bufferFk: buffer
isPickingAllowed: is picking allowed
isPickingAllowed: is picking allowed

View File

@ -13,7 +13,6 @@ columns:
m3: m3
priority: prioridad
etd: etd
expeditionTruckFk: camión
m3boxes: m3 cajas
bufferFk: buffer
isPickingAllowed: está permitido recoger
isPickingAllowed: está permitido recoger

View File

@ -37,17 +37,12 @@ module.exports = Self => {
fields: [
'id',
'name',
'tractorPlate',
'trailerPlate',
'phone',
'supplierFk',
'etd',
'observations',
'price'],
'etd'],
include: [{
relation: 'expeditionTruck',
relation: 'roadmapStop',
scope: {
fields: ['roadmapFk', 'warehouseFk', 'eta', 'description']
fields: ['roadmapFk', 'addressFk', 'eta', 'description']
}
}]

View File

@ -8,6 +8,9 @@
"DeliveryPoint": {
"dataSource": "vn"
},
"RoadmapAddress": {
"dataSource": "vn"
},
"RoadmapStop": {
"dataSource": "vn"
},
@ -25,8 +28,5 @@
},
"RoutesMonitor": {
"dataSource": "vn"
},
"ExpeditionTruck": {
"dataSource": "vn"
}
}

View File

@ -1,9 +0,0 @@
{
"name": "ExpeditionTruck",
"base": "RoadmapStop",
"options": {
"mysql": {
"table": "expeditionTruck"
}
}
}

View File

@ -0,0 +1,26 @@
{
"name": "RoadmapAddress",
"base": "VnModel",
"options": {
"mysql": {
"table": "roadmapAddress"
}
},
"properties": {
"addressFk": {
"type": "number",
"id": true,
"description": "Identifier"
},
"isActive": {
"type": "number"
}
},
"relations": {
"address": {
"type": "belongsTo",
"model": "Address",
"foreignKey": "addressFk"
}
}
}

View File

@ -15,7 +15,7 @@
"roadmapFk": {
"type": "number"
},
"warehouseFk": {
"addressFk": {
"type": "number"
},
"eta": {
@ -34,10 +34,10 @@
"model": "Roadmap",
"foreignKey": "roadmapFk"
},
"warehouse": {
"address": {
"type": "belongsTo",
"model": "Warehouse",
"foreignKey": "warehouseFk"
"model": "Address",
"foreignKey": "addressFk"
}
}
}

View File

@ -48,9 +48,6 @@
"priority": {
"type": "number"
},
"expeditionTruckFk": {
"type": "number"
},
"m3boxes": {
"type": "number"
},