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

This commit is contained in:
Carlos Andrés 2024-11-19 13:52:12 +01:00
commit 63c0747304
268 changed files with 2926 additions and 11023 deletions

View File

@ -57,10 +57,10 @@ module.exports = Self => {
ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving, ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving,
COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving, COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving,
sh.code, sh.code,
p2.code parkingCode, p2.code parkingCodePrevia,
p2.pickingOrder pickingOrder, p2.pickingOrder pickingOrderPrevia,
p.code parkingCodePrevia, p.code parkingCode,
p.pickingOrder pickingOrderPrevia, p.pickingOrder pickingOrder,
iss.id itemShelvingSaleFk, iss.id itemShelvingSaleFk,
iss.isPicked, iss.isPicked,
iss.itemShelvingFk iss.itemShelvingFk
@ -73,7 +73,7 @@ module.exports = Self => {
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN itemShelvingSale iss ON iss.saleFk = s.id JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk
@ -114,7 +114,7 @@ module.exports = Self => {
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN itemShelvingSale iss ON iss.saleFk = s.id JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk
LEFT JOIN origin o ON o.id = i.originFk LEFT JOIN origin o ON o.id = i.originFk

View File

@ -39,6 +39,9 @@ module.exports = Self => {
const xmlString = response.data; const xmlString = response.data;
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', xmlDoc]);
const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent;
return result.toLowerCase().includes('se ha cancelado correctamente'); return result.toLowerCase().includes('se ha cancelado correctamente');
}; };

View File

@ -79,6 +79,9 @@
"ImageCollectionSize": { "ImageCollectionSize": {
"dataSource": "vn" "dataSource": "vn"
}, },
"ImageConfig": {
"dataSource": "vn"
},
"ImageContainer": { "ImageContainer": {
"dataSource": "imageStorage" "dataSource": "imageStorage"
}, },
@ -139,6 +142,12 @@
"StarredModule": { "StarredModule": {
"dataSource": "vn" "dataSource": "vn"
}, },
"SaySimpleCountry": {
"dataSource": "vn"
},
"SaySimpleConfig": {
"dataSource": "vn"
},
"TempContainer": { "TempContainer": {
"dataSource": "tempStorage" "dataSource": "tempStorage"
}, },

View File

@ -44,6 +44,11 @@
"type": "belongsTo", "type": "belongsTo",
"model": "Continent", "model": "Continent",
"foreignKey": "continentFk" "foreignKey": "continentFk"
},
"saySimpleCountry": {
"type": "hasOne",
"model": "SaySimpleCountry",
"foreignKey": "countryFk"
} }
}, },
"acls": [ "acls": [
@ -54,4 +59,4 @@
"permission": "ALLOW" "permission": "ALLOW"
} }
] ]
} }

View File

