Compare commits

...

32 Commits

Author SHA1 Message Date
Sergio De la torre f72bddbc1a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7642_createNewState
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-07-15 16:10:24 +02:00
Sergio De la torre bc86bde5a4 Revert "Revert "Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into 6861_reservas_retro""
This reverts commit fb9bf4126e.
2024-07-15 16:09:13 +02:00
Sergio De la torre fb9bf4126e Revert "Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into 6861_reservas_retro"
This reverts commit 8df64013ee.
2024-07-15 16:08:11 +02:00
Sergio De la torre 1d66a2e752 Revert "feat newState refs #7642"
This reverts commit a821aa317a.
2024-07-15 16:07:59 +02:00
Sergio De la torre a821aa317a feat newState refs #7642 2024-07-15 16:03:28 +02:00
Sergio De la torre 8df64013ee Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into 6861_reservas_retro
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-07-15 13:00:16 +02:00
Sergio De la torre 4d8482c503 Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into 7642_createNewState 2024-07-15 12:54:45 +02:00
Sergio De la torre 31a2c3bbd1 Merge pull request 'feat itemShelvingSale refs #6861' (!2729) from 6861_reservas_gettickets into master
gitea/salix/pipeline/pr-test This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #2729
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
2024-07-15 10:34:40 +00:00
Sergio De la torre 8dbdbdf23b feat newState refs #7642
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-07-15 12:30:09 +02:00
Sergio De la torre 573f5c8d28 feat newState refs #7642
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-07-15 12:28:30 +02:00
Sergio De la torre 689a88b75e Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 7642_createNewState
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-07-15 12:24:58 +02:00
Sergio De la torre 00a1a84205 Merge branch 'master' into 6861_reservas_gettickets
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-15 06:27:52 +00:00
Carlos Satorres 88dcbc726b Merge pull request 'fix(worker_new): fix countryFk' (!2728) from hotFix_workerNew_countryFk into master
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-test This commit looks good Details
Reviewed-on: #2728
Reviewed-by: Carlos Satorres <carlossa@verdnatura.es>
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
2024-07-15 06:26:20 +00:00
Alex Moreno aa3fbf0cb4 Merge branch 'master' into hotFix_workerNew_countryFk
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-15 05:05:18 +00:00
Sergio De la torre 806dc40eb9 Merge branch 'master' into 6861_reservas_gettickets
gitea/salix/pipeline/pr-master There was a failure building this commit Details
2024-07-15 05:05:17 +00:00
Carlos Andrés 67b19ee4ca hotfix: packaging ticket 199070
gitea/salix/pipeline/pr-test This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
2024-07-14 09:08:14 +02:00
Carlos Andrés 97e5bd7a31 Merge pull request 'hotfix: packaging ticket 199070' (!2727) from Hotfix-packaging-ticket-199070 into master
gitea/salix/pipeline/pr-test This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #2727
Reviewed-by: Pako Natek <pako@verdnatura.es>
2024-07-12 11:36:40 +00:00
Sergio De la torre cb107215b6 feat itemShelvingSale refs #6861
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-12 13:14:00 +02:00
Carlos Andrés d2e482d7cd hotfix: packaging ticket 199070
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-12 12:13:21 +02:00
Carlos Andrés 66959dd388 hotfix: packaging ticket 199070
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-12 12:10:43 +02:00
Alex Moreno 896d273da8 fix(worker_new): fix countryFk
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-12 12:06:37 +02:00
Guillermo Bonet 323d26f226 Fix
gitea/salix/pipeline/pr-test This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
2024-07-12 10:37:39 +02:00
Carlos Andrés b93601d6d8 Actualizar db/routines/vn/procedures/itemShelvingSale_addBySale.sql
gitea/salix/pipeline/pr-test There was a failure building this commit Details
gitea/salix/pipeline/head There was a failure building this commit Details
2024-07-12 08:27:24 +00:00
Carlos Andrés b883d0ee2b Merge pull request 'feat itemShelvingSale refs #6861' (!2721) from 6861_reservas_retro into master
gitea/salix/pipeline/pr-test This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #2721
Reviewed-by: Carlos Andrés <carlosap@verdnatura.es>
2024-07-12 07:08:02 +00:00
Sergio De la torre 21987011b6 feat itemShelvingSale refs #6861
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-12 09:06:05 +02:00
Sergio De la torre 69bcad9ce0 feat itemShelvingSale refs #6861
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-11 18:09:00 +02:00
Sergio De la torre 97fe9debf6 feat newState refs #7642
gitea/salix/pipeline/pr-dev There was a failure building this commit Details
2024-07-11 12:57:15 +02:00
Carlos Satorres 741360cd63 Merge pull request 'hotfix routeSummary' (!2718) from hotfix-routeSummary into master
gitea/salix/pipeline/pr-test This commit looks good Details
gitea/salix/pipeline/head This commit looks good Details
Reviewed-on: #2718
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-07-11 07:17:26 +00:00
Carlos Satorres 0579e7dbbf hotfix routeSummary
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-11 09:14:14 +02:00
Sergio De la torre 8c8ec6192a feat newState refs #7642
gitea/salix/pipeline/pr-dev This commit looks good Details
2024-07-10 13:53:38 +02:00
Pablo Natek 3d22192824 Merge pull request 'feat: refs #6403 add dynamic clientType' (!2714) from 6403-addDinamycClient into master
gitea/salix/pipeline/head This commit looks good Details
gitea/salix/pipeline/pr-test This commit looks good Details
Reviewed-on: #2714
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
2024-07-10 09:35:57 +00:00
Pablo Natek 64bddd4f63 feat: refs #6403 add dynamic clientType
gitea/salix/pipeline/pr-master This commit looks good Details
2024-07-10 10:41:52 +02:00
26 changed files with 310 additions and 164 deletions

