Merge branch 'dev' into 6493-refactorizar-procedimientos-vn2008-parte2
gitea/salix/pipeline/pr-dev This commit looks good
Details
|
@ -1,7 +1,6 @@
|
||||||
coverage
|
coverage
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
storage
|
|
||||||
.idea
|
.idea
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
.eslintcache
|
.eslintcache
|
||||||
|
|
|
@ -4,20 +4,21 @@ describe('image download()', () => {
|
||||||
const collection = 'user';
|
const collection = 'user';
|
||||||
const size = '160x160';
|
const size = '160x160';
|
||||||
const employeeId = 1;
|
const employeeId = 1;
|
||||||
|
const developerId = 9;
|
||||||
|
const jessicaJonesId = 1110;
|
||||||
const ctx = {req: {accessToken: {userId: employeeId}}};
|
const ctx = {req: {accessToken: {userId: employeeId}}};
|
||||||
|
|
||||||
it('should return the image content-type of the user', async() => {
|
it('should return the image content-type of the user', async() => {
|
||||||
const userId = 9;
|
const image = await models.Image.download(ctx, collection, size, developerId);
|
||||||
const image = await models.Image.download(ctx, collection, size, userId);
|
|
||||||
const contentType = image[1];
|
const contentType = image[1];
|
||||||
|
|
||||||
expect(contentType).toEqual('image/png');
|
expect(contentType).toEqual('image/png');
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should return false if the user doesn't have image`, async() => {
|
it('should return the user profile picture', async() => {
|
||||||
const userId = 1110;
|
const image = await models.Image.download(ctx, collection, size, jessicaJonesId);
|
||||||
const image = await models.Image.download(ctx, collection, size, userId);
|
const fileName = image[2];
|
||||||
|
|
||||||
expect(image).toBeFalse();
|
expect(fileName).toMatch('1110.png');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -118,18 +118,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType`
|
||||||
|
|
||||||
INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
|
INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
|
||||||
VALUES
|
VALUES
|
||||||
(1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'),
|
||||||
(1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'),
|
||||||
(1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'),
|
||||||
(1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'),
|
||||||
(1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'),
|
||||||
(1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en','1106'),
|
||||||
(1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en','1107'),
|
||||||
(1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en','1108'),
|
||||||
(1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
(1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en','1109'),
|
||||||
(1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL),
|
(1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en','1110'),
|
||||||
(1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL),
|
(1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en','e7723f0b24ff05b32ed09d95196f2f29'),
|
||||||
(1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL);
|
(1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en','e7723f0b24ff05b32ed09d95196f2f29');
|
||||||
|
|
||||||
UPDATE account.`user`
|
UPDATE account.`user`
|
||||||
SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR)
|
SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR)
|
||||||
|
@ -1980,10 +1980,10 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
|
||||||
(5, 1102),
|
(5, 1102),
|
||||||
(9, 1201);
|
(9, 1201);
|
||||||
|
|
||||||
INSERT INTO `vn`.`professionalCategory` (`id`, `name`, `level`, `dayBreak`)
|
INSERT INTO `vn`.`professionalCategory` (`id`, `description`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'employee', NULL, NULL),
|
(1, 'employee'),
|
||||||
(2, 'florist', NULL, NULL);
|
(2, 'florist');
|
||||||
|
|
||||||
INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
|
INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE
|
||||||
|
DEFINER=`root`@`localhost`
|
||||||
|
EVENT `floranet`.`clean`
|
||||||
|
ON SCHEDULE EVERY 1 DAY
|
||||||
|
STARTS '2024-01-01 23:00:00.000'
|
||||||
|
ON COMPLETION PRESERVE
|
||||||
|
ENABLE
|
||||||
|
DO
|
||||||
|
BEGIN
|
||||||
|
DELETE
|
||||||
|
FROM `order`
|
||||||
|
WHERE created < CURDATE()
|
||||||
|
AND isPaid = FALSE;
|
||||||
|
|
||||||
|
DELETE c.*
|
||||||
|
FROM catalogue c
|
||||||
|
LEFT JOIN `order` o ON o.catalogueFk = c.id
|
||||||
|
WHERE c.created < CURDATE()
|
||||||
|
AND o.id IS NULL;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,52 @@
|
||||||
|
DROP PROCEDURE IF EXISTS floranet.catalogue_get;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15))
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Returns list, price and all the stuff regarding the floranet items
|
||||||
|
*
|
||||||
|
* @param vLanded Delivery date
|
||||||
|
* @param vPostalCode Delivery address postal code
|
||||||
|
*/
|
||||||
|
DECLARE vLastCatalogueFk INT;
|
||||||
|
|
||||||
|
START TRANSACTION;
|
||||||
|
|
||||||
|
SELECT * FROM catalogue FOR UPDATE;
|
||||||
|
|
||||||
|
SELECT MAX(id) INTO vLastCatalogueFk
|
||||||
|
FROM catalogue;
|
||||||
|
|
||||||
|
INSERT INTO catalogue(
|
||||||
|
name,
|
||||||
|
price,
|
||||||
|
itemFk,
|
||||||
|
dated,
|
||||||
|
postalCode,
|
||||||
|
`type`,
|
||||||
|
image,
|
||||||
|
description
|
||||||
|
)
|
||||||
|
SELECT i.name,
|
||||||
|
i.`size`,
|
||||||
|
i.id,
|
||||||
|
vLanded,
|
||||||
|
vPostalCode,
|
||||||
|
it.name,
|
||||||
|
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image),
|
||||||
|
i.description
|
||||||
|
FROM vn.item i
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
WHERE it.code IN ('FNR','FNP');
|
||||||
|
|
||||||
|
SELECT *
|
||||||
|
FROM catalogue
|
||||||
|
WHERE id > IFNULL(vLastCatalogueFk,0);
|
||||||
|
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,20 @@
|
||||||
|
DROP PROCEDURE IF EXISTS floranet.contact_request;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost`
|
||||||
|
PROCEDURE floranet.contact_request(
|
||||||
|
vName VARCHAR(100),
|
||||||
|
vPhone VARCHAR(15),
|
||||||
|
vEmail VARCHAR(100),
|
||||||
|
vMessage TEXT)
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Set actions for contact request.
|
||||||
|
*
|
||||||
|
* @param vPostalCode Delivery address postal code
|
||||||
|
*/
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,29 @@
|
||||||
|
DROP PROCEDURE IF EXISTS floranet.deliveryDate_get;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15))
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Returns available dates for this postalCode, in the next seven days
|
||||||
|
*
|
||||||
|
* @param vPostalCode Delivery address postal code
|
||||||
|
*/
|
||||||
|
DECLARE vCurrentDayOfWeek INT;
|
||||||
|
|
||||||
|
SET vCurrentDayOfWeek = DAYOFWEEK(NOW());
|
||||||
|
|
||||||
|
SELECT DISTINCT nextDay
|
||||||
|
FROM (
|
||||||
|
SELECT CURDATE() + INTERVAL IF(
|
||||||
|
apc.dayOfWeek >= vCurrentDayOfWeek,
|
||||||
|
apc.dayOfWeek - vCurrentDayOfWeek,
|
||||||
|
7 - apc.dayOfWeek
|
||||||
|
) DAY nextDay,
|
||||||
|
NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime
|
||||||
|
FROM addressPostCode apc
|
||||||
|
WHERE apc.postCode = vPostalCode
|
||||||
|
HAVING nextDay > minDeliveryTime) sub;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,25 @@
|
||||||
|
DROP PROCEDURE IF EXISTS floranet.order_confirm;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
|
||||||
|
CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT)
|
||||||
|
READS SQL DATA
|
||||||
|
|
||||||
|
BEGIN
|
||||||
|
/** Update order.isPaid field
|
||||||
|
*
|
||||||
|
* @param vCatalogueFk floranet.catalogue.id
|
||||||
|
*
|
||||||
|
* @returns floranet.order.isPaid
|
||||||
|
*/
|
||||||
|
UPDATE `order`
|
||||||
|
SET isPaid = TRUE,
|
||||||
|
payed = NOW()
|
||||||
|
WHERE catalogueFk = vCatalogueFk;
|
||||||
|
|
||||||
|
SELECT isPaid
|
||||||
|
FROM `order`
|
||||||
|
WHERE catalogueFk = vCatalogueFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,42 @@
|
||||||
|
DROP PROCEDURE IF EXISTS floranet.order_put;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON)
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Get and process an order
|
||||||
|
*
|
||||||
|
* @param vOrder Data of the order
|
||||||
|
*
|
||||||
|
* Customer data: <customerName>, <email>, <customerPhone>
|
||||||
|
*
|
||||||
|
* Item data: <catalogueFk>, <message>
|
||||||
|
*
|
||||||
|
* Delivery data: <deliveryName>, <address>, <deliveryPhone>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
INSERT IGNORE INTO `order`(
|
||||||
|
catalogueFk,
|
||||||
|
customerName,
|
||||||
|
email,
|
||||||
|
customerPhone,
|
||||||
|
message,
|
||||||
|
deliveryName,
|
||||||
|
address,
|
||||||
|
deliveryPhone
|
||||||
|
)
|
||||||
|
VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')),
|
||||||
|
JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone'))
|
||||||
|
);
|
||||||
|
|
||||||
|
SELECT LAST_INSERT_ID() orderFk;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,19 @@
|
||||||
|
DROP PROCEDURE IF EXISTS floranet.sliders_get;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
|
CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get()
|
||||||
|
READS SQL DATA
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Returns list of url for sliders
|
||||||
|
*/
|
||||||
|
SELECT
|
||||||
|
CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url,
|
||||||
|
i.longName
|
||||||
|
FROM vn.item i
|
||||||
|
JOIN vn.itemType it ON it.id = i.typeFk
|
||||||
|
WHERE it.code IN ('FNR','FNP');
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -0,0 +1,22 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_checkBooked`(
|
||||||
|
vSelf INT
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
/**
|
||||||
|
* Comprueba si una entrada está contabilizada,
|
||||||
|
* y si lo está retorna un throw.
|
||||||
|
*
|
||||||
|
* @param vSelf Id de entrada
|
||||||
|
*/
|
||||||
|
DECLARE vIsBooked BOOL;
|
||||||
|
|
||||||
|
SELECT isBooked INTO vIsBooked
|
||||||
|
FROM `entry`
|
||||||
|
WHERE id = vSelf;
|
||||||
|
|
||||||
|
IF vIsBooked THEN
|
||||||
|
CALL util.throw('Entry is already booked');
|
||||||
|
END IF;
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -1,158 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
|
|
||||||
vItemFk INT
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
/**
|
|
||||||
* Calcula y proporciona un historial de inventario detallado
|
|
||||||
* para un artículo dividiendo la información
|
|
||||||
* por almacén.
|
|
||||||
*
|
|
||||||
* @param vItemFk Artículo
|
|
||||||
*/
|
|
||||||
DECLARE vDateInventory DATETIME;
|
|
||||||
|
|
||||||
SELECT inventoried INTO vDateInventory FROM config;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory1;
|
|
||||||
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory1
|
|
||||||
SELECT DATE(`date`) `date`,
|
|
||||||
input,
|
|
||||||
`output`,
|
|
||||||
ok,
|
|
||||||
reference,
|
|
||||||
history.id,
|
|
||||||
warehouse,
|
|
||||||
`name` warehouseName
|
|
||||||
FROM (
|
|
||||||
SELECT tr.landed `date`,
|
|
||||||
c.quantity input,
|
|
||||||
NULL `output`,
|
|
||||||
tr.warehouseInFk warehouse,
|
|
||||||
tr.isReceived ok,
|
|
||||||
e.invoiceNumber reference,
|
|
||||||
e.id
|
|
||||||
FROM buy c
|
|
||||||
JOIN `entry` e ON e.id = c.entryFk
|
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
|
||||||
WHERE tr.landed >= vDateInventory
|
|
||||||
AND c.itemFk = vItemFk
|
|
||||||
AND NOT e.isRaid
|
|
||||||
AND c.quantity
|
|
||||||
UNION ALL
|
|
||||||
SELECT tr.shipped,
|
|
||||||
NULL,
|
|
||||||
c.quantity,
|
|
||||||
tr.warehouseOutFk,
|
|
||||||
tr.isDelivered,
|
|
||||||
e.invoiceNumber,
|
|
||||||
e.id
|
|
||||||
FROM buy c
|
|
||||||
JOIN `entry` e ON e.id = c.entryFk
|
|
||||||
JOIN travel tr ON tr.id = e.travelFk
|
|
||||||
WHERE tr.shipped >= vDateInventory
|
|
||||||
AND c.itemFk = vItemFk
|
|
||||||
AND NOT e.isRaid
|
|
||||||
AND c.quantity
|
|
||||||
UNION ALL
|
|
||||||
SELECT t.shipped,
|
|
||||||
NULL,
|
|
||||||
m.quantity,
|
|
||||||
t.warehouseFk,
|
|
||||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
|
|
||||||
t.refFk,
|
|
||||||
t.id
|
|
||||||
FROM sale m
|
|
||||||
JOIN ticket t ON t.id = m.ticketFk
|
|
||||||
WHERE t.shipped >= vDateInventory
|
|
||||||
AND m.itemFk = vItemFk
|
|
||||||
) history
|
|
||||||
JOIN warehouse ON warehouse.id = history.warehouse
|
|
||||||
ORDER BY `date`, input DESC, ok DESC;
|
|
||||||
|
|
||||||
DROP TEMPORARY TABLE IF EXISTS tMultipleHistory2, tMultipleHistory3,
|
|
||||||
tMultipleHistory4, tMultipleHistory5, tMultipleHistory6, tMultipleHistory7, tMultipleHistory8;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory2 SELECT * FROM tMultipleHistory1 WHERE warehouse = 19;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory3 SELECT * FROM tMultipleHistory1 WHERE warehouse = 7;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory4 SELECT * FROM tMultipleHistory1 WHERE warehouse = 60;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory5 SELECT * FROM tMultipleHistory1 WHERE warehouse = 5;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory6 SELECT * FROM tMultipleHistory1 WHERE warehouse = 17;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory7 SELECT * FROM tMultipleHistory1 WHERE warehouse = 37;
|
|
||||||
CREATE TEMPORARY TABLE tMultipleHistory8 SELECT * FROM tMultipleHistory1 WHERE warehouse = 55;
|
|
||||||
|
|
||||||
SELECT *
|
|
||||||
FROM (
|
|
||||||
SELECT `date`, input BOGinput, `output` BOGoutput, ok BOGok, reference BOGreference, id BOGid,
|
|
||||||
NULL VNHinput, NULL VNHoutput, NULL VNHok, NULL VNHreference, NULL VNHid,
|
|
||||||
NULL ALGinput, NULL ALGoutput, NULL ALGok, NULL ALGreference, NULL ALGid,
|
|
||||||
NULL MADinput, NULL MADoutput, NULL MADok, NULL MADreference, NULL MADid,
|
|
||||||
NULL MCFinput, NULL MCFoutput, NULL MCFok, NULL MCFreference, NULL MCFid,
|
|
||||||
NULL VILinput, NULL VILoutput, NULL VILok, NULL VILreference, NULL VILid,
|
|
||||||
NULL BARinput, NULL BARoutput, NULL BARok, NULL BARreference, NULL BARid
|
|
||||||
FROM tMultipleHistory2
|
|
||||||
UNION ALL
|
|
||||||
SELECT `date`,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
input, `output`, ok, reference, id,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL
|
|
||||||
FROM tMultipleHistory3
|
|
||||||
UNION ALL
|
|
||||||
SELECT `date`,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
input, `output`, ok, reference, id,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL
|
|
||||||
FROM tMultipleHistory4
|
|
||||||
UNION ALL
|
|
||||||
SELECT `date`,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
input, `output`, ok, reference, id,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL
|
|
||||||
FROM tMultipleHistory5
|
|
||||||
UNION ALL
|
|
||||||
SELECT `date`,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
input, `output`, ok, reference, id,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL
|
|
||||||
FROM tMultipleHistory6
|
|
||||||
UNION ALL
|
|
||||||
SELECT `date`,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
input, `output`, ok, reference, id,
|
|
||||||
NULL, NULL, NULL, NULL, NULL
|
|
||||||
FROM tMultipleHistory7
|
|
||||||
UNION ALL
|
|
||||||
SELECT `date`,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
NULL, NULL, NULL, NULL, NULL,
|
|
||||||
input, `output`, ok, reference, id
|
|
||||||
FROM tMultipleHistory8
|
|
||||||
) sub
|
|
||||||
ORDER BY `date`, BOGinput IS NULL, VNHinput IS NULL, ALGinput IS NULL,
|
|
||||||
MADinput IS NULL, MCFinput IS NULL, VILinput IS NULL, BARinput IS NULL;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -104,7 +104,7 @@ BEGIN
|
||||||
price)
|
price)
|
||||||
SELECT vTicketFk,
|
SELECT vTicketFk,
|
||||||
vNewItemFk,
|
vNewItemFk,
|
||||||
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName),
|
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name),
|
||||||
vFinalPrice
|
vFinalPrice
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
WHERE id = vNewItemFk;
|
WHERE id = vNewItemFk;
|
||||||
|
|
|
@ -2,54 +2,9 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DECLARE done INT DEFAULT FALSE;
|
|
||||||
DECLARE vNewTicketFk INT;
|
DECLARE vNewTicketFk INT;
|
||||||
DECLARE vOldSaleFk INT;
|
|
||||||
DECLARE vNewSaleFk INT;
|
|
||||||
|
|
||||||
DECLARE cur1 CURSOR FOR
|
CALL ticket_cloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk);
|
||||||
SELECT id
|
|
||||||
FROM vn.sale
|
|
||||||
WHERE ticketFk = vTicketFk;
|
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
|
||||||
|
|
||||||
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
|
|
||||||
|
|
||||||
CALL vn.ticket_Clone(vTicketFk, vNewTicketFk);
|
|
||||||
|
|
||||||
UPDATE vn.ticket
|
|
||||||
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
|
||||||
shipped = vNewShipped
|
|
||||||
WHERE id = vNewTicketFk;
|
|
||||||
|
|
||||||
OPEN cur1;
|
|
||||||
|
|
||||||
read_loop: LOOP
|
|
||||||
|
|
||||||
FETCH cur1 INTO vOldSaleFk;
|
|
||||||
|
|
||||||
IF done THEN
|
|
||||||
LEAVE read_loop;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
INSERT INTO vn.sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
|
|
||||||
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
|
|
||||||
FROM vn.sale
|
|
||||||
WHERE id = vOldSaleFk;
|
|
||||||
|
|
||||||
SELECT max(id) INTO vNewSaleFk
|
|
||||||
FROM vn.sale
|
|
||||||
WHERE ticketFk = vNewTicketFk;
|
|
||||||
|
|
||||||
INSERT INTO vn.saleComponent(saleFk, componentFk, value, isGreuge)
|
|
||||||
SELECT vNewSaleFk, componentFk, value, isGreuge
|
|
||||||
FROM vn.saleComponent
|
|
||||||
WHERE saleFk = vOldSaleFk;
|
|
||||||
|
|
||||||
END LOOP;
|
|
||||||
|
|
||||||
CLOSE cur1;
|
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneAll`(vTicketFk INT, vNewShipped DATE, vWithWarehouse BOOLEAN, OUT vNewTicketFk INT)
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
DECLARE vDone BOOLEAN DEFAULT FALSE;
|
||||||
|
DECLARE vOldSaleFk INT;
|
||||||
|
DECLARE vNewSaleFk INT;
|
||||||
|
|
||||||
|
DECLARE cur1 CURSOR FOR
|
||||||
|
SELECT id
|
||||||
|
FROM sale
|
||||||
|
WHERE ticketFk = vTicketFk;
|
||||||
|
|
||||||
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
SET vNewShipped = IFNULL(vNewShipped, util.VN_CURDATE());
|
||||||
|
|
||||||
|
CALL ticket_Clone(vTicketFk, vNewTicketFk);
|
||||||
|
|
||||||
|
UPDATE ticket
|
||||||
|
SET landed = TIMESTAMPADD(DAY, DATEDIFF(vNewShipped, shipped), landed),
|
||||||
|
shipped = vNewShipped,
|
||||||
|
warehouseFk = IF(vWithWarehouse, warehouseFk, NULL)
|
||||||
|
WHERE id = vNewTicketFk;
|
||||||
|
|
||||||
|
OPEN cur1;
|
||||||
|
|
||||||
|
read_loop: LOOP
|
||||||
|
|
||||||
|
FETCH cur1 INTO vOldSaleFk;
|
||||||
|
|
||||||
|
IF vDone THEN
|
||||||
|
LEAVE read_loop;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
INSERT INTO sale(ticketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed)
|
||||||
|
SELECT vNewTicketFk, itemFk, quantity, concept, price, discount, priceFixed, isPriceFixed
|
||||||
|
FROM sale
|
||||||
|
WHERE id = vOldSaleFk;
|
||||||
|
|
||||||
|
SELECT max(id) INTO vNewSaleFk
|
||||||
|
FROM sale
|
||||||
|
WHERE ticketFk = vNewTicketFk;
|
||||||
|
|
||||||
|
INSERT INTO saleComponent(saleFk, componentFk, value, isGreuge)
|
||||||
|
SELECT vNewSaleFk, componentFk, value, isGreuge
|
||||||
|
FROM saleComponent
|
||||||
|
WHERE saleFk = vOldSaleFk;
|
||||||
|
|
||||||
|
END LOOP;
|
||||||
|
|
||||||
|
CLOSE cur1;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
DELIMITER ;
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete`
|
||||||
BEFORE DELETE ON `buy`
|
BEFORE DELETE ON `buy`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL entry_checkBooked(OLD.entryFk);
|
||||||
IF OLD.printedStickers <> 0 THEN
|
IF OLD.printedStickers <> 0 THEN
|
||||||
CALL util.throw("it is not possible to delete buys with printed labels ");
|
CALL util.throw("it is not possible to delete buys with printed labels ");
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -15,6 +15,7 @@ trig: BEGIN
|
||||||
LEAVE trig;
|
LEAVE trig;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
CALL entry_checkBooked(NEW.entryFk);
|
||||||
IF NEW.printedStickers <> 0 THEN
|
IF NEW.printedStickers <> 0 THEN
|
||||||
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
||||||
END IF;
|
END IF;
|
||||||
|
|
|
@ -13,6 +13,7 @@ trig:BEGIN
|
||||||
LEAVE trig;
|
LEAVE trig;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
CALL entry_checkBooked(OLD.entryFk);
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
SELECT defaultEntry INTO vDefaultEntry
|
SELECT defaultEntry INTO vDefaultEntry
|
||||||
|
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
|
||||||
BEFORE DELETE ON `entry`
|
BEFORE DELETE ON `entry`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
CALL entry_checkBooked(OLD.id);
|
||||||
DELETE FROM buy WHERE entryFk = OLD.id;
|
DELETE FROM buy WHERE entryFk = OLD.id;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -7,6 +7,10 @@ BEGIN
|
||||||
DECLARE vPrintedCount INT;
|
DECLARE vPrintedCount INT;
|
||||||
DECLARE vHasDistinctWarehouses BOOL;
|
DECLARE vHasDistinctWarehouses BOOL;
|
||||||
|
|
||||||
|
IF NEW.isBooked = OLD.isBooked THEN
|
||||||
|
CALL entry_checkBooked(OLD.id);
|
||||||
|
END IF;
|
||||||
|
|
||||||
SET NEW.editorFk = account.myUser_getId();
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
|
|
||||||
IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
|
IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
|
||||||
|
|
|
@ -12,5 +12,5 @@ FROM (
|
||||||
`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`
|
`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
WHERE `pc`.`name` = 'Aux ventas'
|
WHERE `pc`.`description` = 'Aux ventas'
|
||||||
GROUP BY `b`.`workerFk`
|
GROUP BY `b`.`workerFk`
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
CREATE SCHEMA IF NOT EXISTS `floranet`;
|
||||||
|
|
||||||
|
CREATE ROLE IF NOT EXISTS 'floranet' ;
|
||||||
|
|
||||||
|
GRANT Create temporary tables ON floranet.* TO 'floranet';
|
||||||
|
|
||||||
|
GRANT Execute ON floranet.* TO 'floranet';
|
||||||
|
|
||||||
|
GRANT Lock tables ON floranet.* TO 'floranet';
|
||||||
|
|
||||||
|
CREATE USER IF NOT EXISTS 'floranet'@'%';
|
||||||
|
|
||||||
|
GRANT floranet TO floranet@'%';
|
|
@ -0,0 +1,61 @@
|
||||||
|
CREATE OR REPLACE TABLE floranet.`builder` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`itemFk` int(11) NOT NULL,
|
||||||
|
`elementFk` int(11) NOT NULL,
|
||||||
|
`quantity` int(10) unsigned NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `builder_FK` (`itemFk`),
|
||||||
|
KEY `builder_FK_1` (`elementFk`),
|
||||||
|
CONSTRAINT `builder_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Links handmade products with their elements';
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE floranet.`element` (
|
||||||
|
`itemFk` int(11) NOT NULL,
|
||||||
|
`typeFk` smallint(5) unsigned DEFAULT NULL,
|
||||||
|
`size` int(11) DEFAULT NULL,
|
||||||
|
`inkFk` char(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL,
|
||||||
|
`originFk` tinyint(2) unsigned DEFAULT NULL,
|
||||||
|
`name` varchar(30) DEFAULT NULL,
|
||||||
|
`quantity` int(11) NOT NULL DEFAULT 1,
|
||||||
|
PRIMARY KEY (`itemFk`),
|
||||||
|
KEY `element_FK` (`itemFk`),
|
||||||
|
KEY `element_FK_1` (`typeFk`),
|
||||||
|
KEY `element_FK_2` (`inkFk`),
|
||||||
|
KEY `element_FK_3` (`originFk`),
|
||||||
|
CONSTRAINT `element_FK` FOREIGN KEY (`itemFk`) REFERENCES `vn`.`item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `element_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `vn`.`itemType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `element_FK_2` FOREIGN KEY (`inkFk`) REFERENCES `vn`.`ink` (`id`) ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT `element_FK_3` FOREIGN KEY (`originFk`) REFERENCES `vn`.`origin` (`id`) ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Filtro para localizar posibles items que coincidan con la descripción';
|
||||||
|
|
||||||
|
ALTER TABLE floranet.builder ADD CONSTRAINT `builder_FK_1` FOREIGN KEY (`elementFk`) REFERENCES `element` (`itemFk`) ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE floranet.catalogue
|
||||||
|
(id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(50),
|
||||||
|
price DECIMAL(10,2) NOT NULL,
|
||||||
|
itemFk INT NOT NULL,
|
||||||
|
dated DATE,
|
||||||
|
postalCode VARCHAR(12),
|
||||||
|
`type` VARCHAR(50),
|
||||||
|
image VARCHAR(255),
|
||||||
|
description TEXT,
|
||||||
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
payed DATETIME,
|
||||||
|
FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE);
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE TABLE floranet.`order`
|
||||||
|
(id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
catalogueFk INT UNIQUE,
|
||||||
|
customerName VARCHAR(100),
|
||||||
|
email VARCHAR(100),
|
||||||
|
customerPhone VARCHAR(15),
|
||||||
|
message VARCHAR(255),
|
||||||
|
deliveryName VARCHAR(100),
|
||||||
|
address VARCHAR(200),
|
||||||
|
deliveryPhone VARCHAR(100),
|
||||||
|
isPaid BOOL NOT NULL DEFAULT FALSE,
|
||||||
|
payed DATETIME,
|
||||||
|
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (catalogueFk) REFERENCES catalogue(id) ON DELETE RESTRICT ON UPDATE CASCADE);
|
|
@ -0,0 +1,12 @@
|
||||||
|
CREATE TABLE floranet.`addressPostCode` (
|
||||||
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`addressFk` int(11) NOT NULL,
|
||||||
|
`postCode` varchar(30) NOT NULL,
|
||||||
|
`hoursInAdvance` int(10) unsigned NOT NULL DEFAULT 24,
|
||||||
|
`dayOfWeek` int(10) unsigned NOT NULL,
|
||||||
|
`deliveryCost` decimal(10,2) NOT NULL DEFAULT 0.00,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `addressPostCode_unique` (`postCode`,`addressFk`,`dayOfWeek`),
|
||||||
|
KEY `addressPostCode_address_FK` (`addressFk`),
|
||||||
|
CONSTRAINT `addressPostCode_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `vn`.`address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Client''s address registered for floranet network';
|
|
@ -0,0 +1,2 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||||
|
VALUES('Ticket', 'clone', 'WRITE', 'ALLOW', 'ROLE', 'administrative');
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE vn.professionalCategory DROP COLUMN dayBreak, DROP COLUMN `level`;
|
||||||
|
ALTER TABLE vn.professionalCategory
|
||||||
|
CHANGE name description varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
|
@ -22,12 +22,4 @@ describe('Account Connections path', () => {
|
||||||
|
|
||||||
expect(firstResult).toContain(account);
|
expect(firstResult).toContain(account);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should kill this connection and then get redirected to the login page', async() => {
|
|
||||||
await page.waitToClick(selectors.accountConnections.deleteFirstConnection);
|
|
||||||
await page.waitToClick(selectors.globalItems.acceptButton);
|
|
||||||
const message = await page.waitForSnackbar();
|
|
||||||
|
|
||||||
expect(message.text).toContain('Your session has expired, please login again');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethodCtx('clone', {
|
||||||
|
description: 'clone a ticket and return the new ticket id',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [{
|
||||||
|
arg: 'id',
|
||||||
|
type: 'number',
|
||||||
|
required: true,
|
||||||
|
description: 'The ticket id',
|
||||||
|
http: {source: 'path'}
|
||||||
|
}, {
|
||||||
|
arg: 'shipped',
|
||||||
|
type: 'date',
|
||||||
|
}, {
|
||||||
|
arg: 'withWarehouse',
|
||||||
|
type: 'boolean',
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
type: 'number',
|
||||||
|
root: true
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/:id/clone`,
|
||||||
|
verb: 'POST'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.clone = async(ctx, id, shipped, withWarehouse, options) => {
|
||||||
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
|
let tx;
|
||||||
|
|
||||||
|
if (typeof options == 'object')
|
||||||
|
Object.assign(myOptions, options);
|
||||||
|
|
||||||
|
if (!myOptions.transaction) {
|
||||||
|
tx = await Self.beginTransaction({});
|
||||||
|
myOptions.transaction = tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [, [{clonedTicketId}]] = await Self.rawSql(`
|
||||||
|
CALL vn.ticket_cloneAll(?, ?, ?, @clonedTicketId);
|
||||||
|
SELECT @clonedTicketId clonedTicketId;`,
|
||||||
|
[id, shipped, withWarehouse], myOptions);
|
||||||
|
|
||||||
|
if (tx) await tx.commit();
|
||||||
|
return clonedTicketId;
|
||||||
|
} catch (e) {
|
||||||
|
if (tx) await tx.rollback();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,56 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
|
describe('Ticket cloning - clone function', () => {
|
||||||
|
let ctx;
|
||||||
|
let options;
|
||||||
|
let tx;
|
||||||
|
const ticketId = 1;
|
||||||
|
const shipped = Date.vnNew();
|
||||||
|
|
||||||
|
beforeEach(async() => {
|
||||||
|
ctx = {
|
||||||
|
req: {
|
||||||
|
accessToken: {userId: 9},
|
||||||
|
headers: {origin: 'http://localhost'}
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: ctx.req
|
||||||
|
});
|
||||||
|
|
||||||
|
options = {transaction: tx};
|
||||||
|
tx = await models.Ticket.beginTransaction({});
|
||||||
|
options.transaction = tx;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async() => {
|
||||||
|
await tx.rollback();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should clone a new ticket without warehouse', async() => {
|
||||||
|
const originalTicket = await models.Ticket.findById(ticketId, null, options);
|
||||||
|
|
||||||
|
const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, false, options);
|
||||||
|
const newTicket = await models.Ticket.findById(newTicketId, null, options);
|
||||||
|
|
||||||
|
expect(newTicket.clientFk).toEqual(originalTicket.clientFk);
|
||||||
|
expect(newTicket.companyFk).toEqual(originalTicket.companyFk);
|
||||||
|
expect(newTicket.addressFk).toEqual(originalTicket.addressFk);
|
||||||
|
expect(newTicket.warehouseFk).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should clone a new ticket with warehouse', async() => {
|
||||||
|
const originalTicket = await models.Ticket.findById(ticketId, null, options);
|
||||||
|
|
||||||
|
const newTicketId = await models.Ticket.clone(ctx, ticketId, shipped, true, options);
|
||||||
|
const newTicket = await models.Ticket.findById(newTicketId, null, options);
|
||||||
|
|
||||||
|
expect(newTicket.clientFk).toEqual(originalTicket.clientFk);
|
||||||
|
expect(newTicket.companyFk).toEqual(originalTicket.companyFk);
|
||||||
|
expect(newTicket.addressFk).toEqual(originalTicket.addressFk);
|
||||||
|
expect(newTicket.warehouseFk).toEqual(originalTicket.warehouseFk);
|
||||||
|
});
|
||||||
|
});
|
|
@ -46,4 +46,6 @@ module.exports = function(Self) {
|
||||||
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
|
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
|
||||||
require('../methods/ticket/docuwareDownload')(Self);
|
require('../methods/ticket/docuwareDownload')(Self);
|
||||||
require('../methods/ticket/myLastModified')(Self);
|
require('../methods/ticket/myLastModified')(Self);
|
||||||
|
require('../methods/ticket/addSaleByCode')(Self);
|
||||||
|
require('../methods/ticket/clone')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
require('./ticket-methods')(Self);
|
require('./ticket-methods')(Self);
|
||||||
require('../methods/ticket/state')(Self);
|
require('../methods/ticket/state')(Self);
|
||||||
require('../methods/ticket/addSaleByCode')(Self);
|
|
||||||
};
|
};
|
||||||
|
|
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 973 KiB |
After Width: | Height: | Size: 1.6 MiB |
After Width: | Height: | Size: 920 KiB |
After Width: | Height: | Size: 776 KiB |
After Width: | Height: | Size: 1.5 MiB |
After Width: | Height: | Size: 1.3 MiB |
After Width: | Height: | Size: 2.0 MiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 234 KiB |
After Width: | Height: | Size: 181 KiB |
After Width: | Height: | Size: 306 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 288 KiB |
After Width: | Height: | Size: 248 KiB |
After Width: | Height: | Size: 371 KiB |
After Width: | Height: | Size: 231 KiB |
After Width: | Height: | Size: 298 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 9.9 KiB |
After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 124 KiB |
After Width: | Height: | Size: 219 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 207 KiB |
After Width: | Height: | Size: 178 KiB |
After Width: | Height: | Size: 245 KiB |
After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 206 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 9.9 KiB |