@ -0,0 +1,22 @@
{
"name": "ImageConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "hedera.imageConfig"
}
},
"properties": {
"url": {
"type": "string"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -0,0 +1,29 @@
{
"name": "SaySimpleConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "saySimpleConfig"
}
},
"properties": {
"id": {
"type": "number",
"id": true
},
"url": {
"type": "string"
},
"defaultChannel": {
"type": "number"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -0,0 +1,26 @@
{
"name": "SaySimpleCountry",
"base": "VnModel",
"options": {
"mysql": {
"table": "saySimpleCountry"
}
},
"properties": {
"countryFk": {
"type": "number",
"id": true
},
"channel": {
"type": "number"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
}
]
}

View File

@ -2084,7 +2084,7 @@ INSERT INTO `ACL` VALUES (756,'Route','findOne','READ','ALLOW','ROLE','employee'
INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (757,'Route','getRoutesByWorker','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant',NULL); INSERT INTO `ACL` VALUES (758,'Route','canViewAllRoute','READ','ALLOW','ROLE','deliveryAssistant',NULL);
INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (759,'Route','cmr','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (760,'Route','downloadCmrsZip','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (760,'Cmr','downloadZip','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee',NULL);
INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee',NULL);

File diff suppressed because it is too large Load Diff

View File

@ -1254,9 +1254,9 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`) INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `visible`, `grouping`, `packing`,`buyFk`, `userFk`)
VALUES VALUES
(2, 'GVC', 1, 1, 1, 2,1106), (2, 11, 1, 1, 1, 2,1106),
(4, 'HEJ', 1, 1, 1, NULL,1106), (4, 12, 1, 1, 1, NULL,1106),
(1, 'UXN', 2, 12, 12, NULL,1106); (1, 13, 2, 12, 12, NULL,1106);
INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`)
VALUES VALUES
@ -3425,7 +3425,7 @@ INSERT INTO vn.buy
INSERT INTO vn.itemShelving INSERT INTO vn.itemShelving
SET id = 9931, SET id = 9931,
itemFk = 999993, itemFk = 999993,
shelvingFk = 'NCC', shelvingFk = 16,
visible = 10, visible = 10,
`grouping` = 5, `grouping` = 5,
packing = 10; packing = 10;
@ -3752,7 +3752,7 @@ INSERT vn.sale
USE vn; USE vn;
DELETE ish.* FROM vn.itemShelving ish DELETE ish.* FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.warehouse w ON w.id = s.warehouseFk JOIN vn.warehouse w ON w.id = s.warehouseFk
@ -3761,22 +3761,22 @@ DELETE ish.* FROM vn.itemShelving ish
INSERT INTO vn.itemShelving INSERT INTO vn.itemShelving
(itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked) (itemFk, shelvingFk, visible, created, `grouping`, packing, packagingFk, userFk, isChecked)
VALUES VALUES
(999991, 'NAA', 8, '2023-09-20', 1, 20, NULL, 103, NULL), (999991, 14, 8, '2023-09-20', 1, 20, NULL, 103, NULL),
(999998, 'NAA', 80, '2023-09-20', 10, 30, NULL, 103, NULL), (999998, 14, 80, '2023-09-20', 10, 30, NULL, 103, NULL),
(1000001, 'NAA', 6, '2023-09-20', 3, 50, NULL, 103, NULL), (1000001, 14, 6, '2023-09-20', 3, 50, NULL, 103, NULL),
(1000000, 'NBB', 50, '2023-09-18', 25, 500, NULL, 103, NULL), (1000000, 15, 50, '2023-09-18', 25, 500, NULL, 103, NULL),
(999993, 'NBB', 25, '2023-09-18', NULL, 10, NULL, 103, NULL), (999993, 15, 25, '2023-09-18', NULL, 10, NULL, 103, NULL),
(999999, 'NBB', 30, '2023-09-18', 10, 500, NULL, 103, NULL), (999999, 15, 30, '2023-09-18', 10, 500, NULL, 103, NULL),
(999993, 'NCC', 25, '2023-09-20', 5, 10, NULL, 103, NULL), (999993, 16, 25, '2023-09-20', 5, 10, NULL, 103, NULL),
(999997, 'NCC', 10, '2023-09-20', NULL, 100, NULL, 103, NULL), (999997, 16, 10, '2023-09-20', NULL, 100, NULL, 103, NULL),
(999999, 'NCC', 40, '2023-09-20', 10, 500, NULL, 103, NULL), (999999, 16, 40, '2023-09-20', 10, 500, NULL, 103, NULL),
(999995, 'NDD', 10, '2023-09-19', NULL, 20, NULL, 103, NULL), (999995, 17, 10, '2023-09-19', NULL, 20, NULL, 103, NULL),
(999994, 'NDD', 48, '2023-09-19', 4, 20, NULL, 103, NULL), (999994, 17, 48, '2023-09-19', 4, 20, NULL, 103, NULL),
(1000001, 'NEE', 6, '2023-09-21', 3, 50, NULL, 103, NULL), (1000001, 18, 6, '2023-09-21', 3, 50, NULL, 103, NULL),
(999992, 'NEE', 50, '2023-09-21', NULL, 1, NULL, 103, NULL), (999992, 18, 50, '2023-09-21', NULL, 1, NULL, 103, NULL),
(1000000, 'NEE', 25, '2023-09-21', 25, 500, NULL, 103, NULL), (1000000, 18, 25, '2023-09-21', 25, 500, NULL, 103, NULL),
(999996, 'PAA', 5, '2023-09-27', 1, 5, NULL, 103, NULL), (999996, 19, 5, '2023-09-27', 1, 5, NULL, 103, NULL),
(999997, 'PCC', 10, '2023-09-27', 5, 100, NULL, 103, NULL); (999997, 21, 10, '2023-09-27', 5, 100, NULL, 103, NULL);
-- Previous for Bolas de madera -- Previous for Bolas de madera
INSERT IGNORE INTO vn.sectorCollection INSERT IGNORE INTO vn.sectorCollection
@ -4008,6 +4008,10 @@ INSERT IGNORE INTO pbx.queueMember
UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA";
UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS";
INSERT INTO vn.routeAction (id, name, price, isMainlineDelivered) VALUES(1, 'Pintar traje', 50.00, 0);
INSERT INTO vn.routeComplement (id, dated, workerFk, price, routeActionFk) VALUES(1, util.VN_CURDATE(), 9, 50.00, 1);
INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk) INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, code, stratus, hasWorkerWaiting, reserve, routeFk, dayMinute, lastUnloaded, hasStrapper, typeDefaultFk, motors, editorFk)
VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), VALUES (0, 0, 0, 0, NULL, 3, 1, 0, 'ENT', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
(1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL), (1, 0, 9900, 0, NULL, 1, 0, 0, 'NOK', 0, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL),
@ -4022,3 +4026,9 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c
(10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL); (10, 0, 2000, 500, 13000, 1, 1, 1, '05A', 5, 0, NULL, NULL, NULL, NULL, 0, 1, 1, NULL);
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
VALUES (19, '1169'),
(8, '1183');
INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel)
VALUES ('saysimle-url-mock', 1320);

View File

@ -7,8 +7,7 @@ AS SELECT `u`.`id` AS `id`,
`u`.`email` AS `email`, `u`.`email` AS `email`,
`u`.`nickname` AS `nickname`, `u`.`nickname` AS `nickname`,
`u`.`lang` AS `lang`, `u`.`lang` AS `lang`,
`u`.`role` AS `role`, `u`.`role` AS `role`
`u`.`recoverPass` AS `recoverPass`
FROM `account`.`user` `u` FROM `account`.`user` `u`
WHERE `u`.`name` = `myUser_getName`() WHERE `u`.`name` = `myUser_getName`()
WITH CASCADED CHECK OPTION WITH CASCADED CHECK OPTION

View File

@ -32,7 +32,7 @@ BEGIN
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
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
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

View File

@ -9,45 +9,54 @@ BEGIN
* @param vOrder El identificador del pedido * @param vOrder El identificador del pedido
* @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia * @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia
*/ */
-- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany;
CREATE TEMPORARY TABLE tmp.addressCompany CREATE TEMPORARY TABLE tmp.addressCompany
(INDEX (addressFk, companyFk)) (INDEX (addressFk, companyFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT DISTINCT o.address_id addressFk, o.company_id companyFk SELECT DISTINCT o.address_id addressFk, o.company_id companyFk
FROM tmp.`order` tmpOrder FROM tmp.`order` tmpOrder
JOIN hedera.`order` o ON o.id = tmpOrder.orderFk; JOIN `order` o ON o.id = tmpOrder.orderFk;
CALL vn.addressTaxArea; CALL vn.addressTaxArea();
-- Calcula el IVA y el recargo desglosado. -- Calcula el IVA y el recargo desglosado.
CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax
DROP TEMPORARY TABLE IF EXISTS tmp.orderTax; (PRIMARY KEY (orderFk, code, rate))
CREATE TEMPORARY TABLE tmp.orderTax
(INDEX (orderFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT o.id orderFk, WITH orders AS (
SELECT tor.orderFk,
oro.amount * oro.price total,
s.countryFk,
ata.areaFk,
itc.taxClassFk
FROM hedera.orderRow oro
JOIN tmp.order tor ON tor.orderFk = oro.orderFk
JOIN hedera.`order` o ON o.id = tor.orderFk
JOIN vn.item i ON i.id = oro.itemFk
JOIN vn.`client` c ON c.id = o.customer_id
JOIN vn.supplier s ON s.id = o.company_id
JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id
AND ata.companyFk = o.company_id
JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id
AND itc.countryFk = s.countryFk
HAVING total
)
SELECT o.orderFk,
tc.code, tc.code,
SUM(m.amount * m.price) taxableBase, SUM(o.total) taxableBase,
pgc.rate pgc.rate
FROM tmp.`order` tmpOrder FROM orders o
JOIN `order` o ON o.id = tmpOrder.orderFk JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk
JOIN orderRow m ON m.orderFk = o.id AND bp.taxAreaFk = o.areaFk
JOIN vn.item i ON i.id = m.itemFk AND bp.taxClassFk = o.taxClassFk
JOIN vn.`client` c ON c.id = o.customer_id JOIN vn.pgc ON pgc.code = bp.pgcFk
JOIN vn.supplier s ON s.id = o.company_id
JOIN tmp.addressTaxArea ata
ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id
JOIN vn.itemTaxCountry itc
ON itc.itemFk = i.id AND itc.countryFk = s.countryFk
JOIN vn.bookingPlanner bp
ON bp.countryFk = s.countryFk
AND bp.taxAreaFk = ata.areaFk
AND bp.taxClassFk = itc.taxClassFk
JOIN vn.pgc ON pgc.`code` = bp.pgcFk
JOIN vn.taxClass tc ON tc.id = bp.taxClassFk JOIN vn.taxClass tc ON tc.id = bp.taxClassFk
GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate GROUP BY o.orderFk, pgc.code, pgc.rate
HAVING taxableBase != 0; HAVING taxableBase
ORDER BY bp.priority;
-- No poner create or replace, ya que da problemas
DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount;
CREATE TEMPORARY TABLE tmp.orderAmount CREATE TEMPORARY TABLE tmp.orderAmount
(INDEX (orderFk)) (INDEX (orderFk))

View File

@ -14,9 +14,12 @@ BEGIN
SELECT p.geoFk INTO vGeoFk SELECT p.geoFk INTO vGeoFk
FROM address a FROM address a
JOIN town t ON t.provinceFk = a.provinceFk JOIN town t ON t.provinceFk = a.provinceFk
JOIN postCode p ON p.townFk = t.id AND p.`code` = a.postalCode JOIN postCode p ON p.townFk = t.id
AND (p.code = a.postalCode OR a.postalCode IS NULL)
JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE a.id = vSelf WHERE a.id = vSelf
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC ORDER BY (a.city SOUNDS LIKE t.name) DESC,
(p.code = a.postalCode) DESC
LIMIT 1; LIMIT 1;
RETURN vGeoFk; RETURN vGeoFk;

View File

@ -0,0 +1,27 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`client_getGeo`(vSelf INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Returns the geo for the passed client.
*
* @param vSelf The address id
* @return The geo id
*/
DECLARE vGeoFk INT;
SELECT p.geoFk INTO vGeoFk
FROM client c
JOIN town t ON t.provinceFk = c.provinceFk
JOIN postCode p ON p.townFk = t.id
AND (p.code = c.postcode OR c.postcode IS NULL)
JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE c.id = vSelf
ORDER BY (c.city SOUNDS LIKE t.name) DESC,
(p.code = c.postcode) DESC
LIMIT 1;
RETURN vGeoFk;
END$$
DELIMITER ;

View File

@ -1,58 +1,51 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT, CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(vTravelFk INT,
vCurrencyFk INT, vCurrencyFk INT,
vSupplierFk INT vSupplierFk INT
) )
RETURNS int(11) RETURNS int(11)
NOT DETERMINISTIC NOT DETERMINISTIC
READS SQL DATA READS SQL DATA
BEGIN BEGIN
DECLARE vCommission INT; DECLARE vCommission INT;
DECLARE vCurrentCommission INT; DECLARE vCurrentCommission INT;
DECLARE vIsCurrencyUsd INT; DECLARE vIsNotEUR INT;
DECLARE vLastEntryFk INT; DECLARE vLastEntryFk INT;
SELECT count(*) INTO vIsCurrencyUsd
FROM currency c
WHERE c.code = 'USD' AND id = vCurrencyFk;
IF NOT vIsCurrencyUsd THEN
SELECT e.id INTO vLastEntryFk
FROM vn.entry e
JOIN vn.travel tr ON tr.id = e.travelFk
WHERE e.supplierFk = vSupplierFk
ORDER BY tr.landed DESC
LIMIT 1;
IF vLastEntryFk THEN
SELECT commission INTO vCurrentCommission
FROM vn.entry
WHERE id = vLastEntryFk;
ELSE
SELECT commission INTO vCurrentCommission
FROM supplier s
WHERE s.id = vSupplierFk;
END IF;
RETURN vCurrentCommission;
ELSE
SELECT count(*) INTO vIsNotEUR
FROM currency c
WHERE c.code <> 'EUR' AND id = vCurrencyFk;
IF vIsNotEUR THEN
SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission
FROM travel t FROM travel t
LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped LEFT JOIN referenceCurrent r ON r.currencyFk = vCurrencyFk AND r.`dated` <= t.shipped
WHERE t.id = vTravelFk WHERE t.id = vTravelFk
ORDER BY r.`dated` DESC ORDER BY r.`dated` DESC
LIMIT 1; LIMIT 1;
RETURN IFNULL(vCommission, 0); RETURN IFNULL(vCommission, 0);
ELSE
END IF; SELECT e.id INTO vLastEntryFk
FROM `entry` e
JOIN travel tr ON tr.id = e.travelFk
WHERE e.supplierFk = vSupplierFk
ORDER BY tr.landed DESC
LIMIT 1;
IF vLastEntryFk THEN
SELECT commission INTO vCurrentCommission
FROM `entry`
WHERE id = vLastEntryFk;
ELSE
SELECT commission INTO vCurrentCommission
FROM supplier s
WHERE s.id = vSupplierFk;
END IF;
RETURN vCurrentCommission;
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -9,7 +9,7 @@ BEGIN
SELECT count(*) INTO vItemCount SELECT count(*) INTO vItemCount
FROM vn.sale s FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk; AND p.sectorFk = vSectorFk;

View File

@ -10,7 +10,7 @@ BEGIN
SELECT count(*) INTO vItemCount SELECT count(*) INTO vItemCount
FROM vn.sale s FROM vn.sale s
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
WHERE s.ticketFk = vTicketFk WHERE s.ticketFk = vTicketFk
AND p.sectorFk = vSectorFk; AND p.sectorFk = vSectorFk;

View File

@ -0,0 +1,29 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`supplier_getGeo`(vSelf INT)
RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Returns the geo for the passed supplier.
*
* @param vSelf The address id
* @return The geo id
*/
DECLARE vGeoFk INT;
SELECT p.geoFk INTO vGeoFk
FROM supplier s
JOIN town t ON t.provinceFk = s.provinceFk
JOIN postCode p ON p.townFk = t.id
AND (p.code = s.postCode OR s.postCode IS NULL)
LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id
JOIN zoneGeo zg ON zg.id = p.geoFk
WHERE s.id = vSelf
ORDER BY (s.city SOUNDS LIKE t.name) DESC,
(p.code = s.postCode) DESC,
(p.code = sad.postalCode) DESC
LIMIT 1;
RETURN vGeoFk;
END$$
DELIMITER ;

View File

@ -83,7 +83,7 @@ BEGIN
AND s.semaphore = 1 AND s.semaphore = 1
GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk
JOIN itemShelving ish ON ish.itemFk = ts.itemFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk JOIN sectorType st ON st.id = sc.typeFk

View File

@ -1,10 +1,15 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(vShelvingFk VARCHAR(3), vFromEntryFk INT, vToEntryFk INT) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`entry_splitByShelving`(
vShelvingCode VARCHAR(10),
vFromEntryFk INT,
vToEntryFk INT
)
BEGIN BEGIN
/** /**
* Divide las compras entre dos entradas de acuerdo con lo ubicado en una matr<EFBFBD>cula * Divide las compras entre dos entradas de
* acuerdo con lo ubicado en una matricula.
* *
* @param vShelvingFk Identificador de vn.shelving * @param vShelvingCode Código de vn.shelving
* @param vFromEntryFk Entrada origen * @param vFromEntryFk Entrada origen
* @param vToEntryFk Entrada destino * @param vToEntryFk Entrada destino
*/ */
@ -14,7 +19,7 @@ BEGIN
DECLARE vDone BOOLEAN DEFAULT FALSE; DECLARE vDone BOOLEAN DEFAULT FALSE;
DECLARE cur CURSOR FOR DECLARE cur CURSOR FOR
SELECT bb.id buyFk, SELECT bb.id buyFk,
LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers,
bb.stickers buyStickers bb.stickers buyStickers
FROM itemShelving ish FROM itemShelving ish
@ -23,7 +28,7 @@ BEGIN
WHERE b.entryFk = vFromEntryFk WHERE b.entryFk = vFromEntryFk
ORDER BY b.stickers DESC ORDER BY b.stickers DESC
LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci WHERE ish.shelvingFk = vShelvingCode COLLATE utf8_general_ci
AND NOT ish.isSplit AND NOT ish.isSplit
GROUP BY ish.id; GROUP BY ish.id;
@ -107,9 +112,10 @@ BEGIN
UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID(); UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID();
END IF; END IF;
UPDATE itemShelving UPDATE itemShelving ish
SET isSplit = TRUE JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; SET ish.isSplit = TRUE
WHERE sh.code = vShelvingCode COLLATE utf8_general_ci;
END LOOP; END LOOP;
CLOSE cur; CLOSE cur;
END$$ END$$

View File

@ -22,7 +22,7 @@ BEGIN
FROM vn.entry e FROM vn.entry e
JOIN vn.travel t ON t.id = e.travelFk JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk JOIN vn.warehouse w ON w.id = t.warehouseInFk
WHERE t.shipped >= util.VN_CURDATE() WHERE t.landed >= util.VN_CURDATE()
AND e.currencyFk = vCurrency AND e.currencyFk = vCurrency
AND NOT e.isBooked; AND NOT e.isBooked;
@ -33,7 +33,7 @@ BEGIN
SET e.commission = vComission; SET e.commission = vComission;
SELECT `name` INTO vCurrencyName SELECT `name` INTO vCurrencyName
FROM currency FROM currency
WHERE id = vCurrency; WHERE id = vCurrency;
CALL entry_recalc(); CALL entry_recalc();

View File

@ -1,5 +1,9 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(vShelvingFk VARCHAR(10), quantity INT, vItemFk INT) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyAiming`(
vShelvingCode VARCHAR(10),
vQuantity INT,
vItemFk INT
)
BEGIN BEGIN
SELECT ish.itemFk, SELECT ish.itemFk,
@ -9,21 +13,21 @@ BEGIN
ish.itemShelvingFk, ish.itemShelvingFk,
ish.shelving, ish.shelving,
ish.stock, ish.stock,
LEAST(ish.stock,quantity) as total, LEAST(ish.stock,vQuantity) total,
CONCAT( CONCAT(
CAST(FLOOR(LEAST(ish.stock,quantity) / ish.packing) AS DECIMAL(10,0)), CAST(FLOOR(LEAST(ish.stock, vQuantity) / ish.packing) AS DECIMAL(10,0)),
' x ', ' x ',
ish.packing, ish.packing,
IF ( IF (
LEAST(ish.stock,quantity) MOD ish.packing, LEAST(ish.stock, vQuantity) MOD ish.packing,
CONCAT(' + ',CAST(LEAST(ish.stock,quantity) MOD ish.packing AS DECIMAL(10,0))), CONCAT(' + ',CAST(LEAST(ish.stock, vQuantity) MOD ish.packing AS DECIMAL(10,0))),
'' ''
), ),
' = ', ' = ',
LEAST(ish.stock,quantity) LEAST(ish.stock, vQuantity)
) as proposal ) proposal
FROM vn.itemShelvingPlacementSupplyStock ish FROM itemShelvingPlacementSupplyStock ish
WHERE ish.shelving = vShelvingFk COLLATE utf8_general_ci WHERE ish.shelving = vShelvingCode COLLATE utf8_general_ci
AND ish.itemFk = vItemFk; AND ish.itemFk = vItemFk;
END$$ END$$

View File

@ -1,5 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(vSector INT ) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyGetOrder`(
vSectorFk INT
)
BEGIN BEGIN
DECLARE vId INT; DECLARE vId INT;
@ -7,31 +9,35 @@ BEGIN
DECLARE vNextParkingFk INT; DECLARE vNextParkingFk INT;
SELECT sh.parkingFk INTO vLastParkingFk SELECT sh.parkingFk INTO vLastParkingFk
FROM vn.itemShelvingPlacementSupply isps FROM itemShelvingPlacementSupply isps
JOIN vn.itemShelving ish ON ish.id = isps.itemShelvingFk JOIN itemShelving ish ON ish.id = isps.itemShelvingFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
WHERE isps.userFk = getUser() WHERE isps.userFk = getUser()
ORDER BY isps.created DESC ORDER BY isps.created DESC
LIMIT 1; LIMIT 1;
SET vNextParkingFk = vn.itemShelvingPlacementSupply_ClosestGet(vLastParkingFk); SET vNextParkingFk = itemShelvingPlacementSupply_ClosestGet(vLastParkingFk);
SELECT ipsl.id INTO vId SELECT ipsl.id INTO vId
FROM vn.itemPlacementSupplyList ipsl FROM itemPlacementSupplyList ipsl
JOIN vn.itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk JOIN itemShelvingPlacementSupplyStock ispss ON ispss.itemFk = ipsl.itemFk
WHERE ipsl.saldo > 0 WHERE ipsl.saldo > 0
AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser()) AND (ipsl.repoUserFk is NULL OR ipsl.repoUserFk = getUser())
AND ipsl.sectorFk = vSector AND ipsl.sectorFk = vSectorFk
ORDER BY ipsl.repoUserFk DESC, ipsl.priority DESC, (ispss.parkingFk = vNextParkingFk) DESC, ispss.parking DESC, ipsl.created ORDER BY ipsl.repoUserFk DESC,
ipsl.priority DESC,
(ispss.parkingFk = vNextParkingFk) DESC,
ispss.parking DESC,
ipsl.created
LIMIT 1; LIMIT 1;
UPDATE vn.itemPlacementSupply UPDATE itemPlacementSupply
SET repoUserFk = getUser() SET repoUserFk = getUser()
WHERE id = vId; WHERE id = vId;
SELECT * FROM vn.itemPlacementSupplyList SELECT * FROM itemPlacementSupplyList
WHERE id = vId WHERE id = vId
AND sectorFk = vSector; AND sectorFk = vSectorFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,5 +1,8 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(vItemFk INT,vSectorFk INT) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemPlacementSupplyStockGetTargetList`(
vItemFk INT,
vSectorFk INT
)
BEGIN BEGIN
/** /**
* Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa. * Devuelve la lista de ubicaciones para itemFk en ese sector. Se utiliza en la preparación previa.
@ -13,11 +16,11 @@ BEGIN
SUM(ish.visible) stockTotal, SUM(ish.visible) stockTotal,
ish.created, ish.created,
p.pickingOrder p.pickingOrder
FROM vn.itemShelving ish FROM itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk JOIN sector sc ON sc.id = p.sectorFk
JOIN vn.warehouse w ON w.id = sc.warehouseFk JOIN warehouse w ON w.id = sc.warehouseFk
WHERE ish.visible > 0 WHERE ish.visible > 0
AND ish.itemFk = vItemFk AND ish.itemFk = vItemFk
GROUP BY ish.id GROUP BY ish.id

View File

@ -1,14 +1,14 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(
vShelvingCode VARCHAR(10)
)
BEGIN BEGIN
/** /**
* Devuelve el log de los item en cada carro * Devuelve el log de los item en cada carro
* *
* @param vShelvingFk Matrícula del carro * @param vShelvingCode Matrícula del carro
* *
*/ */
SELECT isl.itemShelvingFk, SELECT isl.itemShelvingFk,
isl.created, isl.created,
isl.accion, isl.accion,
@ -28,8 +28,9 @@ BEGIN
FROM item FROM item
JOIN itemShelvingLog isl ON item.id = isl.itemFk JOIN itemShelvingLog isl ON item.id = isl.itemFk
JOIN worker ON isl.workerFk = worker.id JOIN worker ON isl.workerFk = worker.id
WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk JOIN shelving sh ON sh.id = isl.shelvingFk
ORDER BY isl.created DESC; WHERE sh.code = vShelvingCode COLLATE utf8mb3_unicode_ci
OR isl.itemFk = vShelvingCode -- ?? Respeto porque ya estaba
ORDER BY isl.created DESC;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -20,7 +20,7 @@ BEGIN
LEFT JOIN ( LEFT JOIN (
SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas SELECT itemFk, sum(cast(visible / packing AS DECIMAL(10,0))) AS etiquetas
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking pk ON pk.id = sh.parkingFk LEFT JOIN parking pk ON pk.id = sh.parkingFk
WHERE ish.created BETWEEN vFromTimed AND vToTimed WHERE ish.created BETWEEN vFromTimed AND vToTimed
GROUP BY itemFk GROUP BY itemFk

View File

@ -27,7 +27,7 @@ proc: BEGIN
ish.available ish.available
FROM sale s FROM sale s
JOIN itemShelving ish ON ish.itemFk = s.itemFk JOIN itemShelving ish ON ish.itemFk = s.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk JOIN sector sc ON sc.id = p.sectorFk
JOIN productionConfig pc JOIN productionConfig pc
@ -61,7 +61,7 @@ proc: BEGIN
FROM sale s FROM sale s
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN parking p ON p.id = sh.parkingFk
WHERE s.id = vSaleFk; WHERE s.id = vSaleFk;

View File

@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQ
vItemShelvingSaleFk INT(10), vItemShelvingSaleFk INT(10),
vQuantity DECIMAL(10,0), vQuantity DECIMAL(10,0),
vIsItemShelvingSaleEmpty BOOLEAN, vIsItemShelvingSaleEmpty BOOLEAN,
vSectorFk INT vSectorFk INT,
vShelvingFk VARCHAR(10)
) )
BEGIN BEGIN
/** /**
@ -24,6 +25,7 @@ BEGIN
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vTotalQuantity INT; DECLARE vTotalQuantity INT;
DECLARE vStateCode VARCHAR(45); DECLARE vStateCode VARCHAR(45);
DECLARE vCurrentShelvingFk VARCHAR(10);
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
@ -45,18 +47,25 @@ BEGIN
iss.saleFk, iss.saleFk,
iss.itemShelvingFk, iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)), SUM(IFNULL(iss.quantity,0)),
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED'),
ish.shelvingFk
INTO vItemFk, INTO vItemFk,
vSaleFk, vSaleFk,
vItemShelvingFk, vItemShelvingFk,
vReservedQuantity, vReservedQuantity,
vStateCode vStateCode,
vCurrentShelvingFk
FROM itemShelvingSale iss FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk JOIN sale s ON s.id = iss.saleFk
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
WHERE iss.id = vItemShelvingSaleFk WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked; AND NOT iss.isPicked;
IF NOT (vCurrentShelvingFk <=> vShelvingFk) THEN
CALL util.throw('The shelving can not be different from the shelving reserved');
END IF;
IF vQuantity > vReservedQuantity IF vQuantity > vReservedQuantity
OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty)
OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_add`(
vShelvingFk VARCHAR(8), vShelvingCode VARCHAR(10),
vBarcode VARCHAR(22), vBarcode VARCHAR(22),
vQuantity INT, vQuantity INT,
vPackagingFk VARCHAR(10), vPackagingFk VARCHAR(10),
@ -12,7 +12,7 @@ BEGIN
/** /**
* Añade registro o lo actualiza si ya existe. * Añade registro o lo actualiza si ya existe.
* *
* @param vShelvingFk matrícula del carro * @param vShelvingCode matrícula del carro
* @param vBarcode el id del registro * @param vBarcode el id del registro
* @param vQuantity indica la cantidad del producto * @param vQuantity indica la cantidad del producto
* @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra
@ -23,10 +23,15 @@ BEGIN
**/ **/
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vBuyFk INT; DECLARE vBuyFk INT;
DECLARE vShelvingFk INT;
SELECT id INTO vBuyFk SELECT id INTO vBuyFk
FROM buy WHERE id = vBarcode; FROM buy WHERE id = vBarcode;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT barcodeToItem(vBarcode) INTO vItemFk; SELECT barcodeToItem(vBarcode) INTO vItemFk;
IF vBuyFk IS NULL THEN IF vBuyFk IS NULL THEN
@ -40,7 +45,7 @@ BEGIN
END IF; END IF;
IF (SELECT COUNT(*) FROM itemShelving IF (SELECT COUNT(*) FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk AND itemFk = vItemFk
AND packing = vPacking AND packing = vPacking
AND buyFk = vBuyFk) THEN AND buyFk = vBuyFk) THEN
@ -48,7 +53,9 @@ BEGIN
UPDATE itemShelving UPDATE itemShelving
SET visible = visible + vQuantity, SET visible = visible + vQuantity,
available = available + vQuantity available = available + vQuantity
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk AND itemFk = vItemFk AND packing = vPacking; WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk
AND packing = vPacking;
ELSE ELSE

View File

@ -1,29 +1,38 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(vClaimFk INT, vShelvingFk VARCHAR(3)) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addByClaim`(
vClaimFk INT,
vShelvingCode VARCHAR(10)
)
BEGIN BEGIN
/** /**
* Insert items of claim into itemShelving. * Insert items of claim into itemShelving.
* *
* @param vClaimFk The claim * @param vClaimFk The claim
* @param vShelvingFk The shelving * @param vShelvingCode The shelving code
* @table tmp.buyUltimate * @table tmp.buyUltimate
*/ */
DECLARE vWarehouseFk INT; DECLARE vWarehouseFk INT;
DECLARE vShelvingFk INT;
SELECT t.warehouseFk INTO vWarehouseFk SELECT t.warehouseFk INTO vWarehouseFk
FROM claim c FROM claim c
JOIN ticket t ON t.id = c.ticketFk JOIN ticket t ON t.id = c.ticketFk
WHERE c.id = vClaimFk; WHERE c.id = vClaimFk;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE());
INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible)
SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity visible
FROM claim c FROM claim c
JOIN claimBeginning cb ON c.id = cb.claimFk JOIN claimBeginning cb ON c.id = cb.claimFk
JOIN sale s ON s.id = cb.saleFk JOIN sale s ON s.id = cb.saleFk
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk AND bu.warehouseFk = t.warehouseFk JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
AND bu.warehouseFk = t.warehouseFk
JOIN buy b ON b.id = bu.buyFk JOIN buy b ON b.id = bu.buyFk
WHERE c.id = vClaimFk; WHERE c.id = vClaimFk;
END$$ END$$

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_addList`(
vShelvingFk VARCHAR(3), vShelvingCode VARCHAR(10),
vList TEXT, vList TEXT,
vIsChecking BOOL, vIsChecking BOOL,
vWarehouseFk INT vWarehouseFk INT
@ -13,7 +13,7 @@ BEGIN
* Cuando es TRUE sólo inserta los elementos de la colección que no están ya en * Cuando es TRUE sólo inserta los elementos de la colección que no están ya en
* ese shelving, actualizando los valores del campo itemShelving.isChecked * ese shelving, actualizando los valores del campo itemShelving.isChecked
* *
* @param vShelvingFk Identificador de shelving * @param vShelvingCode Código de shelving
* @param vList JSON array con esta estructura: '[value1, value2, ...]' * @param vList JSON array con esta estructura: '[value1, value2, ...]'
* @param vIsChecking Define si hay que añadir o comprobar los items * @param vIsChecking Define si hay que añadir o comprobar los items
* @param vWarehouseFk Identificador de warehouse * @param vWarehouseFk Identificador de warehouse
@ -24,6 +24,11 @@ BEGIN
DECLARE vPath VARCHAR(6); DECLARE vPath VARCHAR(6);
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vIsChecked BOOL; DECLARE vIsChecked BOOL;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
WHILE vCounter < vListLength DO WHILE vCounter < vListLength DO
SET vPath = CONCAT('$[', vCounter, ']'); SET vPath = CONCAT('$[', vCounter, ']');
@ -34,17 +39,17 @@ BEGIN
SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked SELECT IF(COUNT(*), TRUE, FALSE) INTO vIsChecked
FROM itemShelving FROM itemShelving
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk; AND itemFk = vItemFk;
END IF; END IF;
IF NOT vIsChecking OR NOT vIsChecked THEN IF NOT vIsChecking OR NOT vIsChecked THEN
CALL itemShelving_add(vShelvingFk, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk); CALL itemShelving_add(vShelvingCode, vBarcode, 1, NULL, NULL, NULL, vWarehouseFk);
END IF; END IF;
UPDATE itemShelving UPDATE itemShelving
SET isChecked = vIsChecked SET isChecked = vIsChecked
WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk WHERE shelvingFk = vShelvingFk
AND itemFk = vItemFk AND itemFk = vItemFk
AND isChecked IS NULL; AND isChecked IS NULL;

View File

@ -1,10 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(IN vSelf VARCHAR(8)) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_get`(
vShelvingCode VARCHAR(10)
)
BEGIN BEGIN
/** /**
* Lista artículos de itemshelving * Lista artículos de itemShelving.
* *
* @param vSelf matrícula del carro * @param vShelvingCode Matrícula del carro
**/ **/
SELECT ish.itemFk item, SELECT ish.itemFk item,
i.name, i.name,
@ -22,9 +24,9 @@ BEGIN
ish.buyFk ish.buyFk
FROM itemShelving ish FROM itemShelving ish
JOIN item i ON i.id = ish.itemFk JOIN item i ON i.id = ish.itemFk
JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci JOIN shelving s ON s.id = ish.shelvingFk
LEFT JOIN parking p ON s.parkingFk = p.id LEFT JOIN parking p ON p.id = s.parkingFk
JOIN hedera.imageConfig ic JOIN hedera.imageConfig ic
WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; WHERE s.code COLLATE utf8_unicode_ci = vShelvingCode;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,21 +1,31 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(vShelvingFk VARCHAR(10)) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getAlternatives`(
vShelvingCode VARCHAR(10)
)
BEGIN BEGIN
/** /**
* Devuelve un listado de posibles ubicaciones alternativas a ubicar los item de la matricula * Devuelve un listado de posibles ubicaciones alternativas a ubicar
* del carro que se le ha pasado. * los item de la matricula del carro que se le ha pasado.
* *
* @param vShelvingFk matricula del carro * @param vShelvingCode Matricula del carro
*/ */
SELECT is2.id,is2.shelvingFk , p.code, is2.itemFk , is2.visible, p.pickingOrder DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT is2.id,is2.shelvingFk, p.code, is2.itemFk , is2.visible, p.pickingOrder
FROM itemShelving is2 FROM itemShelving is2
JOIN shelving sh ON sh.code = is2.shelvingFk JOIN shelving sh ON sh.id = is2.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk JOIN sector s ON s.id = p.sectorFk
LEFT JOIN operator o ON o.sectorFk = s.id AND o.workerFk = account.myUser_getId() LEFT JOIN operator o ON o.sectorFk = s.id
AND o.workerFk = account.myUser_getId()
JOIN warehouse wh ON wh.id = s.warehouseFk JOIN warehouse wh ON wh.id = s.warehouseFk
JOIN itemShelving is3 ON is3.itemFk = is2.itemFk AND is3.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci JOIN itemShelving is3 ON is3.itemFk = is2.itemFk
WHERE is2.shelvingFk <> vShelvingFk COLLATE utf8_unicode_ci AND is3.shelvingFk = vShelvingFk
WHERE is2.shelvingFk <> vShelvingFk
GROUP BY is2.id GROUP BY is2.id
ORDER BY p.pickingOrder DESC; ORDER BY p.pickingOrder DESC;
END$$ END$$

View File

@ -16,7 +16,7 @@ BEGIN
ish.itemFk itemFk, ish.itemFk itemFk,
sh.priority sh.priority
FROM vn.itemShelving ish FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.`code` = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking pk ON pk.id = sh.parkingFk JOIN vn.parking pk ON pk.id = sh.parkingFk
WHERE ish.itemFk = vItemFk WHERE ish.itemFk = vItemFk
ORDER BY sh.priority DESC, created ASC; ORDER BY sh.priority DESC, created ASC;

View File

@ -1,14 +1,14 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getItemDetails`(
vBarcodeItem INT, vBarcodeItem INT,
vShelvingFK VARCHAR(10) vShelvingCode VARCHAR(10)
) )
BEGIN BEGIN
/** /**
* Obtiene el precio y visible de un item * Obtiene el precio y visible de un item
* *
* @param vBarcodeItem barcode de artículo * @param vBarcodeItem barcode de artículo
* @param vShelvingFK Ubicación actual del artículo * @param vShelvingCode Ubicación actual del artículo
*/ */
DECLARE vIsItem BOOL; DECLARE vIsItem BOOL;
DECLARE vBuyFk INT; DECLARE vBuyFk INT;
@ -38,18 +38,19 @@ BEGIN
WITH visible AS( WITH visible AS(
SELECT itemFk, SELECT itemFk,
IFNULL(buyingValue, 0) + IFNULL(buyingValue, 0) +
IFNULL(freightValue, 0) + IFNULL(freightValue, 0) +
IFNULL(comissionValue, 0) + IFNULL(comissionValue, 0) +
IFNULL(packageValue, 0) itemCost IFNULL(packageValue, 0) itemCost
FROM vn.buy b FROM vn.buy b
WHERE b.id = vBuyFk WHERE b.id = vBuyFk
) SELECT v.itemFk, ) SELECT v.itemFk,
vShelvingFK, vShelvingCode,
v.itemCost, v.itemCost,
SUM(ish.visible) visible SUM(ish.visible) visible
FROM vn.itemShelving ish FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.id = ish.shelvingFK
JOIN visible v JOIN visible v
WHERE ish.shelvingFK = vShelvingFK COLLATE utf8mb3_general_ci WHERE sh.code = vShelvingCode COLLATE utf8mb3_general_ci
AND ish.itemFk = v.itemFk; AND ish.itemFk = v.itemFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,14 +1,20 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(vShelvingFk VARCHAR(3)) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_getSaleDate`(
vShelvingCode VARCHAR(10)
)
BEGIN BEGIN
/**
/* Devuelve la mínima fecha en que se necesita cada producto en esa matrícula. * Devuelve la mínima fecha en que se necesita cada producto en esa matrícula.
* *
* @param vShelvingFk Matrícula del carro o pallet * @param vShelvingCode Matrícula del carro o pallet
*/ */
DECLARE vWarehouseFk INT; DECLARE vWarehouseFk INT;
DECLARE vStockScopeDays INT; DECLARE vStockScopeDays INT;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT s.warehouseFk, stockScopeDays SELECT s.warehouseFk, stockScopeDays
INTO vWarehouseFk, vStockScopeDays INTO vWarehouseFk, vStockScopeDays
@ -30,7 +36,7 @@ BEGIN
ENGINE = MEMORY ENGINE = MEMORY
SELECT itemFk, SUM(visible) visible SELECT itemFk, SUM(visible) visible
FROM itemShelving FROM itemShelving
WHERE shelvingFk = vShelvingFk COLLATE utf8_unicode_ci WHERE shelvingFk = vShelvingFk
GROUP BY itemFk; GROUP BY itemFk;
CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay CREATE OR REPLACE TEMPORARY TABLE tmp.tStockByDay
@ -52,7 +58,7 @@ BEGIN
SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE() SELECT ish.itemFk, - SUM(ish.visible), util.VN_CURDATE()
FROM itemShelving ish FROM itemShelving ish
JOIN tmp.tItems i ON i.itemFk = ish.itemFk JOIN tmp.tItems i ON i.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON sh.parkingFk = p.id JOIN parking p ON sh.parkingFk = p.id
JOIN sector s ON s.id = p.sectorFk JOIN sector s ON s.id = p.sectorFk
WHERE s.isReserve WHERE s.isReserve
@ -110,7 +116,7 @@ BEGIN
UPDATE tmp.tStockByDay sbd UPDATE tmp.tStockByDay sbd
JOIN (SELECT ish.itemFK, SUM(ish.visible) amount JOIN (SELECT ish.itemFK, SUM(ish.visible) amount
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk JOIN sector s ON s.id = p.sectorFk
WHERE s.warehouseFk = vWarehouseFk WHERE s.warehouseFk = vWarehouseFk
@ -150,10 +156,10 @@ BEGIN
p.sectorFk, p.sectorFk,
ish.shelvingFk ish.shelvingFk
FROM itemShelving ish FROM itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
LEFT JOIN parking p ON p.id = parkingFk LEFT JOIN parking p ON p.id = parkingFk
LEFT JOIN vn.sector s ON s.id = p.sectorFk LEFT JOIN vn.sector s ON s.id = p.sectorFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci WHERE ish.shelvingFk = vShelvingFk
) sub4 ON sub4.itemFk = ts.itemFk ) sub4 ON sub4.itemFk = ts.itemFk
LEFT JOIN sector s ON s.id = sub4.sectorFk LEFT JOIN sector s ON s.id = sub4.sectorFk
LEFT JOIN item i ON i.id = ts.itemFk LEFT JOIN item i ON i.id = ts.itemFk

View File

@ -42,7 +42,7 @@ BEGIN
JOIN item i ON i.id = ish.itemFk JOIN item i ON i.id = ish.itemFk
JOIN itemType it ON it.id = i.typeFk JOIN itemType it ON it.id = i.typeFk
JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk JOIN tmp.stockMisfit sm ON sm.itemFk = ish.itemFk
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN ( LEFT JOIN (
SELECT s.itemFk, sum(s.quantity) notPrepared SELECT s.itemFk, sum(s.quantity) notPrepared

View File

@ -1,6 +1,6 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfConsumption`(
vShelvingFk VARCHAR(10) COLLATE utf8_general_ci, vShelvingCode VARCHAR(10) COLLATE utf8_general_ci,
vItemFk INT, vItemFk INT,
vQuantity INT vQuantity INT
) )
@ -9,9 +9,9 @@ BEGIN
* Leave the indicated amount on the shelve * Leave the indicated amount on the shelve
* and create a ticket with the difference. * and create a ticket with the difference.
* *
* @param vShelvingFk id of the shelve where the item is located. * @param vShelvingCode Code of the shelve where the item is located
* @param vItemFk article of which the self-consumption ticket is to be created. * @param vItemFk Item of which the self-consumption ticket is to be created
* @param vQuantity amount that will stay on the shelve * @param vQuantity Amount that will stay on the shelve
*/ */
DECLARE vVisible INT; DECLARE vVisible INT;
DECLARE vClientFk INT; DECLARE vClientFk INT;
@ -21,6 +21,11 @@ BEGIN
DECLARE vAgencyModeFk INT; DECLARE vAgencyModeFk INT;
DECLARE vItemShelvingFk INT; DECLARE vItemShelvingFk INT;
DECLARE vAddressFk INT; DECLARE vAddressFk INT;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code = vShelvingCode;
SELECT c.id, SELECT c.id,
pc.clientSelfConsumptionFk, pc.clientSelfConsumptionFk,
@ -37,7 +42,7 @@ BEGIN
JOIN parking p ON p.sectorFk = s.id JOIN parking p ON p.sectorFk = s.id
JOIN shelving s2 ON s2.parkingFk = p.id JOIN shelving s2 ON s2.parkingFk = p.id
JOIN productionConfig pc JOIN productionConfig pc
WHERE s2.code = vShelvingFk; WHERE s2.id = vShelvingFk;
IF vClientFk IS NULL THEN IF vClientFk IS NULL THEN
CALL util.throw('The company does not have a customer assigned'); CALL util.throw('The company does not have a customer assigned');
@ -47,7 +52,7 @@ BEGIN
CALL util.throw('The shelf cannot have NULL or negative quantities'); CALL util.throw('The shelf cannot have NULL or negative quantities');
END IF; END IF;
IF vShelvingFk IS NULL THEN IF vShelvingCode IS NULL THEN
CALL util.throw('The shelf is necessary'); CALL util.throw('The shelf is necessary');
END IF; END IF;

View File

@ -1,7 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`(
vItemShelvingFk INT, vItemShelvingFk INT,
vShelvingFk VARCHAR(10) vShelvingCode VARCHAR(10)
) )
BEGIN BEGIN
/** /**
@ -9,9 +9,14 @@ BEGIN
* fusionando si coincide el packing y la fecha. * fusionando si coincide el packing y la fecha.
* *
* @param vItemShelvingFk Identificador de itemShelving * @param vItemShelvingFk Identificador de itemShelving
* @param vShelvingFk Identificador de shelving * @param vShelvingCode Código de shelving
*/ */
DECLARE vNewItemShelvingFk INT; DECLARE vNewItemShelvingFk INT;
DECLARE vShelvingFk INT;
SELECT id INTO vShelvingFk
FROM shelving
WHERE code COLLATE utf8_unicode_ci = vShelvingCode;
SELECT MAX(ish.id) INTO vNewItemShelvingFk SELECT MAX(ish.id) INTO vNewItemShelvingFk
FROM itemShelving ish FROM itemShelving ish
@ -26,7 +31,7 @@ BEGIN
AND ish2.packing = ish.packing AND ish2.packing = ish.packing
AND DATE(ish2.created) = DATE(ish.created) AND DATE(ish2.created) = DATE(ish.created)
AND ish2.buyFk = ish.buyFk AND ish2.buyFk = ish.buyFk
WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; WHERE ish.shelvingFk = vShelvingFk;
IF vNewItemShelvingFk THEN IF vNewItemShelvingFk THEN
UPDATE itemShelving ish UPDATE itemShelving ish
@ -38,9 +43,7 @@ BEGIN
DELETE FROM itemShelving DELETE FROM itemShelving
WHERE id = vItemShelvingFk; WHERE id = vItemShelvingFk;
ELSE ELSE
IF (SELECT EXISTS(SELECT id FROM shelving IF (SELECT EXISTS(SELECT id FROM shelving WHERE id = vShelvingFk)) THEN
WHERE code = vShelvingFk COLLATE utf8_unicode_ci)) THEN
UPDATE itemShelving UPDATE itemShelving
SET shelvingFk = vShelvingFk SET shelvingFk = vShelvingFk
WHERE id = vItemShelvingFk; WHERE id = vItemShelvingFk;

View File

@ -1,7 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`( CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_devalueA2`(
vSelf INT, vSelf INT,
vShelvingFK VARCHAR(10), vShelvingCode VARCHAR(10) COLLATE utf8mb3_general_ci,
vBuyingValue DECIMAL(10,4), vBuyingValue DECIMAL(10,4),
vQuantity INT vQuantity INT
) )
@ -12,7 +12,7 @@ BEGIN
* de almacén y shelvings correspondientes * de almacén y shelvings correspondientes
* *
* @param vSelf Id de artículo a devaluar * @param vSelf Id de artículo a devaluar
* @param vShelvingFK Ubicación actual del artículo * @param vShelvingCode Código de shelving / ubicación
* @param vBuyingValue Nuevo precio de coste * @param vBuyingValue Nuevo precio de coste
* @param vQuantity Cantidad del ítem a pasar a A2 * @param vQuantity Cantidad del ítem a pasar a A2
*/ */
@ -109,10 +109,11 @@ BEGIN
CALL util.throw ('The item has not a buy'); CALL util.throw ('The item has not a buy');
END IF; END IF;
SELECT id,visible INTO vTargetItemShelvingFk, vCurrentVisible SELECT ish.id, ish.visible INTO vTargetItemShelvingFk, vCurrentVisible
FROM itemShelving FROM itemShelving ish
WHERE shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci JOIN shelving sh ON sh.id = ish.shelvingFk
AND itemFk = vSelf WHERE sh.code = vShelvingCode
AND ish.itemFk = vSelf
LIMIT 1; LIMIT 1;
IF vCurrentVisible IS NULL THEN IF vCurrentVisible IS NULL THEN
@ -388,16 +389,17 @@ BEGIN
userFk, userFk,
isChecked) isChecked)
SELECT vItemA2Fk, SELECT vItemA2Fk,
shelvingFk, ish.shelvingFk,
vQuantity , vQuantity ,
`grouping`, ish.`grouping`,
packing, ish.packing,
packagingFk, ish.packagingFk,
account.myUser_getId(), account.myUser_getId(),
isChecked ish.isChecked
FROM itemShelving FROM itemShelving ish
WHERE itemFK = vSelf JOIN shelving sh ON sh.id = ish.shelvingFk
AND shelvingFk = vShelvingFK COLLATE utf8mb3_general_ci WHERE ish.itemFK = vSelf
AND sh.code = vShelvingCode
ON DUPLICATE KEY UPDATE ON DUPLICATE KEY UPDATE
visible = vQuantity + VALUES(visible); visible = vQuantity + VALUES(visible);

View File

@ -217,7 +217,7 @@ proc: BEGIN
st.code = 'previousPrepared' isPreviousPrepared, st.code = 'previousPrepared' isPreviousPrepared,
sc.itemPackingTypeFk sc.itemPackingTypeFk
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector sc ON sc.id = p.sectorFk JOIN sector sc ON sc.id = p.sectorFk
JOIN sectorType st ON st.id = sc.typeFk JOIN sectorType st ON st.id = sc.typeFk

View File

@ -27,7 +27,7 @@ BEGIN
DECLARE vQuantity INT; DECLARE vQuantity INT;
DECLARE vRemainder INT DEFAULT 0; DECLARE vRemainder INT DEFAULT 0;
DECLARE vRemainderSaleFk INT; DECLARE vRemainderSaleFk INT;
DECLARE vShelving VARCHAR(10); DECLARE vShelvingFk VARCHAR(10);
DECLARE vTicketFk INT; DECLARE vTicketFk INT;
SELECT s.quantity, SELECT s.quantity,
@ -74,7 +74,7 @@ w1: WHILE vQuantity >= vPacking DO
p.pickingOrder, p.pickingOrder,
ish.created ish.created
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
LEFT JOIN itemShelvingSale iss LEFT JOIN itemShelvingSale iss
ON iss.itemShelvingFk = ish.id ON iss.itemShelvingFk = ish.id
@ -262,9 +262,9 @@ w1: WHILE vQuantity >= vPacking DO
CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE); CALL dipole.expedition_Add(vExpeditionFk,vPrinterFk, TRUE);
SELECT shelvingFk, p.code SELECT shelvingFk, p.code
INTO vShelving, vParkingCode INTO vShelvingFk, vParkingCode
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
WHERE ish.id = vItemShelvingFk; WHERE ish.id = vItemShelvingFk;
@ -273,7 +273,7 @@ w1: WHILE vQuantity >= vPacking DO
itemFk = vItemFk, itemFk = vItemFk,
quantity = vPacking, quantity = vPacking,
longName = vConcept, longName = vConcept,
shelvingFk = vShelving, shelvingFk = vShelvingFk,
parkingCode = vParkingCode, parkingCode = vParkingCode,
phone = RIGHT(phone,vMaxPhoneLength), phone = RIGHT(phone,vMaxPhoneLength),
street = RIGHT(street, vMAxStreetLength) street = RIGHT(street, vMAxStreetLength)

View File

@ -41,7 +41,7 @@ BEGIN
AND iss.created >= vDated AND iss.created >= vDated
GROUP BY iss.itemShelvingFk, s.itemFk) tISS GROUP BY iss.itemShelvingFk, s.itemFk) tISS
ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id ON tISS.itemFk = ish.itemFk AND tISS.itemShelvingFk = ish.id
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk JOIN tmp.productionBuffer pb ON pb.ticketFk = s.ticketFk
JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agencyMode am ON am.id = pb.agencyModeFk

View File

@ -87,7 +87,7 @@ BEGIN
SUM(ish.visible) visible, SUM(ish.visible) visible,
s.warehouseFk warehouseFk s.warehouseFk warehouseFk
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, s.warehouseFk; GROUP BY ish.itemFk, s.warehouseFk;
@ -127,7 +127,7 @@ BEGIN
LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id
AND issw.warehouseFk = t.warehouseFk AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible, 0) < s.quantity WHERE IFNULL(v.visible, 0) < s.quantity
AND IFNULL(av.available, 0) < s.quantity AND IFNULL(av.available, 0) < 0
AND IFNULL(issw.visible, 0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity
AND NOT s.isPicked AND NOT s.isPicked
AND NOT s.reserved AND NOT s.reserved
@ -190,7 +190,7 @@ BEGIN
LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id
AND issw.warehouseFk = t.warehouseFk AND issw.warehouseFk = t.warehouseFk
WHERE IFNULL(v.visible, 0) < s.quantity WHERE IFNULL(v.visible, 0) < s.quantity
AND IFNULL(av.available, 0) >= s.quantity AND IFNULL(av.available, 0) >= 0
AND IFNULL(issw.visible, 0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity
AND s.quantity > 0 AND s.quantity > 0
AND NOT s.isPicked AND NOT s.isPicked

View File

@ -1,11 +1,13 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(IN `vShelvingO` VARCHAR(8), IN `vShelvingD` VARCHAR(8)) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingChange`(
`vShelvingO` VARCHAR(10),
`vShelvingD` VARCHAR(10)
)
BEGIN BEGIN
UPDATE itemShelving ish
UPDATE vn.itemShelving JOIN shelving sh1 ON sh1.code = vShelvingD COLLATE utf8_unicode_ci
SET shelvingFk = vShelvingD COLLATE utf8_unicode_ci JOIN shelving sh2 ON sh2.code = vShelvingO COLLATE utf8_unicode_ci
WHERE shelvingFk = vShelvingO COLLATE utf8_unicode_ci; SET ish.shelvingFk = sh1.id
WHERE ish.shelvingFk = sh2.id;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,8 +1,10 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(vShelvingFk VARCHAR(10), vWarehouseFk INT, vDayRange INT) CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`shelvingParking_get`(
BEGIN vShelvingCode VARCHAR(10),
vWarehouseFk INT,
vDayRange INT
)
BEGIN
SELECT s.itemFk, SELECT s.itemFk,
s.concept, s.concept,
CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir, CAST(SUM(s.quantity) AS DECIMAL(10,0)) as sinServir,
@ -10,14 +12,15 @@ SELECT s.itemFk,
FROM vn.sale s FROM vn.sale s
LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.ticket t ON t.id = s.ticketFk JOIN vn.ticket t ON t.id = s.ticketFk
LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk AND ist.warehouseFk = vWarehouseFk LEFT JOIN vn.itemShelvingStock ist ON ist.itemFk = s.itemFk
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk AND ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci AND ist.warehouseFk = vWarehouseFk
JOIN vn.itemShelving ish ON ish.itemFk = s.itemFk
JOIN shelving sh ON sh.id = ish.shelvingFk
AND sh.code = vShelvingCode COLLATE utf8_general_ci
WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE())) WHERE t.shipped BETWEEN util.VN_CURDATE() AND util.dayend(TIMESTAMPADD(DAY, GREATEST(0,vDayRange), util.VN_CURDATE()))
AND iss.saleFk IS NULL AND iss.saleFk IS NULL
AND t.warehouseFk = vWarehouseFk AND t.warehouseFk = vWarehouseFk
GROUP BY s.itemFk GROUP BY s.itemFk
HAVING sinServir > aparcado; HAVING sinServir > aparcado;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -12,12 +12,12 @@ BEGIN
DELETE ish.* DELETE ish.*
FROM itemShelving ish FROM itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
WHERE sh.parkingFk IS NULL WHERE sh.parkingFk IS NULL
AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); AND ish.created < TIMESTAMPADD(WEEK,-1,util.VN_CURDATE());
UPDATE shelving sh UPDATE shelving sh
LEFT JOIN itemShelving its ON its.shelvingFk = sh.`code` LEFT JOIN itemShelving its ON its.shelvingFk = sh.id
SET isPrinted = 0, SET isPrinted = 0,
parkingFk = NULL parkingFk = NULL
WHERE its.id IS NULL WHERE its.id IS NULL
@ -27,11 +27,11 @@ UPDATE shelving sh
OR OR
sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK
) )
AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN ( AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN (
SELECT DISTINCT LEFT(its.shelvingFk, 2) SELECT DISTINCT LEFT(sh.code, 2)
FROM itemShelving its FROM itemShelving its
WHERE its.shelvingFk REGEXP '^[A-Za-z]{2}[0-9]' JOIN shelving sh ON sh.id = its.shelvingFk
WHERE sh.code REGEXP '^[A-Za-z]{2}[0-9]'
), TRUE); ), TRUE);
END$$ END$$

View File

@ -25,7 +25,7 @@ BEGIN
LEFT JOIN ( LEFT JOIN (
SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva SELECT ish.itemFk, CAST(SUM(ish.visible) AS DECIMAL(10,0)) AS reserva
FROM vn.itemShelving ish FROM vn.itemShelving ish
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.sector s ON s.id = p.sectorFk
WHERE s.code = 'FUENTES_PICASSE' WHERE s.code = 'FUENTES_PICASSE'
@ -68,7 +68,7 @@ BEGIN
sh.isSpam sh.isSpam
FROM vn.itemShelving ish FROM vn.itemShelving ish
JOIN vn.item i ON i.id = ish.itemFk JOIN vn.item i ON i.id = ish.itemFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.sector s ON s.id = p.sectorFk
JOIN vn.warehouse w ON w.id = s.warehouseFk JOIN vn.warehouse w ON w.id = s.warehouseFk

View File

@ -59,7 +59,7 @@ proc: BEGIN
INSERT INTO stockBought(workerFk, bought, dated) INSERT INTO stockBought(workerFk, bought, dated)
SELECT tb.workerFk, SELECT tb.workerFk,
ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 1), ROUND(GREATEST(tb.bought - IFNULL(ts.sold, 0), 0), 2),
vDated vDated
FROM tStockBought tb FROM tStockBought tb
LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk; LEFT JOIN tStockSold ts ON ts.workerFk = tb.workerFk;
@ -80,7 +80,7 @@ proc: BEGIN
UPDATE stockBought s UPDATE stockBought s
JOIN tStockSold ts ON ts.workerFk = s.workerFk JOIN tStockSold ts ON ts.workerFk = s.workerFk
SET s.bought = IF(s.bought < ts.sold, ROUND(s.bought - ts.sold, 1), 0) SET s.bought = IF(s.bought < ABS(ts.sold), 0, ROUND(s.bought - ABS(ts.sold), 1))
WHERE s.dated = vDated; WHERE s.dated = vDated;
DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold; DROP TEMPORARY TABLE tCurrentData, tmp.item, tmp.buyUltimate, tStockSold;

View File

@ -9,7 +9,7 @@ BEGIN
JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.sale s ON s.ticketFk = t.id
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk JOIN vn.itemShelving ish ON ish.id = iss.itemShelvingFk
JOIN vn.shelving sh ON sh.code = ish.shelvingFk JOIN vn.shelving sh ON sh.id = ish.shelvingFk
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
WHERE p.sectorFk = vSectorFk WHERE p.sectorFk = vSectorFk
) sub ON sub.id = td.ticketFk ) sub ON sub.id = td.ticketFk

View File

@ -27,7 +27,7 @@ BEGIN
SUM(ish.visible) visible, SUM(ish.visible) visible,
s.warehouseFk warehouseFk s.warehouseFk warehouseFk
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, GROUP BY ish.itemFk,

View File

@ -28,7 +28,7 @@ BEGIN
SUM(ish.visible) visible, SUM(ish.visible) visible,
s.warehouseFk warehouseFk s.warehouseFk warehouseFk
FROM itemShelving ish FROM itemShelving ish
JOIN shelving sh ON sh.code = ish.shelvingFk JOIN shelving sh ON sh.id = ish.shelvingFk
JOIN parking p ON p.id = sh.parkingFk JOIN parking p ON p.id = sh.parkingFk
JOIN sector s ON s.id = p.sectorFk JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, GROUP BY ish.itemFk,

View File

@ -3,87 +3,124 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki
vSelf INT, vSelf INT,
vOriginalItemPackingTypeFk VARCHAR(1) vOriginalItemPackingTypeFk VARCHAR(1)
) )
proc:BEGIN BEGIN
/** /**
* Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado.
* Respeta el id de ticket original para el tipo de empaquetado propuesto. * Respeta el id inicial para el tipo propuesto.
* *
* @param vSelf Id ticket * @param vSelf Id ticket
* @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original
* @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk)
*/ */
DECLARE vDone INT DEFAULT FALSE; DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H';
DECLARE vHasItemPackingType BOOL;
DECLARE vItemPackingTypeFk INT;
DECLARE vNewTicketFk INT; DECLARE vNewTicketFk INT;
DECLARE vPackingTypesToSplit INT;
DECLARE vDone INT DEFAULT FALSE;
DECLARE vItemPackingTypes CURSOR FOR DECLARE vSaleGroup CURSOR FOR
SELECT DISTINCT itemPackingTypeFk SELECT itemPackingTypeFk
FROM tSalesToMove; FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL
ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
SELECT COUNT(*) INTO vHasItemPackingType START TRANSACTION;
FROM ticket t
JOIN sale s ON s.ticketFk = t.id SELECT id
JOIN item i ON i.id = s.itemFk FROM sale
WHERE t.id = vSelf WHERE ticketFk = vSelf
AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; AND NOT quantity
FOR UPDATE;
DELETE FROM sale
WHERE NOT quantity
AND ticketFk = vSelf;
CREATE OR REPLACE TEMPORARY TABLE tSale
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros
FROM sale s
JOIN item i ON i.id = s.itemFk
LEFT JOIN saleVolume sv ON sv.saleFk = s.id
WHERE s.ticketFk = vSelf;
CREATE OR REPLACE TEMPORARY TABLE tSaleGroup
ENGINE = MEMORY
SELECT itemPackingTypeFk, SUM(litros) totalLitros
FROM tSale
GROUP BY itemPackingTypeFk;
SELECT COUNT(*) INTO vPackingTypesToSplit
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT(
ticketFk INT, ticketFk INT,
itemPackingTypeFk VARCHAR(1) itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY ) ENGINE = MEMORY;
SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk;
IF NOT vHasItemPackingType THEN CASE vPackingTypesToSplit
LEAVE proc; WHEN 0 THEN
END IF; INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
VALUES(vSelf, vItemPackingTypeFk);
WHEN 1 THEN
INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
SELECT vSelf, itemPackingTypeFk
FROM tSaleGroup
WHERE itemPackingTypeFk IS NOT NULL;
ELSE
OPEN vSaleGroup;
FETCH vSaleGroup INTO vItemPackingTypeFk;
CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
ticketFk INT, VALUES(vSelf, vItemPackingTypeFk);
saleFk INT,
itemPackingTypeFk INT
) ENGINE=MEMORY;
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) l: LOOP
SELECT s.id, i.itemPackingTypeFk SET vDone = FALSE;
FROM ticket t FETCH vSaleGroup INTO vItemPackingTypeFk;
JOIN sale s ON s.ticketFk = t.id
JOIN item i ON i.id = s.itemFk
WHERE t.id = vSelf
AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk;
OPEN vItemPackingTypes; IF vDone THEN
LEAVE l;
END IF;
l: LOOP CALL ticket_Clone(vSelf, vNewTicketFk);
SET vDone = FALSE;
FETCH vItemPackingTypes INTO vItemPackingTypeFk;
IF vDone THEN INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk)
LEAVE l; VALUES(vNewTicketFk, vItemPackingTypeFk);
END IF; END LOOP;
CALL ticket_Clone(vSelf, vNewTicketFk); CLOSE vSaleGroup;
UPDATE tSalesToMove SELECT s.id
SET ticketFk = vNewTicketFk FROM sale s
WHERE itemPackingTypeFk = vItemPackingTypeFk; JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
FOR UPDATE;
END LOOP; UPDATE sale s
JOIN tSale ts ON ts.id = s.id
JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk
SET s.ticketFk = t.ticketFk;
CLOSE vItemPackingTypes; SELECT itemPackingTypeFk INTO vItemPackingTypeFk
FROM tSaleGroup sg
WHERE sg.itemPackingTypeFk IS NOT NULL
ORDER BY sg.itemPackingTypeFk
LIMIT 1;
UPDATE sale s UPDATE sale s
JOIN tSalesToMove stm ON stm.saleFk = s.id JOIN tSale ts ON ts.id = s.id
SET s.ticketFk = stm.ticketFk JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk
WHERE stm.ticketFk; SET s.ticketFk = t.ticketFk
WHERE ts.itemPackingTypeFk IS NULL;
END CASE;
INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk) COMMIT;
SELECT ticketFk, itemPackingTypeFk
FROM tSalesToMove
GROUP BY ticketFk;
DROP TEMPORARY TABLE tSalesToMove; DROP TEMPORARY TABLE
tSale,
tSaleGroup;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -6,6 +6,7 @@ BEGIN
DECLARE vIsEqualizated BOOL; DECLARE vIsEqualizated BOOL;
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SET NEW.geoFk = address_getGeo(NEW.id);
IF (NEW.phone <> '') THEN IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone); CALL pbx.phone_isValid(NEW.phone);

View File

@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`address_beforeUpdate`
BEFORE UPDATE ON `address` BEFORE UPDATE ON `address`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN IF !(NEW.phone <=> OLD.phone) AND (NEW.phone <> '') THEN
@ -14,5 +13,10 @@ BEGIN
CALL pbx.phone_isValid(NEW.mobile); CALL pbx.phone_isValid(NEW.mobile);
END IF; END IF;
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
OR (NEW.postalCode <=> OLD.postalCode) THEN
SET NEW.geoFk = address_getGeo(NEW.id);
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -3,8 +3,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`client_beforeInsert`
BEFORE INSERT ON `client` BEFORE INSERT ON `client`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SET NEW.accountingAccount = 4300000000 + NEW.id;
SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
SET NEW.geoFk = client_getGeo(NEW.id);
IF (NEW.phone <> '') THEN IF (NEW.phone <> '') THEN
CALL pbx.phone_isValid(NEW.phone); CALL pbx.phone_isValid(NEW.phone);
@ -13,9 +15,5 @@ BEGIN
IF (NEW.mobile <> '') THEN IF (NEW.mobile <> '') THEN
CALL pbx.phone_isValid(NEW.mobile); CALL pbx.phone_isValid(NEW.mobile);
END IF; END IF;
SET NEW.accountingAccount = 4300000000 + NEW.id;
SET NEW.lastSalesPersonFk = NEW.salesPersonFk;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -72,5 +72,11 @@ BEGIN
IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN IF NOT (NEW.businessTypeFk <=> OLD.businessTypeFk) AND (NEW.businessTypeFk = 'individual' OR OLD.businessTypeFk = 'individual') THEN
SET NEW.isTaxDataChecked = 0; SET NEW.isTaxDataChecked = 0;
END IF; END IF;
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
OR (NEW.postcode <=> OLD.postcode) THEN
SET NEW.geoFk = client_getGeo(NEW.id);
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`supplier_beforeInsert`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SET NEW.geoFk = supplier_getGeo(NEW.id);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -40,5 +40,10 @@ BEGIN
SET NEW.isPayMethodChecked = FALSE; SET NEW.isPayMethodChecked = FALSE;
END IF; END IF;
IF NOT (NEW.provinceFk <=> OLD.provinceFk)
OR (NEW.postCode <=> OLD.postCode) THEN
SET NEW.geoFk = supplier_getGeo(NEW.id);
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -15,7 +15,7 @@ FROM (
( (
( (
`vn`.`itemShelving` `ish` `vn`.`itemShelving` `ish`
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
) )
JOIN `vn`.`item` `i` ON(`i`.`id` = `ish`.`itemFk`) JOIN `vn`.`item` `i` ON(`i`.`id` = `ish`.`itemFk`)
) )

View File

@ -18,7 +18,7 @@ FROM (
( (
( (
`vn`.`itemShelving` `ish` `vn`.`itemShelving` `ish`
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
) )
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
) )

View File

@ -13,7 +13,7 @@ FROM (
`vn`.`itemShelvingSale` `iss` `vn`.`itemShelvingSale` `iss`
JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`) JOIN `vn`.`itemShelving` `ish` ON(`ish`.`id` = `iss`.`itemShelvingFk`)
) )
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
) )
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
) )

