4560-GastosReparto #2544

Merged
jgallego merged 8 commits from 4560-GastosReparto into dev 2024-06-10 08:40:56 +00:00
5 changed files with 32 additions and 12 deletions
Showing only changes of commit b4046de190 - Show all commits

View File

@ -1,5 +1,7 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(
vSelf INT
)
BEGIN BEGIN
/** /**
* Triggered actions when a buy is updated or inserted. * Triggered actions when a buy is updated or inserted.
@ -16,7 +18,7 @@ BEGIN
DECLARE vIsFeedStock BOOL; DECLARE vIsFeedStock BOOL;
DECLARE vWeight DECIMAL(10,2); DECLARE vWeight DECIMAL(10,2);
DECLARE vPacking INT; DECLARE vPacking INT;
SELECT b.entryFk, SELECT b.entryFk,
b.itemFk, b.itemFk,
i.packingOut, i.packingOut,
@ -47,8 +49,11 @@ BEGIN
WHERE e.id = vEntryFk; WHERE e.id = vEntryFk;
IF vIsMerchandise THEN IF vIsMerchandise THEN
IF vWarehouse IS NULL THEN
CALL util.throw('The entry does not have travel');
END IF;
REPLACE itemCost SET REPLACE itemCost SET
itemFk = vItemFk, itemFk = vItemFk,
warehouseFk = vWarehouse, warehouseFk = vWarehouse,
cm3 = buy_getUnitVolume(vSelf), cm3 = buy_getUnitVolume(vSelf),
@ -74,7 +79,7 @@ BEGIN
WHERE b.id = vSelf; WHERE b.id = vSelf;
END IF; END IF;
CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck
SELECT vSelf id; SELECT vSelf id;
CALL buy_checkItem(); CALL buy_checkItem();
END$$ END$$

View File

@ -15,7 +15,8 @@ BEGIN
t.addressFk, t.addressFk,
a.nickname, a.nickname,
sub2.itemPackingTypeConcat, sub2.itemPackingTypeConcat,
est.code est.code,
es.isScanned
FROM expedition e FROM expedition e
JOIN ticket t ON t.id = e.ticketFk JOIN ticket t ON t.id = e.ticketFk
JOIN ticketState ts ON ts.ticketFk = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk
@ -33,6 +34,10 @@ BEGIN
GROUP BY sub.ticketFk GROUP BY sub.ticketFk
) sub2 ON sub2.ticketFk = t.id ) sub2 ON sub2.ticketFk = t.id
LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk
LEFT JOIN expeditionState es ON es.id = (
SELECT MAX(id)
FROM expeditionState es
WHERE expeditionFk = e.id)
WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE
ORDER BY r.created, t.priority DESC; ORDER BY r.created, t.priority DESC;
END$$ END$$

View File

@ -0,0 +1,5 @@
-- Place your SQL code here
USE vn;
ALTER TABLE vn.expeditionState ADD isScanned tinyint(1) DEFAULT false NOT NULL;

View File

@ -44,11 +44,13 @@ module.exports = Self => {
const typeFk = expeditionStateType.id; const typeFk = expeditionStateType.id;
expeditionId = expedition.expeditionFk; expeditionId = expedition.expeditionFk;
const isScannedExpedition = expedition.isScanned ?? false;
await models.ExpeditionState.create({ await models.ExpeditionState.create({
expeditionFk: expedition.expeditionFk, expeditionFk: expedition.expeditionFk,
typeFk, typeFk,
userFk: userId, userFk: userId,
isScanned: isScannedExpedition,
}, myOptions); }, myOptions);
} }

View File

@ -3,7 +3,7 @@
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "expeditionState" "table": "expeditionState"
} }
}, },
"properties": { "properties": {
@ -23,13 +23,16 @@
}, },
"userFk": { "userFk": {
"type": "number" "type": "number"
},
"isScanned": {
"type": "boolean"
} }
}, },
"relations": { "relations": {
"expeditionStateType": { "expeditionStateType": {
"type": "belongsTo", "type": "belongsTo",
"model": "ExpeditionStateType", "model": "ExpeditionStateType",
"foreignKey": "typeFk" "foreignKey": "typeFk"
} }
} }
} }