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),
|
||||
(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
|
||||
(1, -2, '2% retention', 2, 45);
|
||||
|
||||
|
|
|
@ -5,97 +5,90 @@ BEGIN
|
|||
DECLARE vFromDated DATE;
|
||||
DECLARE vForDeleteDated DATE;
|
||||
DECLARE vManaId INT;
|
||||
DECLARE vManaAutoId INT;
|
||||
DECLARE vClaimManaId INT;
|
||||
DECLARE vManaBankId INT;
|
||||
DECLARE vManaGreugeTypeId INT;
|
||||
DECLARE vManaFromDays INT;
|
||||
DECLARE vManaToDays INT;
|
||||
DECLARE vManaAutoId INT;
|
||||
DECLARE vClaimManaId INT;
|
||||
DECLARE vManaBankId INT;
|
||||
DECLARE vManaGreugeTypeId INT;
|
||||
DECLARE vManaFromDays INT;
|
||||
DECLARE vManaToDays INT;
|
||||
|
||||
SELECT id INTO vManaId
|
||||
FROM vn.component WHERE code = 'mana';
|
||||
SELECT id INTO vManaId
|
||||
FROM vn.component WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaAutoId
|
||||
SELECT id INTO vManaAutoId
|
||||
FROM vn.component WHERE code = 'autoMana';
|
||||
|
||||
SELECT id INTO vClaimManaId
|
||||
FROM vn.component WHERE code = 'manaClaim';
|
||||
|
||||
SELECT id INTO vManaBankId
|
||||
SELECT id INTO vManaBankId
|
||||
FROM vn.accounting WHERE code = 'mana';
|
||||
|
||||
SELECT id INTO vManaGreugeTypeId
|
||||
SELECT id INTO vManaGreugeTypeId
|
||||
FROM vn.greugeType WHERE code = 'mana';
|
||||
|
||||
SELECT manaFromDays, manaToDays
|
||||
INTO vManaFromDays, vManaToDays
|
||||
FROM vn.salespersonConfig;
|
||||
SELECT manaFromDays, manaToDays
|
||||
INTO vManaFromDays, vManaToDays
|
||||
FROM vn.salespersonConfig;
|
||||
|
||||
SELECT MAX(dated)
|
||||
INTO vFromDated
|
||||
FROM vn.clientManaCache;
|
||||
SELECT MAX(dated) INTO vFromDated
|
||||
FROM vn.clientManaCache;
|
||||
|
||||
DELETE
|
||||
FROM vn.clientManaCache
|
||||
WHERE dated = vFromDated;
|
||||
|
||||
SELECT MAX(dated)
|
||||
INTO vFromDated
|
||||
FROM vn.clientManaCache;
|
||||
|
||||
IF ISNULL(vFromDated) THEN
|
||||
SELECT manaDateFrom
|
||||
INTO vFromDated
|
||||
FROM vn.salespersonConfig;
|
||||
END IF;
|
||||
DELETE FROM vn.clientManaCache
|
||||
WHERE dated = vFromDated;
|
||||
|
||||
SELECT MAX(dated) INTO vFromDated
|
||||
FROM vn.clientManaCache;
|
||||
|
||||
IF vFromDated IS NULL THEN
|
||||
SELECT manaDateFrom
|
||||
INTO vFromDated
|
||||
FROM vn.salespersonConfig;
|
||||
END IF;
|
||||
|
||||
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
||||
SELECT
|
||||
vFromDated + INTERVAL vManaToDays DAY,
|
||||
vFromDated - INTERVAL vManaFromDays DAY
|
||||
INTO
|
||||
vToDated,
|
||||
vForDeleteDated;
|
||||
|
||||
DELETE FROM vn.clientManaCache
|
||||
WHERE dated <= vForDeleteDated;
|
||||
WHILE vFromDated + INTERVAL vManaToDays DAY < util.VN_CURDATE() DO
|
||||
SELECT vFromDated + INTERVAL vManaToDays DAY,
|
||||
vFromDated - INTERVAL vManaFromDays DAY
|
||||
INTO vToDated,
|
||||
vForDeleteDated;
|
||||
|
||||
DELETE FROM vn.clientManaCache
|
||||
WHERE dated <= vForDeleteDated;
|
||||
|
||||
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
||||
SELECT
|
||||
Id_Cliente,
|
||||
SUM(mana),
|
||||
vToDated
|
||||
FROM
|
||||
(
|
||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value as mana
|
||||
FROM vn.ticket t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.sale s on s.ticketFk = t.id
|
||||
JOIN vn.saleComponent sc on sc.saleFk = s.id
|
||||
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
||||
AND t.shipped > vFromDated
|
||||
AND date(t.shipped) <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, - amountPaid
|
||||
FROM vn.receipt
|
||||
WHERE bankFk = vManaBankId
|
||||
AND payed > vFromDated
|
||||
AND payed <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, amount
|
||||
FROM vn.greuge
|
||||
WHERE greugeTypeFk = vManaGreugeTypeId
|
||||
AND shipped > vFromDated
|
||||
AND shipped <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, mana
|
||||
FROM vn.clientManaCache
|
||||
WHERE dated = vFromDated
|
||||
) sub
|
||||
GROUP BY Id_Cliente
|
||||
HAVING Id_Cliente;
|
||||
INSERT INTO vn.clientManaCache(clientFk, mana, dated)
|
||||
SELECT Id_Cliente,
|
||||
SUM(mana),
|
||||
vToDated
|
||||
FROM (
|
||||
SELECT a.clientFk Id_Cliente, s.quantity * sc.value mana
|
||||
FROM vn.ticket t
|
||||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.sale s ON s.ticketFk = t.id
|
||||
JOIN vn.saleComponent sc ON sc.saleFk = s.id
|
||||
WHERE sc.componentFk IN (vManaAutoId, vManaId, vClaimManaId)
|
||||
AND t.shipped > vFromDated
|
||||
AND DATE(t.shipped) <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, - amountPaid
|
||||
FROM vn.receipt
|
||||
WHERE bankFk = vManaBankId
|
||||
AND payed > vFromDated
|
||||
AND payed <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, amount
|
||||
FROM vn.greuge
|
||||
WHERE greugeTypeFk = vManaGreugeTypeId
|
||||
AND shipped > vFromDated
|
||||
AND shipped <= vToDated
|
||||
UNION ALL
|
||||
SELECT clientFk, mana
|
||||
FROM vn.clientManaCache
|
||||
WHERE dated = vFromDated
|
||||
) sub
|
||||
GROUP BY Id_Cliente
|
||||
HAVING Id_Cliente;
|
||||
|
||||
SET vFromDated = vToDated;
|
||||
END WHILE;
|
||||
SET vFromDated = vToDated;
|
||||
END WHILE;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -53,7 +53,7 @@ BEGIN
|
|||
IFNULL(c.street, ''),
|
||||
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)),
|
||||
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.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
|
@ -91,7 +91,7 @@ BEGIN
|
|||
IFNULL(s.street, ''),
|
||||
s.account,
|
||||
@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.city, ''),
|
||||
IFNULL(pr.CodigoProvincia, ''),
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`(
|
||||
IN vStartingMonth INT,
|
||||
IN vEndingMonth INT,
|
||||
IN vCompany INT,
|
||||
IN vIsConsolidated BOOLEAN,
|
||||
IN vInterGroupSalesIncluded BOOLEAN)
|
||||
vStartingMonth INT,
|
||||
vEndingMonth INT,
|
||||
vCompany INT,
|
||||
vIsConsolidated BOOLEAN,
|
||||
vInterGroupSalesIncluded BOOLEAN
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Crea un balance financiero para una empresa durante
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
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
|
||||
/**
|
||||
* Recalcula los precios de una compra
|
||||
*
|
||||
* @param vBuyFk
|
||||
*/
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
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
|
||||
/**
|
||||
* Recalcula los precios de una entrada
|
||||
*
|
||||
* @param vEntryFk
|
||||
*/
|
||||
*/
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyRecalc;
|
||||
|
||||
CREATE TEMPORARY TABLE tmp.buyRecalc
|
||||
|
|
|
@ -188,11 +188,12 @@ BEGIN
|
|||
FROM tPendingDuedates vp
|
||||
LEFT JOIN supplier s ON s.id = vp.supplierFk
|
||||
LEFT JOIN client c ON c.fi = s.nif
|
||||
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
||||
LEFT JOIN clientRisk cr ON cr.clientFk = c.id
|
||||
AND cr.companyFk = vp.companyFk
|
||||
LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id
|
||||
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 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);
|
||||
|
||||
-- Añadido temporalmente para ver si ya no sucede el cuelgue de db
|
||||
SET vShowType = TRUE;
|
||||
|
||||
WITH itemTags AS (
|
||||
SELECT i.id,
|
||||
typeFk,
|
||||
|
@ -82,7 +79,7 @@ BEGIN
|
|||
AND iss.warehouseFk = vWarehouseFk
|
||||
JOIN itemTags its
|
||||
WHERE a.available > 0
|
||||
AND IF(vShowType, i.typeFk = its.typeFk, TRUE)
|
||||
AND (i.typeFk = its.typeFk OR NOT vShowType)
|
||||
AND i.id <> vSelf
|
||||
ORDER BY `counter` DESC,
|
||||
(t.name = its.name) DESC,
|
||||
|
|
|
@ -34,7 +34,7 @@ BEGIN
|
|||
ticketFk INT(11),
|
||||
saleFk INT(11),
|
||||
isFreezed INTEGER(1) DEFAULT 0,
|
||||
risk DECIMAL(10,2) DEFAULT 0,
|
||||
risk DECIMAL(10,1) DEFAULT 0,
|
||||
hasHighRisk TINYINT(1) DEFAULT 0,
|
||||
hasTicketRequest INTEGER(1) DEFAULT 0,
|
||||
itemShortage VARCHAR(255),
|
||||
|
|
|
@ -7,7 +7,7 @@ BEGIN
|
|||
*
|
||||
* @param vSelf El id del ticket
|
||||
*/
|
||||
DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT;
|
||||
DECLARE vCmrFk INT;
|
||||
SELECT cmrFk INTO vCmrFk
|
||||
FROM ticket
|
||||
WHERE id = vSelf;
|
||||
|
@ -44,8 +44,6 @@ BEGIN
|
|||
AND t.id = vSelf
|
||||
GROUP BY t.id;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
IF vCmrFk THEN
|
||||
UPDATE cmr c
|
||||
JOIN tTicket t
|
||||
|
@ -57,9 +55,7 @@ BEGIN
|
|||
c.supplierFk = t.supplierFk,
|
||||
c.ead = t.landed
|
||||
WHERE id = vCmrFk;
|
||||
ELSE
|
||||
SELECT MAX(id) INTO vPreviousCmrFk FROM cmr;
|
||||
|
||||
ELSE
|
||||
INSERT INTO cmr (
|
||||
senderInstruccions,
|
||||
truckPlate,
|
||||
|
@ -70,17 +66,14 @@ BEGIN
|
|||
ead
|
||||
)
|
||||
SELECT * FROM tTicket;
|
||||
|
||||
SELECT MAX(id) INTO vCurrentCmrFk FROM cmr;
|
||||
|
||||
IF vPreviousCmrFk <> vCurrentCmrFk THEN
|
||||
IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN
|
||||
UPDATE ticket
|
||||
SET cmrFk = vCurrentCmrFk
|
||||
SET cmrFk = LAST_INSERT_ID()
|
||||
WHERE id = vSelf;
|
||||
END IF;
|
||||
END IF;
|
||||
|
||||
COMMIT;
|
||||
DROP TEMPORARY TABLE tTicket;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -7,6 +7,8 @@ BEGIN
|
|||
UPDATE expedition
|
||||
SET hasNewRoute = TRUE
|
||||
WHERE ticketFk = NEW.id;
|
||||
|
||||
CALL ticket_doCmr(NEW.id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -6,7 +6,6 @@ AS SELECT `s`.`id` AS `Id_Proveedor`,
|
|||
`s`.`account` AS `cuenta`,
|
||||
`s`.`countryFk` AS `pais_id`,
|
||||
`s`.`nif` AS `NIF`,
|
||||
`s`.`isFarmer` AS `Agricola`,
|
||||
`s`.`phone` AS `Telefono`,
|
||||
`s`.`retAccount` AS `cuentaret`,
|
||||
`s`.`commission` AS `ComisionProveedor`,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
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.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 Run = require('@verdnatura/myt/myt-run');
|
||||
const Start = require('@verdnatura/myt/myt-start');
|
||||
const watchDatabaseChanges = require('./db/dbWatcher');
|
||||
|
||||
// Configuration
|
||||
|
||||
|
@ -245,6 +246,7 @@ routes.description = 'Merges all module routes file into one file';
|
|||
function watch(done) {
|
||||
gulp.watch(routeFiles, gulp.series(routes));
|
||||
gulp.watch(localeFiles, gulp.series(locales));
|
||||
watchDatabaseChanges();
|
||||
done();
|
||||
}
|
||||
watch.description = `Watches for changes in routes and locale files`;
|
||||
|
|
|
@ -226,4 +226,4 @@
|
|||
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
|
||||
"They're not your subordinate": "They're not your subordinate",
|
||||
"InvoiceIn is already booked": "InvoiceIn is already booked"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"workcenterFk" : {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
@ -24,4 +27,4 @@
|
|||
"foreignKey": "departmentFk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ module.exports = Self => {
|
|||
try {
|
||||
await Self.makePdf(id, options);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw new UserError('Error while generating PDF', 'pdfError');
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,11 @@ module.exports = Self => {
|
|||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
arg: 'checked',
|
||||
type: 'boolean',
|
||||
required: true
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
|
@ -51,6 +56,7 @@ module.exports = Self => {
|
|||
const models = Self.app.models;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
const {id, refFk, newClientFk, cplusRectificationTypeFk, siiTypeInvoiceOutFk, invoiceCorrectionTypeFk} = ctx.args;
|
||||
const checked = ctx.args.checked;
|
||||
let tx;
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
@ -96,9 +102,10 @@ module.exports = Self => {
|
|||
|
||||
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
|
||||
|
||||
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
|
||||
|
||||
return invoiceId;
|
||||
if (!checked) {
|
||||
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions);
|
||||
return invoiceId;
|
||||
}
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
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
|
||||
auto-load="true"
|
||||
url="InvoiceCorrectionTypes"
|
||||
|
@ -211,14 +199,14 @@
|
|||
vn-one
|
||||
vn-id="cplusRectificationType"
|
||||
required="true"
|
||||
data="cplusRectificationTypes"
|
||||
data="$ctrl.cplusRectificationTypes"
|
||||
show-field="description"
|
||||
value-field="id"
|
||||
ng-model="$ctrl.cplusRectificationType"
|
||||
search-function="{or: [{id: $search}, {description: {like: '%'+ $search +'%'}}]}"
|
||||
label="Rectificative type">
|
||||
<tpl-item>
|
||||
{{::description}}
|
||||
{{ ::description}}
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
|
@ -226,7 +214,7 @@
|
|||
<vn-autocomplete
|
||||
vn-one
|
||||
vn-id="siiTypeInvoiceOut"
|
||||
data="siiTypeInvoiceOuts"
|
||||
data="$ctrl.siiTypeInvoiceOuts"
|
||||
show-field="description"
|
||||
value-field="id"
|
||||
fields="['id','code','description']"
|
||||
|
@ -248,6 +236,14 @@
|
|||
label="Type">
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-check
|
||||
ng-model="$ctrl.isChecked"
|
||||
label="destinationClient"
|
||||
info="transferInvoiceInfo"
|
||||
/>
|
||||
</vn-check>
|
||||
</vn-horizontal>
|
||||
</section>
|
||||
</tpl-body>
|
||||
<tpl-buttons>
|
||||
|
|
|
@ -7,6 +7,7 @@ class Controller extends Section {
|
|||
super($element, $);
|
||||
this.vnReport = vnReport;
|
||||
this.vnEmail = vnEmail;
|
||||
this.checked = true;
|
||||
}
|
||||
|
||||
get invoiceOut() {
|
||||
|
@ -23,6 +24,26 @@ class Controller extends Section {
|
|||
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() {
|
||||
const filter = {
|
||||
include: [
|
||||
|
@ -34,7 +55,7 @@ class Controller extends Section {
|
|||
}, {
|
||||
relation: 'client',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'email']
|
||||
fields: ['id', 'name', 'email', 'hasToInvoiceByAddress']
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -136,12 +157,24 @@ class Controller extends Section {
|
|||
newClientFk: this.clientId,
|
||||
cplusRectificationTypeFk: this.cplusRectificationType,
|
||||
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
|
||||
invoiceCorrectionTypeFk: this.invoiceCorrectionType
|
||||
invoiceCorrectionTypeFk: this.invoiceCorrectionType,
|
||||
checked: this.checked
|
||||
};
|
||||
this.$http.post(`InvoiceOuts/transferInvoice`, params).then(res => {
|
||||
const invoiceId = res.data;
|
||||
this.vnApp.showSuccess(this.$t('Transferred invoice'));
|
||||
this.$state.go('invoiceOut.card.summary', {id: invoiceId});
|
||||
|
||||
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 => {
|
||||
const invoiceId = res.data;
|
||||
this.vnApp.showSuccess(this.$t('Transferred invoice'));
|
||||
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}}"
|
||||
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...
|
||||
Rectificative type: Tipo rectificativa
|
||||
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',
|
||||
required: true,
|
||||
description: 'The requested item quantity',
|
||||
}, {
|
||||
arg: 'attenderFk',
|
||||
type: 'number'
|
||||
}],
|
||||
returns: {
|
||||
type: 'object',
|
||||
|
@ -73,12 +76,14 @@ module.exports = Self => {
|
|||
ticketFk: request.ticketFk,
|
||||
itemFk: ctx.args.itemFk,
|
||||
quantity: ctx.args.quantity,
|
||||
attenderFk: ctx.args.attenderFk,
|
||||
concept: item.name
|
||||
}, myOptions);
|
||||
await request.updateAttributes({
|
||||
saleFk: sale.id,
|
||||
itemFk: sale.itemFk,
|
||||
isOk: true
|
||||
isOk: true,
|
||||
attenderFk: sale.attenderFk,
|
||||
}, myOptions);
|
||||
|
||||
const query = `CALL vn.sale_calculateComponent(?, NULL)`;
|
||||
|
|
|
@ -98,6 +98,22 @@ module.exports = Self => {
|
|||
if (isHalfHoliday && hasHalfHoliday)
|
||||
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({
|
||||
businessFk: labour.businessFk,
|
||||
dayOffTypeFk: args.absenceTypeId,
|
||||
|
|
|
@ -104,6 +104,35 @@ describe('Worker createAbsence()', () => {
|
|||
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() => {
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 19}},
|
||||
|
|
|
@ -22,7 +22,10 @@
|
|||
},
|
||||
"holidayEntitlementRate": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"isFestiveEligible": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
|
@ -32,4 +35,4 @@
|
|||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,9 @@
|
|||
},
|
||||
"isF11Allowed": {
|
||||
"type" : "boolean"
|
||||
},
|
||||
"isFreelance": {
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -113,7 +113,8 @@
|
|||
"test:e2e": "node e2e/tests.js",
|
||||
"test:front": "jest --watch",
|
||||
"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": {
|
||||
"projects": [
|
||||
|
|
Loading…
Reference in New Issue