View File

@ -21,7 +21,7 @@ FROM (
( (
( (
`vn`.`itemShelving` `ish` `vn`.`itemShelving` `ish`
LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) LEFT JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
) )
LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) LEFT JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
) )

View File

@ -19,7 +19,7 @@ FROM (
( (
( (
`vn`.`itemShelving` `ish` `vn`.`itemShelving` `ish`
JOIN `vn`.`shelving` `sh` ON(`sh`.`code` = `ish`.`shelvingFk`) JOIN `vn`.`shelving` `sh` ON(`sh`.`id` = `ish`.`shelvingFk`)
) )
JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`) JOIN `vn`.`parking` `p` ON(`p`.`id` = `sh`.`parkingFk`)
) )

View File

@ -1,3 +1,2 @@
UPDATE vn.sale -- Debido a que tardaba mucho en la subida a master, se ha creado una nueva versión para que el proceso no se vea afectado y se ejecute por la noche.
SET originalQuantity = quantity -- Se crea de nuevo en la versión 11344-grayBamboo
WHERE originalQuantity IS NULL

View File

@ -1 +0,0 @@
-- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';

View File

@ -0,0 +1,71 @@
CREATE TABLE IF NOT EXISTS `vn`.`itemTextureTag` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT
CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y encerado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y esponjoso');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y foam');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y látex');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Arenosa');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Aterciopelado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Engomado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Flocado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Foam');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Gasa');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Goma');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Látex');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Latón');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Mate');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Metálico');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y engomado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y engomado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y rugoso');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Pluma');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico engomado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster texturizado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rugoso');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rígido');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Seminatural');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Silicona');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Suave');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con brillo');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con texturas');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela dura');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela engomada');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela escarchada');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada engomada');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela foam');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela micro peach');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plastificada');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plástico engomado');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela poliéster');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela PVC');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela ratan');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rigida');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rugosa');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rústica');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela sintética');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y cristal');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y foam');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y goma');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y látex');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y madera');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y plástico');
INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y seco');
UPDATE vn.tag
SET isFree=0,
sourceTable='itemTextureTag'
WHERE name= 'Textura';
GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemTextureTag TO logisticAssist;

View File

@ -0,0 +1,16 @@
CREATE TABLE IF NOT EXISTS vn.saySimpleCountry(
countryFk MEDIUMINT(8) UNSIGNED,
channel INT(4) COMMENT 'channel de whatsapp de saySimple',
PRIMARY KEY (countryFk),
CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS vn.saySimpleConfig(
id INT AUTO_INCREMENT PRIMARY KEY,
url VARCHAR(255) NOT NULL
);
INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel)
VALUES (19, 1169),
(8, 1183),
(NULL, 1320);

View File

@ -0,0 +1,8 @@
DELETE FROM salix.ACL
WHERE property IN ('cmrs', 'cmr', 'downloadCmrsZip')
AND model = 'Route';
INSERT INTO salix.ACL (model,property,principalId)
VALUES ('Cmr','filter','production'),
('Cmr','downloadZip','production'),
('Cmr','print','production')

View File

@ -0,0 +1,6 @@
CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelving
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT ish.id, s.id shelvingFk
FROM vn.itemShelving ish
JOIN vn.shelving s ON s.code = ish.shelvingFk COLLATE utf8mb3_unicode_ci;

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2,
MODIFY COLUMN shelvingFk int(11) NOT NULL;

View File

@ -0,0 +1,3 @@
UPDATE vn.itemShelving ish
JOIN tmp.tItemShelving tish ON tish.id = ish.id
SET ish.shelvingFk = tish.shelvingFk;

View File

@ -0,0 +1,4 @@
ALTER TABLE vn.itemShelving
ADD CONSTRAINT itemShelving_shelving_FK FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(id)
ON DELETE RESTRICT
ON UPDATE CASCADE;

View File

@ -0,0 +1,8 @@
/*
CREATE OR REPLACE TEMPORARY TABLE tmp.tItemShelvingLog
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT ishl.id, s.id shelvingFk
FROM vn.itemShelvingLog ishl
JOIN vn.shelving s ON s.code = ishl.shelvingFk COLLATE utf8mb3_unicode_ci;
*/

View File

@ -0,0 +1 @@
-- ALTER TABLE vn.itemShelvingLog MODIFY COLUMN shelvingFk int(11) NOT NULL;

View File

@ -0,0 +1,7 @@
/*
UPDATE vn.itemShelvingLog ishl
JOIN tmp.tItemShelvingLog tishl ON tishl.id = ishl.id
SET ishl.shelvingFk = tishl.shelvingFk;
DROP TEMPORARY TABLE tmp.tItemShelvingLog;
*/

View File

@ -0,0 +1,9 @@
INSERT INTO salix.ACL (model, property, accessType, principalId)
VALUES ('Collection', 'create', 'WRITE', 'productionBoss'),
('Collection', 'upsert', 'WRITE', 'productionBoss'),
('Collection', 'replaceById', 'WRITE', 'productionBoss'),
('Collection', 'updateAll', 'WRITE', 'productionBoss'),
('Collection', 'updateAttributes', 'WRITE', 'productionBoss'),
('Collection', 'deleteById', 'WRITE', 'productionBoss'),
('Collection', 'destroyAll', 'WRITE', 'productionBoss'),
('Collection', 'destroyById', 'WRITE', 'productionBoss');

View File

@ -0,0 +1,3 @@
UPDATE vn.sale
SET originalQuantity = quantity
WHERE originalQuantity IS NULL

View File

@ -0,0 +1 @@
ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity';

View File

@ -0,0 +1,2 @@
ALTER TABLE account.user CHANGE recoverPass recoverPass__ tinyint(3) unsigned NOT NULL DEFAULT 1 COMMENT '@deprecated 2024-11-13';
ALTER TABLE account.user CHANGE sync sync__ tinyint(4) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-11-13';

View File

@ -0,0 +1,23 @@
ALTER TABLE vn.address
ADD geoFk int(11) DEFAULT NULL NULL AFTER isLogifloraAllowed,
ADD CONSTRAINT address_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT a.id, p.geoFk
FROM vn.address a
JOIN vn.town t ON t.provinceFk = a.provinceFk
JOIN vn.postCode p ON p.townFk = t.id
AND (p.code = a.postalCode OR a.postalCode IS NULL)
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
GROUP BY a.id
ORDER BY (a.city SOUNDS LIKE t.`name`) DESC,
(p.code = a.postalCode) DESC;
UPDATE vn.address a
JOIN tmp.tAddressGeo tag ON tag.id = a.id
SET a.geoFk = tag.geoFk;
DROP TEMPORARY TABLE tmp.tAddressGeo;

View File

@ -0,0 +1,26 @@
ALTER TABLE vn.client
CHANGE hasDailyInvoice hasDailyInvoice tinyint(1) DEFAULT 0 NOT NULL
COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice'
AFTER recommendedCredit,
ADD geoFk int(11) DEFAULT NULL NULL AFTER hasDailyInvoice,
ADD CONSTRAINT client_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT c.id, p.geoFk
FROM vn.client c
JOIN vn.town t ON t.provinceFk = c.provinceFk
JOIN vn.postCode p ON p.townFk = t.id
AND (p.code = c.postcode OR c.postcode IS NULL)
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
GROUP BY c.id
ORDER BY (c.city SOUNDS LIKE t.`name`) DESC,
(p.code = c.postcode) DESC;
UPDATE vn.client c
JOIN tmp.tClientGeo tcg ON tcg.id = c.id
SET c.geoFk = tcg.geoFk;
DROP TEMPORARY TABLE tmp.tClientGeo;

View File

@ -0,0 +1,27 @@
ALTER TABLE vn.supplier
CHANGE companySize companySize enum('small','medium','big') CHARACTER SET utf8mb3
COLLATE utf8mb3_general_ci DEFAULT NULL NULL AFTER stamp,
ADD geoFk int(11) DEFAULT NULL NULL AFTER companySize,
ADD CONSTRAINT supplier_zoneGeo_FK FOREIGN KEY (geoFk)
REFERENCES vn.zoneGeo(id) ON DELETE RESTRICT ON UPDATE CASCADE;
CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, p.geoFk
FROM vn.supplier s
JOIN vn.town t ON t.provinceFk = s.provinceFk
JOIN vn.postCode p ON p.townFk = t.id
AND (p.code = s.postCode OR s.postCode IS NULL)
LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id
JOIN vn.zoneGeo zg ON zg.id = p.geoFk
GROUP BY s.id
ORDER BY (s.city SOUNDS LIKE t.`name`) DESC,
(p.code = s.postCode) DESC,
(p.code = sad.postalCode) DESC;
UPDATE vn.supplier s
JOIN tmp.tSupplierGeo tsg ON tsg.id = s.id
SET s.geoFk = tsg.geoFk;
DROP TEMPORARY TABLE tmp.tSupplierGeo;

View File

@ -0,0 +1,9 @@
DROP TABLE IF EXISTS vn.saySimpleConfig;
CREATE TABLE vn.saySimpleConfig(
id INT AUTO_INCREMENT PRIMARY KEY,
url VARCHAR(255) NOT NULL,
defaultChannel VARCHAR(128)
);
ALTER TABLE vn.saySimpleCountry MODIFY COLUMN channel VARCHAR(128);

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.clientObservation MODIFY COLUMN observationTypeFk tinyint(3) unsigned DEFAULT 4 NOT NULL;
UPDATE vn.clientObservation SET observationTypeFk=4 WHERE observationTypeFk=0;

View File

@ -0,0 +1,7 @@
UPDATE salix.ACL
SET principalId = 'deliveryAssistant'
WHERE model = 'Ticket'
AND property = 'updateAttributes'
AND principalId = "delivery";

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.shelvingLog
MODIFY COLUMN changedModel enum('Shelving', 'ItemShelving') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT 'Shelving' NOT NULL;

View File

@ -0,0 +1,15 @@
USE vn;
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('RouteAction', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery');
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('RouteComplement', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery');
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('RouteComplement', 'create', 'WRITE', 'ALLOW', 'ROLE', 'delivery');
INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId)
VALUES('RouteComplement', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'delivery');

View File

@ -1,133 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item summary path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'item');
});
afterAll(async() => {
await browser.close();
});
it('should search for an item', async() => {
await page.doSearch('Ranged weapon');
const resultsCount = await page.countElement(selectors.itemsIndex.searchResult);
await page.waitForTextInElement(selectors.itemsIndex.firstSearchResult, 'Ranged weapon');
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
const isVisible = await page.isVisible(selectors.itemSummary.basicData);
expect(resultsCount).toBe(4);
expect(isVisible).toBeTruthy();
});
it(`should check the item summary preview shows fields from basic data`, async() => {
await page.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 200cm');
const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Ranged weapon longbow 200cm');
});
it(`should check the item summary preview shows fields from tags`, async() => {
await page.waitForTextInElement(selectors.itemSummary.tags, 'Brown');
const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
expect(result).toContain('Brown');
});
it(`should check the item summary preview shows fields from botanical`, async() => {
await page.waitForTextInElement(selectors.itemSummary.botanical, 'Abelia');
const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
expect(result).toContain('Abelia');
});
it(`should check the item summary preview shows fields from barcode`, async() => {
await page.waitForTextInElement(selectors.itemSummary.barcode, '1');
const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
expect(result).toContain('1');
});
it(`should close the summary popup`, async() => {
await page.closePopup();
await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true});
});
it('should search for other item', async() => {
await page.doSearch('Melee Reinforced');
const resultsCount = await page.countElement(selectors.itemsIndex.searchResult);
await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton);
await page.waitForSelector(selectors.itemSummary.basicData, {visible: true});
expect(resultsCount).toBe(3);
});
it(`should now check the item summary preview shows fields from basic data`, async() => {
await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee Reinforced weapon combat fist 15cm');
const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Melee Reinforced weapon combat fist 15cm');
});
it(`should now check the item summary preview shows fields from tags`, async() => {
await page.waitForTextInElement(selectors.itemSummary.tags, 'Silver');
const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
expect(result).toContain('Silver');
});
it(`should now check the item summary preview shows fields from botanical`, async() => {
await page.waitForTextInElement(selectors.itemSummary.botanical, '-');
const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
expect(result).toContain('-');
});
it(`should now close the summary popup`, async() => {
await page.closePopup();
await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true});
});
it(`should navigate to one of the items detailed section`, async() => {
await page.accessToSearchResult('Melee weapon combat fist 15cm');
await page.waitForState('item.card.summary');
});
it(`should check the descritor edit button is not visible for employee`, async() => {
const visibleButton = await page.isVisible(selectors.itemDescriptor.editButton);
expect(visibleButton).toBeFalsy();
});
it(`should check the item summary shows fields from basic data section`, async() => {
await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm');
const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText');
expect(result).toContain('Melee weapon combat fist 15cm');
});
it(`should check the item summary shows fields from tags section`, async() => {
const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText');
expect(result).toContain('Silver');
});
it(`should check the item summary shows fields from botanical section`, async() => {
const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText');
expect(result).toContain('procera');
});
it(`should check the item summary shows fields from barcodes section`, async() => {
const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText');
expect(result).toContain('4');
});
});

View File

@ -1,64 +0,0 @@
import getBrowser from '../../helpers/puppeteer';
const $ = {
form: 'vn-item-basic-data form',
intrastatForm: '.vn-dialog.shown form',
newIntrastatButton: 'vn-item-basic-data vn-icon-button[vn-tooltip="New intrastat"] > button'
};
describe('Item Edit basic data path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Melee weapon combat fist 15cm');
});
beforeEach(async() => {
await page.accessToSection('item.card.basicData');
});
afterAll(async() => {
await browser.close();
});
it(`should edit the item basic data and confirm the item data was edited`, async() => {
const values = {
type: 'Anthurium',
intrastat: 'Coral y materiales similares',
relevancy: 1,
generic: 'Pallet',
isActive: false,
priceInKg: true,
isFragile: true,
packingOut: 5
};
const message = await page.sendForm($.form, values);
await page.reloadSection('item.card.basicData');
const formValues = await page.fetchForm($.form, Object.keys(values));
expect(message.isSuccess).toBeTrue();
expect(formValues).toEqual(values);
});
it(`should create a new intrastat and save it`, async() => {
await page.click($.newIntrastatButton);
await page.waitForSelector($.intrastatForm);
await page.fillForm($.intrastatForm, {
id: '588420239',
description: 'Tropical Flowers'
});
await page.respondToDialog('accept');
const message = await page.sendForm($.form);
await page.reloadSection('item.card.basicData');
const formValues = await page.fetchForm($.form, ['intrastat']);
expect(message.isSuccess).toBeTrue();
expect(formValues).toEqual({intrastat: 'Tropical Flowers'});
});
});

View File

@ -1,48 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item edit tax path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 200cm');
await page.accessToSection('item.card.tax');
});
afterAll(async() => {
await browser.close();
});
it(`should add the item tax to all countries`, async() => {
await page.autocompleteSearch(selectors.itemTax.firstClass, 'General VAT');
await page.autocompleteSearch(selectors.itemTax.secondClass, 'General VAT');
await page.waitToClick(selectors.itemTax.submitTaxButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should confirm the first item tax class was edited`, async() => {
await page.reloadSection('item.card.tax');
const firstVatType = await page.waitToGetProperty(selectors.itemTax.firstClass, 'value');
expect(firstVatType).toEqual('General VAT');
});
it(`should confirm the second item tax class was edited`, async() => {
const secondVatType = await page
.waitToGetProperty(selectors.itemTax.secondClass, 'value');
expect(secondVatType).toEqual('General VAT');
});
it(`should edit the first class without saving the form`, async() => {
await page.autocompleteSearch(selectors.itemTax.firstClass, 'Reduced VAT');
const firstVatType = await page.waitToGetProperty(selectors.itemTax.firstClass, 'value');
expect(firstVatType).toEqual('Reduced VAT');
});
});

