Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 6897-entryMigration
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
4508f7bfff
|
@ -103,7 +103,7 @@ pipeline {
|
|||
NODE_ENV = ''
|
||||
}
|
||||
steps {
|
||||
sh 'node back/tests.js --ci --junit --network jenkins'
|
||||
sh 'node back/tests.js --junit'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
|
@ -121,7 +121,7 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
def packageJson = readJSON file: 'package.json'
|
||||
env.VERSION = packageJson.version
|
||||
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||
}
|
||||
sh 'docker-compose build back'
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
def packageJson = readJSON file: 'package.json'
|
||||
env.VERSION = packageJson.version
|
||||
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||
}
|
||||
sh 'gulp build'
|
||||
sh 'docker-compose build front'
|
||||
|
@ -179,7 +179,7 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
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-compose push'
|
||||
|
@ -210,7 +210,7 @@ pipeline {
|
|||
steps {
|
||||
script {
|
||||
def packageJson = readJSON file: 'package.json'
|
||||
env.VERSION = packageJson.version
|
||||
env.VERSION = "${packageJson.version}-vn${env.BUILD_ID}"
|
||||
}
|
||||
withKubeConfig([
|
||||
serverUrl: "$KUBERNETES_API",
|
||||
|
|
|
@ -26,10 +26,11 @@
|
|||
<mrw:Nif><%= expeditionData.fi %></mrw:Nif>
|
||||
<mrw:Nombre><%= expeditionData.clientName %></mrw:Nombre>
|
||||
<mrw:Telefono><%= expeditionData.phone %></mrw:Telefono>
|
||||
<mrw:Observaciones><%= expeditionData.deliveryObservation %></mrw:Observaciones>
|
||||
</mrw:DatosEntrega>
|
||||
<mrw:DatosServicio>
|
||||
<mrw:Fecha><%= expeditionData.created %></mrw:Fecha>
|
||||
<mrw:Referencia><%= expeditionData.expeditionDataId %></mrw:Referencia>
|
||||
<mrw:Referencia><%= expeditionData.reference %></mrw:Referencia>
|
||||
<mrw:CodigoServicio><%= expeditionData.serviceType %></mrw:CodigoServicio>
|
||||
<mrw:NumeroBultos>1</mrw:NumeroBultos>
|
||||
<mrw:EntregaSabado><%= expeditionData.weekDays %></mrw:EntregaSabado>
|
||||
|
|
|
@ -45,7 +45,7 @@ module.exports = Self => {
|
|||
`SELECT
|
||||
CASE co.code
|
||||
WHEN 'ES' THEN a.postalCode
|
||||
WHEN 'PT' THEN LEFT(a.postalCode, 4)
|
||||
WHEN 'PT' THEN LEFT(a.postalCode, mc.portugalPostCodeTrim)
|
||||
WHEN 'AD' THEN REPLACE(a.postalCode, 'AD', '00')
|
||||
END postalCode,
|
||||
a.city,
|
||||
|
@ -56,18 +56,23 @@ module.exports = Self => {
|
|||
c.phone,
|
||||
DATE_FORMAT(t.shipped, '%d/%m/%Y') created,
|
||||
t.shipped,
|
||||
e.id expeditionId,
|
||||
LPAD(IF(mw.params IS NULL, ms.serviceType, mw.serviceType), 4 ,'0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays
|
||||
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
|
||||
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth,'0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||
oa.description deliveryObservation
|
||||
FROM expedition e
|
||||
JOIN ticket t ON e.ticketFk = t.id
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
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 address a ON t.addressFk = a.id
|
||||
LEFT JOIN addressObservation oa ON oa.addressFk = a.id
|
||||
LEFT JOIN observationType ot ON ot.id = oa.observationTypeFk
|
||||
AND ot.code = 'delivery'
|
||||
JOIN province p ON a.provinceFk = p.id
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN mrwConfig mc
|
||||
WHERE e.id = ?
|
||||
LIMIT 1`;
|
||||
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
{
|
||||
"name": "Collection",
|
||||
"base": "VnModel",
|
||||
"properties": {
|
||||
"id": {
|
||||
"id": true,
|
||||
"type": "number",
|
||||
"required": true
|
||||
},
|
||||
"workerFk": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "collection"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
},
|
||||
"vn": {
|
||||
"view": {
|
||||
"expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54"
|
||||
"expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ INSERT INTO vn.itemShelving (id,itemFk,visible,shelvingFk,`grouping`,packing,pac
|
|||
INSERT INTO vn.beach (code,warehouseFk) VALUES
|
||||
('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);
|
||||
/* #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)
|
||||
|
|
|
@ -762,7 +762,12 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF
|
|||
(30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL);
|
||||
(33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL),
|
||||
(34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||
(35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||
(36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL),
|
||||
(37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL);
|
||||
|
||||
INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`)
|
||||
VALUES
|
||||
(1, 11, 1, 'ready'),
|
||||
|
@ -808,7 +813,10 @@ INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `userFk`, `created`)
|
|||
(21, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
|
||||
(22, 1, 19, DATE_ADD(util.VN_NOW(), INTERVAL +1 MONTH)),
|
||||
(23, 16, 21, util.VN_NOW()),
|
||||
(24, 16, 21, util.VN_NOW());
|
||||
(24, 16, 21, util.VN_NOW()),
|
||||
(34, 14, 49, util.VN_NOW()),
|
||||
(35, 14, 18, util.VN_NOW()),
|
||||
(36, 14, 18, util.VN_NOW());
|
||||
|
||||
INSERT INTO `vn`.`deliveryPoint` (`id`, `name`, `ubication`)
|
||||
VALUES
|
||||
|
@ -1068,7 +1076,10 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric
|
|||
(37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()),
|
||||
(38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)),
|
||||
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE());
|
||||
(39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()),
|
||||
(40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE()),
|
||||
(41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE()),
|
||||
(42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE());
|
||||
|
||||
INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`)
|
||||
VALUES
|
||||
|
@ -1247,14 +1258,20 @@ INSERT INTO `vn`.`operator` (`workerFk`, `numberOfWagons`, `trainFk`, `itemPacki
|
|||
INSERT INTO `vn`.`collection`(`id`, `workerFk`, `stateFk`, `created`, `trainFk`)
|
||||
VALUES
|
||||
(1, 1106, 5, DATE_ADD(util.VN_CURDATE(),INTERVAL +1 DAY), 1),
|
||||
(2, 1106, 14, util.VN_CURDATE(), 1);
|
||||
(2, 1106, 14, util.VN_CURDATE(), 1),
|
||||
(4, 49, 5, util.VN_CURDATE(), 1),
|
||||
(5, 18, 5, util.VN_CURDATE(), 1),
|
||||
(6, 18, 5, util.VN_CURDATE(), 1);
|
||||
|
||||
INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`)
|
||||
VALUES
|
||||
(1, 1, 1),
|
||||
(2, 1, NULL),
|
||||
(3, 2, NULL),
|
||||
(23, 1, NULL);
|
||||
(23, 1, NULL),
|
||||
(34, 4, 1),
|
||||
(35, 5, 1),
|
||||
(8, 6, 1);
|
||||
|
||||
INSERT INTO `vn`.`genus`(`id`, `name`)
|
||||
VALUES
|
||||
|
@ -3705,7 +3722,8 @@ INSERT IGNORE INTO vn.saleGroup
|
|||
SET id = 4,
|
||||
userFk = 1,
|
||||
parkingFk = 9,
|
||||
sectorFk = 9992;
|
||||
sectorFk = 9992,
|
||||
ticketFk = 36;
|
||||
|
||||
INSERT IGNORE INTO vn.sectorCollectionSaleGroup
|
||||
SET id = 9999,
|
||||
|
@ -3807,3 +3825,27 @@ INSERT INTO `vn`.`ledgerCompany` SET
|
|||
|
||||
INSERT INTO `vn`.`ledgerConfig` SET
|
||||
maxTolerance = 0.01;
|
||||
|
||||
INSERT INTO vn.sectorCollection
|
||||
SET id = 2,
|
||||
userFk = 18,
|
||||
sectorFk = 1;
|
||||
|
||||
INSERT INTO vn.sectorCollectionSaleGroup
|
||||
SET id = 8,
|
||||
sectorCollectionFk = 2,
|
||||
saleGroupFk = 4;
|
||||
|
||||
INSERT INTO vn.saleGroup (userFk, parkingFk, sectorFk, ticketFk)
|
||||
VALUES
|
||||
(1, 1, 1, 37);
|
||||
|
||||
INSERT INTO vn.sectorCollection
|
||||
SET id = 3,
|
||||
userFk = 18,
|
||||
sectorFk = 1;
|
||||
|
||||
INSERT INTO vn.sectorCollectionSaleGroup
|
||||
SET id = 9,
|
||||
sectorCollectionFk = 3,
|
||||
saleGroupFk = 6;
|
|
@ -65,11 +65,12 @@ BEGIN
|
|||
JOIN vn.ticketLastState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk
|
||||
JOIN vn.state st ON st.id = tt.stateFk
|
||||
JOIN vn.alertLevel al ON al.code = 'DELIVERED'
|
||||
WHERE sc.componentFk = 17
|
||||
AND sc.isGreuge = 0
|
||||
AND t.shipped >= '2016-10-01'
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
AND st.alertLevel >= 3;
|
||||
AND st.alertLevel >= al.id;
|
||||
|
||||
DELETE g.*
|
||||
FROM vn.greuge g
|
||||
|
|
|
@ -46,7 +46,7 @@ BEGIN
|
|||
JOIN vn.address a ON a.id = t.addressFk
|
||||
JOIN vn.province p ON p.id = a.provinceFk
|
||||
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.`zone`z ON z.id = t.zoneFk
|
||||
JOIN vn.agencyMode am ON t.agencyModeFk = am.id
|
||||
|
|
|
@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_getVisible
|
|||
vType INT,
|
||||
vPrefix VARCHAR(255))
|
||||
BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* Gets visible items of the specified type at specified date.
|
||||
*
|
||||
|
@ -14,7 +14,7 @@ BEGIN
|
|||
* @param vType The type id
|
||||
* @param vPrefix The article prefix to filter or %NULL for all
|
||||
* @return tmp.itemVisible Visible items
|
||||
*/
|
||||
*/
|
||||
DECLARE vPrefixLen SMALLINT;
|
||||
DECLARE vFilter VARCHAR(255) DEFAULT NULL;
|
||||
DECLARE vDateInv DATE DEFAULT vn.getInventoryDate();
|
||||
|
@ -23,13 +23,13 @@ BEGIN
|
|||
GET DIAGNOSTICS CONDITION 1
|
||||
@message = MESSAGE_TEXT;
|
||||
CALL vn.mail_insert(
|
||||
'cau@verdnatura.es',
|
||||
NULL,
|
||||
'cau@verdnatura.es',
|
||||
NULL,
|
||||
CONCAT('hedera.item_getVisible error: ', @message),
|
||||
CONCAT(
|
||||
'warehouse: ', IFNULL(vWarehouse, ''),
|
||||
', Fecha:', IFNULL(vDate, ''),
|
||||
', tipo: ', IFNULL(vType,''),
|
||||
'warehouse: ', IFNULL(vWarehouse, ''),
|
||||
', Fecha:', IFNULL(vDate, ''),
|
||||
', tipo: ', IFNULL(vType,''),
|
||||
', prefijo: ', IFNULL(vPrefix,'')));
|
||||
RESIGNAL;
|
||||
END;
|
||||
|
@ -74,9 +74,10 @@ BEGIN
|
|||
FROM vn.sale m
|
||||
JOIN vn.ticket t ON t.id = m.ticketFk
|
||||
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()
|
||||
AND t.warehouseFk = vWarehouse
|
||||
AND s.alertLevel = 3
|
||||
AND s.alertLevel = al.id
|
||||
) t
|
||||
GROUP BY itemFk
|
||||
HAVING quantity > 0;
|
||||
|
@ -108,7 +109,7 @@ BEGIN
|
|||
IF(p.depth > 0, p.depth, 0) depth, p.width, p.height,
|
||||
CEIL(s.quantity / t.packing) etiquetas
|
||||
FROM vn.item i
|
||||
JOIN `filter` f ON f.itemFk = i.id
|
||||
JOIN `filter` f ON f.itemFk = i.id
|
||||
JOIN currentStock s ON s.itemFk = i.id
|
||||
LEFT JOIN tmp t ON t.itemFk = i.id
|
||||
LEFT JOIN vn.packaging p ON p.id = t.packagingFk
|
||||
|
|
|
@ -62,7 +62,7 @@ BEGIN
|
|||
END;
|
||||
|
||||
-- Carga los datos del pedido
|
||||
SELECT o.date_send, o.address_id, o.note, a.clientFk,
|
||||
SELECT o.date_send, o.address_id, o.note, a.clientFk,
|
||||
o.company_id, o.agency_id, c.isTaxDataChecked
|
||||
INTO vDelivery, vAddress, vNotes, vClientId,
|
||||
vCompanyId, vAgencyModeId, vIsTaxDataChecked
|
||||
|
@ -121,6 +121,7 @@ BEGIN
|
|||
)
|
||||
SELECT t.id INTO vTicket
|
||||
FROM vn.ticket t
|
||||
JOIN vn.alertLevel al ON al.code = 'FREE'
|
||||
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
|
||||
LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
|
||||
JOIN hedera.`order` o
|
||||
|
@ -131,7 +132,7 @@ BEGIN
|
|||
WHERE o.id = vSelf
|
||||
AND t.refFk 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;
|
||||
|
||||
-- Crea el ticket en el caso de no existir uno adecuado
|
||||
|
|
|
@ -22,7 +22,7 @@ BEGIN
|
|||
LEFT JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
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;
|
||||
|
||||
RETURN vDayMinute;
|
||||
|
|
|
@ -34,7 +34,7 @@ FROM (
|
|||
)
|
||||
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`)
|
||||
)
|
||||
|
|
|
@ -45,7 +45,7 @@ FROM (
|
|||
)
|
||||
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`
|
||||
)
|
||||
|
|
|
@ -32,7 +32,7 @@ FROM (
|
|||
)
|
||||
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`)
|
||||
)
|
||||
|
|
|
@ -16,12 +16,13 @@ BEGIN
|
|||
m.created,
|
||||
TIMESTAMPADD(DAY, tp.life, t.shipped) expired,
|
||||
m.quantity < 0 isIn,
|
||||
m.isPicked OR s.alertLevel > 1 isPicked
|
||||
m.isPicked OR s.alertLevel > al.id isPicked
|
||||
FROM vn.sale m
|
||||
JOIN vn.ticket t ON t.id = m.ticketFk
|
||||
JOIN vn.ticketState s ON s.ticketFk = t.id
|
||||
JOIN vn.item i ON i.id = m.itemFk
|
||||
JOIN vn.itemType tp ON tp.id = i.typeFk
|
||||
JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION'
|
||||
WHERE (
|
||||
vTableId IS NULL
|
||||
OR (vTableName = 'ticket' AND t.id = vTableId)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
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
|
||||
/**
|
||||
* 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;
|
||||
END IF;
|
||||
END$$
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
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
|
||||
/**
|
||||
* 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;
|
||||
END IF;
|
||||
END$$
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
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
|
||||
/**
|
||||
* 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;
|
||||
END IF;
|
||||
END$$
|
||||
|
|
|
@ -11,10 +11,7 @@ BEGIN
|
|||
*/
|
||||
DECLARE vClient INT DEFAULT NULL;
|
||||
|
||||
-- SET vPhone = vPhone COLLATE 'utf8_unicode_ci';
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tClient;
|
||||
CREATE TEMPORARY TABLE tClient
|
||||
CREATE OR REPLACE TEMPORARY TABLE tClient
|
||||
ENGINE = MEMORY
|
||||
SELECT id clientFk
|
||||
FROM `client`
|
||||
|
@ -27,13 +24,14 @@ BEGIN
|
|||
OR mobile = vPhone
|
||||
UNION
|
||||
SELECT clientFk
|
||||
FROM vn.clientContact
|
||||
FROM clientContact
|
||||
WHERE phone = vPhone;
|
||||
|
||||
SELECT t.clientFk INTO vClient
|
||||
FROM tClient t
|
||||
JOIN `client` c ON c.id = t.clientFk
|
||||
WHERE c.isActive
|
||||
AND c.salesPersonFk
|
||||
LIMIT 1;
|
||||
|
||||
DROP TEMPORARY TABLE tClient;
|
||||
|
|
|
@ -34,7 +34,7 @@ BEGIN
|
|||
LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk
|
||||
LEFT JOIN vn.agency a ON a.id = am.agencyFk
|
||||
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
|
||||
WHERE t.warehouseFk IN (60,1,44)
|
||||
AND e.created BETWEEN vStarted AND vEnded
|
||||
|
|
|
@ -44,7 +44,7 @@ BEGIN
|
|||
JOIN dua d ON d.id = de.duaFk
|
||||
WHERE d.id = vDuaFk
|
||||
LIMIT 1;
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookEntry);
|
||||
CALL ledger_nextTx(vFiscalYear, vBookEntry);
|
||||
END IF;
|
||||
|
||||
OPEN vInvoicesIn;
|
||||
|
|
|
@ -12,7 +12,7 @@ BEGIN
|
|||
WHERE id = vDuaFk;
|
||||
|
||||
IF vBookNumber IS NULL OR NOT vBookNumber THEN
|
||||
CALL ledger_next(YEAR(vBookDated), FALSE, vBookNumber);
|
||||
CALL ledger_nextTx(YEAR(vBookDated), vBookNumber);
|
||||
END IF;
|
||||
|
||||
-- Apunte de la aduana
|
||||
|
|
|
@ -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 ;
|
|
@ -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 ;
|
|
@ -23,7 +23,8 @@ BEGIN
|
|||
JOIN vn.travel t ON t.id = e.travelFk
|
||||
JOIN vn.warehouse w ON w.id = t.warehouseInFk
|
||||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
AND e.currencyFk = vCurrency;
|
||||
AND e.currencyFk = vCurrency
|
||||
AND NOT e.isBooked;
|
||||
|
||||
SET vComission = currency_getCommission(vCurrency);
|
||||
|
||||
|
|
|
@ -56,13 +56,13 @@ BEGIN
|
|||
LIMIT 1;
|
||||
|
||||
IF vPalletFk IS NULL THEN
|
||||
SELECT expeditionTruckFk
|
||||
SELECT roadmapStopFk
|
||||
INTO vTruckFk
|
||||
FROM (
|
||||
SELECT rm.expeditionTruckFk, count(*) n
|
||||
SELECT rm.roadmapStopFk, count(*) n
|
||||
FROM vn.routesMonitor rm
|
||||
JOIN tExpedition e ON e.routeFk = rm.routeFk
|
||||
GROUP BY expeditionTruckFk
|
||||
GROUP BY roadmapStopFk
|
||||
ORDER BY n DESC
|
||||
LIMIT 1) sub;
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ BEGIN
|
|||
LEFT JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
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;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -50,7 +50,7 @@ BEGIN
|
|||
LEFT JOIN vn.route r ON r.id = t.routeFk
|
||||
LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk
|
||||
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;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -70,7 +70,7 @@ BEGIN
|
|||
SELECT YEAR(bookEntried) INTO vFiscalYear FROM tInvoiceIn LIMIT 1;
|
||||
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
||||
CALL ledger_nextTx(vFiscalYear, vBookNumber);
|
||||
END IF;
|
||||
|
||||
-- Apunte del proveedor
|
||||
|
|
|
@ -61,7 +61,7 @@ BEGIN
|
|||
WHERE io.id = vInvoice;
|
||||
|
||||
SELECT YEAR(FECHA) INTO vFiscalYear FROM rs LIMIT 1;
|
||||
CALL ledger_next(vFiscalYear, FALSE, vBookNumber);
|
||||
CALL ledger_nextTx(vFiscalYear, vBookNumber);
|
||||
-- Linea del cliente
|
||||
INSERT INTO XDiario(
|
||||
ASIEN,
|
||||
|
|
|
@ -80,8 +80,8 @@ BEGIN
|
|||
OR t.isDeleted
|
||||
OR c.hasToInvoice = FALSE
|
||||
OR itc.id IS NULL
|
||||
OR a.id IS NULL
|
||||
OR (vTaxArea = 'WORLD'
|
||||
OR a.id IS NULL
|
||||
OR (vTaxArea = 'WORLD'
|
||||
AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL));
|
||||
|
||||
SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0
|
||||
|
@ -153,7 +153,9 @@ BEGIN
|
|||
FROM tmp.ticketToInvoice ti
|
||||
LEFT JOIN ticketState ts ON ti.id = ts.ticketFk
|
||||
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)
|
||||
SELECT * FROM tmp.updateInter;
|
||||
|
|
|
@ -49,7 +49,7 @@ BEGIN
|
|||
ish.isChecked,
|
||||
sub.isAllChecked
|
||||
FROM itemShelvingStock iss
|
||||
JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk
|
||||
JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
LEFT JOIN (
|
||||
SELECT itemFk,
|
||||
IF(
|
||||
|
|
|
@ -28,7 +28,7 @@ BEGIN
|
|||
DECLARE vIsOriginalAClient BOOL;
|
||||
DECLARE vPayMethodCompensation INT;
|
||||
|
||||
CALL ledger_next(YEAR(vDated), FALSE, vNewBookEntry);
|
||||
CALL ledger_nextTx(YEAR(vDated), vNewBookEntry);
|
||||
|
||||
SELECT COUNT(id) INTO vIsOriginalAClient
|
||||
FROM client
|
||||
|
|
|
@ -1,38 +1,21 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ledger_next`(
|
||||
IN vFiscalYear INT,
|
||||
IN vIsManageTransaction BOOLEAN,
|
||||
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
|
||||
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
|
||||
CALL util.throw('Fiscal year is required');
|
||||
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
|
||||
FROM ledgerCompany
|
||||
WHERE fiscalYear = vFiscalYear
|
||||
|
@ -48,13 +31,5 @@ BEGIN
|
|||
UPDATE ledgerCompany
|
||||
SET bookEntry = vLastBookEntry
|
||||
WHERE fiscalYear = vFiscalYear;
|
||||
|
||||
IF NOT vIsManageTransaction THEN
|
||||
IF vHasStartTransaction THEN
|
||||
RELEASE SAVEPOINT sp;
|
||||
ELSE
|
||||
COMMIT;
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -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 ;
|
|
@ -6,14 +6,16 @@ BEGIN
|
|||
(PRIMARY KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.id ticketFk, t.clientFk
|
||||
FROM vn.ticket t
|
||||
LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN vn.client c ON c.id = t.clientFk
|
||||
FROM ticket t
|
||||
JOIN alertLevel al ON al.code = 'DELIVERED'
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = t.id
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
|
||||
WHERE c.typeFk IN ('normal','handMaking','internalUse')
|
||||
AND (
|
||||
t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate
|
||||
OR (
|
||||
ts.alertLevel < 3
|
||||
ts.alertLevel < al.id
|
||||
AND t.shipped >= vStartingDate
|
||||
AND t.shipped < util.VN_CURDATE()
|
||||
)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionControl`(
|
||||
vWarehouseFk INT,
|
||||
vWarehouseFk INT,
|
||||
vScopeDays INT
|
||||
)
|
||||
proc: BEGIN
|
||||
|
@ -67,7 +67,7 @@ proc: BEGIN
|
|||
wk.code salesPersonCode,
|
||||
p.id provinceFk,
|
||||
tls.productionOrder,
|
||||
IFNULL(tls.alertLevel, 0) alertLevel,
|
||||
IFNULL(tls.alertLevel, al.id) alertLevel,
|
||||
t.isBoxed palletized,
|
||||
IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion,
|
||||
tlu.lastUpdated,
|
||||
|
@ -81,6 +81,7 @@ proc: BEGIN
|
|||
rm.bufferFk
|
||||
FROM tmp.productionTicket tt
|
||||
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 `state` st ON st.id = tst.state
|
||||
LEFT JOIN client c ON c.id = t.clientFk
|
||||
|
@ -101,7 +102,7 @@ proc: BEGIN
|
|||
LEFT JOIN parking pk ON pk.id = tp.parkingFk
|
||||
WHERE t.warehouseFk = vWarehouseFk
|
||||
AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP');
|
||||
|
||||
|
||||
UPDATE tmp.productionBuffer pb
|
||||
JOIN (
|
||||
SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking
|
||||
|
@ -109,12 +110,12 @@ proc: BEGIN
|
|||
JOIN sale s ON s.ticketFk = pb.ticketFk
|
||||
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
|
||||
JOIN parking p ON p.id = sg.parkingFk
|
||||
JOIN parking p ON p.id = sg.parkingFk
|
||||
GROUP BY pb.ticketFk
|
||||
) t ON t.ticketFk = pb.ticketFk
|
||||
SET pb.previaParking = t.previaParking;
|
||||
|
||||
-- Problemas por ticket
|
||||
-- Problemas por ticket
|
||||
ALTER TABLE tmp.productionBuffer
|
||||
CHANGE COLUMN `problem` `problem` VARCHAR(255),
|
||||
ADD COLUMN `collectionH` INT,
|
||||
|
|
|
@ -47,7 +47,7 @@ BEGIN
|
|||
LEFT JOIN ticketTrolley tt ON tt.ticket = t.id
|
||||
LEFT JOIN zone zo ON t.zoneFk = zo.id
|
||||
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)
|
||||
GROUP BY t.id
|
||||
ORDER BY cc.code;
|
||||
|
|
|
@ -106,7 +106,7 @@ BEGIN
|
|||
SET rm.m3boxes = sub.m3boxes;
|
||||
|
||||
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;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.routesMonitor;
|
||||
|
|
|
@ -7,13 +7,16 @@ BEGIN
|
|||
DECLARE vShipped DATE;
|
||||
DECLARE vWarehouse TINYINT;
|
||||
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
|
||||
JOIN alertLevel al ON al.code = 'FREE'
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = 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
|
||||
CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped);
|
||||
END IF;
|
||||
|
|
|
@ -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 ;
|
|
@ -1,64 +1,66 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1))
|
||||
BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* Averigua los tickets que se han saltado por un error en el proceso encajado
|
||||
* @param vTicketFk Ticket
|
||||
* @param vItemPackingTypeFk Modo de encajado
|
||||
* @return un select con los tickets afectados
|
||||
*/
|
||||
*/
|
||||
|
||||
DECLARE vParkingFk INT;
|
||||
DECLARE vParked DATETIME;
|
||||
DECLARE vLevel INT;
|
||||
DECLARE vWagon INT;
|
||||
DECLARE vCollectionFk INT;
|
||||
|
||||
SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0)
|
||||
|
||||
SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0)
|
||||
INTO vLevel, vWagon, vCollectionFk
|
||||
FROM vn.ticketCollection tc
|
||||
JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk
|
||||
WHERE ticketFk = vTicketFk
|
||||
ORDER BY c.id DESC
|
||||
LIMIT 1;
|
||||
|
||||
SELECT created, parkingFk
|
||||
|
||||
SELECT created, parkingFk
|
||||
INTO vParked, vParkingFk
|
||||
FROM vn.ticketParking tp
|
||||
JOIN vn.parking p ON p.id = tp.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
JOIN vn.parking p ON p.id = tp.parkingFk
|
||||
JOIN vn.sector s ON s.id = p.sectorFk
|
||||
WHERE ticketFk = vTicketFk
|
||||
AND s.itemPackingTypeFk = vItemPackingTypeFk
|
||||
AND s.isPackagingArea ;
|
||||
|
||||
|
||||
SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', 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
|
||||
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
|
||||
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 sc.isPackagingArea
|
||||
AND (
|
||||
( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked )
|
||||
OR
|
||||
( tc.collectionFk = vCollectionFk
|
||||
( tc.collectionFk = vCollectionFk
|
||||
AND (LEFT(tc.wagon,1) < LEFT(vWagon,1)
|
||||
OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1)))
|
||||
OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1)))
|
||||
)
|
||||
)
|
||||
) -- Etiquetas que no se han escaneado y ya estamos con una posterior
|
||||
OR
|
||||
(s.alertLevel > 1
|
||||
(s.alertLevel > alOnPreparation.id
|
||||
AND tp.parkingFk = vParkingFk
|
||||
AND sc.isPackagingArea
|
||||
AND tp.created < vParked
|
||||
AND tp.created < vParked
|
||||
AND t.packages <=> 0);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45))
|
||||
BEGIN
|
||||
|
||||
|
||||
/* Modifica el estado de un ticket de hoy
|
||||
*
|
||||
*
|
||||
* @param vTicketFk el id del ticket
|
||||
* @param vStateCode estado a modificar del ticket
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
DECLARE vAlertLevel INT;
|
||||
|
||||
SELECT s.alertLevel INTO vAlertLevel
|
||||
FROM state s
|
||||
JOIN ticketStateToday tst ON tst.state = s.id
|
||||
DECLARE vAlertLevelPacked INT;
|
||||
|
||||
SELECT s.alertLevel, al.id
|
||||
INTO vAlertLevel, vAlertLevelPacked
|
||||
FROM state s
|
||||
JOIN ticketStateToday tst ON tst.state = s.id
|
||||
JOIN alertLevel al ON al.code = 'PACKED'
|
||||
WHERE tst.ticketFk = vTicketFk
|
||||
LIMIT 1;
|
||||
|
||||
IF vAlertLevel < 2 THEN
|
||||
|
||||
|
||||
IF vAlertLevel < vAlertLevelPacked THEN
|
||||
|
||||
CALL vn.ticket_setState(vTicketFk, vStateCode);
|
||||
|
||||
|
||||
END IF;
|
||||
|
||||
END$$
|
||||
|
|
|
@ -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 ;
|
|
@ -13,10 +13,11 @@ BEGIN
|
|||
CREATE TEMPORARY TABLE tmp.ticket
|
||||
SELECT ticketFk
|
||||
FROM tmp.productionBuffer
|
||||
JOIN alertLevel al ON al.code = 'FREE'
|
||||
WHERE shipped = util.VN_CURDATE()
|
||||
AND problem LIKE '%I:%'
|
||||
AND (HH <= vHour OR HH = vHour AND mm < vMinute)
|
||||
AND alertLevel = 0;
|
||||
AND alertLevel = al.id;
|
||||
|
||||
OPEN cur1;
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ BEGIN
|
|||
DECLARE vEvaNotes VARCHAR(255);
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vAuxEntryFk INT;
|
||||
DECLARE vTx BOOLEAN DEFAULT @@in_transaction;
|
||||
DECLARE vRsEntry CURSOR FOR
|
||||
DECLARE vIsRequiredTx BOOLEAN DEFAULT NOT @@in_transaction;
|
||||
DECLARE vRsEntry CURSOR FOR
|
||||
SELECT e.id
|
||||
FROM entry e
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
|
@ -35,11 +35,11 @@ BEGIN
|
|||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
CALL util.tx_rollback(vTx);
|
||||
CALL util.tx_rollback(vIsRequiredTx);
|
||||
RESIGNAL;
|
||||
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)
|
||||
SELECT vDateStart, vDateEnd, vWarehouseInFk, vWarehouseOutFk, vAgencyModeFk, vRef, isDelivered, isReceived, m3,cargoSupplierFk, kg,vTravelFk
|
||||
|
@ -76,6 +76,6 @@ BEGIN
|
|||
SET @isModeInventory = FALSE;
|
||||
CLOSE vRsEntry;
|
||||
|
||||
CALL util.tx_commit(vTx);
|
||||
CALL util.tx_commit(vIsRequiredTx);
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -39,7 +39,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`xdiario_new`(
|
|||
*/
|
||||
BEGIN
|
||||
IF vBookNumber IS NULL THEN
|
||||
CALL ledger_next(YEAR(vDated), FALSE, vBookNumber);
|
||||
CALL ledger_nextTx(YEAR(vDated), vBookNumber);
|
||||
END IF;
|
||||
|
||||
INSERT INTO XDiario
|
||||
|
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_beforeDelete`
|
|||
BEFORE DELETE ON `buy`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL entry_checkBooked(OLD.entryFk);
|
||||
CALL entry_isEditable(OLD.entryFk);
|
||||
IF OLD.printedStickers <> 0 THEN
|
||||
CALL util.throw("it is not possible to delete buys with printed labels ");
|
||||
END IF;
|
||||
|
|
|
@ -15,7 +15,7 @@ trig: BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_checkBooked(NEW.entryFk);
|
||||
CALL entry_isEditable(NEW.entryFk);
|
||||
IF NEW.printedStickers <> 0 THEN
|
||||
CALL util.throw('it is not possible to create buy lines with printedstickers other than 0');
|
||||
END IF;
|
||||
|
|
|
@ -13,7 +13,7 @@ trig:BEGIN
|
|||
LEAVE trig;
|
||||
END IF;
|
||||
|
||||
CALL entry_checkBooked(OLD.entryFk);
|
||||
CALL entry_isEditable(OLD.entryFk);
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
SELECT defaultEntry INTO vDefaultEntry
|
||||
|
|
|
@ -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 ;
|
|
@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_beforeDelete`
|
|||
BEFORE DELETE ON `entry`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
CALL entry_isEditable(OLD.id);
|
||||
DELETE FROM buy WHERE entryFk = OLD.id;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -9,7 +9,7 @@ BEGIN
|
|||
DECLARE vTotalBuy INT;
|
||||
|
||||
IF NEW.isBooked = OLD.isBooked THEN
|
||||
CALL entry_checkBooked(OLD.id);
|
||||
CALL entry_isEditable(OLD.id);
|
||||
ELSE
|
||||
IF NEW.isBooked THEN
|
||||
SELECT COUNT(*) INTO vTotalBuy
|
||||
|
|
|
@ -3,25 +3,25 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInse
|
|||
BEFORE INSERT ON `expedition`
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
DECLARE intcounter INT;
|
||||
DECLARE vShipFk INT;
|
||||
DECLARE vMaxCounter INT;
|
||||
|
||||
SET NEW.editorFk = account.myUser_getId();
|
||||
|
||||
IF NEW.freightItemFk IS NOT NULL THEN
|
||||
IF NEW.freightItemFk IS NOT NULL THEN
|
||||
|
||||
UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk;
|
||||
|
||||
SELECT IFNULL(MAX(counter),0) +1 INTO intcounter
|
||||
FROM expedition e
|
||||
INNER JOIN ticket t1 ON e.ticketFk = t1.id
|
||||
SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter
|
||||
FROM expedition e
|
||||
JOIN alertLevel al ON al.code = 'DELIVERED'
|
||||
JOIN ticket t1 ON e.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
|
||||
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;
|
||||
|
||||
SET NEW.`counter` = intcounter;
|
||||
SET NEW.`counter` = vMaxCounter;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -23,7 +23,7 @@ BEGIN
|
|||
FROM supplier
|
||||
WHERE id = NEW.supplierFk;
|
||||
|
||||
CALL ledger_next(YEAR(NEW.received), TRUE, vNewBookEntry);
|
||||
CALL ledger_next(YEAR(NEW.received), vNewBookEntry);
|
||||
|
||||
INSERT INTO XDiario (
|
||||
ASIEN,
|
||||
|
|
|
@ -8,7 +8,9 @@ BEGIN
|
|||
SET hasNewRoute = TRUE
|
||||
WHERE ticketFk = NEW.id;
|
||||
|
||||
CALL ticket_doCmr(NEW.id);
|
||||
IF NEW.cmrFk THEN
|
||||
CALL ticket_doCmr(NEW.id);
|
||||
END IF;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -8,7 +8,7 @@ AS SELECT `rs`.`id` AS `truckFk`,
|
|||
`t`.`routeFk` AS `routeFk`,
|
||||
`es`.`id` AS `scanFk`,
|
||||
`e`.`id` AS `expeditionFk`,
|
||||
`r`.`expeditionTruckFk` AS `expeditionTruckFk`,
|
||||
`r`.`roadmapStopFk` AS `roadmapStopFk`,
|
||||
`t`.`warehouseFk` AS `warehouseFk`,
|
||||
`e`.`created` AS `lastPacked`,
|
||||
`t`.`id` AS `ticketFk`
|
||||
|
@ -18,7 +18,7 @@ FROM (
|
|||
(
|
||||
(
|
||||
`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`)
|
||||
)
|
||||
|
|
|
@ -6,7 +6,7 @@ AS SELECT `rs2`.`description` AS `truck`,
|
|||
`r`.`description` AS `zone`,
|
||||
COUNT(`es`.`id`) AS `eti`,
|
||||
`ep`.`id` AS `palletFk`,
|
||||
`rs`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`,
|
||||
`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,
|
||||
`t`.`warehouseFk` AS `warehouseFk`,
|
||||
IF(
|
||||
`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`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`expeditionTruckFk`)
|
||||
LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`roadmapStopFk`)
|
||||
)
|
||||
GROUP BY `ep`.`id`,
|
||||
`t`.`routeFk`
|
||||
|
|
|
@ -15,7 +15,7 @@ FROM (
|
|||
`vn`.`route` `r`
|
||||
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`)
|
||||
)
|
||||
|
|
|
@ -45,7 +45,7 @@ FROM (
|
|||
)
|
||||
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`)
|
||||
)
|
||||
|
|
|
@ -13,7 +13,7 @@ FROM (
|
|||
)
|
||||
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
|
||||
AND `rs`.`eta` > `util`.`VN_CURDATE`()
|
||||
|
|
|
@ -11,9 +11,9 @@ AS SELECT `e`.`truckFk` AS `id`,
|
|||
COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
|
||||
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
|
||||
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`
|
||||
FROM `vn`.`expeditionCommon` `e`
|
||||
GROUP BY `e`.`truckFk`
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC,
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
|
||||
`e`.`eta`
|
||||
|
|
|
@ -7,12 +7,12 @@ AS SELECT `e`.`truckFk` AS `id`,
|
|||
`e`.`palletFk` AS `pallet`,
|
||||
COUNT(DISTINCT `e`.`routeFk`) AS `routes`,
|
||||
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
|
||||
COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`,
|
||||
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,
|
||||
COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`,
|
||||
sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
|
||||
max(`e`.`lastPacked`) AS `lastPacked`
|
||||
FROM `vn`.`expeditionCommon` `e`
|
||||
GROUP BY `e`.`truckFk`,
|
||||
`e`.`palletFk`
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC,
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
|
||||
`e`.`eta`,
|
||||
`e`.`truckFk`
|
||||
|
|
|
@ -8,15 +8,15 @@ AS SELECT `e`.`truckFk` AS `id`,
|
|||
`e`.`routeFk` AS `route`,
|
||||
COUNT(DISTINCT `e`.`scanFk`) AS `scans`,
|
||||
`rs`.`description` AS `destinos`,
|
||||
sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`,
|
||||
`e`.`expeditionTruckFk` AS `expeditionTruckFk`,
|
||||
max(`e`.`lastPacked`) AS `lastPacked`
|
||||
SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`,
|
||||
`e`.`roadmapStopFk` AS `roadmapStopFk`,
|
||||
MAX(`e`.`lastPacked`) AS `lastPacked`
|
||||
FROM (
|
||||
`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`,
|
||||
`e`.`palletFk`,
|
||||
`e`.`routeFk`
|
||||
ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC,
|
||||
ORDER BY SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC,
|
||||
`e`.`palletFk`
|
||||
|
|
|
@ -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`
|
|
@ -21,7 +21,6 @@ AS SELECT `t`.`id` AS `Id_Ticket`,
|
|||
`t`.`workerFk` AS `Id_Trabajador`,
|
||||
`t`.`observations` AS `Observaciones`,
|
||||
`t`.`isSigned` AS `Firmado`,
|
||||
`t`.`isLabeled` AS `Etiquetasemitidas`,
|
||||
`t`.`isPrinted` AS `PedidoImpreso`,
|
||||
`t`.`hour` AS `Hora`,
|
||||
`t`.`isBlocked` AS `blocked`,
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.item ADD COLUMN photoMotivation VARCHAR(255);
|
|
@ -0,0 +1,46 @@
|
|||
use account;
|
||||
|
||||
INSERT INTO role
|
||||
SET name = 'reviewer',
|
||||
description = 'Revisor de producción',
|
||||
hasLogin = TRUE,
|
||||
created = util.VN_CURDATE(),
|
||||
modified = util.VN_CURDATE(),
|
||||
editorFk = NULL;
|
||||
|
||||
INSERT INTO roleInherit(
|
||||
role,
|
||||
inheritsFrom
|
||||
)
|
||||
SELECT r1.id,
|
||||
r2.id
|
||||
FROM role r1
|
||||
JOIN role r2
|
||||
WHERE r1.name = 'reviewer'
|
||||
AND r2.name = 'production'
|
||||
UNION
|
||||
SELECT ri.role,
|
||||
r2.id
|
||||
FROM roleInherit ri
|
||||
JOIN role r1 ON r1.id = ri.role
|
||||
JOIN role r2 ON r2.name = 'reviewer'
|
||||
WHERE r1.name IN ('claimManager', 'productionBoss')
|
||||
GROUP BY ri.role;
|
||||
|
||||
DELETE ri
|
||||
FROM roleInherit ri
|
||||
JOIN role r1 ON ri.role = r1.id
|
||||
JOIN role r2 ON ri.inheritsFrom = r2.id
|
||||
WHERE r1.name = 'replenisher'
|
||||
AND r2.name = 'buyer';
|
||||
|
||||
UPDATE salix.ACL
|
||||
SET principalId = 'reviewer'
|
||||
WHERE property = 'isInPreparing';
|
||||
|
||||
UPDATE user u
|
||||
JOIN vn.workerDepartment wd ON wd.workerFk = u.id
|
||||
JOIN vn.department d ON wd.departmentFk = d.id
|
||||
JOIN role r ON r.name = 'reviewer'
|
||||
SET u.role = r.id
|
||||
WHERE d.name IN ('REVISION', 'PREVIA');
|
|
@ -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;
|
|
@ -0,0 +1,3 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS expeditionDeadLine TIME NULL
|
||||
COMMENT 'This field stores the latest time by which expeditions can be generated to be sent today';
|
|
@ -0,0 +1,9 @@
|
|||
-- Place your SQL code here
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS counterWidth INT UNSIGNED NULL
|
||||
COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.';
|
||||
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS serviceTypeWidth INT UNSIGNED NULL
|
||||
COMMENT 'If it does not reach the required value, it will be padded with zeros on the left to meet the specified length.';
|
||||
|
||||
ALTER TABLE vn.mrwConfig ADD IF NOT EXISTS portugalPostCodeTrim INT UNSIGNED NULL
|
||||
COMMENT 'It will trim the last characters of the postal code';
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE vn.country DROP COLUMN country;
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
|
||||
VALUES ('Ticket','refund','WRITE','ALLOW','ROLE','logistic');
|
|
@ -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;
|
|
@ -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';
|
|
@ -0,0 +1 @@
|
|||
CREATE INDEX ticketLog_creationDate_IDX USING BTREE ON vn.ticketLog (creationDate,changedModel,`action`);
|
|
@ -225,7 +225,7 @@ describe('Ticket Edit sale path', () => {
|
|||
});
|
||||
|
||||
it('should show error trying to delete a ticket with a refund', async() => {
|
||||
await page.loginAndModule('production', 'ticket');
|
||||
await page.loginAndModule('salesPerson', 'ticket');
|
||||
await page.accessToSearchResult('8');
|
||||
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
|
||||
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
|
||||
|
|
|
@ -61,7 +61,8 @@
|
|||
"Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "I have changed {{changes}} of the ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changes in sales": "the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}*",
|
||||
"Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})",
|
||||
"MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*",
|
||||
|
|
|
@ -124,7 +124,8 @@
|
|||
"Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "He cambiado {{changes}} del ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changes in sales": "la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}*",
|
||||
"State": "Estado",
|
||||
"regular": "normal",
|
||||
"reserved": "reservado",
|
||||
|
@ -358,8 +359,8 @@
|
|||
"Select ticket or client": "Elija un ticket o un client",
|
||||
"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)",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"You can not use the same password": "No puedes usar la misma contraseña"
|
||||
}
|
||||
|
|
|
@ -123,8 +123,9 @@
|
|||
"Added sale to ticket": "J'ai ajouté la ligne suivante au ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}",
|
||||
"Changed sale discount": "J'ai changé le rabais des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Created claim": "J'ai créé la réclamation [{{claimId}}]({{{claimUrl}}}) des lignes suivantes du ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Changed sale price": "J'ai changé le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "J'ai changé la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale price": " le prix de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* du ticket [{{ticketId}}]({{{ticketUrl}}})",,
|
||||
"Changed sale quantity": "J'ai changé {{changes}} du ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changes in sales": "la quantité de {{itemId}} {{concept}} de {{oldQuantity}} ➔ {{newQuantity}}",
|
||||
"State": "État",
|
||||
"regular": "normal",
|
||||
"reserved": "réservé",
|
||||
|
@ -357,4 +358,4 @@
|
|||
"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",
|
||||
"It was not able to create the invoice": "Il n'a pas été possible de créer la facture"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,8 @@
|
|||
"Changed sale discount": "Desconto da venda alterado no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Created claim": "Reclamação criada [{{claimId}}]({{{claimUrl}}}) no ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}",
|
||||
"Changed sale price": "Preço da venda alterado para [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "Quantidade da venda alterada para [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changed sale quantity": "Quantidade da venda alterada para {{changes}} no ticket [{{ticketId}}]({{{ticketUrl}}})",
|
||||
"Changes in sales": " [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* ",
|
||||
"State": "Estado",
|
||||
"regular": "normal",
|
||||
"reserved": "reservado",
|
||||
|
@ -357,4 +358,4 @@
|
|||
"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",
|
||||
"It was not able to create the invoice": "Não foi possível criar a fatura"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,8 +85,12 @@ exports.translateValues = async(instance, changes, options = {}) => {
|
|||
exports.getChanges = (original, changes) => {
|
||||
const oldChanges = {};
|
||||
const newChanges = {};
|
||||
const dateRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
||||
|
||||
for (let property in changes) {
|
||||
if (dateRegex.test(original[property]))
|
||||
original[property] = new Date(Date.parse(original[property]));
|
||||
|
||||
const firstChar = property.substring(0, 1);
|
||||
const isPrivate = firstChar == '$';
|
||||
if (isPrivate) return;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "RoleInherit",
|
||||
"base": "VnModel",
|
||||
"mixins": {
|
||||
"Loggable": true
|
||||
},
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "account.roleInherit"
|
||||
|
|
|
@ -6,6 +6,7 @@ describe('claimBeginning', () => {
|
|||
const claimManagerId = 72;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: claimManagerId},
|
||||
__: value => value
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
|
||||
|
|
|
@ -88,15 +88,17 @@ module.exports = Self => {
|
|||
const updatedClaim = await claim.updateAttributes(args, myOptions);
|
||||
|
||||
// When pickup has been changed
|
||||
if (salesPerson && changedPickup && updatedClaim.pickup)
|
||||
await notifyPickUp(ctx, salesPerson.id, claim);
|
||||
if (salesPerson) {
|
||||
if (changedPickup && updatedClaim.pickup)
|
||||
await notifyPickUp(ctx, salesPerson.id, claim);
|
||||
|
||||
// When claimState has been changed
|
||||
if (args.claimStateFk) {
|
||||
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
|
||||
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
|
||||
if (newState.code == 'canceled')
|
||||
await notifyStateChange(ctx, claim.workerFk, claim, newState.description);
|
||||
// When claimState has been changed
|
||||
if (args.claimStateFk) {
|
||||
const newState = await models.ClaimState.findById(args.claimStateFk, null, myOptions);
|
||||
await notifyStateChange(ctx, salesPerson.id, claim, newState.description);
|
||||
if (newState.code == 'canceled')
|
||||
await notifyStateChange(ctx, claim.workerFk, claim, newState.description);
|
||||
}
|
||||
}
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
|
|
@ -4,7 +4,7 @@ module.exports = Self => {
|
|||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'barcode',
|
||||
type: 'number',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'barcode'
|
||||
}],
|
||||
|
@ -18,7 +18,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.toItem = async(barcode, options) => {
|
||||
Self.toItem = async (barcode, options) => {
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
|
|
@ -64,7 +64,7 @@ describe('item getBalance()', () => {
|
|||
const secondItemBalance = await models.Item.getBalance(ctx, secondFilter, options);
|
||||
|
||||
expect(firstItemBalance[9].claimFk).toEqual(null);
|
||||
expect(secondItemBalance[4].claimFk).toEqual(2);
|
||||
expect(secondItemBalance[7].claimFk).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -155,6 +155,9 @@
|
|||
"minQuantity": {
|
||||
"type": "number",
|
||||
"description": "Min quantity"
|
||||
},
|
||||
"photoMotivation": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -151,7 +151,7 @@ describe('SalesMonitor salesFilter()', () => {
|
|||
const result = await models.SalesMonitor.salesFilter(ctx, filter, options);
|
||||
const firstRow = result[0];
|
||||
|
||||
expect(result.length).toEqual(12);
|
||||
expect(result.length).toEqual(15);
|
||||
expect(firstRow.alertLevel).not.toEqual(0);
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -11,6 +11,12 @@
|
|||
"Sector": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"SectorCollection": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"SectorCollectionSaleGroup": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"Train": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "SectorCollection",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "sectorCollection"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
},
|
||||
"userFk": {
|
||||
"type": "number"
|
||||
},
|
||||
"sectorFk": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "SectorCollectionSaleGroup",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "sectorCollectionSaleGroup"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number",
|
||||
"id": true
|
||||
},
|
||||
"created": {
|
||||
"type": "date"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"sectorCollection": {
|
||||
"type": "belongsTo",
|
||||
"model": "SectorCollection",
|
||||
"foreignKey": "sectorCollectionFk"
|
||||
},
|
||||
"saleGroup": {
|
||||
"type": "belongsTo",
|
||||
"model": "SaleGroup",
|
||||
"foreignKey": "saleGroupFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,10 +2,12 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket setDelivered()', () => {
|
||||
const userId = 50;
|
||||
const userId = 49;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: userId},
|
||||
__: value => value
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
|
||||
beforeAll(async() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
|
@ -19,8 +21,6 @@ describe('ticket setDelivered()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 49}}};
|
||||
|
||||
const originalTicketOne = await models.Ticket.findById(8, null, options);
|
||||
const originalTicketTwo = await models.Ticket.findById(10, null, options);
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ module.exports = Self => {
|
|||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'itemId',
|
||||
type: 'number',
|
||||
arg: 'barcode',
|
||||
type: 'any',
|
||||
required: true
|
||||
},
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.addSale = async(ctx, id, itemId, quantity, options) => {
|
||||
Self.addSale = async(ctx, id, barcode, quantity, options) => {
|
||||
const $t = ctx.req.__; // $translate
|
||||
const models = Self.app.models;
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
|
@ -46,7 +46,9 @@ module.exports = Self => {
|
|||
try {
|
||||
await models.Ticket.isEditableOrThrow(ctx, id, myOptions);
|
||||
|
||||
const itemId = await models.ItemBarcode.toItem(barcode, myOptions);
|
||||
const item = await models.Item.findById(itemId, null, myOptions);
|
||||
|
||||
const ticket = await models.Ticket.findById(id, {
|
||||
include: {
|
||||
relation: 'client',
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
module.exports = Self => {
|
||||
Self.remoteMethodCtx('addSaleByCode', {
|
||||
description: 'Add a collection',
|
||||
accessType: 'WRITE',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'barcode',
|
||||
type: 'string',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'quantity',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'ticketFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
}, {
|
||||
arg: 'warehouseFk',
|
||||
type: 'number',
|
||||
required: true
|
||||
},
|
||||
|
||||
],
|
||||
http: {
|
||||
path: `/addSaleByCode`,
|
||||
verb: 'POST'
|
||||
},
|
||||
});
|
||||
|
||||
Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => {
|
||||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
if (!myOptions.transaction) {
|
||||
tx = await Self.beginTransaction({});
|
||||
myOptions.transaction = tx;
|
||||
}
|
||||
|
||||
try {
|
||||
const [[item]] = await Self.rawSql('CALL vn.item_getInfo(?,?)', [barcode, warehouseFk], myOptions);
|
||||
if (!item?.available) throw new UserError('We do not have availability for the selected item');
|
||||
|
||||
await Self.rawSql('CALL vn.collection_addItem(?, ?, ?)', [item.id, quantity, ticketFk], myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -8,18 +8,13 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
const state = await models.TicketState.findOne({
|
||||
where: {ticketFk: id}
|
||||
}, myOptions);
|
||||
|
||||
const state = await models.TicketState.findOne({where: {ticketFk: id}}, myOptions);
|
||||
const isRoleAdvanced = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'isRoleAdvanced', '*');
|
||||
const isProductionReviewer = await models.ACL.checkAccessAcl(ctx, 'Sale', 'isInPreparing', '*');
|
||||
const canEditWeeklyTicket = await models.ACL.checkAccessAcl(ctx, 'Ticket', 'canEditWeekly', 'WRITE');
|
||||
const alertLevel = state ? state.alertLevel : null;
|
||||
const ticket = await models.Ticket.findById(id, {
|
||||
fields: ['clientFk'],
|
||||
include: {
|
||||
relation: 'client'
|
||||
}
|
||||
fields: ['clientFk'], include: {relation: 'client'}
|
||||
}, myOptions);
|
||||
|
||||
const isLocked = await models.Ticket.isLocked(id, myOptions);
|
||||
|
@ -29,10 +24,24 @@ module.exports = Self => {
|
|||
const isNormalClient = ticket && ticket.client().typeFk == 'normal';
|
||||
const isEditable = !(alertLevelGreaterThanZero && isNormalClient);
|
||||
|
||||
const ticketCollection = await models.TicketCollection.findOne({
|
||||
include: {relation: 'collection'}, where: {ticketFk: id}
|
||||
}, myOptions);
|
||||
let isOwner = ticketCollection?.collection()?.workerFk === ctx.req.accessToken.userId;
|
||||
|
||||
if (!isOwner) {
|
||||
const saleGroup = await models.SaleGroup.findOne({fields: ['id'], where: {ticketFk: id}}, myOptions);
|
||||
const sectorCollectionSaleGroup = saleGroup && await models.SectorCollectionSaleGroup.findOne({
|
||||
include: {relation: 'sectorCollection'}, where: {saleGroupFk: saleGroup.id}
|
||||
}, myOptions);
|
||||
|
||||
isOwner = sectorCollectionSaleGroup?.sectorCollection()?.userFk === ctx.req.accessToken.userId;
|
||||
}
|
||||
|
||||
if (!ticket)
|
||||
throw new ForbiddenError(`The ticket doesn't exist.`);
|
||||
|
||||
if (!isEditable && !isRoleAdvanced)
|
||||
if (!isEditable && !isRoleAdvanced && !isProductionReviewer && !isOwner)
|
||||
throw new ForbiddenError(`This ticket is not editable.`);
|
||||
|
||||
if (isLocked && !isWeekly)
|
||||
|
|
|
@ -140,14 +140,7 @@ module.exports = Self => {
|
|||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||
|
||||
const deliveryState = await models.State.findOne({
|
||||
where: {code: 'DELIVERED'}
|
||||
}, myOptions);
|
||||
|
||||
await models.Ticket.state(ctx, {
|
||||
ticketFk: ticketId,
|
||||
stateFk: deliveryState.id
|
||||
}, myOptions);
|
||||
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions);
|
||||
|
||||
if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) {
|
||||
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
||||
|
|
|
@ -71,7 +71,10 @@ module.exports = Self => {
|
|||
// Check for existing purchase requests
|
||||
const hasPurchaseRequests = await models.TicketRequest.count({
|
||||
ticketFk: id,
|
||||
isOk: true
|
||||
or: [
|
||||
{isOk: true},
|
||||
{isOk: null}
|
||||
]
|
||||
}, myOptions);
|
||||
|
||||
if (hasPurchaseRequests)
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Ticket addSaleByCode()', () => {
|
||||
const quantity = 3;
|
||||
const ticketFk = 13;
|
||||
const warehouseFk = 1;
|
||||
beforeAll(async() => {
|
||||
activeCtx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
|
||||
it('should add a new sale', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const code = '1111111111';
|
||||
|
||||
const salesBefore = await models.Sale.find(null, options);
|
||||
await models.Ticket.addSaleByCode(activeCtx, code, quantity, ticketFk, warehouseFk, options);
|
||||
const salesAfter = await models.Sale.find(null, options);
|
||||
|
||||
expect(salesAfter.length).toEqual(salesBefore.length + 1);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue