Merge branch 'dev' into 7252-deliveryNoteFarmingFk
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-05-09 12:56:05 +00:00
commit f4229284fa
14 changed files with 65 additions and 74 deletions

24
db/dbWatcher.js Normal file
View File

@ -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;

View File

@ -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, ''),

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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 ;

View File

@ -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),

View File

@ -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`;

View File

@ -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

View File

@ -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;

View File

@ -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`;

View File

@ -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)`;

View File

@ -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": [