#6427 - SMS Recover Password #2037
|
@ -20,8 +20,9 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const [,, {collectionFk}] = await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||
[userId], myOptions);
|
||||
const [, , [{collectionFk}]] =
|
||||
await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk',
|
||||
[userId], myOptions);
|
||||
|
||||
if (!collectionFk) throw new UserError('There are not picking tickets');
|
||||
await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions);
|
||||
|
|
|
@ -4,20 +4,21 @@ describe('image download()', () => {
|
|||
const collection = 'user';
|
||||
const size = '160x160';
|
||||
const employeeId = 1;
|
||||
const developerId = 9;
|
||||
const jessicaJonesId = 1110;
|
||||
const ctx = {req: {accessToken: {userId: employeeId}}};
|
||||
|
||||
it('should return the image content-type of the user', async() => {
|
||||
const userId = 9;
|
||||
const image = await models.Image.download(ctx, collection, size, userId);
|
||||
const image = await models.Image.download(ctx, collection, size, developerId);
|
||||
const contentType = image[1];
|
||||
|
||||
expect(contentType).toEqual('image/png');
|
||||
});
|
||||
|
||||
it(`should return false if the user doesn't have image`, async() => {
|
||||
const userId = 1110;
|
||||
const image = await models.Image.download(ctx, collection, size, userId);
|
||||
it('should return the user profile picture', async() => {
|
||||
const image = await models.Image.download(ctx, collection, size, jessicaJonesId);
|
||||
const fileName = image[2];
|
||||
|
||||
expect(image).toBeFalse();
|
||||
expect(fileName).toMatch('1110.png');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -122,7 +122,7 @@ describe('machineWorker updateInTime()', () => {
|
|||
|
||||
expect(isNotParked.outTime).toBeNull();
|
||||
expect(isParked.outTime).toBeDefined();
|
||||
expect(totalAfter.length).toEqual(totalBefore.length + 1);
|
||||
expect(totalAfter.length).toEqual(totalBefore.length);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
|
|
|
@ -48,7 +48,7 @@ module.exports = Self => {
|
|||
}, myOptions);
|
||||
|
||||
const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions);
|
||||
const hoursDifference = (Date.vnNow() - machineWorker.inTime.getTime()) / (60 * 60 * 1000);
|
||||
const hoursDifference = (Date.vnNow() - machineWorker?.inTimed?.getTime() ?? 0) / (60 * 60 * 1000);
|
||||
|
||||
if (machineWorker) {
|
||||
const isHimself = userId == machineWorker.workerFk;
|
||||
|
|
|
@ -40,6 +40,11 @@ module.exports = Self => {
|
|||
fields,
|
||||
};
|
||||
|
||||
return Self.findOne(filter);
|
||||
const result = await Self.findOne(filter);
|
||||
return {
|
||||
isVersionCritical: result?.isVersionBetaCritical ?? result?.isVersionCritical,
|
||||
version: result?.versionBeta ?? result?.version,
|
||||
url: result?.urlBeta ?? result?.urlProduction
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -2,6 +2,8 @@ const {models} = require('vn-loopback/server/server');
|
|||
|
||||
describe('mobileAppVersionControl getVersion()', () => {
|
||||
const appName = 'delivery';
|
||||
const appNameVersion = '9.2';
|
||||
const appNameVersionBeta = '9.7';
|
||||
beforeAll(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
|
@ -13,17 +15,15 @@ describe('mobileAppVersionControl getVersion()', () => {
|
|||
|
||||
it('should get the version app', async() => {
|
||||
ctx.req.accessToken.userId = 9;
|
||||
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
|
||||
expect(version).toEqual('9.2');
|
||||
expect(versionBeta).toBeUndefined();
|
||||
expect(version).toEqual(appNameVersion);
|
||||
});
|
||||
|
||||
it('should get the beta version app', async() => {
|
||||
ctx.req.accessToken.userId = 66;
|
||||
const {version, versionBeta} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
const {version} = await models.MobileAppVersionControl.getVersion(ctx, appName);
|
||||
|
||||
expect(versionBeta).toBeDefined();
|
||||
expect(version).toBeUndefined();
|
||||
expect(version).toEqual(appNameVersionBeta);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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`)
|
||||
VALUES
|
||||
(1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL),
|
||||
(1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL),
|
||||
(1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL);
|
||||
(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','1102'),
|
||||
(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','1104'),
|
||||
(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','1106'),
|
||||
(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','1108'),
|
||||
(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','1110'),
|
||||
(1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en','e7723f0b24ff05b32ed09d95196f2f29'),
|
||||
(1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en','e7723f0b24ff05b32ed09d95196f2f29');
|
||||
|
||||
UPDATE account.`user`
|
||||
SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR)
|
||||
|
@ -760,8 +760,8 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
|
|||
(29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL);
|
||||
|
||||
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL);
|
||||
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
||||
VALUES
|
||||
(1, 11, 1, 'ready'),
|
||||
|
@ -1980,10 +1980,10 @@ INSERT INTO `pbx`.`sip`(`user_id`, `extension`)
|
|||
(5, 1102),
|
||||
(9, 1201);
|
||||
|
||||
INSERT INTO `vn`.`professionalCategory` (`id`, `name`, `level`, `dayBreak`)
|
||||
INSERT INTO `vn`.`professionalCategory` (`id`, `description`)
|
||||
VALUES
|
||||
(1, 'employee', NULL, NULL),
|
||||
(2, 'florist', NULL, NULL);
|
||||
(1, 'employee'),
|
||||
(2, 'florist');
|
||||
|
||||
INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
|
||||
VALUES
|
||||
|
|
|
@ -23,7 +23,7 @@ BEGIN
|
|||
ENGINE = MEMORY
|
||||
SELECT Id_Ticket
|
||||
FROM vn2008.Tickets t
|
||||
JOIN vn.invoiceOut io ON io.id = t.Factura
|
||||
JOIN vn.invoiceOut io ON io.`ref` = t.Factura
|
||||
WHERE year(io.issued) = vYear
|
||||
AND month(io.issued) = vMonth;
|
||||
|
||||
|
|
|
@ -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 ;
|
|
@ -3,10 +3,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vI
|
|||
BEGIN
|
||||
/**
|
||||
* Traslada la info de contabilidad relacionada con las facturas recibidas
|
||||
*
|
||||
*
|
||||
* @vInvoiceInFk Factura recibida
|
||||
* @vXDiarioFk Id tabla XDiario
|
||||
*/
|
||||
*/
|
||||
DECLARE vInvoiceInOriginalFk INT;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vBase DOUBLE;
|
||||
DECLARE vVat DOUBLE;
|
||||
|
@ -23,25 +24,25 @@ BEGIN
|
|||
DECLARE vInvoiceTypeInformative VARCHAR(1);
|
||||
DECLARE vIsInformativeExportation BOOL DEFAULT FALSE;
|
||||
|
||||
DECLARE vCursor CURSOR FOR
|
||||
DECLARE vCursor CURSOR FOR
|
||||
SELECT it.taxableBase,
|
||||
CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
|
||||
t.PorcentajeIva,
|
||||
it.transactionTypeSageFk,
|
||||
it.taxTypeSageFk,
|
||||
tty.isIntracommunity,
|
||||
tt.ClaveOperacionDefecto
|
||||
tt.ClaveOperacionDefecto
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id
|
||||
JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk
|
||||
JOIN taxType tty ON tty.id = t.CodigoIva
|
||||
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
|
||||
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
|
||||
WHERE i.id = vInvoiceInFk
|
||||
WHERE i.id = vInvoiceInFk
|
||||
AND d.id IS NULL;
|
||||
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
|
||||
DELETE FROM movContaIVA
|
||||
WHERE id = vXDiarioFk;
|
||||
|
||||
|
@ -64,22 +65,22 @@ BEGIN
|
|||
vTaxCode,
|
||||
vIsIntracommunity,
|
||||
vOperationCode;
|
||||
|
||||
IF vDone THEN
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
IF vOperationCode IS NOT NULL THEN
|
||||
IF vOperationCode IS NOT NULL THEN
|
||||
UPDATE movContaIVA
|
||||
SET ClaveOperacionFactura = vOperationCode
|
||||
WHERE id = vXDiarioFk;
|
||||
END IF;
|
||||
|
||||
|
||||
SET vCounter = vCounter + 1;
|
||||
CASE vCounter
|
||||
CASE vCounter
|
||||
WHEN 1 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva1 = vBase,
|
||||
|
@ -115,31 +116,31 @@ BEGIN
|
|||
WHERE id = vXDiarioFk;
|
||||
ELSE
|
||||
SELECT vXDiarioFk INTO vXDiarioFk;
|
||||
END CASE;
|
||||
END CASE;
|
||||
|
||||
IF vIsIntracommunity THEN
|
||||
UPDATE movContaIVA
|
||||
SET Intracomunitaria = TRUE
|
||||
WHERE id = vXDiarioFk;
|
||||
END IF;
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
END LOOP;
|
||||
|
||||
CLOSE vCursor;
|
||||
|
||||
SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation
|
||||
FROM vn.dua d
|
||||
LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
|
||||
LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
|
||||
AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
|
||||
WHERE d.ASIEN = (
|
||||
SELECT ASIEN
|
||||
FROM vn.XDiario
|
||||
FROM vn.XDiario
|
||||
WHERE id = vXDiarioFk)
|
||||
LIMIT 1;
|
||||
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
JOIN vn.XDiario x ON x.id = mci.id
|
||||
|
@ -151,13 +152,13 @@ BEGIN
|
|||
mci.Serie = ii.serial,
|
||||
mci.Factura = ii.id,
|
||||
mci.FechaFactura = ii.issued,
|
||||
mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
|
||||
IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
|
||||
IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
|
||||
mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
|
||||
IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
|
||||
IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
|
||||
IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0),
|
||||
mci.TipoFactura = IF(id.id,
|
||||
IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
|
||||
IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
|
||||
mci.TipoFactura = IF(id.id,
|
||||
IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
|
||||
IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
|
||||
mci.CodigoCuentaFactura = x.SUBCTA,
|
||||
mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif),
|
||||
mci.Nombre = s.name,
|
||||
|
@ -185,7 +186,7 @@ BEGIN
|
|||
JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
|
||||
FROM vn.XDiario x1
|
||||
JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN
|
||||
WHERE x2.BASEEURO <> 0
|
||||
WHERE x2.BASEEURO <> 0
|
||||
AND x1.id = vXDiarioFk
|
||||
)sub
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio'
|
||||
|
@ -193,10 +194,41 @@ BEGIN
|
|||
mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura),
|
||||
mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase),
|
||||
mci.PorRetencion = t.PorcentajeRetencion,
|
||||
mci.ImporteRetencion = iit.taxableBase * - 1
|
||||
WHERE mci.id = vXDiarioFk
|
||||
mci.ImporteRetencion = iit.taxableBase * - 1
|
||||
WHERE mci.id = vXDiarioFk
|
||||
AND e.name = 'Retenciones'
|
||||
AND id.id IS NULL;
|
||||
|
||||
SELECT correctedFk INTO vInvoiceInOriginalFk
|
||||
FROM vn.invoiceInCorrection
|
||||
WHERE correctingFk = vInvoiceInFk;
|
||||
|
||||
IF vInvoiceInOriginalFk THEN
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk
|
||||
JOIN (SELECT issued,
|
||||
SUM(sub.taxableBase) taxableBase,
|
||||
SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat
|
||||
FROM(SELECT issued,
|
||||
SUM(iit.taxableBase) taxableBase,
|
||||
ti.PorcentajeIva
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE i.id = vInvoiceInOriginalFk
|
||||
GROUP BY ti.CodigoIva)sub
|
||||
)invoiceInOriginal
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa'
|
||||
SET mci.TipoRectificativa = iir.refundCategoryFk,
|
||||
mci.ClaseAbonoRectificativas = iir.refundType,
|
||||
mci.FechaFacturaOriginal = invoiceInOriginal.issued,
|
||||
mci.FechaOperacion = invoiceInOriginal.issued,
|
||||
mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase,
|
||||
mci.CuotaIvaOriginal = invoiceInOriginal.vat,
|
||||
mci.ClaveOperacionFactura = co.ClaveOperacionFactura_
|
||||
WHERE mci.id = vXDiarioFk;
|
||||
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
DELIMITER ;
|
|
@ -0,0 +1,102 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
|
||||
vItemFk INT,
|
||||
vWarehouseFk INT,
|
||||
vDate DATETIME
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula y proporciona un historial de inventario absoluto
|
||||
* para un artículo específico en un almacén dado
|
||||
* hasta una fecha determinada.
|
||||
*
|
||||
* @param vItemFk Id de artículo
|
||||
* @param vWarehouseFk Id de almacén
|
||||
* @param vDate Fecha
|
||||
*/
|
||||
DECLARE vCalculatedInventory INT;
|
||||
DECLARE vToday DATETIME DEFAULT util.VN_CURDATE();
|
||||
DECLARE vStartDate DATE DEFAULT '2001-01-01';
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tHistoricalPast
|
||||
ENGINE = MEMORY
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT tr.landed `date`,
|
||||
b.quantity input,
|
||||
NULL `output`,
|
||||
tr.isReceived ok,
|
||||
s.name alias,
|
||||
e.invoiceNumber reference,
|
||||
e.id id,
|
||||
tr.isDelivered f5
|
||||
FROM buy b
|
||||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
WHERE tr.landed >= vStartDate
|
||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||
AND vWarehouseFk IN (tr.warehouseInFk, 0)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
UNION ALL
|
||||
SELECT tr.shipped,
|
||||
NULL,
|
||||
b.quantity,
|
||||
tr.isDelivered,
|
||||
s.name,
|
||||
e.invoiceNumber,
|
||||
e.id,
|
||||
tr.isDelivered
|
||||
FROM buy b
|
||||
JOIN `entry` e ON e.id = b.entryFk
|
||||
JOIN travel tr ON tr.id = e.travelFk
|
||||
JOIN supplier s ON s.id = e.supplierFk
|
||||
WHERE tr.shipped >= vStartDate
|
||||
AND vWarehouseFk = tr.warehouseOutFk
|
||||
AND s.id <> (SELECT supplierFk FROM inventoryConfig)
|
||||
AND b.itemFk = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
AND NOT e.isRaid
|
||||
UNION ALL
|
||||
SELECT t.shipped,
|
||||
NULL,
|
||||
m.quantity,
|
||||
(m.isPicked OR t.isLabeled OR t.refFk IS NOT NULL),
|
||||
t.nickname,
|
||||
t.refFk,
|
||||
t.id,
|
||||
t.isPrinted
|
||||
FROM sale m
|
||||
JOIN ticket t ON t.id = m.ticketFk
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped >= vStartDate
|
||||
AND m.itemFk = vItemFk
|
||||
AND vWarehouseFk IN (t.warehouseFk, 0)
|
||||
) t1
|
||||
ORDER BY `date`, input DESC, ok DESC;
|
||||
|
||||
SELECT SUM(input) - SUM(`output`) INTO vCalculatedInventory
|
||||
FROM tHistoricalPast
|
||||
WHERE `date` < vDate;
|
||||
|
||||
SELECT p1.*, NULL v_virtual
|
||||
FROM (
|
||||
SELECT vDate `date`,
|
||||
vCalculatedInventory input,
|
||||
NULL `output`,
|
||||
1 ok,
|
||||
'Inventario calculado' alias,
|
||||
'' reference,
|
||||
0 id,
|
||||
1 f5
|
||||
UNION ALL
|
||||
SELECT *
|
||||
FROM tHistoricalPast
|
||||
WHERE `date` >= vDate
|
||||
) p1;
|
||||
|
||||
DROP TEMPORARY TABLE tHistoricalPast;
|
||||
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 ;
|
|
@ -10,20 +10,15 @@ BEGIN
|
|||
* @param vInvoiceInFk Id de factura recibida
|
||||
*/
|
||||
DECLARE vRate DOUBLE DEFAULT 1;
|
||||
DECLARE vDated DATE;
|
||||
DECLARE vExpenseFk INT;
|
||||
DECLARE vExpenseFk VARCHAR(10);
|
||||
|
||||
SELECT MAX(rr.dated) INTO vDated
|
||||
SELECT `value` INTO vRate
|
||||
FROM referenceRate rr
|
||||
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
WHERE rr.dated <= ii.issued
|
||||
AND rr.currencyFk = ii.currencyFk;
|
||||
|
||||
IF vDated THEN
|
||||
SELECT `value` INTO vRate
|
||||
FROM referenceRate
|
||||
WHERE dated = vDated;
|
||||
END IF;
|
||||
AND rr.currencyFk = ii.currencyFk
|
||||
ORDER BY dated DESC
|
||||
LIMIT 1;
|
||||
|
||||
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
|
||||
|
||||
|
|
|
@ -1,234 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `sage`.`invoiceIn_add`(vInvoiceInFk INT, vXDiarioFk INT)
|
||||
BEGIN
|
||||
/**
|
||||
* Traslada la info de contabilidad relacionada con las facturas recibidas
|
||||
*
|
||||
* @vInvoiceInFk Factura recibida
|
||||
* @vXDiarioFk Id tabla XDiario
|
||||
*/
|
||||
DECLARE vInvoiceInOriginalFk INT;
|
||||
DECLARE vDone BOOL DEFAULT FALSE;
|
||||
DECLARE vBase DOUBLE;
|
||||
DECLARE vVat DOUBLE;
|
||||
DECLARE vRate DOUBLE;
|
||||
DECLARE vTransactionCode INT;
|
||||
DECLARE vCounter INT DEFAULT 0;
|
||||
DECLARE vTransactionCodeOld INT;
|
||||
DECLARE vTaxCode INT;
|
||||
DECLARE vTaxCodeOld INT;
|
||||
DECLARE vOperationCode VARCHAR(1);
|
||||
DECLARE vIsIntracommunity BOOL DEFAULT FALSE;
|
||||
DECLARE vSerialDua VARCHAR(1) DEFAULT 'D';
|
||||
DECLARE vInvoiceTypeReceived VARCHAR(1);
|
||||
DECLARE vInvoiceTypeInformative VARCHAR(1);
|
||||
DECLARE vIsInformativeExportation BOOL DEFAULT FALSE;
|
||||
|
||||
DECLARE vCursor CURSOR FOR
|
||||
SELECT it.taxableBase,
|
||||
CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)),
|
||||
t.PorcentajeIva,
|
||||
it.transactionTypeSageFk,
|
||||
it.taxTypeSageFk,
|
||||
tty.isIntracommunity,
|
||||
tt.ClaveOperacionDefecto
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax it ON it.InvoiceInFk = i.id
|
||||
JOIN TiposIva t ON t.CodigoIva = it.taxTypeSageFk
|
||||
JOIN taxType tty ON tty.id = t.CodigoIva
|
||||
JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk
|
||||
LEFT JOIN vn.dua d ON d.id = vInvoiceInFk
|
||||
WHERE i.id = vInvoiceInFk
|
||||
AND d.id IS NULL;
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
DELETE FROM movContaIVA
|
||||
WHERE id = vXDiarioFk;
|
||||
|
||||
SELECT codeSage INTO vInvoiceTypeReceived
|
||||
FROM invoiceType WHERE code ='received';
|
||||
|
||||
SELECT codeSage INTO vInvoiceTypeInformative
|
||||
FROM invoiceType WHERE code ='informative';
|
||||
|
||||
INSERT INTO movContaIVA(id, LibreA1)
|
||||
VALUES (vXDiarioFk, vInvoiceInFk);
|
||||
|
||||
OPEN vCursor;
|
||||
|
||||
l: LOOP
|
||||
FETCH vCursor INTO vBase,
|
||||
vVat,
|
||||
vRate,
|
||||
vTransactionCode,
|
||||
vTaxCode,
|
||||
vIsIntracommunity,
|
||||
vOperationCode;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE l;
|
||||
END IF;
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
IF vOperationCode IS NOT NULL THEN
|
||||
UPDATE movContaIVA
|
||||
SET ClaveOperacionFactura = vOperationCode
|
||||
WHERE id = vXDiarioFk;
|
||||
END IF;
|
||||
|
||||
SET vCounter = vCounter + 1;
|
||||
CASE vCounter
|
||||
WHEN 1 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva1 = vBase,
|
||||
PorIva1 = vRate,
|
||||
CuotaIva1 = vVat,
|
||||
CodigoTransaccion1 = vTransactionCode,
|
||||
CodigoIva1 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
|
||||
WHEN 2 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva2 = vBase,
|
||||
PorIva2 = vRate,
|
||||
CuotaIva2 = vVat,
|
||||
CodigoTransaccion2 = vTransactionCode,
|
||||
CodigoIva2 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
WHEN 3 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva3 = vBase,
|
||||
PorIva3 = vRate,
|
||||
CuotaIva3 = vVat,
|
||||
CodigoTransaccion3 = vTransactionCode,
|
||||
CodigoIva3 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
WHEN 4 THEN
|
||||
UPDATE movContaIVA
|
||||
SET BaseIva4 = vBase,
|
||||
PorIva4 = vRate,
|
||||
CuotaIva4 = vVat,
|
||||
CodigoTransaccion4 = vTransactionCode,
|
||||
CodigoIva4 = vTaxCode
|
||||
WHERE id = vXDiarioFk;
|
||||
ELSE
|
||||
SELECT vXDiarioFk INTO vXDiarioFk;
|
||||
END CASE;
|
||||
|
||||
IF vIsIntracommunity THEN
|
||||
UPDATE movContaIVA
|
||||
SET Intracomunitaria = TRUE
|
||||
WHERE id = vXDiarioFk;
|
||||
END IF;
|
||||
|
||||
SET vTransactionCodeOld = vTransactionCode;
|
||||
SET vTaxCodeOld = vTaxCode;
|
||||
|
||||
END LOOP;
|
||||
|
||||
CLOSE vCursor;
|
||||
|
||||
SELECT d.ASIEN AND x.ASIEN IS NULL INTO vIsInformativeExportation
|
||||
FROM vn.dua d
|
||||
LEFT JOIN vn.XDiario x ON x.ASIEN = d.ASIEN
|
||||
AND x.SERIE = vSerialDua COLLATE utf8mb3_unicode_ci
|
||||
WHERE d.ASIEN = (
|
||||
SELECT ASIEN
|
||||
FROM vn.XDiario
|
||||
WHERE id = vXDiarioFk)
|
||||
LIMIT 1;
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN tmp.invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
JOIN vn.XDiario x ON x.id = mci.id
|
||||
LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
|
||||
JOIN vn.supplier s ON s.id = ii.supplierFk
|
||||
JOIN Naciones n ON n.countryFk = s.countryFk
|
||||
SET mci.CodigoDivisa = ii.currencyFk,
|
||||
mci.Año = YEAR(ii.issued),
|
||||
mci.Serie = ii.serial,
|
||||
mci.Factura = ii.id,
|
||||
mci.FechaFactura = ii.issued,
|
||||
mci.ImporteFactura = IFNULL(mci.BaseIva1, 0) + IFNULL(mci.CuotaIva1, 0) +
|
||||
IFNULL(mci.BaseIva2, 0) + IFNULL(mci.CuotaIva2, 0) +
|
||||
IFNULL(mci.BaseIva3, 0) + IFNULL(mci.CuotaIva3, 0) +
|
||||
IFNULL(mci.BaseIva4, 0) + IFNULL(mci.CuotaIva4, 0),
|
||||
mci.TipoFactura = IF(id.id,
|
||||
IF( ii.serial = vSerialDua COLLATE utf8mb3_unicode_ci, vInvoiceTypeReceived, vInvoiceTypeInformative),
|
||||
IF(vIsInformativeExportation,vInvoiceTypeInformative, vInvoiceTypeReceived)),
|
||||
mci.CodigoCuentaFactura = x.SUBCTA,
|
||||
mci.CifDni = IF(LEFT(TRIM(s.nif), 2) = n.SiglaNacion, SUBSTRING(TRIM(s.nif), 3), s.nif),
|
||||
mci.Nombre = s.name,
|
||||
mci.SiglaNacion = n.SiglaNacion,
|
||||
mci.EjercicioFactura = YEAR(ii.issued),
|
||||
mci.FechaOperacion = ii.issued,
|
||||
mci.MantenerAsiento = TRUE,
|
||||
mci.SuFacturaNo = ii.supplierRef,
|
||||
mci.IvaDeducible1 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva1, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.IvaDeducible2 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva2, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.IvaDeducible3 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva3, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.IvaDeducible4 = IF(id.id, FALSE, IF(IFNULL(mci.BaseIva4, FALSE) = FALSE, FALSE, ii.isVatDeductible)),
|
||||
mci.FechaFacturaOriginal = x.FECHA_EX
|
||||
WHERE mci.id = vXDiarioFk;
|
||||
|
||||
-- RETENCIONES
|
||||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceIn ii ON ii.id = vInvoiceInFk
|
||||
JOIN vn.XDiario x ON x.id = mci.id
|
||||
JOIN vn.supplier s ON s.id = supplierFk
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = ii.id
|
||||
JOIN vn.expense e ON e.id = iit.expenseFk
|
||||
JOIN TiposRetencion t ON t.CodigoRetencion = ii.withholdingSageFk
|
||||
LEFT JOIN tmp.invoiceDua id ON id.id = mci.id
|
||||
JOIN (SELECT SUM(x2.BASEEURO) taxableBase, SUM(x2.EURODEBE) taxBase
|
||||
FROM vn.XDiario x1
|
||||
JOIN vn.XDiario x2 ON x1.ASIEN = x2.ASIEN
|
||||
WHERE x2.BASEEURO <> 0
|
||||
AND x1.id = vXDiarioFk
|
||||
)sub
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Arrendamiento de locales de negocio'
|
||||
SET mci.CodigoRetencion = t.CodigoRetencion,
|
||||
mci.ClaveOperacionFactura = IF( t.Retencion = 'ARRENDAMIENTO Y SUBARRENDAMIENTO', co.ClaveOperacionFactura_, mci.ClaveOperacionFactura),
|
||||
mci.BaseRetencion = IF (t.Retencion = 'ACTIVIDADES AGRICOLAS O GANADERAS', sub.taxableBase + sub.taxBase, sub.taxableBase),
|
||||
mci.PorRetencion = t.PorcentajeRetencion,
|
||||
mci.ImporteRetencion = iit.taxableBase * - 1
|
||||
WHERE mci.id = vXDiarioFk
|
||||
AND e.name = 'Retenciones'
|
||||
AND id.id IS NULL;
|
||||
|
||||
SELECT correctedFk INTO vInvoiceInOriginalFk
|
||||
FROM vn.invoiceInCorrection
|
||||
WHERE correctingFk = vInvoiceInFk;
|
||||
|
||||
IF vInvoiceInOriginalFk THEN
|
||||
|
||||
UPDATE movContaIVA mci
|
||||
JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk
|
||||
JOIN (SELECT issued,
|
||||
SUM(sub.taxableBase) taxableBase,
|
||||
SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat
|
||||
FROM(SELECT issued,
|
||||
SUM(iit.taxableBase) taxableBase,
|
||||
ti.PorcentajeIva
|
||||
FROM vn.invoiceIn i
|
||||
JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id
|
||||
JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk
|
||||
WHERE i.id = vInvoiceInOriginalFk
|
||||
GROUP BY ti.CodigoIva)sub
|
||||
)invoiceInOriginal
|
||||
JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa'
|
||||
SET mci.TipoRectificativa = iir.refundCategoryFk,
|
||||
mci.ClaseAbonoRectificativas = iir.refundType,
|
||||
mci.FechaFacturaOriginal = invoiceInOriginal.issued,
|
||||
mci.FechaOperacion = invoiceInOriginal.issued,
|
||||
mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase,
|
||||
mci.CuotaIvaOriginal = invoiceInOriginal.vat,
|
||||
mci.ClaveOperacionFactura = co.ClaveOperacionFactura_
|
||||
WHERE mci.id = vXDiarioFk;
|
||||
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -21,6 +21,8 @@ BEGIN
|
|||
|
||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
||||
|
||||
-- Añadido temporalmente para ver si ya no sucede el cuelgue de db
|
||||
SET vShowType = TRUE;
|
||||
|
||||
WITH itemTags AS (
|
||||
SELECT i.id,
|
||||
|
@ -87,6 +89,7 @@ BEGIN
|
|||
(i.tag7 = its.tag7) DESC,
|
||||
match7 DESC,
|
||||
(i.tag8 = its.tag8) DESC,
|
||||
match8 DESC;
|
||||
match8 DESC
|
||||
LIMIT 100;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -104,7 +104,7 @@ BEGIN
|
|||
price)
|
||||
SELECT vTicketFk,
|
||||
vNewItemFk,
|
||||
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ',i.longName),
|
||||
CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name),
|
||||
vFinalPrice
|
||||
FROM vn.item i
|
||||
WHERE id = vNewItemFk;
|
||||
|
|
|
@ -1,55 +1,10 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketClon`(vTicketFk INT, vNewShipped DATE)
|
||||
BEGIN
|
||||
|
||||
DECLARE done INT DEFAULT FALSE;
|
||||
DECLARE vNewTicketFk INT;
|
||||
DECLARE vOldSaleFk INT;
|
||||
DECLARE vNewSaleFk INT;
|
||||
|
||||
DECLARE cur1 CURSOR FOR
|
||||
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;
|
||||
|
||||
DECLARE vNewTicketFk INT;
|
||||
|
||||
CALL ticket_cloneAll(vTicketFk, vNewShipped, TRUE, vNewTicketFk);
|
||||
|
||||
END$$
|
||||
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`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL entry_checkBooked(OLD.entryFk);
|
||||
IF OLD.printedStickers <> 0 THEN
|
||||
CALL util.throw("it is not possible to delete buys with printed labels ");
|
||||
END IF;
|
||||
|
|
|
@ -15,6 +15,7 @@ trig: BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_checkBooked(NEW.entryFk);
|
||||
IF NEW.printedStickers <> 0 THEN
|
||||
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
||||
END IF;
|
||||
|
|
|
@ -13,6 +13,7 @@ trig:BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_checkBooked(OLD.entryFk);
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT defaultEntry INTO vDefaultEntry
|
||||
|
|
|
@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
|
|||
BEFORE DELETE ON `entry`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
DELETE FROM buy WHERE entryFk = OLD.id;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -6,9 +6,13 @@ BEGIN
|
|||
DECLARE vIsVirtual BOOL;
|
||||
DECLARE vPrintedCount INT;
|
||||
DECLARE vHasDistinctWarehouses BOOL;
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked THEN
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
END IF;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
|
||||
IF NOT (NEW.travelFk <=> OLD.travelFk) THEN
|
||||
|
||||
IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN
|
||||
|
|
|
@ -12,5 +12,5 @@ FROM (
|
|||
`pc`.`id` = `b`.`workerBusinessProfessionalCategoryFk`
|
||||
)
|
||||
)
|
||||
WHERE `pc`.`name` = 'Aux ventas'
|
||||
WHERE `pc`.`description` = 'Aux ventas'
|
||||
GROUP BY `b`.`workerFk`
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`add_awb_component`(IN vAwbFk SMALLINT)
|
||||
BEGIN
|
||||
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vHasStems BOOLEAN;
|
||||
|
||||
SELECT t.shipped, IF(a.stems, TRUE, FALSE)
|
||||
INTO vShipped, vHasStems
|
||||
FROM vn.travel t
|
||||
JOIN vn.awb a ON a.id = t.awbFk
|
||||
WHERE awbFk = vAwbFk
|
||||
LIMIT 1;
|
||||
|
||||
INSERT IGNORE INTO awb_component (awb_id,Id_Proveedor,awb_component_type_id,awb_role_id,awb_unit_id,value,Id_Moneda)
|
||||
SELECT id, Id_Proveedor, awb_component_type_id, awb_role_id,awb_unit_id, LEAST(GREATEST(value1, IFNULL(min_value, value1)), IFNULL(max_value, value1)), Id_Moneda
|
||||
FROM (
|
||||
SELECT a.id,
|
||||
IFNULL(act.carguera_id,
|
||||
CASE awb_role_id
|
||||
WHEN 1 THEN a.carguera_id
|
||||
WHEN 2 THEN a.transitario_id
|
||||
WHEN 3 THEN f.airline_id
|
||||
END
|
||||
) Id_Proveedor,
|
||||
act.awb_component_type_id,
|
||||
act.awb_role_id,
|
||||
act.awb_unit_id,
|
||||
value *
|
||||
CASE awb_unit_id
|
||||
WHEN '1000Tj-20' THEN ((CAST(stems AS SIGNED) - 20000)/1000) + (min_value / value)
|
||||
WHEN '1000Tj-10' THEN ((CAST(stems AS SIGNED) - 10000)/1000) + (min_value / value)
|
||||
WHEN '100GW' THEN peso/100
|
||||
WHEN 'AWB' THEN 1 -- No action
|
||||
WHEN 'FB' THEN hb/2
|
||||
WHEN 'GW' THEN peso
|
||||
WHEN 'TW' THEN GREATEST(peso,volume_weight)
|
||||
WHEN 'PN' THEN LEAST(90, value + a.propertyNumber * 10)
|
||||
END value1,
|
||||
value,
|
||||
act.Id_Moneda,
|
||||
act.min_value,
|
||||
act.max_value
|
||||
FROM awb a
|
||||
JOIN flight f ON f.flight_id = a.flight_id
|
||||
LEFT JOIN awb_component_template act ON
|
||||
((IFNULL(act.carguera_id, a.carguera_id) = a.carguera_id AND awb_role_id = 1)
|
||||
OR (IFNULL(act.carguera_id, a.transitario_id) = a.transitario_id AND awb_role_id = 2)
|
||||
OR (IFNULL(act.airline_id, f.airline_id) = f.airline_id AND awb_role_id = 3)
|
||||
OR (awb_role_id = 4))
|
||||
AND IFNULL(act.airport_out, f.airport_out) = f.airport_out
|
||||
AND IFNULL(act.airport_in, f.airport_in) = f.airport_in
|
||||
AND IFNULL(act.airline_id, f.airline_id) = f.airline_id
|
||||
AND INSTR(IFNULL(act.days, WEEKDAY(vShipped) + 1),WEEKDAY(vShipped) + 1)
|
||||
JOIN awb_component_type acty ON acty.awb_component_type_id = act.awb_component_type_id
|
||||
WHERE a.id = vAwbFk AND Fecha <= vShipped
|
||||
AND (vHasStems = TRUE OR acty.hasStems)
|
||||
ORDER BY Fecha DESC, act.days DESC LIMIT 10000000000000000000
|
||||
) t;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,50 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`agencyModeImbalance`(vStarted DATE, vEnded DATE)
|
||||
BEGIN
|
||||
/**
|
||||
* Devuelve el valor de los precios teorico, practico de las agencias
|
||||
* y si ademas es de mrw lo compara con su fichero previamente procesado
|
||||
*
|
||||
* @param vEktFk Identificador de edi.ekt
|
||||
*/
|
||||
DECLARE vEndedDayEnd DATETIME;
|
||||
|
||||
SET vEndedDayEnd = util.dayEnd(vEnded);
|
||||
|
||||
SELECT t.id ticketFk,t.addressFk,
|
||||
CAST(v.amount AS DECIMAL (10,2)) AS VN,
|
||||
CAST(v.amount - e.shipping_charge AS DECIMAL (10,2)) AS Difer,
|
||||
CAST(mrwPrice AS DECIMAL (10,2)) mrwPrice,
|
||||
CAST(e.shipping_charge - mrwPrice AS DECIMAL (10,2)) mrwDifference,
|
||||
CAST(e.shipping_charge AS DECIMAL (10,2)) AS teorico,
|
||||
CAST(e.extraCharge AS DECIMAL (10,2)) AS extraCharge,
|
||||
t.packages, t.clientFk,
|
||||
t.zoneFk, a.provinceFk, mrwCount
|
||||
FROM vn.ticket t
|
||||
LEFT JOIN
|
||||
(SELECT ticketFk, SUM(amount) amount, fc.shipped
|
||||
FROM vn.sale_freightComponent fc
|
||||
JOIN vn.ticket t ON t.id = fc.ticketFk
|
||||
JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
|
||||
WHERE fc.shipped BETWEEN vStarted AND vEndedDayEnd
|
||||
GROUP BY ticketFk) v ON t.id = v.ticketFk
|
||||
LEFT JOIN (SELECT t.id,
|
||||
SUM(t.zonePrice) shipping_charge,
|
||||
SUM(IFNULL(aex.price,0)) extraCharge
|
||||
FROM vn.ticket t
|
||||
LEFT JOIN vn.expedition e ON e.ticketFk = t.id
|
||||
LEFT JOIN vn.packaging p ON p.id = e.packagingFk
|
||||
JOIN tmp.agencyMode amc ON amc.agencyModeFk = t.agencyModeFk
|
||||
JOIN vn.agencyMode am ON am.id = amc.agencyModeFk
|
||||
LEFT JOIN vn.agencyExtraCharge aex ON p.width+p.depth+p.height BETWEEN aex.sizeMin AND aex.sizeMax AND aex.agencyFk = am.agencyFk
|
||||
WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd
|
||||
GROUP BY t.id
|
||||
) e ON t.id = e.id
|
||||
LEFT JOIN (SELECT ticketFk, SUM(price) mrwPrice, COUNT(*) mrwCount
|
||||
FROM vn.mrw
|
||||
GROUP BY ticketFk) mrw ON mrw.ticketFk = t.id
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN tmp.agencyMode am ON am.agencyModeFk = t.agencyModeFk
|
||||
WHERE t.shipped BETWEEN vStarted AND vEndedDayEnd;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,91 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_absoluto`(IN idART INT, IN wh INT, IN datfecha DATETIME)
|
||||
BEGIN
|
||||
|
||||
DECLARE inv_calculado INT;
|
||||
DECLARE inv INT;
|
||||
DECLARE today DATETIME;
|
||||
DECLARE fecha_inv DATETIME;
|
||||
|
||||
SET today = util.VN_CURDATE();
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE historico_pasado
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT TR.landing Fecha,
|
||||
C.Cantidad Entrada,
|
||||
NULL Salida,
|
||||
(TR.received != FALSE) OK,
|
||||
P.Proveedor Alias,
|
||||
E.Referencia Referencia,
|
||||
E.Id_Entrada id,
|
||||
TR.delivered F5
|
||||
FROM Compres C -- mirar perque no entra en received
|
||||
INNER JOIN Entradas E USING (Id_Entrada)
|
||||
INNER JOIN travel TR ON TR.id = E.travel_id
|
||||
INNER JOIN Proveedores P USING (Id_Proveedor)
|
||||
WHERE TR.landing >= '2001-01-01'
|
||||
AND Id_proveedor <> 4
|
||||
AND wh IN (TR.warehouse_id , 0)
|
||||
AND C.Id_Article = idART
|
||||
AND E.Inventario = 0
|
||||
AND E.Redada = 0
|
||||
UNION ALL
|
||||
SELECT TR.shipment Fecha,
|
||||
NULL Entrada,
|
||||
C.Cantidad Salida,
|
||||
TR.delivered OK,
|
||||
P.Proveedor Alias,
|
||||
E.Referencia Referencia,
|
||||
E.Id_Entrada id,
|
||||
TR.delivered F5
|
||||
FROM Compres C
|
||||
INNER JOIN Entradas E USING (Id_Entrada)
|
||||
INNER JOIN travel TR ON TR.id = E.travel_id
|
||||
INNER JOIN Proveedores P USING (Id_Proveedor)
|
||||
WHERE TR.shipment >= '2001-01-01'
|
||||
AND wh = TR.warehouse_id_out
|
||||
AND Id_Proveedor <> 4
|
||||
AND C.Id_Article = idART
|
||||
AND E.Inventario = 0
|
||||
AND E.Redada = 0
|
||||
UNION ALL
|
||||
SELECT T.Fecha Fecha,
|
||||
NULL Entrada,
|
||||
M.Cantidad Salida,
|
||||
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK,
|
||||
T.Alias Alias,
|
||||
T.Factura Referencia,
|
||||
T.Id_Ticket,
|
||||
T.PedidoImpreso
|
||||
FROM Movimientos M
|
||||
INNER JOIN Tickets T USING (Id_Ticket)
|
||||
JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente
|
||||
WHERE T.Fecha >= '2001-01-01'
|
||||
AND M.Id_Article = idART
|
||||
AND wh IN (T.warehouse_id , 0)
|
||||
) t1
|
||||
ORDER BY Fecha, Entrada DESC, OK DESC;
|
||||
|
||||
SELECT sum(Entrada) - sum(Salida) INTO inv_calculado
|
||||
FROM historico_pasado
|
||||
WHERE Fecha < datfecha;
|
||||
|
||||
SELECT p1.*, NULL v_virtual
|
||||
FROM(
|
||||
SELECT datfecha Fecha,
|
||||
inv_calculado Entrada,
|
||||
NULL Salida,
|
||||
1 OK,
|
||||
'Inventario calculado' Alias,
|
||||
'' Referencia, 0 id,
|
||||
1 F5
|
||||
UNION ALL
|
||||
SELECT *
|
||||
FROM historico_pasado
|
||||
WHERE Fecha >= datfecha
|
||||
) p1;
|
||||
|
||||
DROP TEMPORARY TABLE historico_pasado;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,206 +0,0 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`historico_multiple`(IN vItemFk INT)
|
||||
BEGIN
|
||||
|
||||
DECLARE vDateInventory DATETIME;
|
||||
|
||||
SELECT Fechainventario INTO vDateInventory FROM tblContadores;
|
||||
|
||||
SET @a = 0;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS hm1;
|
||||
|
||||
CREATE TEMPORARY TABLE hm1
|
||||
SELECT DATE(Fecha) as Fecha,
|
||||
Entrada,
|
||||
Salida,
|
||||
OK,
|
||||
Referencia,
|
||||
Historia.id,
|
||||
|
||||
wh,
|
||||
|
||||
`name` as wh_name
|
||||
|
||||
FROM
|
||||
|
||||
( SELECT TR.landing as Fecha,
|
||||
C.Cantidad as Entrada,
|
||||
NULL as Salida,
|
||||
|
||||
IF(warehouse_id = 44, 1, warehouse_id) as wh,
|
||||
(TR.received != FALSE) as OK,
|
||||
E.Referencia as Referencia,
|
||||
E.Id_Entrada as id
|
||||
|
||||
|
||||
|
||||
FROM Compres C
|
||||
INNER JOIN Entradas E USING (Id_Entrada)
|
||||
INNER JOIN travel TR ON TR.id = E.travel_id
|
||||
WHERE TR.landing >= vDateInventory
|
||||
AND C.Id_Article = vItemFk
|
||||
AND E.Redada = 0
|
||||
|
||||
AND C.Cantidad <> 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT TR.shipment as Fecha,
|
||||
NULL as Entrada,
|
||||
C.Cantidad as Salida,
|
||||
warehouse_id_out as wh,
|
||||
TR.delivered as OK,
|
||||
E.Referencia as Referencia,
|
||||
E.Id_Entrada as id
|
||||
|
||||
FROM Compres C
|
||||
INNER JOIN Entradas E USING (Id_Entrada)
|
||||
INNER JOIN travel TR ON TR.id = E.travel_id
|
||||
WHERE TR.shipment >= vDateInventory
|
||||
AND C.Id_Article = vItemFk
|
||||
|
||||
AND E.Redada = 0
|
||||
|
||||
AND C.Cantidad <> 0
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT T.Fecha as Fecha,
|
||||
NULL as Entrada,
|
||||
M.Cantidad as Salida,
|
||||
warehouse_id as wh,
|
||||
(M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK,
|
||||
T.Factura as Referencia,
|
||||
T.Id_Ticket as id
|
||||
|
||||
FROM Movimientos M
|
||||
INNER JOIN Tickets T USING (Id_Ticket)
|
||||
WHERE T.Fecha >= vDateInventory
|
||||
AND M.Id_Article = vItemFk
|
||||
|
||||
) AS Historia
|
||||
|
||||
INNER JOIN warehouse ON warehouse.id = Historia.wh
|
||||
ORDER BY Fecha, Entrada DESC, OK DESC;
|
||||
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS hm2;
|
||||
DROP TEMPORARY TABLE IF EXISTS hm3;
|
||||
DROP TEMPORARY TABLE IF EXISTS hm4;
|
||||
DROP TEMPORARY TABLE IF EXISTS hm5;
|
||||
DROP TEMPORARY TABLE IF EXISTS hm6;
|
||||
DROP TEMPORARY TABLE IF EXISTS hm7;
|
||||
DROP TEMPORARY TABLE IF EXISTS hm8;
|
||||
CREATE TEMPORARY TABLE hm2 SELECT * FROM hm1 WHERE wh = 19;
|
||||
CREATE TEMPORARY TABLE hm3 SELECT * FROM hm1 WHERE wh = 7;
|
||||
CREATE TEMPORARY TABLE hm4 SELECT * FROM hm1 WHERE wh = 60;
|
||||
CREATE TEMPORARY TABLE hm5 SELECT * FROM hm1 WHERE wh = 5;
|
||||
CREATE TEMPORARY TABLE hm6 SELECT * FROM hm1 WHERE wh = 17;
|
||||
CREATE TEMPORARY TABLE hm7 SELECT * FROM hm1 WHERE wh = 37;
|
||||
CREATE TEMPORARY TABLE hm8 SELECT * FROM hm1 WHERE wh = 55;
|
||||
|
||||
SELECT * FROM
|
||||
|
||||
(
|
||||
|
||||
SELECT Fecha, Entrada as BOGEntrada, Salida as BOGSalida, OK as BOGOK, Referencia as BOGReferencia, id as BOGid,
|
||||
|
||||
NULL AS VNHEntrada, NULL AS VNHSalida, NULL AS VNHOK, NULL AS VNHReferencia, NULL AS VNHid,
|
||||
|
||||
NULL AS ALGEntrada, NULL AS ALGSalida, NULL AS ALGOK, NULL AS ALGReferencia, NULL AS ALGid,
|
||||
|
||||
NULL AS MADEntrada, NULL AS MADSalida, NULL AS MADOK, NULL AS MADReferencia, NULL AS MADid,
|
||||
|
||||
NULL AS MCFEntrada, NULL AS MCFSalida, NULL AS MCFOK, NULL AS MCFReferencia, NULL AS MCFid,
|
||||
|
||||
NULL AS VILEntrada, NULL AS VILSalida, NULL AS VILOK, NULL AS VILReferencia, NULL AS VILid,
|
||||
|
||||
NULL AS BAREntrada, NULL AS BARSalida, NULL AS BAROK, NULL AS BARReferencia, NULL AS BARid
|
||||
|
||||
FROM hm2
|
||||
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Fecha
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
,Entrada, Salida, OK, Referencia, 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 hm3
|
||||
|
||||
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Fecha
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, Entrada, Salida, OK, Referencia, id
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
FROM hm4
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Fecha
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, Entrada, Salida, OK, Referencia, id
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
FROM hm5
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Fecha
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, Entrada, Salida, OK, Referencia, id
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
FROM hm6
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Fecha
|
||||
, 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
|
||||
, Entrada, Salida, OK, Referencia, id
|
||||
, NULL, NULL, NULL, NULL, NULL
|
||||
|
||||
|
||||
FROM hm7
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT Fecha
|
||||
, 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
|
||||
, Entrada, Salida, OK, Referencia, id
|
||||
|
||||
FROM hm8
|
||||
|
||||
) sub
|
||||
|
||||
ORDER BY Fecha, BOGEntrada IS NULL, VNHEntrada IS NULL, ALGEntrada IS NULL, MADEntrada IS NULL, MCFEntrada IS NULL, VILEntrada IS NULL, BAREntrada IS NULL;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -5,7 +5,6 @@ AS SELECT `c`.`id` AS `id`,
|
|||
`c`.`code` AS `abbreviation`,
|
||||
`c`.`supplierAccountFk` AS `Id_Proveedores_account`,
|
||||
`c`.`workerManagerFk` AS `gerente_id`,
|
||||
`c`.`sage200Company` AS `digito_factura`,
|
||||
`c`.`phytosanitary` AS `phytosanitary`,
|
||||
`c`.`companyCode` AS `CodigoEmpresa`,
|
||||
`c`.`companyGroupFk` AS `empresa_grupo`,
|
||||
|
|
|
@ -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,22 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`multipleInventoryHistory`(
|
||||
vItemFk INT)
|
||||
BEGIN
|
||||
DECLARE vDateInventory DATETIME;
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`absoluteInventoryHistory`(
|
||||
vItemFk INT, vWarehouse INT, vDate DATETIME)
|
||||
BEGIN
|
||||
DECLARE vCalculatedInventory INT;
|
||||
SET vCalculatedInventory = 0;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
||||
GRANT EXECUTE ON PROCEDURE vn.absoluteInventoryHistory TO buyer;
|
||||
GRANT EXECUTE ON PROCEDURE vn.multipleInventoryHistory TO buyer;
|
|
@ -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 @@
|
|||
ALTER TABLE util.debug MODIFY COLUMN value text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
|
@ -0,0 +1,7 @@
|
|||
-- Place your SQL code here
|
||||
USE vn;
|
||||
|
||||
INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId)
|
||||
VALUES
|
||||
('ExpeditionPallet', '*', 'READ', 'ALLOW', 'ROLE', 'production'),
|
||||
('Ticket', 'addSaleByCode', 'WRITE', 'ALLOW', 'ROLE', 'production');
|
|
@ -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;
|
|
@ -24,7 +24,7 @@ describe('Ticket descriptor path', () => {
|
|||
|
||||
it('should go back to the ticket index then search and access a ticket summary', async() => {
|
||||
await page.accessToSection('ticket.index');
|
||||
await page.accessToSearchResult('11');
|
||||
await page.accessToSearchResult('33');
|
||||
});
|
||||
|
||||
it('should add the ticket to thursday turn using the descriptor more menu', async() => {
|
||||
|
@ -33,7 +33,7 @@ describe('Ticket descriptor path', () => {
|
|||
await page.waitToClick(selectors.ticketDescriptor.thursdayButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
expect(message.text).toContain('Current ticket deleted and added to shift');
|
||||
});
|
||||
|
||||
it('should again click on the Tickets button of the top bar menu', async() => {
|
||||
|
@ -43,7 +43,7 @@ describe('Ticket descriptor path', () => {
|
|||
await page.waitForState('ticket.index');
|
||||
});
|
||||
|
||||
it('should confirm the ticket 11 was added to thursday', async() => {
|
||||
it('should confirm the ticket 33 was added to thursday', async() => {
|
||||
await page.accessToSection('ticket.weekly.index');
|
||||
const result = await page.waitToGetProperty(selectors.ticketsIndex.thirdWeeklyTicket, 'value');
|
||||
|
||||
|
@ -57,8 +57,8 @@ describe('Ticket descriptor path', () => {
|
|||
await page.waitForState('ticket.index');
|
||||
});
|
||||
|
||||
it('should now search for the ticket 11', async() => {
|
||||
await page.accessToSearchResult('11');
|
||||
it('should now search for the ticket 33', async() => {
|
||||
await page.accessToSearchResult('33');
|
||||
await page.waitForState('ticket.card.summary');
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe('Ticket descriptor path', () => {
|
|||
await page.waitToClick(selectors.ticketDescriptor.saturdayButton);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
expect(message.text).toContain('Data saved!');
|
||||
expect(message.text).toContain('Current ticket deleted and added to shift');
|
||||
});
|
||||
|
||||
it('should click on the Tickets button of the top bar menu once again', async() => {
|
||||
|
@ -78,7 +78,7 @@ describe('Ticket descriptor path', () => {
|
|||
await page.waitForState('ticket.index');
|
||||
});
|
||||
|
||||
it('should confirm the ticket 11 was added on saturday', async() => {
|
||||
it('should confirm the ticket 33 was added on saturday', async() => {
|
||||
await page.accessToSection('ticket.weekly.index');
|
||||
await page.waitForTimeout(5000);
|
||||
|
||||
|
@ -87,14 +87,14 @@ describe('Ticket descriptor path', () => {
|
|||
expect(result).toEqual('Saturday');
|
||||
});
|
||||
|
||||
it('should now search for the weekly ticket 11', async() => {
|
||||
await page.doSearch('11');
|
||||
it('should now search for the weekly ticket 33', async() => {
|
||||
await page.doSearch('33');
|
||||
const nResults = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
|
||||
|
||||
expect(nResults).toEqual(2);
|
||||
});
|
||||
|
||||
it('should delete the weekly ticket 11', async() => {
|
||||
it('should delete the weekly ticket 33', async() => {
|
||||
await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon);
|
||||
await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn);
|
||||
const message = await page.waitForSnackbar();
|
||||
|
|
|
@ -22,12 +22,4 @@ describe('Account Connections path', () => {
|
|||
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -347,6 +347,7 @@
|
|||
"Cmr file does not exist": "El archivo del cmr no existe",
|
||||
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
|
||||
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
|
||||
"The line could not be marked": "La linea no puede ser marcada",
|
||||
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
|
||||
"They're not your subordinate": "No es tu subordinado/a.",
|
||||
"Phone not valid": "Teléfono no es válido",
|
||||
|
|
|
@ -2,7 +2,7 @@ const {models} = require('vn-loopback/server/server');
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
// #6276
|
||||
xdescribe('ItemShelving upsertItem()', () => {
|
||||
describe('ItemShelving upsertItem()', () => {
|
||||
const warehouseFk = 1;
|
||||
let ctx;
|
||||
let options;
|
||||
|
@ -30,7 +30,7 @@ xdescribe('ItemShelving upsertItem()', () => {
|
|||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should add two new records', async() => {
|
||||
xit('should add two new records', async() => {
|
||||
const shelvingFk = 'ZPP';
|
||||
const items = [1, 1, 1, 2];
|
||||
|
||||
|
@ -40,7 +40,7 @@ xdescribe('ItemShelving upsertItem()', () => {
|
|||
expect(itemShelvings.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('should update the visible items', async() => {
|
||||
xit('should update the visible items', async() => {
|
||||
const shelvingFk = 'GVC';
|
||||
const items = [2, 2];
|
||||
const {visible: itemsBefore} = await models.ItemShelving.findOne({
|
|
@ -89,16 +89,10 @@ module.exports = Self => {
|
|||
const {itemOriginalFk} = await models.Buy.findById(buyFk, {fields: ['itemOriginalFk']}, myOptions);
|
||||
if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions);
|
||||
} catch (e) {
|
||||
throw new UserError('The sale cannot be tracked');
|
||||
if (tx) await tx.commit();
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (e.message == 'The sale cannot be tracked') {
|
||||
if (tx) tx.commit();
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (tx) await tx.rollback();
|
||||
throw new UserError('The line could not be marked');
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ describe('saleTracking setPicked()', () => {
|
|||
} catch (e) {
|
||||
const error = e;
|
||||
|
||||
expect(error.message).toEqual('The sale cannot be tracked');
|
||||
expect(error.message).toEqual('The line could not be marked');
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -58,6 +58,11 @@ module.exports = Self => {
|
|||
AND t.refFk IS NULL
|
||||
GROUP BY t.id
|
||||
`, [toDate, toDate]);
|
||||
const ticketIds = tickets.map(ticket => ticket.id);
|
||||
await Self.rawSql(`
|
||||
INSERT INTO util.debug (variable, value)
|
||||
VALUES ('nightInvoicing', ?)
|
||||
`, [ticketIds.join(',')]);
|
||||
|
||||
await closure(ctx, Self, tickets);
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ module.exports = async function(ctx, Self, tickets, reqArgs = {}) {
|
|||
const failedtickets = [];
|
||||
for (const ticket of tickets) {
|
||||
try {
|
||||
await Self.rawSql(`CALL util.debugAdd('invoicingTicket', ?)`, [ticket.id], {userId});
|
||||
|
||||
await Self.app.models.InvoiceOut.getSerial(ticket.clientFk, ticket.companyFk, ticket.addressFk, 'M');
|
||||
await Self.rawSql(
|
||||
`CALL vn.ticket_closeByTicket(?)`,
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -68,7 +68,7 @@ describe('ticket filter()', () => {
|
|||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
expect(result.length).toEqual(6);
|
||||
expect(result.length).toEqual(7);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -46,4 +46,6 @@ module.exports = function(Self) {
|
|||
require('../methods/ticket/invoiceTicketsAndPdf')(Self);
|
||||
require('../methods/ticket/docuwareDownload')(Self);
|
||||
require('../methods/ticket/myLastModified')(Self);
|
||||
require('../methods/ticket/addSaleByCode')(Self);
|
||||
require('../methods/ticket/clone')(Self);
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
module.exports = Self => {
|
||||
require('../methods/ticket-weekly/filter')(Self);
|
||||
|
@ -8,4 +9,11 @@ module.exports = Self => {
|
|||
return new UserError(`This ticket is already on weekly tickets`);
|
||||
return err;
|
||||
});
|
||||
|
||||
Self.observe('after save', async ctx => {
|
||||
const loopBackContext = LoopBackContext.getCurrentContext();
|
||||
const httpCtx = {req: loopBackContext.active};
|
||||
const httpRequest = httpCtx.req.http;
|
||||
await Self.app.models.Ticket.setDeleted(httpRequest, ctx.instance.ticketFk, ctx.options);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
module.exports = Self => {
|
||||
require('./ticket-methods')(Self);
|
||||
require('../methods/ticket/state')(Self);
|
||||
require('../methods/ticket/addSaleByCode')(Self);
|
||||
};
|
||||
|
|
|
@ -147,7 +147,8 @@ class Controller extends Section {
|
|||
return this.$http.patch(`TicketWeeklies`, params)
|
||||
.then(() => {
|
||||
this.$.addTurn.hide();
|
||||
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||
this.vnApp.showSuccess(this.$t('Current ticket deleted and added to shift'));
|
||||
this.reload();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => {
|
|||
}));
|
||||
|
||||
describe('addTurn()', () => {
|
||||
pending('refs #6302');
|
||||
it('should make a query and call $.addTurn.hide() and vnApp.showSuccess()', () => {
|
||||
controller.$.addTurn = {hide: () => {}};
|
||||
jest.spyOn(controller.$.addTurn, 'hide');
|
||||
|
|
|
@ -28,3 +28,4 @@ Create a single ticket with all the content of the current ticket: Crea un ticke
|
|||
Set ticket weight: Establecer peso al ticket
|
||||
Ticket weight: Peso del ticket
|
||||
This address has incoterms, you should set the weight before invoice it: Este consigatario tiene incoterms, deberías establecer el peso antes de facturar
|
||||
Current ticket deleted and added to shift: Ticket actual borrado y añadido a turno
|
|
@ -56,7 +56,7 @@
|
|||
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
|
||||
"@babel/preset-env": "^7.11.0",
|
||||
"@babel/register": "^7.7.7",
|
||||
"@verdnatura/myt": "^1.6.8",
|
||||
"@verdnatura/myt": "^1.6.9",
|
||||
"angular-mocks": "^1.7.9",
|
||||
"babel-jest": "^26.0.1",
|
||||
"babel-loader": "^8.2.4",
|
||||
|
|
|
@ -131,8 +131,8 @@ devDependencies:
|
|||
specifier: ^7.7.7
|
||||
version: 7.23.7(@babel/core@7.23.9)
|
||||
'@verdnatura/myt':
|
||||
specifier: ^1.6.8
|
||||
version: 1.6.8
|
||||
specifier: ^1.6.9
|
||||
version: 1.6.9
|
||||
angular-mocks:
|
||||
specifier: ^1.7.9
|
||||
version: 1.8.3
|
||||
|
@ -2633,8 +2633,8 @@ packages:
|
|||
dev: false
|
||||
optional: true
|
||||
|
||||
/@verdnatura/myt@1.6.8:
|
||||
resolution: {integrity: sha512-jpadr6yAR9TQXPv+has5yOYAolR/YEzsxbLgMR7BoDrpLyVFLHJEy4Dfe+Hy11r3AmxCB/8lWM+La1YGvXMWOA==}
|
||||
/@verdnatura/myt@1.6.9:
|
||||
resolution: {integrity: sha512-29IauYra9igfdPWwV4+pVV/tBXvIg0fkVHEpSz8Zz3G3lRtzm286FN2Kv6hZkxmD/F1n52O37jN9WLiLHDTW1Q==}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@sqltools/formatter': 1.2.5
|
||||
|
@ -4886,6 +4886,7 @@ packages:
|
|||
/deep-extend@0.6.0:
|
||||
resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
requiresBuild: true
|
||||
|
||||
/deep-is@0.1.4:
|
||||
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
|
||||
|
@ -12714,6 +12715,7 @@ packages:
|
|||
/strip-json-comments@2.0.1:
|
||||
resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
requiresBuild: true
|
||||
|
||||
/strip-json-comments@3.1.1:
|
||||
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
|
||||
|
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 973 KiB After Width: | Height: | Size: 973 KiB |
Before Width: | Height: | Size: 1.6 MiB After Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 920 KiB After Width: | Height: | Size: 920 KiB |
Before Width: | Height: | Size: 776 KiB After Width: | Height: | Size: 776 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 234 KiB |
Before Width: | Height: | Size: 181 KiB After Width: | Height: | Size: 181 KiB |
Before Width: | Height: | Size: 306 KiB After Width: | Height: | Size: 306 KiB |
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 172 KiB |
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 288 KiB |
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 248 KiB |
Before Width: | Height: | Size: 371 KiB After Width: | Height: | Size: 371 KiB |
Before Width: | Height: | Size: 231 KiB After Width: | Height: | Size: 231 KiB |
Before Width: | Height: | Size: 298 KiB After Width: | Height: | Size: 298 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 159 KiB |
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 124 KiB |
Before Width: | Height: | Size: 219 KiB After Width: | Height: | Size: 219 KiB |
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |