#6243 generalize cmr section #2406

Merged
jorgep merged 10 commits from 6243-generalizeCmrSection into dev 2024-06-11 07:41:21 +00:00
91 changed files with 402 additions and 372 deletions
Showing only changes of commit faf450e075 - Show all commits

10
Jenkinsfile vendored
View File

@ -103,7 +103,7 @@ pipeline {
NODE_ENV = '' NODE_ENV = ''
} }
steps { steps {
sh 'node back/tests.js --ci --junit --network jenkins' sh 'node back/tests.js --junit'
} }
post { post {
always { always {
@ -121,7 +121,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
sh 'docker-compose build back' sh 'docker-compose build back'
} }
@ -159,7 +159,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
sh 'gulp build' sh 'gulp build'
sh 'docker-compose build front' sh 'docker-compose build front'
@ -179,7 +179,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY'
sh 'docker-compose push' sh 'docker-compose push'
@ -210,7 +210,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
} }
withKubeConfig([ withKubeConfig([
serverUrl: "$KUBERNETES_API", serverUrl: "$KUBERNETES_API",

View File

@ -57,14 +57,14 @@ module.exports = Self => {
DATE_FORMAT(t.shipped, '%d/%m/%Y') created, DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
t.shipped, t.shipped,
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType, LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
IF(mw.weekdays, 'S', 'N') weekDays, IF(mw.weekdays, 'S', 'N') weekDays,
oa.description deliveryObservation oa.description deliveryObservation
FROM expedition e FROM expedition e
JOIN ticket t ON e.ticketFk = t.id JOIN ticket t ON e.ticketFk = t.id
JOIN agencyMode am ON am.id = t.agencyModeFk JOIN agencyMode am ON am.id = t.agencyModeFk
JOIN mrwService ms ON ms.agencyModeCodeFk = am.code JOIN mrwService ms ON ms.agencyModeCodeFk = am.code
LEFT JOIN mrwServiceWeekday mw ON mw.weekdays = DATE_FORMAT(t.shipped, '%a') LEFT JOIN mrwServiceWeekday mw ON mw.weekdays | 1 << WEEKDAY(t.landed)
JOIN client c ON t.clientFk = c.id JOIN client c ON t.clientFk = c.id
JOIN address a ON t.addressFk = a.id JOIN address a ON t.addressFk = a.id
LEFT JOIN addressObservation oa ON oa.addressFk = a.id LEFT JOIN addressObservation oa ON oa.addressFk = a.id

View File

@ -9,7 +9,7 @@
}, },
"vn": { "vn": {
"view": { "view": {
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345"
} }
} }
} }

View File

@ -129,7 +129,7 @@ INSERT INTO vn.itemShelving (id,itemFk,visible,shelvingFk,`grouping`,packing,pac
INSERT INTO vn.beach (code,warehouseFk) VALUES INSERT INTO vn.beach (code,warehouseFk) VALUES
('TEST',1); ('TEST',1);
INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,expeditionTruckFk) VALUES INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,roadmapStopFk) VALUES
(1,'TEST','TEST',1.0,1); (1,'TEST','TEST',1.0,1);
/* #5483 /* #5483
INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressFk, workerFk, observations, isSigned, isLabeled, isPrinted, packages, location, `hour`, created, isBlocked, solution, routeFk, priority, hasPriority, companyFk, agencyModeFk, landed, isBoxed, isDeleted, zoneFk, zonePrice, zoneBonus, totalWithVat, totalWithoutVat, weight) INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressFk, workerFk, observations, isSigned, isLabeled, isPrinted, packages, location, `hour`, created, isBlocked, solution, routeFk, priority, hasPriority, companyFk, agencyModeFk, landed, isBoxed, isDeleted, zoneFk, zonePrice, zoneBonus, totalWithVat, totalWithoutVat, weight)

View File

@ -65,11 +65,12 @@ BEGIN
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
JOIN vn.state st ON st.id = tt.stateFk JOIN vn.state st ON st.id = tt.stateFk
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
WHERE sc.componentFk = 17 WHERE sc.componentFk = 17
AND sc.isGreuge = 0 AND sc.isGreuge = 0
AND t.shipped >= '2016-10-01' AND t.shipped >= '2016-10-01'
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
AND st.alertLevel >= 3; AND st.alertLevel >= al.id;
DELETE g.* DELETE g.*
FROM vn.greuge g FROM vn.greuge g

View File

@ -46,7 +46,7 @@ BEGIN
JOIN vn.address a ON a.id = t.addressFk JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p ON p.id = a.provinceFk JOIN vn.province p ON p.id = a.provinceFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
LEFT JOIN vn.beach b ON b.code = rm.beachFk LEFT JOIN vn.beach b ON b.code = rm.beachFk
LEFT JOIN vn.`zone`z ON z.id = t.zoneFk LEFT JOIN vn.`zone`z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON t.agencyModeFk = am.id JOIN vn.agencyMode am ON t.agencyModeFk = am.id

View File

@ -74,9 +74,10 @@ BEGIN
FROM vn.sale m FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE()
AND t.warehouseFk = vWarehouse AND t.warehouseFk = vWarehouse
AND s.alertLevel = 3 AND s.alertLevel = al.id
) t ) t
GROUP BY itemFk GROUP BY itemFk
HAVING quantity > 0; HAVING quantity > 0;

View File

@ -121,6 +121,7 @@ BEGIN
) )
SELECT t.id INTO vTicket SELECT t.id INTO vTicket
FROM vn.ticket t FROM vn.ticket t
JOIN vn.alertLevel al ON al.code = 'FREE'
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
JOIN hedera.`order` o JOIN hedera.`order` o
@ -131,7 +132,7 @@ BEGIN
WHERE o.id = vSelf WHERE o.id = vSelf
AND t.refFk IS NULL AND t.refFk IS NULL
AND tp.ticketFk IS NULL AND tp.ticketFk IS NULL
AND IFNULL(tls.alertLevel,0) = 0 AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id)
LIMIT 1; LIMIT 1;
-- Crea el ticket en el caso de no existir uno adecuado -- Crea el ticket en el caso de no existir uno adecuado

View File

@ -22,7 +22,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk
LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id LEFT JOIN vn.roadmapStop rs ON rm.roadmapStopFk = rs.id
WHERE e.id = vExpeditionFk; WHERE e.id = vExpeditionFk;
RETURN vDayMinute; RETURN vDayMinute;

View File

@ -34,7 +34,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`)
) )
LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`) LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`)
) )

View File

@ -45,7 +45,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`)
) )
JOIN `srt`.`config` `c` JOIN `srt`.`config` `c`
) )

View File

@ -32,7 +32,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`)
) )
JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`) JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`)
) )

View File

@ -16,12 +16,13 @@ BEGIN
m.created, m.created,
TIMESTAMPADD(DAY, tp.life, t.shipped) expired, TIMESTAMPADD(DAY, tp.life, t.shipped) expired,
m.quantity < 0 isIn, m.quantity < 0 isIn,
m.isPicked OR s.alertLevel > 1 isPicked m.isPicked OR s.alertLevel > al.id isPicked
FROM vn.sale m FROM vn.sale m
JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticket t ON t.id = m.ticketFk
JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.ticketState s ON s.ticketFk = t.id
JOIN vn.item i ON i.id = m.itemFk JOIN vn.item i ON i.id = m.itemFk
JOIN vn.itemType tp ON tp.id = i.typeFk JOIN vn.itemType tp ON tp.id = i.typeFk
JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION'
WHERE ( WHERE (
vTableId IS NULL vTableId IS NULL
OR (vTableName = 'ticket' AND t.id = vTableId) OR (vTableName = 'ticket' AND t.id = vTableId)

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_commit`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Confirma los cambios asociados a una transacción. * Confirma los cambios asociados a una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF isTx THEN IF vIsTx THEN
COMMIT; COMMIT;
END IF; END IF;
END$$ END$$

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_rollback`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Deshace los cambios asociados a una transacción. * Deshace los cambios asociados a una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF isTx THEN IF vIsTx THEN
ROLLBACK; ROLLBACK;
END IF; END IF;
END$$ END$$

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(isTx BOOL) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`tx_start`(vIsTx BOOL)
BEGIN BEGIN
/** /**
* Inicia una transacción. * Inicia una transacción.
* *
* @param isTx es true si existe transacción asociada * @param vIsTx es true si existe transacción asociada
*/ */
IF isTx THEN IF vIsTx THEN
START TRANSACTION; START TRANSACTION;
END IF; END IF;
END$$ END$$

