fixes #5418 Buscador lateral en item/fixed-price #1412

Merged
alexandre merged 14 commits from 5418-buscador-lateral-fixed-price into dev 2023-04-18 08:50:46 +00:00
10 changed files with 38 additions and 23 deletions
Showing only changes of commit ac4772e44e - Show all commits

View File

@ -0,0 +1 @@
DROP TRIGGER IF EXISTS `vn`.`claimBeginning_afterInsert`;

View File

@ -1774,12 +1774,12 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`,
( 6, 'mana', 'Mana', 72, 4, 0),
( 7, 'lack', 'Faltas', 72, 2, 0);
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`)
INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `rma`, `ticketFk`)
VALUES
(1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183'),
(2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL),
(3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL),
(4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL);
(1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, '02676A049183', 11),
(2, util.VN_CURDATE(), 2, 1101, 18, 3, 0, util.VN_CURDATE(), 1, NULL, 16),
(3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, NULL, 7),
(4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, NULL, 8);
INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`)
VALUES

View File

@ -274,5 +274,6 @@
"This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado",
"Insert a date range": "Inserte un rango de fechas",
"Added observation": "{{user}} añadió esta observacion: {{text}}",
"Comment added to client": "Observación añadida al cliente {{clientFk}}"
"Comment added to client": "Observación añadida al cliente {{clientFk}}",
"Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen"
}

View File

@ -311,7 +311,7 @@ class VnMySQL extends MySQL {
return super[method].apply(this, args);
this.invokeMethodP(method, [...args], model, ctx, opts)
.then(res => cb(...res), cb);
.then(res => cb(...[null].concat(res)), cb);
}
async invokeMethodP(method, args, model, ctx, opts) {
@ -331,8 +331,7 @@ class VnMySQL extends MySQL {
const userId = opts.httpCtx && opts.httpCtx.active.accessToken.userId;
const user = await Model.app.models.Account.findById(userId, { fields: ['name'] }, opts);
await this.executeP(`CALL account.myUser_loginWithName(?)`, [user.name], opts);
}
else {
} else {
where = ctx.where;
id = ctx.id;
data = ctx.data;
@ -358,9 +357,12 @@ class VnMySQL extends MySQL {
}
}
const res = await new Promise(resolve => {
const res = await new Promise((resolve, reject) => {
const fnArgs = args.slice(0, -2);
fnArgs.push(opts, (...args) => resolve(args));
fnArgs.push(opts, (err, ...args) => {
if (err) return reject(err);
resolve(args);
});
super[method].apply(this, fnArgs);
});
@ -375,11 +377,11 @@ class VnMySQL extends MySQL {
case 'update': {
switch (method) {
case 'createAll':
for (const row of res[1])
for (const row of res[0])
ids.push(row[idName]);
break;
case 'create':
ids.push(res[1]);
ids.push(res[0]);
break;
case 'update':
if (data[idName] != null)
@ -387,7 +389,7 @@ class VnMySQL extends MySQL {
break;
}
const newWhere = ids.length ? { [idName]: ids } : where;
const newWhere = ids.length ? {[idName]: {inq: ids}} : where;
const stmt = this.buildSelectStmt(op, data, idName, model, newWhere, limit);
newInstances = await this.executeStmt(stmt, opts);
@ -671,4 +673,4 @@ SQLConnector.prototype.all = function find(model, filter, options, cb) {
cb(error, [])
}
});
};
};

View File

@ -2,9 +2,9 @@ const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
describe('Claim createFromSales()', () => {
const ticketId = 16;
const ticketId = 23;
const newSale = [{
id: 3,
id: 31,
instance: 0,
quantity: 10
}];

View File

@ -10,8 +10,16 @@ module.exports = Self => {
});
Self.observe('before save', async ctx => {
if (ctx.isNewInstance) return;
//await claimIsEditable(ctx);
if (ctx.isNewInstance) {
const models = Self.app.models;
const options = ctx.options;
const instance = ctx.instance;
const ticket = await models.Sale.findById(instance.saleFk, {fields: ['ticketFk']}, options);
const claim = await models.Claim.findById(instance.claimFk, {fields: ['ticketFk']}, options);
if (ticket.ticketFk != claim.ticketFk)
throw new UserError(`Cannot create a new claimBeginning from a different ticket`);
}
// await claimIsEditable(ctx);
});
Self.observe('before delete', async ctx => {

View File

@ -50,7 +50,7 @@ describe('Item editFixedPrice()', () => {
await models.FixedPrice.editFixedPrice(ctx, field, newValue, null, filter, options);
const [result] = await models.FixedPrice.filter(ctx, null, options);
const [result] = await models.FixedPrice.filter(ctx, filter, options);
expect(result[field]).toEqual(newValue);

View File

@ -20,6 +20,9 @@
},
"created": {
"type": "date"
},
"isChecked": {
"type": "boolean"
}
},
"relations": {

View File

@ -1,6 +1,6 @@
{
"name": "salix-back",
"version": "23.14.01",
"version": "23.16.01",
"author": "Verdnatura Levante SL",
"description": "Salix backend",
"license": "GPL-3.0",

View File

@ -12,8 +12,8 @@ SELECT ep.id palletFk,
JOIN vn.expedition e ON e.id = es.expeditionFk
JOIN vn.ticket t ON t.id = e.ticketFk
JOIN vn.route r ON r.id = t.routeFk
LEFT JOIN vn2008.Rutas_monitor rm ON rm.Id_Ruta = r.id
LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id
LEFT JOIN vn.expeditionTruck et2 ON et2.id = rm.expeditionTruckFk
WHERE ep.id = ?
GROUP BY ep.id, t.routeFk
ORDER BY t.routeFk
ORDER BY t.routeFk