Merge branch 'dev' into hotFix_liliumRedirection
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
bdf9b7810c
|
@ -63,8 +63,7 @@ module.exports = Self => {
|
|||
iss.isPicked
|
||||
FROM ticketCollection tc
|
||||
LEFT JOIN collection c ON c.id = tc.collectionFk
|
||||
JOIN ticket t ON t.id = tc.ticketFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN sale s ON s.ticketFk = tc.ticketFk
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk
|
||||
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
||||
|
@ -103,9 +102,8 @@ module.exports = Self => {
|
|||
FROM sectorCollection sc
|
||||
JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id
|
||||
JOIN saleGroup sg ON sg.id = ss.saleGroupFk
|
||||
JOIN ticket t ON t.id = sg.ticketFk
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
|
||||
LEFT JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
||||
JOIN sale s ON s.id = sgd.saleFk
|
||||
LEFT JOIN parking p2 ON p2.id = sg.parkingFk
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<soap:Header>
|
||||
<mrw:AuthInfo>
|
||||
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
|
||||
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoDepartamento/>
|
||||
<mrw:UserName><%= mrw.user %></mrw:UserName>
|
||||
<mrw:Password><%= mrw.password %></mrw:Password>
|
||||
|
|
|
@ -27,9 +27,9 @@ module.exports = Self => {
|
|||
|
||||
const mrw = await models.MrwConfig.findOne();
|
||||
const {externalId} = await models.Expedition.findById(expeditionFk);
|
||||
|
||||
const clientType = await models.MrwConfig.getClientType(expeditionFk);
|
||||
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, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<soap:Header>
|
||||
<mrw:AuthInfo>
|
||||
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
|
||||
<mrw:CodigoAbonado><%= expeditionData.clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoDepartamento/>
|
||||
<mrw:UserName><%= mrw.user %></mrw:UserName>
|
||||
<mrw:Password><%= mrw.password %></mrw:Password>
|
||||
|
|
|
@ -22,6 +22,7 @@ module.exports = Self => {
|
|||
Self.createShipment = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
const mrw = await Self.getConfig();
|
||||
const clientType = await models.MrwConfig.getClientType(expeditionFk);
|
||||
|
||||
const today = Date.vnNew();
|
||||
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,
|
||||
LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType,
|
||||
IF(mw.weekdays, 'S', 'N') weekDays,
|
||||
oa.description deliveryObservation,
|
||||
LPAD(ms.clientType, mc.clientTypeWidth, '0') clientType
|
||||
oa.description deliveryObservation
|
||||
FROM expedition e
|
||||
JOIN ticket t ON e.ticketFk = t.id
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
|
@ -63,8 +63,7 @@ module.exports = Self => {
|
|||
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'
|
||||
AND oa.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery')
|
||||
JOIN province p ON a.provinceFk = p.id
|
||||
JOIN country co ON co.id = p.countryFk
|
||||
JOIN mrwConfig mc
|
||||
|
@ -73,22 +72,19 @@ module.exports = Self => {
|
|||
|
||||
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))
|
||||
throw new UserError(`This ticket has a shipped date earlier than today`);
|
||||
|
||||
const shipmentResponse = await Self.sendXmlDoc(
|
||||
__dirname + `/createShipment.ejs`,
|
||||
{mrw, expeditionData},
|
||||
{mrw, expeditionData, clientType},
|
||||
'application/soap+xml'
|
||||
);
|
||||
const shipmentId = Self.getTextByTag(shipmentResponse, 'NumeroEnvio');
|
||||
|
||||
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};
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<soapenv:Header>
|
||||
<mrw:AuthInfo>
|
||||
<mrw:CodigoFranquicia><%= mrw.franchiseCode %></mrw:CodigoFranquicia>
|
||||
<mrw:CodigoAbonado><%= mrw.subscriberCode %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoAbonado><%= clientType %></mrw:CodigoAbonado>
|
||||
<mrw:CodigoDepartamento/>
|
||||
<mrw:UserName><%= mrw.user %></mrw:UserName>
|
||||
<mrw:Password><%= mrw.password %></mrw:Password>
|
||||
|
|
|
@ -6,7 +6,13 @@ module.exports = Self => {
|
|||
arg: 'shipmentId',
|
||||
type: 'string',
|
||||
required: true
|
||||
}],
|
||||
},
|
||||
{
|
||||
arg: 'clientType',
|
||||
type: 'string',
|
||||
required: true
|
||||
},
|
||||
],
|
||||
returns: {
|
||||
type: 'string',
|
||||
root: true
|
||||
|
@ -17,10 +23,14 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.getLabel = async shipmentId => {
|
||||
Self.getLabel = async(shipmentId, clientType) => {
|
||||
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');
|
||||
};
|
||||
|
|
|
@ -40,15 +40,12 @@ describe('MRWConfig createShipment()', () => {
|
|||
|
||||
);
|
||||
|
||||
await models.MrwService.create(
|
||||
{'agencyModeCodeFk': 'mrw', 'clientType': '000001', 'serviceType': 105, 'kg': 10}
|
||||
);
|
||||
|
||||
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.Expedition.create(expedition1);
|
||||
});
|
||||
|
@ -82,7 +79,8 @@ describe('MRWConfig createShipment()', () => {
|
|||
'user': 'user',
|
||||
'password': 'password',
|
||||
'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() => {
|
||||
let error;
|
||||
await models.MrwConfig.createShipment(undefined).catch(e => {
|
||||
await models.MrwConfig.createShipment(15).catch(e => {
|
||||
error = e;
|
||||
}).finally(async() => {
|
||||
expect(error.message).toEqual(`This expedition is not a MRW shipment`);
|
||||
expect(error.message).toEqual(`ClientType not available`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.renderer = async (expeditionFk) => {
|
||||
Self.renderer = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
|
@ -109,7 +109,7 @@ module.exports = Self => {
|
|||
const ticket = expedition.ticket();
|
||||
const sender = ticket.company().client();
|
||||
const shipped = ticket.shipped.toISOString();
|
||||
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk)
|
||||
const isInterdia = (ticket.agencyModeFk === viaexpressConfig.agencyModeFk);
|
||||
const data = {
|
||||
viaexpressConfig,
|
||||
sender,
|
||||
|
|
|
@ -192,5 +192,8 @@
|
|||
},
|
||||
"RouteConfig": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"MrwService": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
|
@ -31,5 +31,30 @@ module.exports = Self => {
|
|||
});
|
||||
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');
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
},
|
||||
"notified":{
|
||||
"type": "date"
|
||||
},
|
||||
"clientTypeWidth": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -314,5 +314,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`)
|
|||
SELECT SUBSTR(`User`, @prefixLen + 1), `Host`, `Role`, `Admin_option`
|
||||
FROM mysql.roles_mapping
|
||||
WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost;
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
|
|
|
@ -121,7 +121,7 @@ INSERT INTO hedera.orderConfig (`id`, `employeeFk`, `defaultAgencyFk`, `guestMet
|
|||
INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`)
|
||||
VALUES
|
||||
(1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'),
|
||||
(1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'),
|
||||
(1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 131, 1, 'PetterParker@mydomain.com', 'en','1102'),
|
||||
(1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'),
|
||||
(1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'),
|
||||
(1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'),
|
||||
|
@ -1500,7 +1500,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO
|
|||
(5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5),
|
||||
(6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6),
|
||||
(7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7),
|
||||
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10);
|
||||
(8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10),
|
||||
(10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10);
|
||||
|
||||
INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`)
|
||||
VALUES
|
||||
|
@ -1511,7 +1512,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed
|
|||
(5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'),
|
||||
(6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'),
|
||||
(7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'),
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, '');
|
||||
(8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''),
|
||||
(9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''),
|
||||
(10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, '');
|
||||
|
||||
INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`)
|
||||
VALUES
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isProblemCalcNeeded`(
|
||||
vSelf INT
|
||||
)
|
||||
RETURNS BOOL
|
||||
DETERMINISTIC
|
||||
BEGIN
|
||||
/**
|
||||
* Check if the ticket requires to update column vn.ticket.problem
|
||||
*
|
||||
* @param vSelf Id ticket
|
||||
* @return BOOL
|
||||
*/
|
||||
DECLARE vIsProblemCalcNeeded BOOL;
|
||||
|
||||
SELECT COUNT(*) INTO vIsProblemCalcNeeded
|
||||
FROM ticket t
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
JOIN agencyMode am ON am.id = t.agencyModeFk
|
||||
JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk
|
||||
WHERE t.id = vSelf
|
||||
AND dm.code IN ('AGENCY','DELIVERY','PICKUP')
|
||||
AND c.typeFk = 'normal';
|
||||
|
||||
RETURN vIsProblemCalcNeeded;
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -1,5 +1,8 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`(vWarehouseFk SMALLINT, vDated DATE)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`(
|
||||
vWarehouseFk SMALLINT,
|
||||
vDated DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula las últimas compras realizadas hasta una fecha
|
||||
|
@ -19,21 +22,22 @@ BEGIN
|
|||
FROM cache.last_buy
|
||||
WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL;
|
||||
|
||||
CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated);
|
||||
IF vDated >= util.VN_CURDATE() THEN
|
||||
CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated);
|
||||
|
||||
REPLACE INTO tmp.buyUltimate
|
||||
SELECT itemFk, buyFk, warehouseFk, landed landing
|
||||
FROM tmp.buyUltimateFromInterval
|
||||
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||
AND landed <= vDated
|
||||
AND NOT isIgnored;
|
||||
|
||||
INSERT IGNORE INTO tmp.buyUltimate
|
||||
SELECT itemFk, buyFk, warehouseFk, landed landing
|
||||
FROM tmp.buyUltimateFromInterval
|
||||
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||
AND landed > vDated
|
||||
ORDER BY isIgnored = FALSE DESC;
|
||||
REPLACE INTO tmp.buyUltimate
|
||||
SELECT itemFk, buyFk, warehouseFk, landed landing
|
||||
FROM tmp.buyUltimateFromInterval
|
||||
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||
AND landed <= vDated
|
||||
AND NOT isIgnored;
|
||||
|
||||
INSERT IGNORE INTO tmp.buyUltimate
|
||||
SELECT itemFk, buyFk, warehouseFk, landed landing
|
||||
FROM tmp.buyUltimateFromInterval
|
||||
WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL)
|
||||
AND landed > vDated
|
||||
ORDER BY isIgnored = FALSE DESC;
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE)
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInterval`(
|
||||
vWarehouseFk SMALLINT,
|
||||
vStarted DATE,
|
||||
vEnded DATE
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Calcula las últimas compras realizadas
|
||||
|
@ -21,12 +25,13 @@ BEGIN
|
|||
-- Item
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval;
|
||||
CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval
|
||||
(PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk))
|
||||
(PRIMARY KEY (itemFk, warehouseFk),
|
||||
INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT itemFk,
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
MAX(landed) landed,
|
||||
landed,
|
||||
isIgnored
|
||||
FROM (SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
|
@ -45,93 +50,117 @@ BEGIN
|
|||
|
||||
|
||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||
SELECT
|
||||
b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed > vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.price2 > 0
|
||||
AND NOT b.isIgnored
|
||||
GROUP BY itemFk, warehouseInFk;
|
||||
SELECT itemFk,
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
landed,
|
||||
isIgnored
|
||||
FROM (SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed > vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.price2 > 0
|
||||
AND NOT b.isIgnored
|
||||
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
||||
LIMIT 10000000000000000000) sub
|
||||
GROUP BY itemFk, warehouseFk;
|
||||
|
||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||
SELECT
|
||||
b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.quantity = 0
|
||||
GROUP BY itemFk, warehouseInFk;
|
||||
SELECT itemFk,
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
landed,
|
||||
isIgnored
|
||||
FROM (SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.quantity = 0
|
||||
ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC
|
||||
LIMIT 10000000000000000000) sub
|
||||
GROUP BY itemFk, warehouseFk;
|
||||
|
||||
-- ItemOriginal
|
||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||
SELECT itemFk,
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
MAX(landed) landed,
|
||||
isIgnored
|
||||
FROM (SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
itemOriginalFk,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.price2 > 0
|
||||
AND NOT b.isIgnored
|
||||
AND b.quantity > 0
|
||||
AND itemOriginalFk
|
||||
ORDER BY t.landed DESC, b.id DESC
|
||||
LIMIT 10000000000000000000) sub
|
||||
GROUP BY itemOriginalFk, warehouseFk;
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
landed,
|
||||
isIgnored
|
||||
FROM (SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
itemOriginalFk,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.price2 > 0
|
||||
AND NOT b.isIgnored
|
||||
AND b.quantity > 0
|
||||
AND itemOriginalFk
|
||||
ORDER BY t.landed DESC, b.id DESC
|
||||
LIMIT 10000000000000000000) sub
|
||||
GROUP BY itemFk, warehouseFk;
|
||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||
SELECT itemFk,
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
landed,
|
||||
isIgnored
|
||||
FROM (SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed > vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.price2 > 0
|
||||
AND NOT b.isIgnored
|
||||
AND itemOriginalFk
|
||||
ORDER BY t.landed DESC, b.id DESC
|
||||
LIMIT 10000000000000000000) sub
|
||||
GROUP BY itemFk, warehouseFk;
|
||||
|
||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||
SELECT
|
||||
b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed > vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.price2 > 0
|
||||
AND NOT b.isIgnored
|
||||
AND itemOriginalFk
|
||||
GROUP BY itemOriginalFk, warehouseInFk;
|
||||
|
||||
INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored)
|
||||
SELECT
|
||||
b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.quantity = 0
|
||||
AND itemOriginalFk
|
||||
GROUP BY itemOriginalFk, warehouseInFk;
|
||||
SELECT itemFk,
|
||||
warehouseFk,
|
||||
buyFk,
|
||||
landed,
|
||||
isIgnored
|
||||
FROM
|
||||
(SELECT b.itemFk,
|
||||
t.warehouseInFk warehouseFk,
|
||||
b.id buyFk,
|
||||
t.landed,
|
||||
b.isIgnored
|
||||
FROM buy b
|
||||
JOIN entry e ON e.id = b.entryFk
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
WHERE t.landed BETWEEN vStarted AND vEnded
|
||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||
AND b.quantity = 0
|
||||
AND itemOriginalFk
|
||||
ORDER BY t.landed DESC, b.id DESC
|
||||
LIMIT 10000000000000000000) sub
|
||||
GROUP BY itemFk, warehouseFk;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -34,20 +34,25 @@ BEGIN
|
|||
DECLARE vIsTaxDataChecked TINYINT(1);
|
||||
DECLARE vHasCoreVnl BOOLEAN;
|
||||
DECLARE vMandateTypeFk INT;
|
||||
DECLARE vHasDailyInvoice BOOLEAN;
|
||||
|
||||
SELECT defaultPayMethodFk,
|
||||
defaultDueDay,
|
||||
defaultCredit,
|
||||
defaultIsTaxDataChecked,
|
||||
defaultHasCoreVnl,
|
||||
defaultMandateTypeFk
|
||||
SELECT cc.defaultPayMethodFk,
|
||||
cc.defaultDueDay,
|
||||
cc.defaultCredit,
|
||||
cc.defaultIsTaxDataChecked,
|
||||
cc.defaultHasCoreVnl,
|
||||
cc.defaultMandateTypeFk,
|
||||
c.hasDailyInvoice
|
||||
INTO vPayMethodFk,
|
||||
vDueDay,
|
||||
vDefaultCredit,
|
||||
vIsTaxDataChecked,
|
||||
vHasCoreVnl,
|
||||
vMandateTypeFk
|
||||
FROM clientConfig;
|
||||
vMandateTypeFk,
|
||||
vHasDailyInvoice
|
||||
FROM clientConfig cc
|
||||
LEFT JOIN province p ON p.id = vProvinceFk
|
||||
LEFT JOIN country c ON c.id = p.countryFk;
|
||||
|
||||
INSERT INTO `client`
|
||||
SET id = vUserFk,
|
||||
|
@ -65,7 +70,8 @@ BEGIN
|
|||
credit = vDefaultCredit,
|
||||
isTaxDataChecked = vIsTaxDataChecked,
|
||||
hasCoreVnl = vHasCoreVnl,
|
||||
isEqualizated = FALSE
|
||||
isEqualizated = FALSE,
|
||||
hasDailyInvoice = vHasDailyInvoice
|
||||
ON duplicate KEY UPDATE
|
||||
payMethodFk = vPayMethodFk,
|
||||
dueDay = vDueDay,
|
||||
|
|
|
@ -16,6 +16,8 @@ proc: BEGIN
|
|||
DECLARE vReservedQuantity INT;
|
||||
DECLARE vOutStanding INT;
|
||||
DECLARE vUserFk INT;
|
||||
DECLARE vTotalReservedQuantity INT;
|
||||
DECLARE vSaleQuantity INT;
|
||||
|
||||
DECLARE vItemShelvingAvailable CURSOR FOR
|
||||
SELECT ish.id itemShelvingFk,
|
||||
|
@ -43,8 +45,8 @@ proc: BEGIN
|
|||
RESIGNAL;
|
||||
END;
|
||||
|
||||
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0))
|
||||
INTO vLastPickingOrder, vOutStanding
|
||||
SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity
|
||||
INTO vLastPickingOrder, vOutStanding, vSaleQuantity
|
||||
FROM sale s
|
||||
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
||||
LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk
|
||||
|
@ -64,6 +66,16 @@ proc: BEGIN
|
|||
FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable;
|
||||
|
||||
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;
|
||||
END IF;
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ BEGIN
|
|||
DECLARE vRemainingQuantity INT;
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vTotalQuantity INT;
|
||||
DECLARE vStateCode VARCHAR(45);
|
||||
|
||||
DECLARE EXIT HANDLER FOR SQLEXCEPTION
|
||||
BEGIN
|
||||
|
@ -32,10 +33,19 @@ BEGIN
|
|||
CALL util.throw('Reservation completed');
|
||||
END IF;
|
||||
|
||||
SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0))
|
||||
INTO vItemFk, vSaleFk, vItemShelvingFk, vReservedQuantity
|
||||
SELECT s.itemFk,
|
||||
iss.saleFk,
|
||||
iss.itemShelvingFk,
|
||||
SUM(IFNULL(iss.quantity,0)),
|
||||
IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED')
|
||||
INTO vItemFk,
|
||||
vSaleFk,
|
||||
vItemShelvingFk,
|
||||
vReservedQuantity,
|
||||
vStateCode
|
||||
FROM itemShelvingSale iss
|
||||
JOIN sale s ON s.id = iss.saleFk
|
||||
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk
|
||||
WHERE iss.id = vItemShelvingSaleFk
|
||||
AND NOT iss.isPicked;
|
||||
|
||||
|
@ -74,7 +84,7 @@ BEGIN
|
|||
vTotalQuantity,
|
||||
`account`.`myUser_getId`(),
|
||||
NULL,
|
||||
'PREPARED',
|
||||
vStateCode,
|
||||
TRUE);
|
||||
|
||||
UPDATE sale s
|
||||
|
|
|
@ -19,21 +19,20 @@ BEGIN
|
|||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(saleFk INT PRIMARY KEY)
|
||||
SELECT
|
||||
s.ticketFk,
|
||||
s.id saleFk,
|
||||
s.itemFk,
|
||||
s.concept,
|
||||
s.quantity,
|
||||
MAKETIME(pb.HH,pb.mm,0) etd,
|
||||
pb.routeFk,
|
||||
FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
|
||||
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
|
||||
b.packagingFk
|
||||
SELECT s.ticketFk,
|
||||
s.id saleFk,
|
||||
s.itemFk,
|
||||
s.concept,
|
||||
s.quantity,
|
||||
MAKETIME(pb.HH,pb.mm,0) etd,
|
||||
pb.routeFk,
|
||||
FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers,
|
||||
IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing,
|
||||
IF(pa.isPackageReturnable, pc.defaultBigPackageFk, b.packagingFk) packagingFk
|
||||
FROM sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
JOIN itemShelving ish ON ish.itemFk = s.itemFk
|
||||
LEFT JOIN ( SELECT iss.itemShelvingFk,
|
||||
LEFT JOIN ( SELECT iss.itemShelvingFk,
|
||||
s.itemFk,
|
||||
SUM(iss.quantity) reserve
|
||||
FROM itemShelvingSale iss
|
||||
|
@ -52,6 +51,8 @@ BEGIN
|
|||
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 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)
|
||||
<= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0))
|
||||
AND NOT pb.problem
|
||||
|
|
|
@ -7,7 +7,7 @@ BEGIN
|
|||
* Update column sale.problem with a problem code
|
||||
*
|
||||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.sale(saleFk, hasProblem)
|
||||
* @table tmp.sale(saleFk, hasProblem, isProblemCalcNeeded)
|
||||
*/
|
||||
DECLARE vSaleFk INT;
|
||||
DECLARE vHasProblem INT;
|
||||
|
|
|
@ -10,9 +10,13 @@ BEGIN
|
|||
* @param vSelf Id del sale
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk))
|
||||
(INDEX(saleFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem;
|
||||
SELECT vSelf saleFk,
|
||||
sale_hasComponentLack(vSelf) hasProblem,
|
||||
ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded
|
||||
FROM sale
|
||||
WHERE id = vSelf;
|
||||
|
||||
CALL sale_setProblem('hasComponentLack');
|
||||
|
||||
|
|
|
@ -10,11 +10,13 @@ BEGIN
|
|||
* @param vComponentFk Id component
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
(INDEX(saleFk))
|
||||
(INDEX(saleFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem
|
||||
SELECT saleFk,
|
||||
sale_hasComponentLack(saleFk) hasProblem,
|
||||
ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded
|
||||
FROM (
|
||||
SELECT s.id saleFk
|
||||
SELECT s.id saleFk, s.ticketFk
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
||||
|
|
|
@ -11,9 +11,10 @@ BEGIN
|
|||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vShipped DATE;
|
||||
DECLARE vQuantity INT;
|
||||
DECLARE vIsProblemCalcNeeded BOOL;
|
||||
|
||||
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity
|
||||
INTO vItemFk, vWarehouseFk, vShipped, vQuantity
|
||||
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity, ticket_isProblemCalcNeeded(t.id)
|
||||
INTO vItemFk, vWarehouseFk, vShipped, vQuantity, vIsProblemCalcNeeded
|
||||
FROM sale s
|
||||
JOIN ticket t ON t.id = s.ticketFk
|
||||
WHERE s.id = vSelf;
|
||||
|
@ -21,7 +22,9 @@ BEGIN
|
|||
CALL buyUltimate(vWarehouseFk, vShipped);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem
|
||||
SELECT vSelf saleFk,
|
||||
MOD(vQuantity, b.`grouping`) hasProblem,
|
||||
vIsProblemCalcNeeded isProblemCalcNeeded
|
||||
FROM tmp.buyUltimate bu
|
||||
JOIN buy b ON b.id = bu.buyFk
|
||||
WHERE bu.itemFk = vItemFk;
|
||||
|
|
|
@ -44,14 +44,14 @@ BEGIN
|
|||
t.shipped,
|
||||
IFNULL(a.hasDailyInvoice, co.hasDailyInvoice),
|
||||
w.isManaged,
|
||||
c.hasToInvoice
|
||||
c.hasToInvoice
|
||||
INTO vClientFk,
|
||||
vIsTaxDataChecked,
|
||||
vCompanyFk,
|
||||
vShipped,
|
||||
vHasDailyInvoice,
|
||||
vWithPackage,
|
||||
vHasToInvoice
|
||||
vHasToInvoice
|
||||
FROM ticket t
|
||||
JOIN `client` c ON c.id = t.clientFk
|
||||
JOIN province p ON p.id = c.provinceFk
|
||||
|
@ -64,8 +64,12 @@ BEGIN
|
|||
(SELECT vCurTicketFk, p.id, COUNT(*)
|
||||
FROM expedition e
|
||||
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
|
||||
AND vWithPackage
|
||||
AND NOT dm.`code`= 'PICKUP'
|
||||
GROUP BY p.itemFk);
|
||||
|
||||
-- No retornables o no catalogados
|
||||
|
|
|
@ -4,10 +4,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblem`(
|
|||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update column ticket.problem with a problem code
|
||||
* Update column ticket.problem with a problem code and SET NULL when
|
||||
* the problem is not requiered
|
||||
*
|
||||
* @param vProblemCode Code to set or unset
|
||||
* @table tmp.ticket(ticketFk, hasProblem)
|
||||
* @table tmp.ticket(ticketFk, hasProblem, isProblemCalcNeeded)
|
||||
*/
|
||||
DECLARE vTicketFk INT;
|
||||
DECLARE vHasProblem INT;
|
||||
|
|
|
@ -9,9 +9,11 @@ BEGIN
|
|||
* @param vClientFk Id Cliente, if NULL all clients
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(INDEX(ticketFk))
|
||||
(INDEX(ticketFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.id ticketFk, FALSE hasProblem
|
||||
SELECT t.id ticketFk,
|
||||
FALSE hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM ticket t
|
||||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
AND (vClientFk IS NULL OR t.clientFk = vClientFk);
|
||||
|
|
|
@ -9,9 +9,11 @@ BEGIN
|
|||
* @param vSelf Id ticket, if NULL ALL tickets
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(INDEX(ticketFk))
|
||||
(INDEX(ticketFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.id ticketFk, FALSE hasProblem
|
||||
SELECT t.id ticketFk,
|
||||
FALSE hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM ticket t
|
||||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
AND (vSelf IS NULL OR t.id = vSelf);
|
||||
|
|
|
@ -10,21 +10,30 @@ BEGIN
|
|||
*/
|
||||
DECLARE vHasRisk BOOL;
|
||||
DECLARE vHasHighRisk BOOL;
|
||||
DECLARE vIsProblemCalcNeeded BOOL;
|
||||
|
||||
SELECT t.risk > (c.credit + 10), ((t.risk - cc.riskTolerance) > (c.credit + 10))
|
||||
INTO vHasRisk, vHasHighRisk
|
||||
SELECT t.risk > (c.credit + 10),
|
||||
(t.risk - cc.riskTolerance) > (c.credit + 10),
|
||||
ticket_isProblemCalcNeeded(t.id)
|
||||
INTO vHasRisk, vHasHighRisk, vIsProblemCalcNeeded
|
||||
FROM client c
|
||||
JOIN ticket t ON t.clientFk = c.id
|
||||
JOIN clientConfig cc
|
||||
WHERE t.id = vSelf;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
SELECT vSelf ticketFk, vHasRisk hasProblem;
|
||||
ENGINE = MEMORY
|
||||
SELECT vSelf ticketFk,
|
||||
vHasRisk hasProblem,
|
||||
vIsProblemCalcNeeded isProblemCalcNeeded;
|
||||
|
||||
CALL ticket_setProblem('hasRisk');
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
SELECT vSelf ticketFk, vHasHighRisk hasProblem;
|
||||
ENGINE = MEMORY
|
||||
SELECT vSelf ticketFk,
|
||||
vHasHighRisk hasProblem,
|
||||
vIsProblemCalcNeeded isProblemCalcNeeded;
|
||||
|
||||
CALL ticket_setProblem('hasHighRisk');
|
||||
|
||||
|
|
|
@ -19,7 +19,10 @@ BEGIN
|
|||
CALL buyUltimate(vWarehouseFk, vDated);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||
SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem
|
||||
(INDEX(saleFk, isProblemCalcNeeded))
|
||||
SELECT s.id saleFk ,
|
||||
MOD(s.quantity, b.`grouping`) hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||
|
|
|
@ -9,9 +9,11 @@ BEGIN
|
|||
* @param vClientFk Id cliente, if NULL all clients
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(INDEX(ticketFk))
|
||||
(INDEX(ticketFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem
|
||||
SELECT t.id ticketFk,
|
||||
IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM ticket t
|
||||
JOIN client c ON c.id = t.clientFk
|
||||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
|
|
|
@ -8,13 +8,17 @@ BEGIN
|
|||
*
|
||||
* @param vSelf Id del ticket
|
||||
*/
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(INDEX(ticketFk))
|
||||
(INDEX(ticketFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
SELECT vSelf ticketFk, ticket_isTooLittle(vSelf) hasProblem;
|
||||
SELECT vSelf ticketFk,
|
||||
ticket_isTooLittle(vSelf) hasProblem,
|
||||
ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded;
|
||||
|
||||
CALL ticket_setProblem('isTooLittle');
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
|
@ -10,7 +10,7 @@ BEGIN
|
|||
* @param vItemFk Id del item, NULL ALL items
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||
(INDEX(ticketFk))
|
||||
(INDEX(ticketFk, isProblemCalcNeeded))
|
||||
ENGINE = MEMORY
|
||||
WITH tickets AS(
|
||||
SELECT t.id ticketFk
|
||||
|
@ -19,7 +19,9 @@ BEGIN
|
|||
WHERE t.shipped >= util.VN_CURDATE()
|
||||
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
|
||||
GROUP BY t.id
|
||||
)SELECT ticketFk, ticket_isTooLittle(ticketFk) hasProblem
|
||||
)SELECT ticketFk,
|
||||
ticket_isTooLittle(ticketFk) hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM tickets;
|
||||
|
||||
CALL ticket_setProblem('isTooLittle');
|
||||
|
|
|
@ -8,6 +8,7 @@ BEGIN
|
|||
* @param vClientFk Id cliente
|
||||
*/
|
||||
DECLARE vHasDebt BOOL;
|
||||
DECLARE vStarted DATETIME;
|
||||
|
||||
SELECT COUNT(*) INTO vHasDebt
|
||||
FROM `client`
|
||||
|
@ -16,22 +17,24 @@ BEGIN
|
|||
|
||||
IF vHasDebt THEN
|
||||
|
||||
SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted
|
||||
FROM clientConfig;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTicketRisk
|
||||
(KEY (ticketFk))
|
||||
ENGINE = MEMORY
|
||||
WITH ticket AS(
|
||||
SELECT id ticketFk, companyFk, DATE(shipped) dated
|
||||
FROM vn.ticket t
|
||||
SELECT id ticketFk,
|
||||
companyFk,
|
||||
DATE(shipped) dated,
|
||||
totalWithVat,
|
||||
ticket_isProblemCalcNeeded(id) isProblemCalcNeeded
|
||||
FROM vn.ticket
|
||||
WHERE clientFk = vClientFk
|
||||
AND refFk IS NULL
|
||||
AND NOT isDeleted
|
||||
AND totalWithoutVat <> 0
|
||||
), dated AS(
|
||||
SELECT t.companyFk, MIN(DATE(t.dated) - INTERVAL cc.riskScope MONTH) started,
|
||||
MAX(DATE(t.dated)) ended
|
||||
FROM ticket t
|
||||
JOIN vn.clientConfig cc
|
||||
GROUP BY t.companyFk
|
||||
AND IFNULL(totalWithVat, 0) <> 0
|
||||
AND shipped > vStarted
|
||||
), balance AS(
|
||||
SELECT SUM(amount)amount, companyFk
|
||||
FROM (
|
||||
|
@ -49,15 +52,11 @@ BEGIN
|
|||
WHERE companyFk
|
||||
GROUP BY companyFk
|
||||
), uninvoiced AS(
|
||||
SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount
|
||||
FROM vn.ticket t
|
||||
JOIN dated d
|
||||
WHERE t.clientFk = vClientFk
|
||||
AND t.refFk IS NULL
|
||||
AND t.shipped BETWEEN d.started AND d.ended
|
||||
GROUP BY t.companyFk, DATE(t.shipped)
|
||||
SELECT companyFk, dated, SUM(totalWithVat) amount
|
||||
FROM ticket
|
||||
GROUP BY companyFk, dated
|
||||
), receipt AS(
|
||||
SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount
|
||||
SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount
|
||||
FROM vn.receipt
|
||||
WHERE clientFk = vClientFk
|
||||
AND payed > util.VN_CURDATE()
|
||||
|
@ -79,7 +78,15 @@ BEGIN
|
|||
|
||||
UPDATE ticket t
|
||||
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
||||
SET t.risk = tr.amount;
|
||||
SET t.risk = tr.amount
|
||||
WHERE tr.isProblemCalcNeeded
|
||||
ORDER BY t.id;
|
||||
|
||||
UPDATE ticket t
|
||||
JOIN tTicketRisk tr ON tr.ticketFk = t.id
|
||||
SET t.risk = NULL
|
||||
WHERE tr.isProblemCalcNeeded
|
||||
ORDER BY t.id;
|
||||
|
||||
DROP TEMPORARY TABLE tTicketRisk;
|
||||
END IF;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE `vn`.`client`
|
||||
ADD COLUMN `hasDailyInvoice` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice';
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
ALTER TABLE vn.ticketLastState MODIFY COLUMN name varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL;
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
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);
|
|
@ -57,7 +57,7 @@ describe('Ticket List sale path', () => {
|
|||
let searchValue = 'Melee weapon heavy shield 100cm';
|
||||
await page.autocompleteSearch(selectors.ticketSales.secondSaleIdAutocomplete, searchValue);
|
||||
await page.waitToClick(selectors.ticketSales.secondSaleQuantityCell);
|
||||
await page.type(selectors.ticketSales.secondSaleQuantity, '1');
|
||||
await page.type(selectors.ticketSales.secondSaleQuantity, '8');
|
||||
await page.keyboard.press('Enter');
|
||||
const message = await page.waitForSnackbar();
|
||||
|
||||
|
|
|
@ -99,6 +99,10 @@ module.exports = Self => {
|
|||
{
|
||||
arg: 'hasElectronicInvoice',
|
||||
type: 'boolean'
|
||||
},
|
||||
{
|
||||
arg: 'hasDailyInvoice',
|
||||
type: 'boolean'
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -117,8 +121,6 @@ module.exports = Self => {
|
|||
const myOptions = {};
|
||||
const models = Self.app.models;
|
||||
const args = ctx.args;
|
||||
const userId = ctx.req.accessToken.userId;
|
||||
const $t = ctx.req.__;
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
|
|
@ -144,6 +144,9 @@
|
|||
},
|
||||
"recommendedCredit": {
|
||||
"type": "number"
|
||||
},
|
||||
"hasDailyInvoice": {
|
||||
"type": "boolean"
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<vn-autocomplete vn-one
|
||||
ng-model="$ctrl.location.countryFk"
|
||||
url="Countries"
|
||||
show-field="country"
|
||||
show-field="name"
|
||||
value-field="id"
|
||||
label="Country">
|
||||
</vn-autocomplete>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
||||
const buildFilter = require('vn-loopback/util/filter').buildFilter;
|
||||
const mergeFilters = require('vn-loopback/util/filter').mergeFilters;
|
||||
|
@ -95,6 +94,11 @@ module.exports = Self => {
|
|||
arg: 'to',
|
||||
type: 'date',
|
||||
description: `The to date filter`
|
||||
},
|
||||
{
|
||||
arg: 'days',
|
||||
type: 'number',
|
||||
description: `N days interval`
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
|
@ -192,6 +196,15 @@ module.exports = Self => {
|
|||
JOIN vn.currency cu ON cu.id = e.currencyFk`
|
||||
);
|
||||
|
||||
if (ctx.args.days) {
|
||||
stmt.merge({
|
||||
sql: `
|
||||
AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY
|
||||
AND t.shipped >= util.VN_CURDATE()
|
||||
`,
|
||||
params: [ctx.args.days]
|
||||
});
|
||||
}
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
const itemsIndex = stmts.push(stmt) - 1;
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ module.exports = Self => {
|
|||
'stickers',
|
||||
'packing',
|
||||
'grouping',
|
||||
'packing',
|
||||
'groupingMode',
|
||||
'quantity',
|
||||
'packagingFk',
|
||||
|
@ -80,7 +81,9 @@ module.exports = Self => {
|
|||
fields: [
|
||||
'id',
|
||||
'typeFk',
|
||||
'stems',
|
||||
'name',
|
||||
'category',
|
||||
'subName',
|
||||
'size',
|
||||
'minPrice',
|
||||
|
@ -96,14 +99,31 @@ module.exports = Self => {
|
|||
'value9',
|
||||
'tag10',
|
||||
'value10',
|
||||
'groupingMode'
|
||||
'groupingMode',
|
||||
'inkFk',
|
||||
'originFk',
|
||||
'producerFk'
|
||||
],
|
||||
include: {
|
||||
relation: 'itemType',
|
||||
scope: {
|
||||
fields: ['code', 'description']
|
||||
include: [
|
||||
{
|
||||
relation: 'itemType',
|
||||
scope: {
|
||||
fields: ['code', 'description']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'origin',
|
||||
scope: {
|
||||
fields: ['code']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'producer',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
|
|
@ -39,7 +39,7 @@ describe('Entry filter()', () => {
|
|||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(9);
|
||||
expect(result.length).toEqual(11);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -55,13 +55,13 @@ describe('Entry filter()', () => {
|
|||
|
||||
try {
|
||||
const ctx = {
|
||||
args: {},
|
||||
args: {days: 6},
|
||||
req: {accessToken: {userId: 1102}}
|
||||
};
|
||||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(6);
|
||||
expect(result.length).toEqual(2);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -84,7 +84,7 @@ describe('Entry filter()', () => {
|
|||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(6);
|
||||
expect(result.length).toEqual(8);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -107,7 +107,7 @@ describe('Entry filter()', () => {
|
|||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(6);
|
||||
expect(result.length).toEqual(8);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
@ -131,7 +131,7 @@ describe('Entry filter()', () => {
|
|||
|
||||
const result = await models.Entry.filter(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(8);
|
||||
expect(result.length).toEqual(10);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
</vn-one>
|
||||
<vn-one>
|
||||
<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 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 label="Km Start"
|
||||
value="{{$ctrl.summary.route.kmStart}}">
|
||||
|
|
|
@ -140,7 +140,16 @@ module.exports = Self => {
|
|||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, 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) {
|
||||
await models.Ticket.saveCmr(ctx, [ticketId], myOptions);
|
||||
|
|
|
@ -26,4 +26,36 @@ describe('Ticket saveSign()', () => {
|
|||
|
||||
expect(error).toBeDefined();
|
||||
});
|
||||
|
||||
it('should change state for ticket', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
const ticketWithPackedState = 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 = [ticketWithPackedState];
|
||||
|
||||
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: ticketWithPackedState}
|
||||
}, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(ticketTrackingAfter.name).toBe('PARTIAL_DELIVERED');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -79,7 +79,7 @@ describe('Travel extraCommunityFilter()', () => {
|
|||
|
||||
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
|
||||
|
||||
expect(result.length).toEqual(8);
|
||||
expect(result.length).toEqual(9);
|
||||
});
|
||||
|
||||
it('should return the travel matching "cargoSupplierFk"', async() => {
|
||||
|
@ -110,6 +110,6 @@ describe('Travel extraCommunityFilter()', () => {
|
|||
|
||||
const result = await app.models.Travel.extraCommunityFilter(ctx, filter);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
expect(result.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ describe('Travel filter()', () => {
|
|||
|
||||
const result = await app.models.Travel.filter(ctx);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
expect(result.length).toEqual(6);
|
||||
});
|
||||
|
||||
it('should return the routes matching "shipped from" and "shipped to"', async() => {
|
||||
|
@ -80,6 +80,6 @@ describe('Travel filter()', () => {
|
|||
|
||||
const result = await app.models.Travel.filter(ctx);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
expect(result.length).toEqual(6);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -171,8 +171,8 @@ module.exports = Self => {
|
|||
const address = await models.Address.create({
|
||||
clientFk: user.id,
|
||||
street: street,
|
||||
city: city,
|
||||
provinceFk: provinceFk,
|
||||
city,
|
||||
provinceFk,
|
||||
postalCode: postcode,
|
||||
mobile: phone,
|
||||
nickname: nickname,
|
||||
|
@ -193,7 +193,13 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
await user.updateAttribute('email', email, myOptions);
|
||||
|
||||
let countryFk;
|
||||
if (provinceFk) {
|
||||
const province = await Self.app.models.Province.findById(provinceFk, {
|
||||
fields: ['countryFk']
|
||||
});
|
||||
countryFk = province.countryFk;
|
||||
}
|
||||
await models.Worker.create({
|
||||
id: user.id,
|
||||
firstName,
|
||||
|
@ -202,7 +208,7 @@ module.exports = Self => {
|
|||
bossFk,
|
||||
fi,
|
||||
birth,
|
||||
|
||||
originCountryFk: countryFk
|
||||
}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
|
@ -212,11 +218,8 @@ module.exports = Self => {
|
|||
const message = e.sqlMessage;
|
||||
|
||||
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(`PRIMARY`)) throw new UserError(`This worker already exists`);
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,11 +27,10 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
async function tinIsValid(err, done) {
|
||||
const filter = {
|
||||
const country = await Self.app.models.Country.findOne({
|
||||
fields: ['code'],
|
||||
where: {id: this.countryFk}
|
||||
};
|
||||
const country = await Self.app.models.Country.findOne(filter);
|
||||
where: {id: this.originCountryFk}
|
||||
});
|
||||
const code = country ? country.code.toLowerCase() : null;
|
||||
|
||||
if (!this.fi || !validateTin(this.fi, code))
|
||||
|
|
|
@ -60,6 +60,11 @@
|
|||
"type": "hasMany",
|
||||
"model": "Zone",
|
||||
"foreignKey": "agencyModeFk"
|
||||
},
|
||||
"mrwService": {
|
||||
"type": "belongsTo",
|
||||
"model": "MrwService",
|
||||
"foreignKey": "code"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "salix-back",
|
||||
"version": "24.30.0",
|
||||
"version": "24.32.0",
|
||||
"author": "Verdnatura Levante SL",
|
||||
"description": "Salix backend",
|
||||
"license": "GPL-3.0",
|
||||
|
|
Loading…
Reference in New Issue