View File

@ -34,7 +34,7 @@ BEGIN
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.agency a ON a.id = am.agencyFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
JOIN vn.packagingConfig pc JOIN vn.packagingConfig pc
WHERE t.warehouseFk IN (60,1,44) WHERE t.warehouseFk IN (60,1,44)
AND e.created BETWEEN vStarted AND vEnded AND e.created BETWEEN vStarted AND vEnded

View File

@ -44,7 +44,7 @@ BEGIN
JOIN dua d ON d.id = de.duaFk JOIN dua d ON d.id = de.duaFk
WHERE d.id = vDuaFk WHERE d.id = vDuaFk
LIMIT 1; LIMIT 1;
CALL ledger_next(vFiscalYear, FALSE, vBookEntry); CALL ledger_nextTx(vFiscalYear, vBookEntry);
END IF; END IF;
OPEN vInvoicesIn; OPEN vInvoicesIn;

View File

@ -12,7 +12,7 @@ BEGIN
WHERE id = vDuaFk; WHERE id = vDuaFk;
IF vBookNumber IS NULL OR NOT vBookNumber THEN IF vBookNumber IS NULL OR NOT vBookNumber THEN
CALL ledger_next(YEAR(vBookDated), FALSE, vBookNumber); CALL ledger_nextTx(YEAR(vBookDated), vBookNumber);
END IF; END IF;
-- Apunte de la aduana -- Apunte de la aduana

View File

@ -1,22 +0,0 @@
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 AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw('Entry is already booked');
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,24 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_isEditable`(
vSelf INT
)
BEGIN
/**
* Comprueba si una entrada se puede actualizar
* si no se puede retorna un throw.
*
* @param vSelf Id de entrada
*/
DECLARE vIsEditable BOOL;
SELECT e.isBooked INTO vIsEditable
FROM `entry` e
JOIN entryType et ON et.code = e.typeFk
WHERE NOT et.isInformal
AND e.id = vSelf;
IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
CALL util.throw('Entry is not editable');
END IF;
END$$
DELIMITER ;

View File

@ -23,7 +23,8 @@ BEGIN
JOIN vn.travel t ON t.id = e.travelFk JOIN vn.travel t ON t.id = e.travelFk
JOIN vn.warehouse w ON w.id = t.warehouseInFk JOIN vn.warehouse w ON w.id = t.warehouseInFk
WHERE t.shipped >= util.VN_CURDATE() WHERE t.shipped >= util.VN_CURDATE()
AND e.currencyFk = vCurrency; AND e.currencyFk = vCurrency
AND NOT e.isBooked;
SET vComission = currency_getCommission(vCurrency); SET vComission = currency_getCommission(vCurrency);

View File

@ -56,13 +56,13 @@ BEGIN
LIMIT 1; LIMIT 1;
IF vPalletFk IS NULL THEN IF vPalletFk IS NULL THEN
SELECT expeditionTruckFk SELECT roadmapStopFk
INTO vTruckFk INTO vTruckFk
FROM ( FROM (
SELECT rm.expeditionTruckFk, count(*) n SELECT rm.roadmapStopFk, count(*) n
FROM vn.routesMonitor rm FROM vn.routesMonitor rm
JOIN tExpedition e ON e.routeFk = rm.routeFk JOIN tExpedition e ON e.routeFk = rm.routeFk
GROUP BY expeditionTruckFk GROUP BY roadmapStopFk
ORDER BY n DESC ORDER BY n DESC
LIMIT 1) sub; LIMIT 1) sub;

View File

@ -67,7 +67,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
WHERE e.id = vExpeditionFk; WHERE e.id = vExpeditionFk;
END$$ END$$

View File

@ -50,7 +50,7 @@ BEGIN
LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
WHERE e.id = vExpeditionFk; WHERE e.id = vExpeditionFk;
END$$ END$$

View File

@ -70,7 +70,7 @@ BEGIN
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1; SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
IF vBookNumber IS NULL THEN IF vBookNumber IS NULL THEN
CALL ledger_next(vFiscalYear, FALSE, vBookNumber); CALL ledger_nextTx(vFiscalYear, vBookNumber);
END IF; END IF;
-- Apunte del proveedor -- Apunte del proveedor

View File

@ -61,7 +61,7 @@ BEGIN
WHERE io.id = vInvoice; WHERE io.id = vInvoice;
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1; SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
CALL ledger_next(vFiscalYear, FALSE, vBookNumber); CALL ledger_nextTx(vFiscalYear, vBookNumber);
-- Linea del cliente -- Linea del cliente
INSERT INTO XDiario( INSERT INTO XDiario(
ASIEN, ASIEN,

View File

@ -153,7 +153,9 @@ BEGIN
FROM tmp.ticketToInvoice ti FROM tmp.ticketToInvoice ti
LEFT JOIN ticketState ts ON ti.id = ts.ticketFk LEFT JOIN ticketState ts ON ti.id = ts.ticketFk
JOIN state s JOIN state s
WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); JOIN alertLevel al ON al.code = 'DELIVERED'
WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id)
AND s.`code` = getAlert3State(ti.id);
INSERT INTO ticketTracking(stateFk, ticketFk, userFk) INSERT INTO ticketTracking(stateFk, ticketFk, userFk)
SELECT * FROM tmp.updateInter; SELECT * FROM tmp.updateInter;

View File

@ -49,7 +49,7 @@ BEGIN
ish.isChecked, ish.isChecked,
sub.isAllChecked sub.isAllChecked
FROM itemShelvingStock iss FROM itemShelvingStock iss
JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
LEFT JOIN ( LEFT JOIN (
SELECT itemFk, SELECT itemFk,
IF( IF(

View File

@ -28,7 +28,7 @@ BEGIN
DECLARE vIsOriginalAClient BOOL; DECLARE vIsOriginalAClient BOOL;
DECLARE vPayMethodCompensation INT; DECLARE vPayMethodCompensation INT;
CALL ledger_next(YEAR(vDated), FALSE, vNewBookEntry); CALL ledger_nextTx(YEAR(vDated), vNewBookEntry);
SELECT COUNT(id) INTO vIsOriginalAClient SELECT COUNT(id) INTO vIsOriginalAClient
FROM client FROM client

View File

@ -1,38 +1,21 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
IN vFiscalYear INT, IN vFiscalYear INT,
IN vIsManageTransaction BOOLEAN,
OUT vLastBookEntry INT OUT vLastBookEntry INT
) )
/**
* Devuelve un número de asiento válido, según el contador de asientos
* tabla vn.ledgerConfig, si no existe lo inicializa a 1
* No inicia transacción, para transaccionar usar vn.ledger_nextTx
*
* @param vFiscalYear Id del año contable
* @return vLastBookEntry Id del asiento
*/
BEGIN BEGIN
DECLARE vHasStartTransaction BOOLEAN;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
IF vHasStartTransaction THEN
ROLLBACK TO sp;
RESIGNAL;
ELSE
ROLLBACK;
CALL util.throw ('It has not been possible to generate a new ledger');
END IF;
END;
IF vFiscalYear IS NULL THEN IF vFiscalYear IS NULL THEN
CALL util.throw('Fiscal year is required'); CALL util.throw('Fiscal year is required');
END IF; END IF;
IF NOT vIsManageTransaction THEN
SELECT @@in_transaction INTO vHasStartTransaction;
IF NOT vHasStartTransaction THEN
START TRANSACTION;
ELSE
SAVEPOINT sp;
END IF;
END IF;
SELECT bookEntry + 1 INTO vLastBookEntry SELECT bookEntry + 1 INTO vLastBookEntry
FROM ledgerCompany FROM ledgerCompany
WHERE fiscalYear = vFiscalYear WHERE fiscalYear = vFiscalYear
@ -48,13 +31,5 @@ BEGIN
UPDATE ledgerCompany UPDATE ledgerCompany
SET bookEntry = vLastBookEntry SET bookEntry = vLastBookEntry
WHERE fiscalYear = vFiscalYear; WHERE fiscalYear = vFiscalYear;
IF NOT vIsManageTransaction THEN
IF vHasStartTransaction THEN
RELEASE SAVEPOINT sp;
ELSE
COMMIT;
END IF;
END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,30 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_nextTx`(
IN vFiscalYear INT,
OUT vLastBookEntry INT
)
/**
* Devuelve un número de asiento válido, según el contador de asientos
* tabla vn.ledgerConfig, si no existe lo inicializa a 1
* Lo hace transaccionando el proceso
*
* @param vFiscalYear Id del año contable
* @return vLastBookEntry Id del asiento
*/
BEGIN
DECLARE vIsRequiredTx BOOL DEFAULT NOT @@in_transaction;
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL;
END;
IF vFiscalYear IS NULL THEN
CALL util.throw('Fiscal year is required');
END IF;
CALL util.tx_start(vIsRequiredTx);
CALL ledger_next(vFiscalYear, vLastBookEntry);
CALL util.tx_commit(vIsRequiredTx);
END$$
DELIMITER ;

View File

@ -6,14 +6,16 @@ BEGIN
(PRIMARY KEY (ticketFk)) (PRIMARY KEY (ticketFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT t.id ticketFk, t.clientFk SELECT t.id ticketFk, t.clientFk
FROM vn.ticket t FROM ticket t
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN alertLevel al ON al.code = 'DELIVERED'
JOIN vn.client c ON c.id = t.clientFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id
JOIN client c ON c.id = t.clientFk
WHERE c.typeFk IN ('normal','handMaking','internalUse') WHERE c.typeFk IN ('normal','handMaking','internalUse')
AND ( AND (
t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate
OR ( OR (
ts.alertLevel < 3 ts.alertLevel < al.id
AND t.shipped >= vStartingDate AND t.shipped >= vStartingDate
AND t.shipped < util.VN_CURDATE() AND t.shipped < util.VN_CURDATE()
) )

View File

@ -67,7 +67,7 @@ proc: BEGIN
wk.code salesPersonCode, wk.code salesPersonCode,
p.id provinceFk, p.id provinceFk,
tls.productionOrder, tls.productionOrder,
IFNULL(tls.alertLevel, 0) alertLevel, IFNULL(tls.alertLevel, al.id) alertLevel,
t.isBoxed palletized, t.isBoxed palletized,
IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion,
tlu.lastUpdated, tlu.lastUpdated,
@ -81,6 +81,7 @@ proc: BEGIN
rm.bufferFk rm.bufferFk
FROM tmp.productionTicket tt FROM tmp.productionTicket tt
JOIN ticket t ON tt.ticketFk = t.id JOIN ticket t ON tt.ticketFk = t.id
JOIN alertLevel al ON al.code = 'FREE'
LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id
LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN `state` st ON st.id = tst.state
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk

View File

@ -47,7 +47,7 @@ BEGIN
LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
LEFT JOIN zone zo ON t.zoneFk = zo.id LEFT JOIN zone zo ON t.zoneFk = zo.id
LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN roadmapStop rs ON rs.id = rm.roadmapStopFk
WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam)
GROUP BY t.id GROUP BY t.id
ORDER BY cc.code; ORDER BY cc.code;

View File

@ -106,7 +106,7 @@ BEGIN
SET rm.m3boxes = sub.m3boxes; SET rm.m3boxes = sub.m3boxes;
UPDATE routesMonitor rm UPDATE routesMonitor rm
JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
SET rm.etd = rs.eta; SET rm.etd = rs.eta;
DROP TEMPORARY TABLE tmp.routesMonitor; DROP TEMPORARY TABLE tmp.routesMonitor;

View File

@ -7,13 +7,16 @@ BEGIN
DECLARE vShipped DATE; DECLARE vShipped DATE;
DECLARE vWarehouse TINYINT; DECLARE vWarehouse TINYINT;
DECLARE vAlertLevel INT; DECLARE vAlertLevel INT;
DECLARE vAlertLevelFree INT;
SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id
INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree
FROM ticket t FROM ticket t
JOIN alertLevel al ON al.code = 'FREE'
LEFT JOIN ticketState ts ON ts.ticketFk = vTicket LEFT JOIN ticketState ts ON ts.ticketFk = vTicket
WHERE t.id = vTicket; WHERE t.id = vTicket;
IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN
IF vShipped >= util.VN_CURDATE() THEN IF vShipped >= util.VN_CURDATE() THEN
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
END IF; END IF;

View File

@ -1,49 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketMissed_List`(vTicketFk INT)
BEGIN
DECLARE vParkingFk INT;
DECLARE vParked DATETIME;
DECLARE vLevel INT;
DECLARE vCollectionFk INT;
SELECT IFNULL(`level`,0), IFNULL(collectionFk,0)
INTO vLevel, vCollectionFk
FROM vn.ticketCollection
WHERE ticketFk = vTicketFk
LIMIT 1;
SELECT created, parkingFk
INTO vParked, vParkingFk
FROM vn.ticketParking
WHERE ticketFk = vTicketFk;
SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia
FROM vn.ticketParking tp
JOIN vn.parking p ON p.id = tp.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk
JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk
JOIN vn.ticket t ON t.id = tp.ticketFk
JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk
JOIN vn.state s ON s.id = tst.state
WHERE (s.alertLevel < 2
AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea
AND (
(
( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked )
OR
( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) )
)
)) -- Etiquetas que no se han escaneado y ya estamos con una posterior
OR
(s.alertLevel > 1
AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea
AND tp.created < vParked
AND t.packages <=> 0);
END$$
DELIMITER ;

View File

@ -34,15 +34,17 @@ BEGIN
SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia
FROM vn.ticketParking tp FROM vn.ticketParking tp
JOIN vn.parking p ON p.id = tp.parkingFk JOIN vn.parking p ON p.id = tp.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.sector sc ON sc.id = p.sectorFk
LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk
JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk
JOIN vn.ticket t ON t.id = tp.ticketFk JOIN vn.ticket t ON t.id = tp.ticketFk
JOIN vn.zone z ON z.id = t.zoneFk JOIN vn.zone z ON z.id = t.zoneFk
JOIN vn.agencyMode am ON am.id = z.agencyModeFk JOIN vn.agencyMode am ON am.id = z.agencyModeFk
JOIN vn.state s ON s.id = tst.state JOIN vn.state s ON s.id = tst.state
WHERE (s.alertLevel < 2 JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED'
JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION'
WHERE (s.alertLevel < alPacked.id
AND tp.parkingFk = vParkingFk AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea AND sc.isPackagingArea
AND ( AND (
@ -55,7 +57,7 @@ BEGIN
) )
) -- Etiquetas que no se han escaneado y ya estamos con una posterior ) -- Etiquetas que no se han escaneado y ya estamos con una posterior
OR OR
(s.alertLevel > 1 (s.alertLevel > alOnPreparation.id
AND tp.parkingFk = vParkingFk AND tp.parkingFk = vParkingFk
AND sc.isPackagingArea AND sc.isPackagingArea
AND tp.created < vParked AND tp.created < vParked

View File

@ -10,14 +10,17 @@ BEGIN
*/ */
DECLARE vAlertLevel INT; DECLARE vAlertLevel INT;
DECLARE vAlertLevelPacked INT;
SELECT s.alertLevel INTO vAlertLevel SELECT s.alertLevel, al.id
INTO vAlertLevel, vAlertLevelPacked
FROM state s FROM state s
JOIN ticketStateToday tst ON tst.state = s.id JOIN ticketStateToday tst ON tst.state = s.id
JOIN alertLevel al ON al.code = 'PACKED'
WHERE tst.ticketFk = vTicketFk WHERE tst.ticketFk = vTicketFk
LIMIT 1; LIMIT 1;
IF vAlertLevel < 2 THEN IF vAlertLevel < vAlertLevelPacked THEN
CALL vn.ticket_setState(vTicketFk, vStateCode); CALL vn.ticket_setState(vTicketFk, vStateCode);

View File

@ -1,26 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45))
BEGIN
/*
* @deprecated:utilizar ticket_setState
*/
DECLARE vAlertLevel INT;
SELECT s.alertLevel INTO vAlertLevel
FROM vn.state s
JOIN vn.ticketState ts ON ts.stateFk = s.id
WHERE ts.ticketFk = vTicketFk;
IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN
INSERT INTO ticketTracking(stateFk, ticketFk, userFk)
SELECT id, vTicketFk, account.myUser_getId()
FROM vn.state
WHERE `code` = vStateCode collate utf8_unicode_ci;
END IF;
END$$
DELIMITER ;

View File

@ -13,10 +13,11 @@ BEGIN
CREATE TEMPORARY TABLE tmp.ticket CREATE TEMPORARY TABLE tmp.ticket
SELECT ticketFk SELECT ticketFk
FROM tmp.productionBuffer FROM tmp.productionBuffer
JOIN alertLevel al ON al.code = 'FREE'
WHERE shipped = util.VN_CURDATE() WHERE shipped = util.VN_CURDATE()
AND problem LIKE '%I:%' AND problem LIKE '%I:%'
AND (HH <= vHour OR HH = vHour AND mm < vMinute) AND (HH <= vHour OR HH = vHour AND mm < vMinute)
AND alertLevel = 0; AND alertLevel = al.id;
OPEN cur1; OPEN cur1;

View File

@ -24,8 +24,8 @@ BEGIN
DECLARE vEvaNotes VARCHAR(255); DECLARE vEvaNotes VARCHAR(255);
DECLARE vDone BOOL; DECLARE vDone BOOL;
DECLARE vAuxEntryFk INT; DECLARE vAuxEntryFk INT;
DECLARE vTx BOOLEAN DEFAULT @@in_transaction; DECLARE vIsRequiredTx BOOLEAN DEFAULT NOT @@in_transaction;
DECLARE vRsEntry CURSOR FOR DECLARE vRsEntry CURSOR FOR
SELECT e.id SELECT e.id
FROM entry e FROM entry e
JOIN travel t ON t.id = e.travelFk JOIN travel t ON t.id = e.travelFk
@ -35,11 +35,11 @@ BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
CALL util.tx_rollback(vTx); CALL util.tx_rollback(vIsRequiredTx);
RESIGNAL; RESIGNAL;
END; END;
CALL util.tx_start(vTx); CALL util.tx_start(vIsRequiredTx);
INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom) INSERT INTO travel (shipped, landed, warehouseInFk, warehouseOutFk, agencyModeFk, `ref`, isDelivered, isReceived, m3, cargoSupplierFk, kg,clonedFrom)
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
@ -76,6 +76,6 @@ BEGIN
SET @isModeInventory = FALSE; SET @isModeInventory = FALSE;
CLOSE vRsEntry; CLOSE vRsEntry;
CALL util.tx_commit(vTx); CALL util.tx_commit(vIsRequiredTx);
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -39,7 +39,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`(
*/ */
BEGIN BEGIN
IF vBookNumber IS NULL THEN IF vBookNumber IS NULL THEN
CALL ledger_next(YEAR(vDated), FALSE, vBookNumber); CALL ledger_nextTx(YEAR(vDated), vBookNumber);
END IF; END IF;
INSERT INTO XDiario INSERT INTO XDiario

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete`
BEFORE DELETE ON `buy` BEFORE DELETE ON `buy`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
CALL entry_checkBooked(OLD.entryFk); CALL entry_isEditable(OLD.entryFk);
IF OLD.printedStickers <> 0 THEN IF OLD.printedStickers <> 0 THEN
CALL util.throw("it is not possible to delete buys with printed labels "); CALL util.throw("it is not possible to delete buys with printed labels ");
END IF; END IF;

View File

@ -15,7 +15,7 @@ trig: BEGIN
LEAVE trig; LEAVE trig;
END IF; END IF;
CALL entry_checkBooked(NEW.entryFk); CALL entry_isEditable(NEW.entryFk);
IF NEW.printedStickers <> 0 THEN IF NEW.printedStickers <> 0 THEN
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0'); CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
END IF; END IF;

View File

@ -13,7 +13,7 @@ trig:BEGIN
LEAVE trig; LEAVE trig;
END IF; END IF;
CALL entry_checkBooked(OLD.entryFk); CALL entry_isEditable(OLD.entryFk);
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
SELECT defaultEntry INTO vDefaultEntry SELECT defaultEntry INTO vDefaultEntry

View File

@ -0,0 +1,11 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimRatio_afterInsert`
AFTER INSERT ON `claimRatio`
FOR EACH ROW
BEGIN
INSERT INTO clientRate(clientFk, `value`)
VALUES(NEW.clientFk, NEW.priceIncreasing)
ON DUPLICATE KEY UPDATE
`value` = VALUES(`value`);
END$$
DELIMITER ;

View File

@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
BEFORE DELETE ON `entry` BEFORE DELETE ON `entry`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
CALL entry_checkBooked(OLD.id); CALL entry_isEditable(OLD.id);
DELETE FROM buy WHERE entryFk = OLD.id; DELETE FROM buy WHERE entryFk = OLD.id;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -9,7 +9,7 @@ BEGIN
DECLARE vTotalBuy INT; DECLARE vTotalBuy INT;
IF NEW.isBooked = OLD.isBooked THEN IF NEW.isBooked = OLD.isBooked THEN
CALL entry_checkBooked(OLD.id); CALL entry_isEditable(OLD.id);
ELSE ELSE
IF NEW.isBooked THEN IF NEW.isBooked THEN
SELECT COUNT(*) INTO vTotalBuy SELECT COUNT(*) INTO vTotalBuy

View File

@ -3,8 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInse
BEFORE INSERT ON `expedition` BEFORE INSERT ON `expedition`
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
DECLARE intcounter INT; DECLARE vMaxCounter INT;
DECLARE vShipFk INT;
SET NEW.editorFk = account.myUser_getId(); SET NEW.editorFk = account.myUser_getId();
@ -12,16 +11,17 @@ BEGIN
UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk;
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter
FROM expedition e FROM expedition e
INNER JOIN ticket t1 ON e.ticketFk = t1.id JOIN alertLevel al ON al.code = 'DELIVERED'
JOIN ticket t1 ON e.ticketFk = t1.id
LEFT JOIN ticketState ts ON ts.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticketFk = t1.id
INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped)
AND t1.warehouseFk = t2.warehouseFk AND t1.warehouseFk = t2.warehouseFk
WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk
AND t1.agencyModeFk = t2.agencyModeFk; AND t1.agencyModeFk = t2.agencyModeFk;
SET NEW.`counter` = intcounter; SET NEW.`counter` = vMaxCounter;
END IF; END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -23,7 +23,7 @@ BEGIN
FROM supplier FROM supplier
WHERE id = NEW.supplierFk; WHERE id = NEW.supplierFk;
CALL ledger_next(YEAR(NEW.received), TRUE, vNewBookEntry); CALL ledger_next(YEAR(NEW.received), vNewBookEntry);
INSERT INTO XDiario ( INSERT INTO XDiario (
ASIEN, ASIEN,

View File

@ -8,7 +8,9 @@ BEGIN
SET hasNewRoute = TRUE SET hasNewRoute = TRUE
WHERE ticketFk = NEW.id; WHERE ticketFk = NEW.id;
CALL ticket_doCmr(NEW.id); IF NEW.cmrFk THEN
CALL ticket_doCmr(NEW.id);
END IF;
END IF; END IF;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -8,7 +8,7 @@ AS SELECT `rs`.`id` AS `truckFk`,
`t`.`routeFk` AS `routeFk`, `t`.`routeFk` AS `routeFk`,
`es`.`id` AS `scanFk`, `es`.`id` AS `scanFk`,
`e`.`id` AS `expeditionFk`, `e`.`id` AS `expeditionFk`,
`r`.`expeditionTruckFk` AS `expeditionTruckFk`, `r`.`roadmapStopFk` AS `roadmapStopFk`,
`t`.`warehouseFk` AS `warehouseFk`, `t`.`warehouseFk` AS `warehouseFk`,
`e`.`created` AS `lastPacked`, `e`.`created` AS `lastPacked`,
`t`.`id` AS `ticketFk` `t`.`id` AS `ticketFk`
@ -18,7 +18,7 @@ FROM (
( (
( (
`vn`.`roadmapStop` `rs` `vn`.`roadmapStop` `rs`
LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`expeditionTruckFk`) LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`roadmapStopFk`)
) )
LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`) LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`)
) )

View File

@ -6,7 +6,7 @@ AS SELECT `rs2`.`description` AS `truck`,
`r`.`description` AS `zone`, `r`.`description` AS `zone`,
COUNT(`es`.`id`) AS `eti`, COUNT(`es`.`id`) AS `eti`,
`ep`.`id` AS `palletFk`, `ep`.`id` AS `palletFk`,
`rs`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`, `rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,
`t`.`warehouseFk` AS `warehouseFk`, `t`.`warehouseFk` AS `warehouseFk`,
IF( IF(
`r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY, `r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY,
@ -33,7 +33,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`expeditionTruckFk`) LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`roadmapStopFk`)
) )
GROUP BY `ep`.`id`, GROUP BY `ep`.`id`,
`t`.`routeFk` `t`.`routeFk`

View File

@ -15,7 +15,7 @@ FROM (
`vn`.`route` `r` `vn`.`route` `r`
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`r`.`id` = `rm`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`r`.`id` = `rm`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`)
) )
JOIN `vn`.`ticket` `t` ON(`t`.`routeFk` = `r`.`id`) JOIN `vn`.`ticket` `t` ON(`t`.`routeFk` = `r`.`id`)
) )

View File

@ -45,7 +45,7 @@ FROM (
) )
LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`)
) )
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`)
) )
LEFT JOIN `vn`.`beach` `b` ON(`b`.`code` = `rm`.`beachFk`) LEFT JOIN `vn`.`beach` `b` ON(`b`.`code` = `rm`.`beachFk`)
) )

View File

@ -13,7 +13,7 @@ FROM (
) )
JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`) JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`)
) )
JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`)
) )
WHERE `e`.`id` IS NULL WHERE `e`.`id` IS NULL
AND `rs`.`eta` > `util`.`VN_CURDATE`() AND `rs`.`eta` > `util`.`VN_CURDATE`()

View File

@ -11,9 +11,9 @@ AS SELECT `e`.`truckFk` AS `id`,
COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`,
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
max(`e`.`lastPacked`) AS `lastPacked` max(`e`.`lastPacked`) AS `lastPacked`
FROM `vn`.`expeditionCommon` `e` FROM `vn`.`expeditionCommon` `e`
GROUP BY `e`.`truckFk` GROUP BY `e`.`truckFk`
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
`e`.`eta` `e`.`eta`

View File

@ -7,12 +7,12 @@ AS SELECT `e`.`truckFk` AS `id`,
`e`.`palletFk` AS `pallet`, `e`.`palletFk` AS `pallet`,
COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`,
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
max(`e`.`lastPacked`) AS `lastPacked` max(`e`.`lastPacked`) AS `lastPacked`
FROM `vn`.`expeditionCommon` `e` FROM `vn`.`expeditionCommon` `e`
GROUP BY `e`.`truckFk`, GROUP BY `e`.`truckFk`,
`e`.`palletFk` `e`.`palletFk`
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
`e`.`eta`, `e`.`eta`,
`e`.`truckFk` `e`.`truckFk`

View File

@ -8,15 +8,15 @@ AS SELECT `e`.`truckFk` AS `id`,
`e`.`routeFk` AS `route`, `e`.`routeFk` AS `route`,
COUNT(DISTINCT `e`.`scanFk`) AS `scans`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
`rs`.`description` AS `destinos`, `rs`.`description` AS `destinos`,
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
`e`.`expeditionTruckFk` AS `expeditionTruckFk`, `e`.`roadmapStopFk` AS `roadmapStopFk`,
max(`e`.`lastPacked`) AS `lastPacked` MAX(`e`.`lastPacked`) AS `lastPacked`
FROM ( FROM (
`vn`.`expeditionCommon` `e` `vn`.`expeditionCommon` `e`
LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`roadmapStopFk`)
) )
GROUP BY `e`.`truckFk`, GROUP BY `e`.`truckFk`,
`e`.`palletFk`, `e`.`palletFk`,
`e`.`routeFk` `e`.`routeFk`
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, ORDER BY SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
`e`.`palletFk` `e`.`palletFk`

