Merge branch 'test' into dev
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-07-23 09:27:05 +02:00
commit c6b49e2134
5 changed files with 54 additions and 66 deletions

View File

@ -13,30 +13,16 @@ BEGIN
* @param vBookEntry Id de asiento, si es NULL se genera uno nuevo
*/
DECLARE vFiscalYear INT;
DECLARE vDistinctTransactions INT;
DECLARE vHasRepeatedTransactions BOOL;
SELECT COUNT(DISTINCT iit.transactionTypeSageFk) INTO vDistinctTransactions
FROM invoiceIn ii
JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id
JOIN invoiceInSerial iis ON iis.code = ii.serial
WHERE iit.invoiceInFk = vSelf
AND iis.taxAreaFk = 'CEE'
AND iit.transactionTypeSageFk;
IF vDistinctTransactions > 1 THEN
CALL util.throw ('This invoice does not allow different types of transactions');
END IF;
SELECT TRUE INTO vHasRepeatedTransactions
FROM invoiceInTax
WHERE invoiceInFk = vSelf
GROUP BY transactionTypeSageFk
HAVING COUNT(transactionTypeSageFk) > 1
HAVING COUNT(DISTINCT transactionTypeSageFk) > 1
LIMIT 1;
IF vHasRepeatedTransactions THEN
CALL util.throw ('This invoice contains repeated types of transactions');
CALL util.throw ('This invoice contains different types of transactions');
END IF;
CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn

View File

@ -98,11 +98,12 @@ proc: BEGIN
itemShelvingFk,
saleFk,
quantity,
userFk)
isPicked)
SELECT vItemShelvingFk,
vSaleFk,
vReservedQuantity,
vUserFk;
vUserFk,
FALSE;
UPDATE itemShelving
SET available = available - vReservedQuantity

View File

@ -91,11 +91,13 @@ module.exports = Self => {
SELECT t.cmrFk,
t.id ticketFk,
t.routeFk,
co.name country,
co.id countryFk,
co.name countryName,
t.clientFk,
IF(sub.id, TRUE, FALSE) hasCmrDms,
DATE(t.shipped) shipped,
t.warehouseFk
t.warehouseFk,
w.name warehouseName
FROM ticket t
JOIN ticketState ts ON ts.ticketFk = t.id
JOIN state s ON s.id = ts.stateFk

View File

@ -91,25 +91,20 @@ module.exports = Self => {
let where = buildFilter(ctx.args, (param, value) => {
switch (param) {
case 'search':
return {'r.id': value};
return {'id': value};
case 'from':
return {'r.created': {gte: value}};
return {'created': {gte: value}};
case 'to':
return {'r.created': {lte: value}};
case 'm3':
return {'r.m3': value};
return {'created': {lte: value}};
case 'description':
return {'r.description': {like: `%${value}%`}};
return {'description': {like: `%${value}%`}};
case 'isOk':
case 'm3':
case 'warehouseFk':
param = `v.${param}`;
return {[param]: value};
case 'workerFk':
case 'vehicleFk':
case 'agencyModeFk':
param = `r.${param}`;
return {[param]: value};
case 'isOk':
return {'r.isOk': value};
}
});
@ -119,34 +114,38 @@ module.exports = Self => {
let stmt;
stmt = new ParameterizedSQL(
`SELECT
r.id,
r.workerFk,
r.created,
r.vehicleFk,
r.agencyModeFk,
r.time,
r.isOk,
r.kmStart,
r.kmEnd,
r.started,
r.finished,
r.gestdocFk,
r.cost,
r.m3,
r.description,
am.name agencyName,
u.name AS workerUserName,
v.numberPlate AS vehiclePlateNumber,
Date_format(r.time, '%H:%i') hour,
eu.email
FROM route r
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN agency a ON a.id = am.agencyFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.id
LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk`
`SELECT *
FROM(
SELECT
r.id,
r.workerFk,
r.created,
r.vehicleFk,
r.agencyModeFk,
r.time,
r.isOk,
r.kmStart,
r.kmEnd,
r.started,
r.finished,
r.gestdocFk,
r.cost,
r.m3,
r.description,
am.name agencyName,
u.name workerUserName,
v.numberPlate vehiclePlateNumber,
Date_format(r.time, '%H:%i') hour,
eu.email,
v.warehouseFk
FROM route r
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
LEFT JOIN agency a ON a.id = am.agencyFk
LEFT JOIN vehicle v ON v.id = r.vehicleFk
LEFT JOIN worker w ON w.id = r.workerFk
LEFT JOIN account.user u ON u.id = w.id
LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk
) sub`
);
stmt.merge(conn.makeSuffix(filter));

View File

@ -28,11 +28,11 @@ module.exports = Self => {
if (canViewAll) {
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
filterGrant = {
where: {'a.warehouseFk': userConfig.warehouseFk}
where: {'warehouseFk': userConfig.warehouseFk}
};
} else {
filterGrant = {
where: {'r.workerFk': userId}
where: {'workerFk': userId}
};
}
@ -46,16 +46,16 @@ module.exports = Self => {
and: [
{
or: [
{'r.created': currentDate},
{'r.created': nextDay}
{'created': currentDate},
{'created': nextDay}
]
}
]
},
order: [
'r.created ASC',
'r.time ASC',
'am.name ASC'
'created ASC',
'time ASC',
'agencyName ASC'
]
};