View File

@ -63,8 +63,7 @@ module.exports = Self => {
iss.isPicked iss.isPicked
FROM ticketCollection tc FROM ticketCollection tc
LEFT JOIN collection c ON c.id = tc.collectionFk LEFT JOIN collection c ON c.id = tc.collectionFk
JOIN ticket t ON t.id = tc.ticketFk JOIN sale s ON s.ticketFk = tc.ticketFk
JOIN sale s ON s.ticketFk = t.id
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
LEFT JOIN parking p2 ON p2.id = sg.parkingFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk
@ -103,9 +102,8 @@ module.exports = Self => {
FROM sectorCollection sc FROM sectorCollection sc
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
JOIN saleGroup sg ON sg.id = ss.saleGroupFk JOIN saleGroup sg ON sg.id = ss.saleGroupFk
JOIN ticket t ON t.id = sg.ticketFk LEFT JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
JOIN sale s ON s.ticketFk = t.id JOIN sale s ON s.id = sgd.saleFk
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
LEFT JOIN parking p2 ON p2.id = sg.parkingFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN itemShelvingSale iss ON iss.saleFk = s.id JOIN itemShelvingSale iss ON iss.saleFk = s.id

View File

@ -2,7 +2,7 @@
<soap:Header> <soap:Header>
<mrw:AuthInfo> <mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia> <mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado> <mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/> <mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName> <mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password> <mrw:Password><%= mrw.password %></mrw:Password>

View File

@ -27,9 +27,9 @@ module.exports = Self => {
const mrw = await models.MrwConfig.findOne(); const mrw = await models.MrwConfig.findOne();
const {externalId} = await models.Expedition.findById(expeditionFk); const {externalId} = await models.Expedition.findById(expeditionFk);
const clientType = await models.MrwConfig.getClientType(expeditionFk);
const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8'); const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8');
const renderedXml = ejs.render(template, {mrw, externalId}); const renderedXml = ejs.render(template, {mrw, externalId, clientType});
const response = await axios.post(mrw.url, renderedXml, { const response = await axios.post(mrw.url, renderedXml, {
headers: { headers: {
'Content-Type': 'application/soap+xml; charset=utf-8' 'Content-Type': 'application/soap+xml; charset=utf-8'

View File

@ -3,7 +3,7 @@
<soap:Header> <soap:Header>
<mrw:AuthInfo> <mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia> <mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= expeditionData.clientType %></mrw:CodigoAbonado> <mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/> <mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName> <mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password> <mrw:Password><%= mrw.password %></mrw:Password>

View File

@ -22,6 +22,7 @@ module.exports = Self => {
Self.createShipment = async expeditionFk => { Self.createShipment = async expeditionFk => {
const models = Self.app.models; const models = Self.app.models;
const mrw = await Self.getConfig(); const mrw = await Self.getConfig();
const clientType = await models.MrwConfig.getClientType(expeditionFk);
const today = Date.vnNew(); const today = Date.vnNew();
const [hours, minutes] = mrw?.expeditionDeadLine ? mrw.expeditionDeadLine.split(':').map(Number) : [0, 0]; const [hours, minutes] = mrw?.expeditionDeadLine ? mrw.expeditionDeadLine.split(':').map(Number) : [0, 0];
@ -52,8 +53,7 @@ module.exports = Self => {
CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference,
LPAD(IF(mw.serviceType 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
LPAD(ms.clientType, mc.clientTypeWidth, '0') clientType
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
@ -73,22 +73,19 @@ module.exports = Self => {
const [expeditionData] = await Self.rawSql(query, [expeditionFk]); const [expeditionData] = await Self.rawSql(query, [expeditionFk]);
if (!expeditionData)
throw new UserError(`This expedition is not a MRW shipment`);
if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today.setHours(0, 0, 0, 0)) if (expeditionData?.shipped.setHours(0, 0, 0, 0) < today.setHours(0, 0, 0, 0))
throw new UserError(`This ticket has a shipped date earlier than today`); throw new UserError(`This ticket has a shipped date earlier than today`);
const shipmentResponse = await Self.sendXmlDoc( const shipmentResponse = await Self.sendXmlDoc(
__dirname + `/createShipment.ejs`, __dirname + `/createShipment.ejs`,
{mrw, expeditionData}, {mrw, expeditionData, clientType},
'application/soap+xml' 'application/soap+xml'
); );
const shipmentId = Self.getTextByTag(shipmentResponse, 'NumeroEnvio'); const shipmentId = Self.getTextByTag(shipmentResponse, 'NumeroEnvio');
if (!shipmentId) throw new UserError(Self.getTextByTag(shipmentResponse, 'Mensaje')); if (!shipmentId) throw new UserError(Self.getTextByTag(shipmentResponse, 'Mensaje'));
const file = await models.MrwConfig.getLabel(shipmentId); const file = await models.MrwConfig.getLabel(shipmentId, clientType);
return {shipmentId, file}; return {shipmentId, file};
}; };

View File

@ -2,7 +2,7 @@
<soapenv:Header> <soapenv:Header>
<mrw:AuthInfo> <mrw:AuthInfo>
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia> <mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado> <mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
<mrw:CodigoDepartamento/> <mrw:CodigoDepartamento/>
<mrw:UserName><%= mrw.user %></mrw:UserName> <mrw:UserName><%= mrw.user %></mrw:UserName>
<mrw:Password><%= mrw.password %></mrw:Password> <mrw:Password><%= mrw.password %></mrw:Password>

View File

@ -6,7 +6,13 @@ module.exports = Self => {
arg: 'shipmentId', arg: 'shipmentId',
type: 'string', type: 'string',
required: true required: true
}], },
{
arg: 'clientType',
type: 'string',
required: true
},
],
returns: { returns: {
type: 'string', type: 'string',
root: true root: true
@ -17,10 +23,14 @@ module.exports = Self => {
} }
}); });
Self.getLabel = async shipmentId => { Self.getLabel = async(shipmentId, clientType) => {
const mrw = await Self.getConfig(); const mrw = await Self.getConfig();
const getLabelResponse = await Self.sendXmlDoc(__dirname + `/getLabel.ejs`, {mrw, shipmentId}, 'text/xml'); const getLabelResponse = await Self.sendXmlDoc(
__dirname + `/getLabel.ejs`,
{mrw, shipmentId, clientType},
'text/xml'
);
return Self.getTextByTag(getLabelResponse, 'EtiquetaFile'); return Self.getTextByTag(getLabelResponse, 'EtiquetaFile');
}; };

View File

@ -40,15 +40,12 @@ describe('MRWConfig createShipment()', () => {
); );
await models.MrwService.create(
{'agencyModeCodeFk': 'mrw', 'clientType': '000001', 'serviceType': 105, 'kg': 10}
);
await createMrwConfig(); await createMrwConfig();
await models.Application.rawSql(
`INSERT INTO vn.mrwService
SET agencyModeCodeFk = 'mrw',
clientType = 1,
serviceType = 1,
kg = 1`, null
);
await models.Ticket.create(ticket1); await models.Ticket.create(ticket1);
await models.Expedition.create(expedition1); await models.Expedition.create(expedition1);
}); });
@ -82,7 +79,8 @@ describe('MRWConfig createShipment()', () => {
'user': 'user', 'user': 'user',
'password': 'password', 'password': 'password',
'franchiseCode': 'franchiseCode', 'franchiseCode': 'franchiseCode',
'subscriberCode': 'subscriberCode' 'subscriberCode': 'subscriberCode',
'clientTypeWidth': 6
} }
); );
} }
@ -115,10 +113,10 @@ describe('MRWConfig createShipment()', () => {
it('should fail if expeditionFk is not a MrwExpedition', async() => { it('should fail if expeditionFk is not a MrwExpedition', async() => {
let error; let error;
await models.MrwConfig.createShipment(undefined).catch(e => { await models.MrwConfig.createShipment(15).catch(e => {
error = e; error = e;
}).finally(async() => { }).finally(async() => {
expect(error.message).toEqual(`This expedition is not a MRW shipment`); expect(error.message).toEqual(`ClientType not available`);
}); });
}); });

View File

@ -20,7 +20,7 @@ module.exports = Self => {
} }
}); });
Self.renderer = async (expeditionFk) => { Self.renderer = async expeditionFk => {
const models = Self.app.models; const models = Self.app.models;
const viaexpressConfig = await models.ViaexpressConfig.findOne({ const viaexpressConfig = await models.ViaexpressConfig.findOne({
@ -109,7 +109,7 @@ module.exports = Self => {
const ticket = expedition.ticket(); const ticket = expedition.ticket();
const sender = ticket.company().client(); const sender = ticket.company().client();
const shipped = ticket.shipped.toISOString(); const shipped = ticket.shipped.toISOString();
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk) const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk);
const data = { const data = {
viaexpressConfig, viaexpressConfig,
sender, sender,

View File

@ -192,5 +192,8 @@
}, },
"RouteConfig": { "RouteConfig": {
"dataSource": "vn" "dataSource": "vn"
},
"MrwService": {
"dataSource": "vn"
} }
} }

View File

@ -31,5 +31,30 @@ module.exports = Self => {
}); });
return parser.parseFromString(data.data, 'text/xml'); return parser.parseFromString(data.data, 'text/xml');
}; };
Self.getClientType = async function(expeditionFk) {
if (!expeditionFk) throw new UserError(`No expeditionFk defined`);
const {clientTypeWidth} = await Self.getConfig();
const result = await Self.app.models.Expedition.findById(expeditionFk,
{include: [{
relation: 'ticket',
scope: {
include: {
relation: 'agencyMode',
scope: {
include: {
relation: 'mrwService',
}
}
}
}
}]}
);
const clientType = result?.ticket()?.agencyMode()?.mrwService()?.clientType;
if (!clientType || !clientTypeWidth) throw new UserError(`ClientType not available`);
return clientType.toString().padStart(clientTypeWidth, '0');
};
}; };

View File

@ -45,6 +45,9 @@
}, },
"notified":{ "notified":{
"type": "date" "type": "date"
},
"clientTypeWidth": {
"type": "number"
} }
} }
} }

View File

@ -0,0 +1,33 @@
{
"name": "MrwService",
"base": "VnModel",
"options": {
"mysql": {
"table": "mrwService"
}
},
"properties": {
"agencyModeCodeFk": {
"id": true,
"type": "string",
"required": true
},
"clientType": {
"type": "number",
"required": true
},
"serviceType": {
"type": "number"
},
"kg": {
"type": "number"
}
},
"relations": {
"agency": {
"type": "hasOne",
"model": "AgencyMode",
"foreignKey": "code"
}
}
}

View File

@ -16,6 +16,8 @@ proc: BEGIN
DECLARE vReservedQuantity INT; DECLARE vReservedQuantity INT;
DECLARE vOutStanding INT; DECLARE vOutStanding INT;
DECLARE vUserFk INT; DECLARE vUserFk INT;
DECLARE vTotalReservedQuantity INT;
DECLARE vSaleQuantity INT;
DECLARE vItemShelvingAvailable CURSOR FOR DECLARE vItemShelvingAvailable CURSOR FOR
SELECT ish.id itemShelvingFk, SELECT ish.id itemShelvingFk,
@ -43,8 +45,8 @@ proc: BEGIN
RESIGNAL; RESIGNAL;
END; END;
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)) SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
INTO vLastPickingOrder, vOutStanding INTO vLastPickingOrder, vOutStanding, vSaleQuantity
FROM sale s FROM sale s
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
@ -64,6 +66,16 @@ proc: BEGIN
FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable; FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable;
IF vOutStanding <= 0 OR vDone THEN IF vOutStanding <= 0 OR vDone THEN
SELECT SUM(IFNULL(quantity, 0))
INTO vTotalReservedQuantity
FROM itemShelvingSale
WHERE saleFk = vSaleFk;
IF vTotalReservedQuantity <> vSaleQuantity THEN
UPDATE sale
SET quantity = vTotalReservedQuantity
WHERE id = vSaleFk;
END IF;
LEAVE l; LEAVE l;
END IF; END IF;