View File

@ -1,10 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`Saldos_Prevision`
AS SELECT `fb`.`id` AS `Saldos_Prevision_id`,
`fb`.`description` AS `Descripcion`,
`fb`.`amount` AS `Importe`,
`fb`.`dated` AS `Fecha`,
`fb`.`accountingFk` AS `Id_Banco`,
`fb`.`companyFk` AS `empresa_id`
FROM `vn`.`forecastedBalance` `fb`

View File

@ -21,7 +21,6 @@ AS SELECT `t`.`id` AS `Id_Ticket`,
`t`.`workerFk` AS `Id_Trabajador`, `t`.`workerFk` AS `Id_Trabajador`,
`t`.`observations` AS `Observaciones`, `t`.`observations` AS `Observaciones`,
`t`.`isSigned` AS `Firmado`, `t`.`isSigned` AS `Firmado`,
`t`.`isLabeled` AS `Etiquetasemitidas`,
`t`.`isPrinted` AS `PedidoImpreso`, `t`.`isPrinted` AS `PedidoImpreso`,
`t`.`hour` AS `Hora`, `t`.`hour` AS `Hora`,
`t`.`isBlocked` AS `blocked`, `t`.`isBlocked` AS `blocked`,

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.routesMonitor CHANGE expeditionTruckFk roadmapStopFk int(11) DEFAULT NULL NULL;
ALTER TABLE vn.routesMonitor ADD COLUMN expeditionTruckFk int(11) AS (roadmapStopFk) VIRTUAL;