View File

@ -1,79 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item create tags path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 200cm');
await page.accessToSection('item.card.tags');
});
afterAll(async() => {
await browser.close();
});
it('should create a new tag and delete a former one', async() => {
await page.waitToClick(selectors.itemTags.fourthRemoveTagButton);
await page.waitToClick(selectors.itemTags.addItemTagButton);
await page.autocompleteSearch(selectors.itemTags.seventhTag, 'Ancho de la base');
await page.write(selectors.itemTags.seventhValue, '50');
await page.clearInput(selectors.itemTags.seventhRelevancy);
await page.write(selectors.itemTags.seventhRelevancy, '4');
await page.waitToClick(selectors.itemTags.submitItemTagsButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should confirm the fourth row data is the expected one', async() => {
await page.reloadSection('item.card.tags');
await page.waitForSelector('vn-item-tags');
let result = await page.waitToGetProperty(selectors.itemTags.fourthTag, 'value');
expect(result).toEqual('Ancho de la base');
result = await page
.waitToGetProperty(selectors.itemTags.fourthValue, 'value');
expect(result).toEqual('50');
result = await page
.waitToGetProperty(selectors.itemTags.fourthRelevancy, 'value');
expect(result).toEqual('4');
});
it('should confirm the fifth row data is the expected one', async() => {
let tag = await page
.waitToGetProperty(selectors.itemTags.fifthTag, 'value');
let value = await page
.waitToGetProperty(selectors.itemTags.fifthValue, 'value');
let relevancy = await page
.waitToGetProperty(selectors.itemTags.fifthRelevancy, 'value');
expect(tag).toEqual('Color');
expect(value).toEqual('Brown');
expect(relevancy).toEqual('5');
});
it('should confirm the sixth row data is the expected one', async() => {
let tag = await page
.waitToGetProperty(selectors.itemTags.sixthTag, 'value');
let value = await page
.waitToGetProperty(selectors.itemTags.sixthValue, 'value');
let relevancy = await page
.waitToGetProperty(selectors.itemTags.sixthRelevancy, 'value');
expect(tag).toEqual('Categoria');
expect(value).toEqual('+1 precission');
expect(relevancy).toEqual('6');
});
});

