refs #6321 feat: updates
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2024-03-05 08:07:54 +01:00
parent bc09ad7da7
commit 871447cc6e
3 changed files with 51 additions and 34 deletions

View File

@ -1,3 +1,5 @@
-- Auto-generated SQL script #202401191358
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Ticket','itemLack','READ','ALLOW','ROLE','employee');
INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId)
VALUES ('Ticket','itemLackDetail','READ','ALLOW','ROLE','employee');

View File

@ -167,7 +167,7 @@ module.exports = Self => {
return [
{
'itemFk': 7176,
'itemFk': 72176,
'longName': 'Anthurium Olivius x20',
'warehouseFk': 60,
'producer': null,

View File

@ -1,4 +1,5 @@
/* eslint-disable no-console */
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => {
Self.remoteMethod('itemLackDetail', {
description: 'Download a ticket delivery note document',
@ -8,62 +9,76 @@ module.exports = Self => {
arg: 'id',
type: 'number',
description: 'The item id',
}
},
],
returns: [
{
arg: 'body',
type: ['object'],
root: true
}
root: true,
},
],
http: {
path: `/itemLack/:id/detail`,
verb: 'GET'
}
verb: 'GET',
},
});
Self.itemLackDetail = async(id, options) => {
const myOptions = {};
// const versionSQL = false;
if (typeof options == 'object')
Object.assign(myOptions, options);
const conn = Self.dataSource.connector;
const detail = await Self.rawSQL(`
const myOptions = {};
if (typeof options == 'object') Object.assign(myOptions, options);
const stmt = new ParameterizedSQL(
`
SELECT
s.Id_Movimiento, st.code, t.Id_Ticket, t.Alias, t.Fecha, s.Cantidad, ag.Agencia,
s.id saleFk,
st.code,
t.id ticketFk,
t.nickname,
t.hour,
s.quantity,
ag.name,
ts.alertLevel alertLevel,
st.name stateName,
st.id stateId,
s.Id_Article id,
s.itemFk itemFk,
al.code alertLevelCode,
z.name,
z.hour theoreticalhour,
cn.isRookie,
sc.saleClonedFk turno,
tr.saleFk peticionCompra,
t.Fecha minTimed
t.hour minTimed
FROM
Sale s
JOIN Tickets t ON t.Id_Ticket=s.Id_Ticket -- vn.ticket
LEFT JOIN zone z ON z.id = t.zoneFk -- vn.zone
LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND zc.dated = DateValue(t.Fecha)
JOIN Clientes c ON c.Id_Cliente=t.Id_Cliente -- vn.client
LEFT JOIN clientNewBorn cn ON cn.clientFk=c.Id_Cliente
JOIN Agencias ag ON ag.Id_Agencia=t.Id_Agencia -- vn.agencyMode
JOIN ticketState tls ON ts.ticketFk=t.Id_Ticket -- vn.sale
LEFT JOIN state s ON st.id=ts.state
LEFT JOIN alertLevel al ON al.id = st.alertLevel
LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.Id_Movimiento
LEFT JOIN ticketRequest tr ON tr.saleFk = s.Id_Movimiento
WHERE
AND s.Id_Article = ?
AND NOT Cantidad
AND Fecha >= util.VN_CURDATE()
AND Fecha < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY
ORDER BY s.Id_Movimiento DESC+
`, [id, 2], myOptions);
vn.sale s
JOIN vn.ticket t ON t.id=s.ticketFk -- vn.ticket
LEFT JOIN vn.zone z ON z.id = t.zoneFk -- vn.zone
LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk -- AND zc.dated = DateValue(t.Fecha)
JOIN vn.client c ON c.id=t.clientFk -- vn.client
LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id
JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk -- vn.agencyMode
JOIN vn.agency ag ON ag.id=agm.id -- vn.agencyMode
JOIN vn.ticketState ts ON ts.ticketFk=t.id -- vn.sale
LEFT JOIN vn.state st ON st.id=ts.state
LEFT JOIN vn.alertLevel al ON al.id = st.alertLevel
LEFT JOIN vn.saleCloned sc ON sc.saleClonedFk = s.id
LEFT JOIN vn.ticketRequest tr ON tr.saleFk = s.id
LIMIT 1
`,
null
);
// WHERE
// s.itemFk = ?
return detail;
// AND t.landed >= util.VN_CURDATE()
// AND t.landed < INTERVAL util.VN_CURDATE() + INTERVAL ? + 1 DAY
// ORDER BY s.id DESC+
// [id,2]
const sql = ParameterizedSQL.join([stmt], ';');
const result = await conn.executeStmt(sql, myOptions);
return result;
};
};