View File

@ -0,0 +1 @@
ALTER TABLE vn.country DROP COLUMN country;

View File

@ -0,0 +1,3 @@
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Ticket','refund','WRITE','ALLOW','ROLE','logistic');

View File

@ -0,0 +1,9 @@
CREATE TABLE `vn`.`clientRate` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`clientFk` int(11) NOT NULL,
`dated` date NOT NULL DEFAULT current_timestamp(),
`value` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `clientRate_unique` (`clientFk`,`dated`),
CONSTRAINT `clientRate_client_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;

View File

@ -0,0 +1,4 @@
ALTER TABLE vn.ticket MODIFY COLUMN IF EXISTS isLabeled__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7496 deprecated 2024-06-20';
ALTER TABLE IF EXISTS vn.forecastedBalance RENAME vn.forecastedBalance__ ;
ALTER TABLE IF EXISTS vn.forecastedBalance__ COMMENT='@deprecated 2024-05-21';

View File

@ -0,0 +1,3 @@
INSERT INTO salix.ACL(model,property,accessType,permission,principalType,principalId)
VALUES('InvoiceIn', 'create', 'WRITE', 'ALLOW', 'ROLE', 'administrative'),
('InvoiceIn', 'create', 'WRITE', 'ALLOW', 'ROLE', 'buyer');

View File

@ -0,0 +1 @@
CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate,changedModel,`action`);

View File

@ -229,5 +229,8 @@
"InvoiceIn is already booked": "InvoiceIn is already booked", "InvoiceIn is already booked": "InvoiceIn is already booked",
"This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency",
"You can only have one PDA": "You can only have one PDA", "You can only have one PDA": "You can only have one PDA",
"Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member" "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member",
"It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated",
"It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated"
} }

View File

@ -359,8 +359,10 @@
"Select ticket or client": "Elija un ticket o un client", "Select ticket or client": "Elija un ticket o un client",
"It was not able to create the invoice": "No se pudo crear la factura", "It was not able to create the invoice": "No se pudo crear la factura",
"ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)",
"This PDA is already assigned to another user": "Esta PDA ya está asignado a otro usuario",
"You can only have one PDA": "Solo puedes tener una PDA",
"Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE",
"You can not use the same password": "No puedes usar la misma contraseña" "You can not use the same password": "No puedes usar la misma contraseña",
"This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario",
"You can only have one PDA": "Solo puedes tener un PDA",
"It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF",
"It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono"
} }

View File

@ -357,5 +357,7 @@
"InvoiceIn is already booked": "La facture reçue est déjà comptabilisée", "InvoiceIn is already booked": "La facture reçue est déjà comptabilisée",
"This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence", "This workCenter is already assigned to this agency": "Ce centre de travail est déjà assigné à cette agence",
"Select ticket or client": "Choisissez un ticket ou un client", "Select ticket or client": "Choisissez un ticket ou un client",
"It was not able to create the invoice": "Il n'a pas été possible de créer la facture" "It was not able to create the invoice": "Il n'a pas été possible de créer la facture",
"It has been invoiced but the PDF could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré",
"It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré"
} }

View File

@ -357,5 +357,7 @@
"InvoiceIn is already booked": "InvoiceIn já está reservado", "InvoiceIn is already booked": "InvoiceIn já está reservado",
"This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência", "This workCenter is already assigned to this agency": "Este centro de trabalho já está atribuído a esta agência",
"Select ticket or client": "Selecione um ticket ou cliente", "Select ticket or client": "Selecione um ticket ou cliente",
"It was not able to create the invoice": "Não foi possível criar a fatura" "It was not able to create the invoice": "Não foi possível criar a fatura",
"It has been invoiced but the PDF could not be generated": "Foi faturado, mas o PDF não pôde ser gerado",
"It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso"
} }

View File

@ -1,6 +1,9 @@
{ {
"name": "RoleInherit", "name": "RoleInherit",
"base": "VnModel", "base": "VnModel",
"mixins": {
"Loggable": true
},
"options": { "options": {
"mysql": { "mysql": {
"table": "account.roleInherit" "table": "account.roleInherit"

View File

@ -1,4 +1,3 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const LoopBackContext = require('loopback-context');
@ -17,26 +16,27 @@ describe('InvoiceOut transferInvoice()', () => {
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx active: activeCtx
}); });
spyOn(models.InvoiceOut, 'makePdfAndNotify');
}); });
it('should return the id of the created issued invoice', async() => { it('should return the id of the created issued invoice', async() => {
const tx = await models.InvoiceOut.beginTransaction({}); const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};
const args = { const id = 4;
id: '4', const newClient = 1;
refFk: 'T4444444', spyOn(models.InvoiceOut, 'makePdfList');
newClientFk: 1,
cplusRectificationTypeFk: 1,
siiTypeInvoiceOutFk: 1,
invoiceCorrectionTypeFk: 1
};
ctx.args = args;
try { try {
const {clientFk: oldClient} = await models.InvoiceOut.findById(args.id, {fields: ['clientFk']}); const {clientFk: oldClient} = await models.InvoiceOut.findById(id, {fields: ['clientFk']});
const invoicesBefore = await models.InvoiceOut.find({}, options); const invoicesBefore = await models.InvoiceOut.find({}, options);
const result = await models.InvoiceOut.transferInvoice( const result = await models.InvoiceOut.transferInvoice(
ctx, ctx,
id,
'T4444444',
newClient,
1,
1,
1,
true,
options); options);
const invoicesAfter = await models.InvoiceOut.find({}, options); const invoicesAfter = await models.InvoiceOut.find({}, options);
const rectificativeInvoice = invoicesAfter[invoicesAfter.length - 2]; const rectificativeInvoice = invoicesAfter[invoicesAfter.length - 2];
@ -45,7 +45,7 @@ describe('InvoiceOut transferInvoice()', () => {
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(invoicesAfter.length - invoicesBefore.length).toEqual(2); expect(invoicesAfter.length - invoicesBefore.length).toEqual(2);
expect(rectificativeInvoice.clientFk).toEqual(oldClient); expect(rectificativeInvoice.clientFk).toEqual(oldClient);
expect(newInvoice.clientFk).toEqual(args.newClientFk); expect(newInvoice.clientFk).toEqual(newClient);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
@ -54,22 +54,13 @@ describe('InvoiceOut transferInvoice()', () => {
} }
}); });
it('should throw an UserError when it is the same client', async() => { it('should throw an error when it is the same client', async() => {
const tx = await models.InvoiceOut.beginTransaction({}); const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};
const args = { spyOn(models.InvoiceOut, 'makePdfList');
id: '1',
refFk: 'T1111111',
newClientFk: 1101,
cplusRectificationTypeFk: 1,
siiTypeInvoiceOutFk: 1,
invoiceCorrectionTypeFk: 1
};
ctx.args = args;
try { try {
await models.InvoiceOut.transferInvoice( await models.InvoiceOut.transferInvoice(ctx, '1', 'T1111111', 1101, 1, 1, 1, true, options);
ctx,
options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
expect(e.message).toBe(`Select a different client`); expect(e.message).toBe(`Select a different client`);
@ -77,26 +68,49 @@ describe('InvoiceOut transferInvoice()', () => {
} }
}); });
it('should throw an UserError when it is refund', async() => { it('should throw an error when it is refund', async() => {
const tx = await models.InvoiceOut.beginTransaction({}); const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx}; const options = {transaction: tx};
const args = { spyOn(models.InvoiceOut, 'makePdfList');
id: '1',
refFk: 'T1111111',
newClientFk: 1102,
cplusRectificationTypeFk: 1,
siiTypeInvoiceOutFk: 1,
invoiceCorrectionTypeFk: 1
};
ctx.args = args;
try { try {
await models.InvoiceOut.transferInvoice( await models.InvoiceOut.transferInvoice(ctx, '1', 'T1111111', 1102, 1, 1, 1, true, options);
ctx,
options);
await tx.rollback(); await tx.rollback();
} catch (e) { } catch (e) {
expect(e.message).toContain(`This ticket is already a refund`); expect(e.message).toContain(`This ticket is already a refund`);
await tx.rollback(); await tx.rollback();
} }
}); });
it('should throw an error when pdf failed', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
spyOn(models.InvoiceOut, 'makePdfList').and.returnValue(() => {
throw new Error('test');
});
try {
await models.InvoiceOut.transferInvoice(ctx, '1', 'T1111111', 1102, 1, 1, 1, true, options);
await tx.rollback();
} catch (e) {
expect(e.message).toContain(`It has been invoiced but the PDF could not be generated`);
await tx.rollback();
}
});
it('should not generate an invoice', async() => {
const tx = await models.InvoiceOut.beginTransaction({});
const options = {transaction: tx};
spyOn(models.InvoiceOut, 'makePdfList');
let response;
try {
response = await models.InvoiceOut.transferInvoice(ctx, '1', 'T1111111', 1102, 1, 1, 1, false, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(response).not.toBeDefined();
});
}); });

View File

@ -37,13 +37,13 @@ module.exports = Self => {
required: true required: true
}, },
{ {
arg: 'checked', arg: 'makeInvoice',
type: 'boolean', type: 'boolean',
required: true required: true
}, },
], ],
returns: { returns: {
type: 'boolean', type: 'object',
root: true root: true
}, },
http: { http: {
@ -52,11 +52,22 @@ module.exports = Self => {
} }
}); });
Self.transferInvoice = async(ctx, options) => { Self.transferInvoice = async(
ctx,
id,
refFk,
newClientFk,
cplusRectificationTypeFk,
siiTypeInvoiceOutFk,
invoiceCorrectionTypeFk,
makeInvoice,
options
) => {
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; let invoiceId;
const checked = ctx.args.checked; let refundId;
let tx; let tx;
if (typeof options == 'object') if (typeof options == 'object')
Object.assign(myOptions, options); Object.assign(myOptions, options);
@ -100,15 +111,29 @@ module.exports = Self => {
}; };
const refundTicketIds = refundTickets.map(ticket => ticket.id); const refundTicketIds = refundTickets.map(ticket => ticket.id);
await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions); refundId = await models.Ticket.invoiceTickets(ctx, refundTicketIds, invoiceCorrection, myOptions);
if (!checked) { if (makeInvoice)
const [invoiceId] = await models.Ticket.invoiceTicketsAndPdf(ctx, clonedTicketIds, null, myOptions); invoiceId = await models.Ticket.invoiceTickets(ctx, clonedTicketIds, null, myOptions);
return invoiceId;
} tx && await tx.commit();
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
throw e; throw e;
} }
if (tx && makeInvoice) {
try {
await models.InvoiceOut.makePdfList(ctx, invoiceId);
} catch (e) {
throw new UserError('It has been invoiced but the PDF could not be generated');
}
try {
await models.InvoiceOut.makePdfList(ctx, refundId);
} catch (e) {
throw new UserError('It has been invoiced but the PDF of refund not be generated');
}
}
return invoiceId;
}; };
}; };

View File

@ -158,7 +158,7 @@ class Controller extends Section {
cplusRectificationTypeFk: this.cplusRectificationType, cplusRectificationTypeFk: this.cplusRectificationType,
siiTypeInvoiceOutFk: this.siiTypeInvoiceOut, siiTypeInvoiceOutFk: this.siiTypeInvoiceOut,
invoiceCorrectionTypeFk: this.invoiceCorrectionType, invoiceCorrectionTypeFk: this.invoiceCorrectionType,
checked: this.checked makeInvoice: this.checked
}; };
this.$http.get(`Clients/${this.clientId}`).then(response => { this.$http.get(`Clients/${this.clientId}`).then(response => {

View File

@ -135,6 +135,7 @@ module.exports = Self => {
const now = Date.vnNew(); const now = Date.vnNew();
const ticket = await models.Ticket.findById(ticketId, null, myOptions); const ticket = await models.Ticket.findById(ticketId, null, myOptions);
if (!ctx.args) ctx.args = {};
ctx.args.clientId = ticket.clientFk; ctx.args.clientId = ticket.clientFk;
ctx.args.shipped = now; ctx.args.shipped = now;
ctx.args.landed = now; ctx.args.landed = now;

View File

@ -140,14 +140,7 @@ module.exports = Self => {
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
await ticket.updateAttribute('isSigned', true, myOptions); await ticket.updateAttribute('isSigned', true, myOptions);
const deliveryState = await models.State.findOne({ await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
where: {code: 'DELIVERED'}
}, myOptions);
await models.Ticket.state(ctx, {
ticketFk: ticketId,
stateFk: deliveryState.id
}, myOptions);
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) { if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
await models.Ticket.saveCmr(ctx, [ticketId], myOptions); await models.Ticket.saveCmr(ctx, [ticketId], myOptions);

View File

@ -71,7 +71,10 @@ module.exports = Self => {
// Check for existing purchase requests // Check for existing purchase requests
const hasPurchaseRequests = await models.TicketRequest.count({ const hasPurchaseRequests = await models.TicketRequest.count({
ticketFk: id, ticketFk: id,
isOk: true or: [
{isOk: true},
{isOk: null}
]
}, myOptions); }, myOptions);
if (hasPurchaseRequests) if (hasPurchaseRequests)

View File

@ -49,7 +49,7 @@ describe('ticket setDeleted()', () => {
ctx.req.__ = value => { ctx.req.__ = value => {
return value; return value;
}; };
const ticketId = 23; const ticketId = 24;
const [sectorCollectionBefore] = await models.Ticket.rawSql( const [sectorCollectionBefore] = await models.Ticket.rawSql(
`SELECT COUNT(*) numberRows `SELECT COUNT(*) numberRows
FROM vn.sectorCollection`, [], options); FROM vn.sectorCollection`, [], options);
@ -87,7 +87,7 @@ describe('ticket setDeleted()', () => {
const [ticketCollectionOld] = await models.Ticket.rawSql( const [ticketCollectionOld] = await models.Ticket.rawSql(
`SELECT COUNT(*) numberRows `SELECT COUNT(*) numberRows
FROM vn.ticketCollection`, [], options); FROM vn.ticketCollection`, [], options);
const ticketId = 23; const ticketId = 34;
await models.Ticket.setDeleted(ctx, ticketId, options); await models.Ticket.setDeleted(ctx, ticketId, options);

View File

@ -1,5 +1,6 @@
import ngModule from '../module'; import ngModule from '../module';
import ModuleCard from 'salix/components/module-card'; import ModuleCard from 'salix/components/module-card';
import UserError from 'core/lib/user-error';
class Controller extends ModuleCard { class Controller extends ModuleCard {
reload() { reload() {
@ -59,6 +60,10 @@ class Controller extends ModuleCard {
], ],
}; };
if (!this.$params.id) {
this.$state.go('ticket.index');
throw new UserError(`You must select a ticket`);
}
return this.$http.get(`Tickets/${this.$params.id}`, {filter}) return this.$http.get(`Tickets/${this.$params.id}`, {filter})
.then(res => this.onData(res.data)); .then(res => this.onData(res.data));
} }

View File

@ -152,7 +152,7 @@
</vn-item> </vn-item>
<vn-item class="dropdown" <vn-item class="dropdown"
vn-click-stop="refundMenu.show($event, 'left')" vn-click-stop="refundMenu.show($event, 'left')"
vn-acl="invoicing, claimManager, salesAssistant" vn-acl="invoicing, claimManager, salesAssistant, logistic"
vn-acl-action="remove" vn-acl-action="remove"
vn-tooltip="Create a single ticket with all the content of the current ticket" vn-tooltip="Create a single ticket with all the content of the current ticket"
translate> translate>

View File

@ -64,6 +64,7 @@ You are going to delete this ticket: Vas a eliminar este ticket
Ticket deleted. You can undo this action within the first hour: Ticket eliminado. Puedes deshacer esta acción durante la primera hora Ticket deleted. You can undo this action within the first hour: Ticket eliminado. Puedes deshacer esta acción durante la primera hora
Search ticket by id or alias: Buscar tickets por identificador o alias Search ticket by id or alias: Buscar tickets por identificador o alias
ticket: ticket ticket: ticket
You must select a ticket: Debes seleccionar un ticket
#sections #sections
List: Listado List: Listado

View File

@ -26,18 +26,17 @@ module.exports = Self => {
Self.cloneWithEntries = async(ctx, id, options) => { Self.cloneWithEntries = async(ctx, id, options) => {
const conn = Self.dataSource.connector; const conn = Self.dataSource.connector;
let tx;
const myOptions = {}; const myOptions = {};
let tx = options?.transaction;
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
try { try {
if (typeof options == 'object')
Object.assign(myOptions, options);
if (!myOptions.transaction) {
tx = await Self.beginTransaction({});
myOptions.transaction = tx;
}
const travel = await Self.findById(id, { const travel = await Self.findById(id, {
fields: [ fields: [
'id', 'id',
@ -89,6 +88,8 @@ module.exports = Self => {
'ref' 'ref'
] ]
}, myOptions); }, myOptions);
if (tx) await tx.commit();
return newTravel.id; return newTravel.id;
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();

View File

@ -7,19 +7,22 @@ describe('Travel cloneWithEntries()', () => {
const ctx = {req: {accessToken: {userId: currentUserId}}}; const ctx = {req: {accessToken: {userId: currentUserId}}};
let newTravelId; let newTravelId;
it(`should clone the travel and the containing entries`, async() => { it(`should clone the travel and the containing entries`, async() => {
const tx = await models.Travel.beginTransaction({ const tx = await models.Travel.beginTransaction({});
});
const warehouseThree = 3; const warehouseThree = 3;
const agencyModeOne = 1; const agencyModeOne = 1;
let travelRemoved;
try { try {
const options = {transaction: tx}; const options = {transaction: tx};
newTravelId = await models.Travel.cloneWithEntries(ctx, travelId, options); newTravelId = await models.Travel.cloneWithEntries(ctx, travelId, options);
const travelEntries = await models.Entry.find({ const travelEntries = await models.Entry.find({
where: { where: {
travelFk: newTravelId travelFk: newTravelId
} }
}, options); }, options);
const newTravel = await models.Travel.findById(travelId); const newTravel = await models.Travel.findById(travelId, null, options);
travelRemoved = await models.Travel.findById(newTravelId);
expect(newTravelId).not.toEqual(travelId); expect(newTravelId).not.toEqual(travelId);
expect(newTravel.ref).toEqual('fifth travel'); expect(newTravel.ref).toEqual('fifth travel');
@ -27,14 +30,9 @@ describe('Travel cloneWithEntries()', () => {
expect(newTravel.warehouseOutFk).toEqual(warehouseThree); expect(newTravel.warehouseOutFk).toEqual(warehouseThree);
expect(newTravel.agencyModeFk).toEqual(agencyModeOne); expect(newTravel.agencyModeFk).toEqual(agencyModeOne);
expect(travelEntries.length).toBeGreaterThan(0); expect(travelEntries.length).toBeGreaterThan(0);
await models.Entry.destroyAll({
travelFk: newTravelId
}, options);
await models.Travel.destroyById(newTravelId, options);
await tx.rollback();
const travelRemoved = await models.Travel.findById(newTravelId, options);
expect(travelRemoved).toBeNull(); expect(travelRemoved).toBeNull();
await tx.rollback();
} catch (e) { } catch (e) {
if (tx) await tx.rollback(); if (tx) await tx.rollback();
throw e; throw e;

View File

@ -20,7 +20,7 @@ module.exports = Self => {
const notifications = await models.NotificationQueue.find( const notifications = await models.NotificationQueue.find(
{where: {created: {gte: new Date(Date.vnNow() - (backupPrinterNotificationDelay * 1000))}, {where: {created: {gte: new Date(Date.vnNow() - (backupPrinterNotificationDelay * 1000))},
notificationFk: notificationName, notificationFk: notificationName,
status: 'sent' status: {neq: 'error'}
} }
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-back", "name": "salix-back",
"version": "24.24.3", "version": "24.26.0",
"author": "Verdnatura Levante SL", "author": "Verdnatura Levante SL",
"description": "Salix backend", "description": "Salix backend",
"license": "GPL-3.0", "license": "GPL-3.0",

View File

@ -35,7 +35,7 @@ SELECT c.itemPackingTypeFk code,
LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id
LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk
LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN vn.productionConfig pc JOIN vn.productionConfig pc
WHERE t.id IN (?) WHERE t.id IN (?)

View File

@ -5,7 +5,7 @@ SELECT ep.id palletFk,
COUNT(es.id) labels, COUNT(es.id) labels,
t.warehouseFk warehouseFk, t.warehouseFk warehouseFk,
dayname(r.created) `dayName`, dayname(r.created) `dayName`,
rs.id <=> rm.expeditionTruckFk isMatch rs.id <=> rm.roadmapStopFk isMatch
FROM vn.roadmapStop rs FROM vn.roadmapStop rs
JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id
JOIN vn.expeditionScan es ON es.palletFk = ep.id JOIN vn.expeditionScan es ON es.palletFk = ep.id
@ -13,7 +13,7 @@ SELECT ep.id palletFk,
JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.ticket t ON t.id = e.ticketFk
JOIN vn.route r ON r.id = t.routeFk JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.expeditionTruckFk LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.roadmapStopFk
WHERE ep.id = ? WHERE ep.id = ?
GROUP BY ep.id, t.routeFk GROUP BY ep.id, t.routeFk
ORDER BY t.routeFk ORDER BY t.routeFk