View File

@ -1,66 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item Create botanical path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.accessToSection('item.card.botanical');
});
afterAll(async() => {
await browser.close();
});
it(`should create a new botanical for the item`, async() => {
await page.autocompleteSearch(selectors.itemBotanical.genus, 'Abelia');
await page.autocompleteSearch(selectors.itemBotanical.species, 'dealbata');
await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should confirm the Genus for the item was created`, async() => {
await page.waitForTextInField(selectors.itemBotanical.genus, 'Abelia');
const result = await page
.waitToGetProperty(selectors.itemBotanical.genus, 'value');
expect(result).toEqual('Abelia');
});
it(`should confirm the Species for the item was created`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBotanical.species, 'value');
expect(result).toEqual('dealbata');
});
it(`should edit botanical for the item`, async() => {
await page.autocompleteSearch(selectors.itemBotanical.genus, 'Abies');
await page.autocompleteSearch(selectors.itemBotanical.species, 'decurrens');
await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should confirm the Genus for the item was edited`, async() => {
await page.waitForTextInField(selectors.itemBotanical.genus, 'Abies');
const result = await page
.waitToGetProperty(selectors.itemBotanical.genus, 'value');
expect(result).toEqual('Abies');
});
it(`should confirm the Species for the item was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBotanical.species, 'value');
expect(result).toEqual('decurrens');
});
});

View File

@ -1,37 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item Create barcodes path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 200cm');
await page.accessToSection('item.card.itemBarcode');
});
afterAll(async() => {
await browser.close();
});
it(`should click create a new code and delete a former one`, async() => {
await page.waitToClick(selectors.itemBarcodes.firstCodeRemoveButton);
await page.waitToClick(selectors.itemBarcodes.addBarcodeButton);
await page.write(selectors.itemBarcodes.thirdCode, '5');
await page.waitToClick(selectors.itemBarcodes.submitBarcodesButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, async() => {
await page.reloadSection('item.card.itemBarcode');
await page.waitForTextInField(selectors.itemBarcodes.thirdCode, '5');
const result = await page
.waitToGetProperty(selectors.itemBarcodes.thirdCode, 'value');
expect(result).toEqual('5');
});
});

View File

@ -1,65 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
const $ = {
form: 'vn-item-create form'
};
describe('Item Create', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
});
afterAll(async() => {
await browser.close();
});
it('should access to the create item view by clicking the create floating button', async() => {
await page.waitToClick(selectors.itemsIndex.createItemButton);
await page.waitForState('item.create');
});
it('should return to the item index by clickig the cancel button', async() => {
await page.waitToClick(selectors.itemCreateView.cancelButton);
await page.waitForState('item.index');
});
it('should now access to the create item view by clicking the create floating button', async() => {
await page.waitToClick(selectors.itemsIndex.createItemButton);
await page.waitForState('item.create');
});
it('should throw an error when insert an invalid priority', async() => {
const values = {
name: 'Infinity Gauntlet',
type: 'Crisantemo',
intrastat: 'Coral y materiales similares',
origin: 'Holand',
priority: null
};
const message = await page.sendForm($.form, values);
expect(message.text).toContain('Valid priorities');
});
it('should create the Infinity Gauntlet item', async() => {
const values = {
name: 'Infinity Gauntlet',
type: 'Crisantemo',
intrastat: 'Coral y materiales similares',
origin: 'Holand',
priority: '2'
};
await page.fillForm($.form, values);
const formValues = await page.fetchForm($.form, Object.keys(values));
const message = await page.sendForm($.form);
expect(message.isSuccess).toBeTrue();
expect(formValues).toEqual(values);
});
});

View File

@ -1,141 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item regularize path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'item');
});
afterAll(async() => {
await browser.close();
});
it('should edit the user local warehouse', async() => {
await page.waitForSpinnerLoad();
await page.waitToClick(selectors.globalItems.userMenuButton);
await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should check the local settings were saved', async() => {
const userLocalWarehouse = await page
.waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value');
await page.closePopup();
expect(userLocalWarehouse).toContain('Warehouse Four');
});
it('should search for a specific item', async() => {
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.waitForState('item.card.summary');
});
it('should open the regularize dialog and check the warehouse matches the local user settings', async() => {
await page.waitToClick(selectors.itemDescriptor.moreMenu);
await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
const result = await page.waitToGetProperty(selectors.itemDescriptor.regularizeWarehouse, 'value');
expect(result).toEqual('Warehouse Four');
});
it('should regularize the item', async() => {
await page.write(selectors.itemDescriptor.regularizeQuantity, '100');
await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouse, 'Warehouse One');
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should click on the Tickets button of the top bar menu', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await Promise.all([
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitToClick(selectors.globalItems.ticketsButton)
]);
await page.waitForState('ticket.index');
});
it('should clear the user local settings now', async() => {
await page.waitToClick(selectors.globalItems.userMenuButton);
await page.waitForContentLoaded();
await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should search for the ticket with alias missing', async() => {
await page.keyboard.press('Escape');
await page.accessToSearchResult('missing');
await page.waitForState('ticket.card.summary');
});
it(`should check the ticket sale quantity is showing a negative value`, async() => {
await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
const result = await page
.waitToGetProperty(selectors.ticketSummary.firstSaleQuantity, 'innerText');
expect(result).toContain('-100');
});
it(`should check the ticket sale discount is 100%`, async() => {
const result = await page
.waitToGetProperty(selectors.ticketSummary.firstSaleDiscount, 'innerText');
expect(result).toContain('100 %');
});
it('should now click on the Items button of the top bar menu', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.itemsButton);
await page.waitForState('item.index');
});
it('should search for the item once again', async() => {
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.waitForState('item.card.summary');
});
it('should regularize the item once more', async() => {
await page.waitToClick(selectors.itemDescriptor.moreMenu);
await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
await page.write(selectors.itemDescriptor.regularizeQuantity, '100');
await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouse, 'Warehouse One');
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should again click on the Tickets button of the top bar menu', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
await Promise.all([
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitToClick(selectors.globalItems.ticketsButton)
]);
await page.waitForState('ticket.index');
});
it('should search for the ticket missing once again', async() => {
await page.accessToSearchResult('Missing');
await page.waitForState('ticket.card.summary');
});
it(`should check the ticket contains now two sales`, async() => {
await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
const result = await page.countElement(selectors.ticketSummary.sale);
expect(result).toEqual(2);
});
});

View File

@ -1,84 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item index path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesPerson', 'item');
await page.waitToClick(selectors.globalItems.searchButton);
});
afterAll(async() => {
await browser.close();
});
it('should click on the fields to show button to open the list of columns to show', async() => {
await page.waitToClick(selectors.itemsIndex.shownColumns);
const visible = await page.isVisible(selectors.itemsIndex.shownColumnsList);
expect(visible).toBeTruthy();
});
it('should unmark all checkboxes except the first and the last ones', async() => {
await page.waitToClick(selectors.itemsIndex.idCheckbox);
await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
await page.waitToClick(selectors.itemsIndex.typeCheckbox);
await page.waitToClick(selectors.itemsIndex.categoryCheckbox);
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.weightByPieceCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should navigate forth and back to see the images column is still visible', async() => {
await page.closePopup();
await page.waitToClick(selectors.itemsIndex.firstSearchResult);
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
await page.waitToClick(selectors.globalItems.searchButton);
await page.waitForSelector(selectors.itemsIndex.searchResult);
await page.waitImgLoad(selectors.itemsIndex.firstItemImage);
const imageVisible = await page.isVisible(selectors.itemsIndex.firstItemImageTd);
expect(imageVisible).toBeTruthy();
});
it('should check the ids column is not visible', async() => {
await page.waitForSelector(selectors.itemsIndex.firstItemId, {hidden: true});
});
it('should mark all unchecked boxes to leave the index as it was', async() => {
await page.waitToClick(selectors.itemsIndex.shownColumns);
await page.waitToClick(selectors.itemsIndex.idCheckbox);
await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
await page.waitToClick(selectors.itemsIndex.typeCheckbox);
await page.waitToClick(selectors.itemsIndex.categoryCheckbox);
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.weightByPieceCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should now navigate forth and back to see the ids column is now visible', async() => {
await page.closePopup();
await page.waitToClick(selectors.itemsIndex.firstSearchResult);
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
await page.waitToClick(selectors.globalItems.searchButton);
await page.waitForSelector(selectors.itemsIndex.searchResult);
const idVisible = await page.isVisible(selectors.itemsIndex.firstItemId);
expect(idVisible).toBeTruthy();
});
});

View File

@ -1,45 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item log path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('developer', 'item');
});
afterAll(async() => {
await browser.close();
});
it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => {
await page.doSearch('Knowledge artifact');
const nResults = await page.countElement(selectors.itemsIndex.searchResult);
expect(nResults).toEqual(1);
});
it('should access to the create item view by clicking the create floating button', async() => {
await page.waitToClick(selectors.itemsIndex.createItemButton);
await page.waitForState('item.create');
});
it('should create the Knowledge artifact item', async() => {
await page.write(selectors.itemCreateView.temporalName, 'Knowledge artifact');
await page.autocompleteSearch(selectors.itemCreateView.type, 'Crisantemo');
await page.autocompleteSearch(selectors.itemCreateView.intrastat, 'Coral y materiales similares');
await page.autocompleteSearch(selectors.itemCreateView.origin, 'Holand');
await page.waitToClick(selectors.itemCreateView.createButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should return to the items index by clicking the return to items button', async() => {
await page.waitToClick(selectors.itemBasicData.goToItemIndexButton);
await page.waitForSelector(selectors.itemsIndex.createItemButton);
await page.waitForState('item.index');
});
});

View File

@ -1,41 +0,0 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item descriptor path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('1');
await page.accessToSection('item.card.basicData');
});
afterAll(async() => {
await browser.close();
});
it('should set the item to inactive', async() => {
await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should reload the section and check the inactive icon is visible', async() => {
await page.reloadSection('item.card.basicData');
const visibleIcon = await page.isVisible(selectors.itemDescriptor.inactiveIcon);
expect(visibleIcon).toBeTruthy();
});
it('should set the item back to active', async() => {
await page.waitToClick(selectors.itemBasicData.isActiveCheckbox);
await page.waitToClick(selectors.itemBasicData.submitBasicDataButton);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
});

Some files were not shown because too many files have changed in this diff Show More