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

This commit is contained in:
Javier Segarra 2025-01-28 08:45:00 +01:00
parent 1a0992da78
commit 10eef6d1b6
8 changed files with 141 additions and 9 deletions

View File

@ -5,4 +5,4 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType
('Ticket','itemLackOrigin','WRITE','ALLOW','ROLE','employee'),
('Ticket','split','WRITE','ALLOW','ROLE','employee'),
('Ticket','negativeOrigin','READ','ALLOW','ROLE','employee'),
('Sale','replaceItem','READ','ALLOW','ROLE','employee');
('Sale','replaceItem','WRITE','ALLOW','ROLE','employee');

View File

@ -255,6 +255,6 @@
"Holidays to past days not available": "Holidays to past days not available",
"Incorrect delivery order alert on route": "Incorrect delivery order alert on route: {{ route }} zone: {{ zone }}",
"Ticket has been delivered out of order": "The ticket {{ticket}} {{{fullUrl}}} has been delivered out of order.",
"negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})"
"negativeReplaced": "(Negativos) Sustituido el articulo [{{oldItemId}}]({{oldItemUrl}}) por[{{newItemId}}]({{newItemUrl}}) {{newItemId}} del ticket [{{ticketId}}]({{{ticketUrl}})",
"price retrieval failed": "price retrieval failed"
}

View File

@ -43,6 +43,14 @@ module.exports = Self => {
arg: 'postcode',
type: 'string',
},
{
arg: 'sageTransactionTypeFk',
type: 'number',
},
{
arg: 'sageTaxTypeFk',
type: 'number',
},
{
arg: 'provinceFk',
type: 'number',
@ -79,6 +87,10 @@ module.exports = Self => {
return /^\d+$/.test(value)
? {'c.id': {inq: value}}
: {'c.name': {like: `%${value}%`}};
case 'sageTaxTypeFk':
return {'sti.CodigoIva': value};
case 'sageTransactionTypeFk':
return {'stt.CodigoTransaccion': value};
case 'name':
case 'salesPersonFk':
case 'fi':

View File

@ -0,0 +1,104 @@
const {ParameterizedSQL} = require('loopback-connector');
module.exports = Self => {
Self.remoteMethod('itemLackDetail', {
description: 'Retrieve detail from ticket',
accessType: 'READ',
accepts: [
{
arg: 'itemFk',
type: 'number',
description: 'The item id',
},
{
arg: 'warehouseFk',
type: 'number',
description: 'The warehouse id',
},
{
arg: 'filter',
type: 'object',
description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string',
http: {source: 'query'}
}
],
returns: [
{
arg: 'body',
type: ['object'],
root: true,
},
],
http: {
path: `/itemLack/:itemFk`,
verb: 'GET',
},
});
Self.itemLackDetail = async(itemFk, warehouseFk, filter, options) => {
const conn = Self.dataSource.connector;
const myOptions = {};
if (typeof options == 'object') Object.assign(myOptions, options);
const stmt = new ParameterizedSQL(
`
SELECT
s.id saleFk,
st.code,
t.id ticketFk,
t.nickname,
t.shipped,
t.hour,
s.quantity,
ag.name agName,
ts.alertLevel alertLevel,
st.name stateName,
st.id stateId,
s.itemFk itemFk,
s.price price,
al.code alertLevelCode,
z.id zoneFk,
z.name zoneName,
z.hour theoreticalhour,
cn.isRookie,
IF(sc.saleClonedFk, 1, 0 ) as turno,
IF(tr.saleFk , 1, 0 ) as peticionCompra,
t.hour minTimed,
c.id customerId,
c.name customerName,
ot.code observationTypeCode
FROM
vn.sale s
JOIN vn.ticket t ON t.id=s.ticketFk
LEFT JOIN vn.zone z ON z.id = t.zoneFk
LEFT JOIN vn.zoneClosure zc ON zc.zoneFk = t.zoneFk
JOIN vn.client c ON c.id=t.clientFk
LEFT JOIN bs.clientNewBorn cn ON cn.clientFk=c.id
JOIN vn.agencyMode agm ON agm.id=t.agencyModeFk
JOIN vn.agency ag ON ag.id=agm.id
JOIN vn.ticketState ts ON ts.ticketFk=t.id
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
LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id
LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk
WHERE
s.itemFk = ?
AND t.landed >= util.VN_CURDATE()
AND t.landed < util.VN_CURDATE() + INTERVAL ? + 1 DAY
`,
[itemFk, 2]);
if (filter.where.stateFk) {
stmt.merge({
sql: `AND ts.alertLevel=?`, params: [filter.where.stateFk]});
}
// }
// stmt.merge(conn.makeWhere(filter.where));
const sql = ParameterizedSQL.join([stmt], ';');
const result = await conn.executeStmt(sql, myOptions);
return result;
};
};

View File

@ -79,7 +79,11 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const filterKeyOrder = ['days', 'itemFk', 'longname', 'supplier', 'colour', 'size', 'originFk', 'lack', 'warehouseFk'];
const filterKeyOrder = [
'days', 'itemFk', 'longname', 'supplier',
'colour', 'size', 'originFk',
'lack', 'warehouseFk'
];
delete ctx?.args?.ctx;

View File

@ -46,12 +46,15 @@ module.exports = Self => {
t.shipped,
s.quantity,
ag.name,
ag.id agencyFk,
IF(ISNULL(tls.alertLevel),0,tls.alertLevel) alertLevel,
IF(ISNULL(st.name),'Libre',st.name) stateName,
s.id stateId,
s.id saleFk,
s.itemFk,
s.price price,
al.code AS alertLevelCode,
z.name,
z.name zoneName,
z.id zoneFk,
Format(z.hour, "hh:mm") theoreticalhour,
cn.isRookie,
IF(ISNULL(sc.saleClonedFk),0,1) turno,
@ -98,6 +101,7 @@ module.exports = Self => {
r.shipment,
r.amount,
ag.name,
ag.id,
NULL,
NULL,
NULL,
@ -105,6 +109,8 @@ module.exports = Self => {
NULL,
NULL,
NULL,
NULL,
NULL,
cn.isRookie,
NULL,
NULL,

View File

@ -17,6 +17,12 @@ module.exports = Self => {
description: 'Destination ticket id',
required: false
},
{
arg: 'newDate',
type: 'date',
description: 'Custom new date',
required: false
},
{
arg: 'sales',
type: ['object'],
@ -33,7 +39,7 @@ module.exports = Self => {
}
});
Self.transferSales = async(ctx, id, ticketId, sales, options) => {
Self.transferSales = async(ctx, id, ticketId, sales, newDate, options) => {
const userId = ctx.req.accessToken.userId;
const models = Self.app.models;
const myOptions = {userId};

View File

@ -13,7 +13,7 @@ module.exports = Self => {
require('../methods/sale/usesMana')(Self);
require('../methods/sale/clone')(Self);
require('../methods/sale/getFromSectorCollection')(Self);
// require('../methods/sale/replaceItem')(Self);
require('../methods/sale/replaceItem')(Self);
Self.validatesPresenceOf('concept', {
message: `Concept cannot be blank`