WIP: #5770 - Sync Groups Samba #1946
|
@ -0,0 +1,24 @@
|
||||||
|
const fs = require('fs');
|
||||||
|
const {spawn} = require('child_process');
|
||||||
|
|
||||||
|
function watchDatabaseChanges() {
|
||||||
|
console.log('Watching for changes in db/routines and db/versions');
|
||||||
|
fs.watch('db', {recursive: true}, (eventType, filename) => {
|
||||||
|
if (filename.endsWith('.sql')) {
|
||||||
|
let command;
|
||||||
|
if (filename.startsWith('routines')) command = 'push';
|
||||||
|
else if (filename.startsWith('versions')) command = 'run';
|
||||||
|
|
||||||
|
if (command) {
|
||||||
|
const process = spawn('myt', [command]);
|
||||||
|
process.stdout.on('data', data => console.log(data.toString()));
|
||||||
|
process.stderr.on('data', data => console.error(`stderr: ${data}`));
|
||||||
|
process.on('error', error => console.error(`error: ${error.message}`));
|
||||||
|
process.on('close', () => console.log('Watching for changes in db/routines and db/versions'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (require.main === module) watchDatabaseChanges();
|
||||||
|
module.exports = watchDatabaseChanges;
|
|
@ -2562,7 +2562,7 @@ REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issu
|
||||||
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1),
|
(9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1),
|
||||||
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1);
|
(10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1);
|
||||||
|
|
||||||
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`)
|
INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageFarmerWithholdingFk`, `daysAgo`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, -2, '2% retention', 2, 45);
|
(1, -2, '2% retention', 2, 45);
|
||||||
|
|
||||||
|
|
|
@ -31,50 +31,43 @@ BEGIN
|
||||||
INTO vManaFromDays, vManaToDays
|
INTO vManaFromDays, vManaToDays
|
||||||
FROM vn.salespersonConfig;
|
FROM vn.salespersonConfig;
|
||||||
|
|
||||||
SELECT MAX(dated)
|
SELECT MAX(dated) INTO vFromDated
|
||||||
INTO vFromDated
|
|
||||||
FROM vn.clientManaCache;
|
FROM vn.clientManaCache;
|
||||||
|
|
||||||
DELETE
|
DELETE FROM vn.clientManaCache
|
||||||
FROM vn.clientManaCache
|
|
||||||
WHERE dated = vFromDated;
|
WHERE dated = vFromDated;
|
||||||
|
|
||||||
SELECT MAX(dated)
|
SELECT MAX(dated) INTO vFromDated
|
||||||
INTO vFromDated
|
|
||||||
FROM vn.clientManaCache;
|
FROM vn.clientManaCache;
|
||||||
|
|
||||||
IF ISNULL(vFromDated) THEN
|
IF vFromDated IS NULL THEN
|
||||||
SELECT manaDateFrom
|
SELECT manaDateFrom
|
||||||
INTO vFromDated
|
INTO vFromDated
|
||||||
FROM vn.salespersonConfig;
|
FROM vn.salespersonConfig;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
||||||
SELECT
|
SELECT vFromDated + INTERVAL vManaToDays DAY,
|
||||||
vFromDated + INTERVAL vManaToDays DAY,
|
|
||||||
vFromDated - INTERVAL vManaFromDays DAY
|
vFromDated - INTERVAL vManaFromDays DAY
|
||||||
INTO
|
INTO vToDated,
|
||||||
vToDated,
|
|
||||||
vForDeleteDated;
|
vForDeleteDated;
|
||||||
|
|
||||||
DELETE FROM vn.clientManaCache
|
DELETE FROM vn.clientManaCache
|
||||||
WHERE dated <= vForDeleteDated;
|
WHERE dated <= vForDeleteDated;
|
||||||
|
|
||||||
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
||||||
SELECT
|
SELECT Id_Cliente,
|
||||||
Id_Cliente,
|
|
||||||
SUM(mana),
|
SUM(mana),
|
||||||
vToDated
|
vToDated
|
||||||
FROM
|
FROM (
|
||||||
(
|
SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
|
||||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana
|
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN vn.address a ON a.id = t.addressFk
|
JOIN vn.address a ON a.id = t.addressFk
|
||||||
JOIN vn.sale s on s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN vn.saleComponent sc on sc.saleFk = s.id
|
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||||
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
||||||
AND t.shipped > vFromDated
|
AND t.shipped > vFromDated
|
||||||
AND date(t.shipped) <= vToDated
|
AND DATE(t.shipped) <= vToDated
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT clientFk, - amountPaid
|
SELECT clientFk, - amountPaid
|
||||||
FROM vn.receipt
|
FROM vn.receipt
|
||||||
|
|
|
@ -53,7 +53,7 @@ BEGIN
|
||||||
IFNULL(c.street, ''),
|
IFNULL(c.street, ''),
|
||||||
c.accountingAccount,
|
c.accountingAccount,
|
||||||
@fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)),
|
@fi := IF(cu.code = LEFT(TRIM(c.fi), 2) AND c.isVies, MID(TRIM(c.fi), 3, LENGTH(TRIM(c.fi))-1), TRIM(c.fi)),
|
||||||
IF(c.isVies, CONCAT(cu.code, @fi ), TRIM(c.fi)),
|
IF(c.isVies, CONCAT(IFNULL(cu.viesCode,cu.code), @fi ), TRIM(c.fi)),
|
||||||
IFNULL(c.postcode, ''),
|
IFNULL(c.postcode, ''),
|
||||||
IFNULL(c.city, ''),
|
IFNULL(c.city, ''),
|
||||||
IFNULL(pr.CodigoProvincia, ''),
|
IFNULL(pr.CodigoProvincia, ''),
|
||||||
|
@ -91,7 +91,7 @@ BEGIN
|
||||||
IFNULL(s.street, ''),
|
IFNULL(s.street, ''),
|
||||||
s.account,
|
s.account,
|
||||||
@nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)),
|
@nif := IF(co.code = LEFT(TRIM(s.nif), 2), MID(TRIM(s.nif), 3, LENGTH(TRIM(s.nif))-1), TRIM(s.nif)),
|
||||||
IF(s.isVies, CONCAT(co.code, @nif), TRIM(s.nif)),
|
IF(s.isVies, CONCAT(IFNULL(co.viesCode,co.code), @nif), TRIM(s.nif)),
|
||||||
IFNULL(s.postCode,''),
|
IFNULL(s.postCode,''),
|
||||||
IFNULL(s.city, ''),
|
IFNULL(s.city, ''),
|
||||||
IFNULL(pr.CodigoProvincia, ''),
|
IFNULL(pr.CodigoProvincia, ''),
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`(
|
||||||
IN vStartingMonth INT,
|
vStartingMonth INT,
|
||||||
IN vEndingMonth INT,
|
vEndingMonth INT,
|
||||||
IN vCompany INT,
|
vCompany INT,
|
||||||
IN vIsConsolidated BOOLEAN,
|
vIsConsolidated BOOLEAN,
|
||||||
IN vInterGroupSalesIncluded BOOLEAN)
|
vInterGroupSalesIncluded BOOLEAN
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Crea un balance financiero para una empresa durante
|
* Crea un balance financiero para una empresa durante
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByBuy`(IN vBuyFk INT(11))
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByBuy`(
|
||||||
|
vBuyFk INT(11)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Recalcula los precios de una compra
|
* Recalcula los precios de una compra
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByEntry`(IN vEntryFk INT(11))
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_recalcPricesByEntry`(
|
||||||
|
vEntryFk INT(11)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Recalcula los precios de una entrada
|
* Recalcula los precios de una entrada
|
||||||
|
|
|
@ -192,7 +192,8 @@ BEGIN
|
||||||
AND cr.companyFk = vp.companyFk
|
AND cr.companyFk = vp.companyFk
|
||||||
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
||||||
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
|
LEFT JOIN bankEntity be ON be.id = sa.bankEntityFk
|
||||||
LEFT JOIN country co ON co.id = be.countryFk;
|
LEFT JOIN country co ON co.id = be.countryFk
|
||||||
|
GROUP BY vp.id;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tOpeningBalances;
|
DROP TEMPORARY TABLE tOpeningBalances;
|
||||||
DROP TEMPORARY TABLE tPendingDuedates;
|
DROP TEMPORARY TABLE tPendingDuedates;
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
DELIMITER $$
|
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`(
|
|
||||||
vItemFk INT,
|
|
||||||
vWarehouseFk INT,
|
|
||||||
vQuantity INT,
|
|
||||||
vIsTrash BOOLEAN)
|
|
||||||
BEGIN
|
|
||||||
DECLARE vTicketFk INT;
|
|
||||||
DECLARE vClientFk INT;
|
|
||||||
DECLARE vCompanyVnlFk INT DEFAULT 442;
|
|
||||||
DECLARE vCalc INT;
|
|
||||||
|
|
||||||
SELECT barcodeToItem(vItemFk) INTO vItemFk;
|
|
||||||
|
|
||||||
SELECT IF(vIsTrash, 200, 400) INTO vClientFk;
|
|
||||||
|
|
||||||
SELECT t.id INTO vTicketFk
|
|
||||||
FROM ticket t
|
|
||||||
JOIN address a ON a.id=t.addressFk
|
|
||||||
WHERE t.warehouseFk = vWarehouseFk
|
|
||||||
AND t.clientFk = vClientFk
|
|
||||||
AND DATE(t.shipped) = util.VN_CURDATE()
|
|
||||||
AND a.isDefaultAddress
|
|
||||||
LIMIT 1;
|
|
||||||
|
|
||||||
CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk);
|
|
||||||
|
|
||||||
IF vTicketFk IS NULL THEN
|
|
||||||
CALL ticket_add(
|
|
||||||
vClientFk,
|
|
||||||
util.VN_CURDATE(),
|
|
||||||
vWarehouseFk,
|
|
||||||
vCompanyVnlFk,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
util.VN_CURDATE(),
|
|
||||||
account.myUser_getId(),
|
|
||||||
FALSE,
|
|
||||||
vTicketFk);
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
INSERT INTO sale(ticketFk, itemFk, concept, quantity)
|
|
||||||
SELECT vTicketFk,
|
|
||||||
vItemFk,
|
|
||||||
CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)),
|
|
||||||
vQuantity
|
|
||||||
FROM item
|
|
||||||
WHERE id = vItemFk;
|
|
||||||
|
|
||||||
UPDATE cache.visible
|
|
||||||
SET visible = visible - vQuantity
|
|
||||||
WHERE calc_id = vCalc
|
|
||||||
AND item_id = vItemFk;
|
|
||||||
END$$
|
|
||||||
DELIMITER ;
|
|
|
@ -21,9 +21,6 @@ BEGIN
|
||||||
|
|
||||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
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 (
|
WITH itemTags AS (
|
||||||
SELECT i.id,
|
SELECT i.id,
|
||||||
typeFk,
|
typeFk,
|
||||||
|
@ -82,7 +79,7 @@ BEGIN
|
||||||
AND iss.warehouseFk = vWarehouseFk
|
AND iss.warehouseFk = vWarehouseFk
|
||||||
JOIN itemTags its
|
JOIN itemTags its
|
||||||
WHERE a.available > 0
|
WHERE a.available > 0
|
||||||
AND IF(vShowType, i.typeFk = its.typeFk, TRUE)
|
AND (i.typeFk = its.typeFk OR NOT vShowType)
|
||||||
AND i.id <> vSelf
|
AND i.id <> vSelf
|
||||||
ORDER BY `counter` DESC,
|
ORDER BY `counter` DESC,
|
||||||
(t.name = its.name) DESC,
|
(t.name = its.name) DESC,
|
||||||
|
|
|
@ -34,7 +34,7 @@ BEGIN
|
||||||
ticketFk INT(11),
|
ticketFk INT(11),
|
||||||
saleFk INT(11),
|
saleFk INT(11),
|
||||||
isFreezed INTEGER(1) DEFAULT 0,
|
isFreezed INTEGER(1) DEFAULT 0,
|
||||||
risk DECIMAL(10,2) DEFAULT 0,
|
risk DECIMAL(10,1) DEFAULT 0,
|
||||||
hasHighRisk TINYINT(1) DEFAULT 0,
|
hasHighRisk TINYINT(1) DEFAULT 0,
|
||||||
hasTicketRequest INTEGER(1) DEFAULT 0,
|
hasTicketRequest INTEGER(1) DEFAULT 0,
|
||||||
itemShortage VARCHAR(255),
|
itemShortage VARCHAR(255),
|
||||||
|
|
|
@ -7,7 +7,7 @@ BEGIN
|
||||||
*
|
*
|
||||||
* @param vSelf El id del ticket
|
* @param vSelf El id del ticket
|
||||||
*/
|
*/
|
||||||
DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT;
|
DECLARE vCmrFk INT;
|
||||||
SELECT cmrFk INTO vCmrFk
|
SELECT cmrFk INTO vCmrFk
|
||||||
FROM ticket
|
FROM ticket
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
|
@ -44,8 +44,6 @@ BEGIN
|
||||||
AND t.id = vSelf
|
AND t.id = vSelf
|
||||||
GROUP BY t.id;
|
GROUP BY t.id;
|
||||||
|
|
||||||
START TRANSACTION;
|
|
||||||
|
|
||||||
IF vCmrFk THEN
|
IF vCmrFk THEN
|
||||||
UPDATE cmr c
|
UPDATE cmr c
|
||||||
JOIN tTicket t
|
JOIN tTicket t
|
||||||
|
@ -58,8 +56,6 @@ BEGIN
|
||||||
c.ead = t.landed
|
c.ead = t.landed
|
||||||
WHERE id = vCmrFk;
|
WHERE id = vCmrFk;
|
||||||
ELSE
|
ELSE
|
||||||
SELECT MAX(id) INTO vPreviousCmrFk FROM cmr;
|
|
||||||
|
|
||||||
INSERT INTO cmr (
|
INSERT INTO cmr (
|
||||||
senderInstruccions,
|
senderInstruccions,
|
||||||
truckPlate,
|
truckPlate,
|
||||||
|
@ -71,16 +67,13 @@ BEGIN
|
||||||
)
|
)
|
||||||
SELECT * FROM tTicket;
|
SELECT * FROM tTicket;
|
||||||
|
|
||||||
SELECT MAX(id) INTO vCurrentCmrFk FROM cmr;
|
IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN
|
||||||
|
|
||||||
IF vPreviousCmrFk <> vCurrentCmrFk THEN
|
|
||||||
UPDATE ticket
|
UPDATE ticket
|
||||||
SET cmrFk = vCurrentCmrFk
|
SET cmrFk = LAST_INSERT_ID()
|
||||||
WHERE id = vSelf;
|
WHERE id = vSelf;
|
||||||
END IF;
|
END IF;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
COMMIT;
|
|
||||||
DROP TEMPORARY TABLE tTicket;
|
DROP TEMPORARY TABLE tTicket;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -7,6 +7,8 @@ BEGIN
|
||||||
UPDATE expedition
|
UPDATE expedition
|
||||||
SET hasNewRoute = TRUE
|
SET hasNewRoute = TRUE
|
||||||
WHERE ticketFk = NEW.id;
|
WHERE ticketFk = NEW.id;
|
||||||
|
|
||||||
|
CALL ticket_doCmr(NEW.id);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `Id_Proveedor`,
|
||||||
`s`.`account` AS `cuenta`,
|
`s`.`account` AS `cuenta`,
|
||||||
`s`.`countryFk` AS `pais_id`,
|
`s`.`countryFk` AS `pais_id`,
|
||||||
`s`.`nif` AS `NIF`,
|
`s`.`nif` AS `NIF`,
|
||||||
`s`.`isFarmer` AS `Agricola`,
|
|
||||||
`s`.`phone` AS `Telefono`,
|
`s`.`phone` AS `Telefono`,
|
||||||
`s`.`retAccount` AS `cuentaret`,
|
`s`.`retAccount` AS `cuentaret`,
|
||||||
`s`.`commission` AS `ComisionProveedor`,
|
`s`.`commission` AS `ComisionProveedor`,
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
CREATE OR REPLACE PROCEDURE `vn`.`balance_create`() BEGIN END;
|
CREATE OR REPLACE PROCEDURE `vn`.`balance_create`() BEGIN END;
|
||||||
CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByEntry`() BEGIN END;
|
|
||||||
CREATE OR REPLACE PROCEDURE `vn`.`buy_recalcPricesByBuy`() BEGIN END;
|
|
||||||
|
|
||||||
GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`, `hrBoss`;
|
GRANT EXECUTE ON PROCEDURE vn.balance_create TO `financialBoss`, `hrBoss`;
|
||||||
GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`, `claimManager`, `employee`;
|
GRANT EXECUTE ON PROCEDURE vn.buy_recalcPricesByEntry TO `buyer`, `claimManager`, `employee`;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
ALTER TABLE vn.country
|
||||||
|
ADD IF NOT EXISTS viesCode varchar(2) DEFAULT NULL NULL AFTER code;
|
||||||
|
|
||||||
|
UPDATE IGNORE vn.country
|
||||||
|
SET viesCode = 'FR'
|
||||||
|
WHERE code = 'MC'; -- Mónaco
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.absenceType ADD isFestiveEligible BOOL DEFAULT 1 NOT NULL COMMENT 'Para marcar un tipo de absence';
|
||||||
|
|
||||||
|
UPDATE vn.absenceType
|
||||||
|
SET isFestiveEligible = 0
|
||||||
|
WHERE code = 'holiday';
|
||||||
|
|
||||||
|
UPDATE vn.absenceType
|
||||||
|
SET isFestiveEligible=0
|
||||||
|
WHERE code = 'halfHoliday';
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- Place your SQL code here
|
||||||
|
ALTER TABLE vn.packaging
|
||||||
|
MODIFY COLUMN height decimal(10,2) DEFAULT NULL NULL,
|
||||||
|
MODIFY COLUMN `depth` decimal(10,2) DEFAULT NULL NULL,
|
||||||
|
MODIFY COLUMN width decimal(10,2) DEFAULT NULL NULL;
|
|
@ -0,0 +1 @@
|
||||||
|
REVOKE UPDATE (`size`, longName, name) ON vn.item FROM buyer;
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE vn.invoiceInConfig CHANGE sageWithholdingFk sageFarmerWithholdingFk smallint(6) NOT NULL;
|
||||||
|
ALTER TABLE vn.supplier CHANGE isFarmer isFarmer__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk';
|
||||||
|
ALTER TABLE vn.supplier MODIFY COLUMN isFarmer__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7345 @deprecated 2024-05-10 - Utilizar withholdingSageFk';
|
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE vn.item
|
||||||
|
MODIFY nonRecycledPlastic DECIMAL(10,2) DEFAULT NULL NULL,
|
||||||
|
MODIFY recycledPlastic DECIMAL(10,2) DEFAULT NULL NULL;
|
|
@ -6,6 +6,7 @@ const log = require('fancy-log');
|
||||||
const Myt = require('@verdnatura/myt/myt');
|
const Myt = require('@verdnatura/myt/myt');
|
||||||
const Run = require('@verdnatura/myt/myt-run');
|
const Run = require('@verdnatura/myt/myt-run');
|
||||||
const Start = require('@verdnatura/myt/myt-start');
|
const Start = require('@verdnatura/myt/myt-start');
|
||||||
|
const watchDatabaseChanges = require('./db/dbWatcher');
|
||||||
|
|
||||||
// Configuration
|
// Configuration
|
||||||
|
|
||||||
|
@ -245,6 +246,7 @@ routes.description = 'Merges all module routes file into one file';
|
||||||
function watch(done) {
|
function watch(done) {
|
||||||
gulp.watch(routeFiles, gulp.series(routes));
|
gulp.watch(routeFiles, gulp.series(routes));
|
||||||
gulp.watch(localeFiles, gulp.series(locales));
|
gulp.watch(localeFiles, gulp.series(locales));
|
||||||
|
watchDatabaseChanges();
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
watch.description = `Watches for changes in routes and locale files`;
|
watch.description = `Watches for changes in routes and locale files`;
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
"id": {
|
"id": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"id": true
|
"id": true
|
||||||
|
},
|
||||||
|
"workcenterFk" : {
|
||||||
|
"type": "number"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -33,7 +33,6 @@ module.exports = Self => {
|
||||||
try {
|
try {
|
||||||
await Self.makePdf(id, options);
|
await Self.makePdf(id, options);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
|
||||||
throw new UserError('Error while generating PDF', 'pdfError');
|
throw new UserError('Error while generating PDF', 'pdfError');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,11 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
arg: 'checked',
|
||||||
|
type: 'boolean',
|
||||||
|
required: true
|
||||||
|
},
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
|
@ -51,6 +56,7 @@ module.exports = Self => {
|
||||||
const models = Self.app.models;
|
const models = Self.app.models;
|
||||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||||
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
|
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
|
||||||
|
const checked = ctx.args.checked;
|
||||||
let tx;
|
let tx;
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
Object.assign(myOptions, options);
|
Object.assign(myOptions, options);
|
||||||
|
@ -96,9 +102,10 @@ module.exports = Self => {
|
||||||
|
|
||||||
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
|
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
|
||||||
|
|
||||||
|
if (!checked) {
|
||||||
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
|
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
|
||||||
|
|
||||||
return invoiceId;
|
return invoiceId;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tx) await tx.rollback();
|
if (tx) await tx.rollback();
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -1,15 +1,3 @@
|
||||||
<vn-crud-model
|
|
||||||
auto-load="true"
|
|
||||||
url="CplusRectificationTypes"
|
|
||||||
data="cplusRectificationTypes"
|
|
||||||
order="description">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-crud-model
|
|
||||||
auto-load="true"
|
|
||||||
url="SiiTypeInvoiceOuts"
|
|
||||||
data="siiTypeInvoiceOuts"
|
|
||||||
where="{code: {like: 'R%'}}">
|
|
||||||
</vn-crud-model>
|
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
url="InvoiceCorrectionTypes"
|
url="InvoiceCorrectionTypes"
|
||||||
|
@ -211,7 +199,7 @@
|
||||||
vn-one
|
vn-one
|
||||||
vn-id="cplusRectificationType"
|
vn-id="cplusRectificationType"
|
||||||
required="true"
|
required="true"
|
||||||
data="cplusRectificationTypes"
|
data="$ctrl.cplusRectificationTypes"
|
||||||
show-field="description"
|
show-field="description"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
ng-model="$ctrl.cplusRectificationType"
|
ng-model="$ctrl.cplusRectificationType"
|
||||||
|
@ -226,7 +214,7 @@
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
vn-id="siiTypeInvoiceOut"
|
vn-id="siiTypeInvoiceOut"
|
||||||
data="siiTypeInvoiceOuts"
|
data="$ctrl.siiTypeInvoiceOuts"
|
||||||
show-field="description"
|
show-field="description"
|
||||||
value-field="id"
|
value-field="id"
|
||||||
fields="['id','code','description']"
|
fields="['id','code','description']"
|
||||||
|
@ -248,6 +236,14 @@
|
||||||
label="Type">
|
label="Type">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
<vn-horizontal>
|
||||||
|
<vn-check
|
||||||
|
ng-model="$ctrl.isChecked"
|
||||||
|
label="destinationClient"
|
||||||
|
info="transferInvoiceInfo"
|
||||||
|
/>
|
||||||
|
</vn-check>
|
||||||
|
</vn-horizontal>
|
||||||
</section>
|
</section>
|
||||||
</tpl-body>
|
</tpl-body>
|
||||||
<tpl-buttons>
|
<tpl-buttons>
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Controller extends Section {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this.vnReport = vnReport;
|
this.vnReport = vnReport;
|
||||||
this.vnEmail = vnEmail;
|
this.vnEmail = vnEmail;
|
||||||
|
this.checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
get invoiceOut() {
|
get invoiceOut() {
|
||||||
|
@ -23,6 +24,26 @@ class Controller extends Section {
|
||||||
return this.aclService.hasAny(['invoicing']);
|
return this.aclService.hasAny(['invoicing']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isChecked() {
|
||||||
|
return this.checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
set isChecked(value) {
|
||||||
|
this.checked = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$onInit() {
|
||||||
|
this.$http.get(`CplusRectificationTypes`, {filter: {order: 'description'}})
|
||||||
|
.then(res => {
|
||||||
|
this.cplusRectificationTypes = res.data;
|
||||||
|
this.cplusRectificationType = res.data.filter(type => type.description == 'I – Por diferencias')[0].id;
|
||||||
|
});
|
||||||
|
this.$http.get(`SiiTypeInvoiceOuts`, {filter: {where: {code: {like: 'R%'}}}})
|
||||||
|
.then(res => {
|
||||||
|
this.siiTypeInvoiceOuts = res.data;
|
||||||
|
this.siiTypeInvoiceOut = res.data.filter(type => type.code == 'R4')[0].id;
|
||||||
|
});
|
||||||
|
}
|
||||||
loadData() {
|
loadData() {
|
||||||
const filter = {
|
const filter = {
|
||||||
include: [
|
include: [
|
||||||
|
@ -34,7 +55,7 @@ class Controller extends Section {
|
||||||
}, {
|
}, {
|
||||||
relation: 'client',
|
relation: 'client',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'name', 'email']
|
fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -136,13 +157,25 @@ class Controller extends Section {
|
||||||
newClientFk: this.clientId,
|
newClientFk: this.clientId,
|
||||||
cplusRectificationTypeFk: this.cplusRectificationType,
|
cplusRectificationTypeFk: this.cplusRectificationType,
|
||||||
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
|
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
|
||||||
invoiceCorrectionTypeFk: this.invoiceCorrectionType
|
invoiceCorrectionTypeFk: this.invoiceCorrectionType,
|
||||||
|
checked: this.checked
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.$http.get(`Clients/${this.clientId}`).then(response => {
|
||||||
|
const clientData = response.data;
|
||||||
|
const hasToInvoiceByAddress = clientData.hasToInvoiceByAddress;
|
||||||
|
|
||||||
|
if (this.checked && hasToInvoiceByAddress) {
|
||||||
|
if (!window.confirm(this.$t('confirmTransferInvoice')))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
|
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
|
||||||
const invoiceId = res.data;
|
const invoiceId = res.data;
|
||||||
this.vnApp.showSuccess(this.$t('Transferred invoice'));
|
this.vnApp.showSuccess(this.$t('Transferred invoice'));
|
||||||
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
|
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}"
|
The following refund tickets have been created: "The following refund tickets have been created: {{ticketIds}}"
|
||||||
Transfer invoice to...: Transfer invoice to...
|
Transfer invoice to...: Transfer invoice to...
|
||||||
Cplus Type: Cplus Type
|
Cplus Type: Cplus Type
|
||||||
|
transferInvoice: Transfer Invoice
|
||||||
|
destinationClient: Bill destination client
|
||||||
|
transferInvoiceInfo: New tickets from the destination customer will be generated in the default consignee.
|
||||||
|
confirmTransferInvoice: Destination customer has marked to bill by consignee, do you want to continue?
|
|
@ -24,3 +24,7 @@ Refund...: Abono...
|
||||||
Transfer invoice to...: Transferir factura a...
|
Transfer invoice to...: Transferir factura a...
|
||||||
Rectificative type: Tipo rectificativa
|
Rectificative type: Tipo rectificativa
|
||||||
Transferred invoice: Factura transferida
|
Transferred invoice: Factura transferida
|
||||||
|
transferInvoice: Transferir factura
|
||||||
|
destinationClient: Facturar cliente destino
|
||||||
|
transferInvoiceInfo: Los nuevos tickets del cliente destino serán generados en el consignatario por defecto.
|
||||||
|
confirmTransferInvoice: El cliente destino tiene marcado facturar por consignatario, ¿desea continuar?
|
|
@ -19,6 +19,9 @@ module.exports = Self => {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The requested item quantity',
|
description: 'The requested item quantity',
|
||||||
|
}, {
|
||||||
|
arg: 'attenderFk',
|
||||||
|
type: 'number'
|
||||||
}],
|
}],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -73,12 +76,14 @@ module.exports = Self => {
|
||||||
ticketFk: request.ticketFk,
|
ticketFk: request.ticketFk,
|
||||||
itemFk: ctx.args.itemFk,
|
itemFk: ctx.args.itemFk,
|
||||||
quantity: ctx.args.quantity,
|
quantity: ctx.args.quantity,
|
||||||
|
attenderFk: ctx.args.attenderFk,
|
||||||
concept: item.name
|
concept: item.name
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
await request.updateAttributes({
|
await request.updateAttributes({
|
||||||
saleFk: sale.id,
|
saleFk: sale.id,
|
||||||
itemFk: sale.itemFk,
|
itemFk: sale.itemFk,
|
||||||
isOk: true
|
isOk: true,
|
||||||
|
attenderFk: sale.attenderFk,
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
||||||
|
|
|
@ -98,6 +98,22 @@ module.exports = Self => {
|
||||||
if (isHalfHoliday && hasHalfHoliday)
|
if (isHalfHoliday && hasHalfHoliday)
|
||||||
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
|
throw new UserError(`Cannot add more than one '1/2 day vacation'`);
|
||||||
|
|
||||||
|
const isFestive = absenceType.isFestiveEligible;
|
||||||
|
|
||||||
|
const workCenter = await models.Business.findOne({
|
||||||
|
where: {id: args.businessFk}
|
||||||
|
},);
|
||||||
|
|
||||||
|
const [holiday] = await models.CalendarHoliday.find({
|
||||||
|
where: {
|
||||||
|
dated: args.dated,
|
||||||
|
workCenterFk: workCenter.workCenterFk
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (holiday && isFestive)
|
||||||
|
throw new UserError(`Cannot add holidays on this day`);
|
||||||
|
|
||||||
const absence = await models.Calendar.create({
|
const absence = await models.Calendar.create({
|
||||||
businessFk: labour.businessFk,
|
businessFk: labour.businessFk,
|
||||||
dayOffTypeFk: args.absenceTypeId,
|
dayOffTypeFk: args.absenceTypeId,
|
||||||
|
|
|
@ -104,6 +104,35 @@ describe('Worker createAbsence()', () => {
|
||||||
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
|
expect(error.message).toEqual(`Cannot add more than one '1/2 day vacation'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`should throw an error when adding a "Holiday" absence if there's a festivity`, async() => {
|
||||||
|
const ctx = {
|
||||||
|
req: {accessToken: {userId: 9}},
|
||||||
|
args: {
|
||||||
|
id: 3,
|
||||||
|
businessFk: 3,
|
||||||
|
absenceTypeId: 1,
|
||||||
|
dated: '2001-12-08T23:00:00.000Z'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const workerId = 1;
|
||||||
|
|
||||||
|
const tx = await app.models.Calendar.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await app.models.Worker.createAbsence(ctx, workerId, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toEqual(`Cannot add holidays on this day`);
|
||||||
|
});
|
||||||
|
|
||||||
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
req: {accessToken: {userId: 19}},
|
req: {accessToken: {userId: 19}},
|
||||||
|
|
|
@ -22,6 +22,9 @@
|
||||||
},
|
},
|
||||||
"holidayEntitlementRate": {
|
"holidayEntitlementRate": {
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"isFestiveEligible": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
|
|
@ -59,6 +59,9 @@
|
||||||
},
|
},
|
||||||
"isF11Allowed": {
|
"isF11Allowed": {
|
||||||
"type" : "boolean"
|
"type" : "boolean"
|
||||||
|
},
|
||||||
|
"isFreelance": {
|
||||||
|
"type" : "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -113,7 +113,8 @@
|
||||||
"test:e2e": "node e2e/tests.js",
|
"test:e2e": "node e2e/tests.js",
|
||||||
"test:front": "jest --watch",
|
"test:front": "jest --watch",
|
||||||
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
|
"back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back",
|
||||||
"lint": "eslint ./ --cache --ignore-pattern .gitignore"
|
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
|
||||||
|
"watch:db": "node ./db/dbWatcher.js"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"projects": [
|
"projects": [
|
||||||
|
|
Loading…
Reference in New Issue