View File

@ -21,6 +21,7 @@ BEGIN
DECLARE vRemainingQuantity INT; DECLARE vRemainingQuantity INT;
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vTotalQuantity INT; DECLARE vTotalQuantity INT;
DECLARE vStateCode VARCHAR(45);
DECLARE EXIT HANDLER FOR SQLEXCEPTION DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN BEGIN
@ -32,10 +33,19 @@ BEGIN
CALL util.throw('Reservation completed'); CALL util.throw('Reservation completed');
END IF; END IF;
SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0)) SELECT s.itemFk,
INTO vItemFk, vSaleFk, vItemShelvingFk, vReservedQuantity iss.saleFk,
iss.itemShelvingFk,
SUM(IFNULL(iss.quantity,0)),
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED')
INTO vItemFk,
vSaleFk,
vItemShelvingFk,
vReservedQuantity,
vStateCode
FROM itemShelvingSale iss FROM itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk JOIN sale s ON s.id = iss.saleFk
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
WHERE iss.id = vItemShelvingSaleFk WHERE iss.id = vItemShelvingSaleFk
AND NOT iss.isPicked; AND NOT iss.isPicked;
@ -74,7 +84,7 @@ BEGIN
vTotalQuantity, vTotalQuantity,
`account`.`myUser_getId`(), `account`.`myUser_getId`(),
NULL, NULL,
'PREPARED', vStateCode,
TRUE); TRUE);
UPDATE sale s UPDATE sale s

View File

@ -19,8 +19,7 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.sale CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(saleFk INT PRIMARY KEY) (saleFk INT PRIMARY KEY)
SELECT SELECT s.ticketFk,
s.ticketFk,
s.id saleFk, s.id saleFk,
s.itemFk, s.itemFk,
s.concept, s.concept,
@ -29,7 +28,7 @@ BEGIN
pb.routeFk, pb.routeFk,
FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
b.packagingFk IF(pa.isPackageReturnable, pc.defaultBigPackageFk, b.packagingFk) packagingFk
FROM sale s FROM sale s
JOIN item i ON i.id = s.itemFk JOIN item i ON i.id = s.itemFk
JOIN itemShelving ish ON ish.itemFk = s.itemFk JOIN itemShelving ish ON ish.itemFk = s.itemFk
@ -52,6 +51,8 @@ BEGIN
LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk
LEFT JOIN buy b ON b.id = lb.buy_id LEFT JOIN buy b ON b.id = lb.buy_id
LEFT JOIN packaging pa ON pa.id = b.packagingFk
JOIN packagingConfig pc
WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut) WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut)
<= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0)) <= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0))
AND NOT pb.problem AND NOT pb.problem

View File

@ -64,8 +64,12 @@ BEGIN
(SELECT vCurTicketFk, p.id, COUNT(*) (SELECT vCurTicketFk, p.id, COUNT(*)
FROM expedition e FROM expedition e
JOIN packaging p ON p.id = e.packagingFk JOIN packaging p ON p.id = e.packagingFk
JOIN ticket t ON t.id = e.ticketFk
LEFT JOIN agencyMode am ON am.id = t.agencyModeFk
LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable
AND vWithPackage AND vWithPackage
AND NOT dm.`code`= 'PICKUP'
GROUP BY p.itemFk); GROUP BY p.itemFk);
-- No retornables o no catalogados -- No retornables o no catalogados

View File

@ -0,0 +1,2 @@
ALTER TABLE vn.ticketLastState MODIFY COLUMN name varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;

View File

@ -0,0 +1,5 @@
-- Place your SQL code here
INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIAL_DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL);

View File

@ -53,7 +53,7 @@
<vn-autocomplete vn-one <vn-autocomplete vn-one
ng-model="$ctrl.location.countryFk" ng-model="$ctrl.location.countryFk"
url="Countries" url="Countries"
show-field="country" show-field="name"
value-field="id" value-field="id"
label="Country"> label="Country">
</vn-autocomplete> </vn-autocomplete>

View File

@ -35,10 +35,10 @@
</vn-one> </vn-one>
<vn-one> <vn-one>
<vn-label-value label="Starting time" <vn-label-value label="Starting time"
value="{{$ctrl.summary.route.time | date: 'HH:MM'}}"> value="{{$ctrl.summary.route.started | date: 'HH:mm'}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="Finishing time" <vn-label-value label="Finishing time"
value="{{$ctrl.summary.route.finished | date: 'HH:MM'}}"> value="{{$ctrl.summary.route.finished | date: 'HH:mm'}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="Km Start" <vn-label-value label="Km Start"
value="{{$ctrl.summary.route.kmStart}}"> value="{{$ctrl.summary.route.kmStart}}">

View File

@ -140,7 +140,16 @@ 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);
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, 'DELIVERED'], myOptions); const [{stateCode}] = await Self.rawSql(`
SELECT
IF((SUM(CASE WHEN est.code = 'DELIVERED' THEN 1 ELSE 0 END) = COUNT(*)),
'DELIVERED','PARTIAL_DELIVERED') stateCode
FROM vn.expedition e
JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk
WHERE e.ticketFk = ?;
`, [ticketId], myOptions);
await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [ticketId, stateCode], 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

@ -26,4 +26,36 @@ describe('Ticket saveSign()', () => {
expect(error).toBeDefined(); expect(error).toBeDefined();
}); });
it('should change state for ticket', async() => {
const tx = await models.State.beginTransaction({});
const ticketWithOkState = 7;
const ticketStateId = 16;
const ticketCode = 'PARTIAL_DELIVERED';
spyOn(models.Dms, 'uploadFile').and.returnValue([{id: 1}]);
let ticketTrackingAfter;
try {
const options = {transaction: tx};
const tickets = [ticketWithOkState];
const state = await models.State.findById(ticketStateId, null, options);
await state.updateAttributes({
code: ticketCode,
name: ticketCode
}, options);
await models.Ticket.saveSign(ctx, tickets, null, null, options);
ticketTrackingAfter = await models.TicketLastState.findOne({
where: {ticketFk: ticketWithOkState}
}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
throw e;
}
expect(ticketTrackingAfter.name).toBe('PARTIAL_DELIVERED');
});
}); });

View File

@ -171,8 +171,8 @@ module.exports = Self => {
const address = await models.Address.create({ const address = await models.Address.create({
clientFk: user.id, clientFk: user.id,
street: street, street: street,
city: city, city,
provinceFk: provinceFk, provinceFk,
postalCode: postcode, postalCode: postcode,
mobile: phone, mobile: phone,
nickname: nickname, nickname: nickname,
@ -193,7 +193,9 @@ module.exports = Self => {
} }
await user.updateAttribute('email', email, myOptions); await user.updateAttribute('email', email, myOptions);
const {countryFk} = await Self.app.models.Province.findById(provinceFk, {
fields: ['countryFk']
});
await models.Worker.create({ await models.Worker.create({
id: user.id, id: user.id,
firstName, firstName,
@ -202,6 +204,7 @@ module.exports = Self => {
bossFk, bossFk,
fi, fi,
birth, birth,
originCountryFk: countryFk
}, myOptions); }, myOptions);
@ -212,11 +215,8 @@ module.exports = Self => {
const message = e.sqlMessage; const message = e.sqlMessage;
if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`); if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`);
if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) throw new UserError(`This worker code already exists`); if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) throw new UserError(`This worker code already exists`);
if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`); if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`);
throw e; throw e;
} }

View File

@ -27,11 +27,10 @@ module.exports = Self => {
}); });
async function tinIsValid(err, done) { async function tinIsValid(err, done) {
const filter = { const country = await Self.app.models.Country.findOne({
fields: ['code'], fields: ['code'],
where: {id: this.countryFk} where: {id: this.originCountryFk}
}; });
const country = await Self.app.models.Country.findOne(filter);
const code = country ? country.code.toLowerCase() : null; const code = country ? country.code.toLowerCase() : null;
if (!this.fi || !validateTin(this.fi, code)) if (!this.fi || !validateTin(this.fi, code))

View File

@ -60,6 +60,11 @@
"type": "hasMany", "type": "hasMany",
"model": "Zone", "model": "Zone",
"foreignKey": "agencyModeFk" "foreignKey": "agencyModeFk"
},
"mrwService": {
"type": "belongsTo",
"model": "MrwService",
"foreignKey": "code"
} }
}, },
"acls": [ "acls": [