#6964 _ itemOlder #2197
|
@ -1,3 +1,4 @@
|
||||||
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethod('hasItemOlder', {
|
Self.remoteMethod('hasItemOlder', {
|
||||||
description:
|
description:
|
||||||
|
@ -35,8 +36,9 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
sergiodt marked this conversation as resolved
Outdated
|
|||||||
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
|
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
|
||||||
sergiodt marked this conversation as resolved
alexm
commented
const myOptions = {};
if (typeof options == 'object')
Object.assign(myOptions, options);
|
|||||||
|
if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving');
|
||||||
sergiodt marked this conversation as resolved
Outdated
carlosap
commented
Millor fiquem un alias al cam Millor fiquem un alias al cam
alexm
commented
Faltaria la traduccion Faltaria la traduccion
sergiodt
commented
Afegida Afegida
|
|||||||
const result = await Self.rawSql(`
|
const result = await Self.rawSql(`
|
||||||
sergiodt marked this conversation as resolved
Outdated
carlosap
commented
Tabulació Tabulació
|
|||||||
SELECT COUNT(ish.id)
|
SELECT COUNT(ish.id) countItemOlder
|
||||||
FROM vn.itemShelving ish
|
FROM vn.itemShelving ish
|
||||||
JOIN (
|
JOIN (
|
||||||
SELECT ish.itemFk, created,shelvingFk, p.code
|
SELECT ish.itemFk, created,shelvingFk, p.code
|
||||||
|
@ -52,6 +54,6 @@ module.exports = Self => {
|
||||||
AND (ish.shelvingFk <> ? OR ? IS NULL)
|
AND (ish.shelvingFk <> ? OR ? IS NULL)
|
||||||
sergiodt marked this conversation as resolved
Outdated
alexm
commented
falta gastar la transaccio (...shelvingFkOut, itemFk, itemFk], options) falta gastar la transaccio (...shelvingFkOut, itemFk, itemFk], options)
sergiodt
commented
Llevat options Llevat options
alexm
commented
Es ficarlo sino no gastarà la transaccio Es ficarlo sino no gastarà la transaccio
sergiodt
commented
L'he posat però no veia que fera falta... L'he posat però no veia que fera falta...
|
|||||||
AND (ish.itemFk <> ? OR ? IS NULL)`,
|
AND (ish.itemFk <> ? OR ? IS NULL)`,
|
||||||
sergiodt marked this conversation as resolved
Outdated
alexm
commented
Si li poses el alias aci hi ha que canviarlo Si li poses el alias aci hi ha que canviarlo
|
|||||||
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
|
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
|
||||||
sergiodt marked this conversation as resolved
Outdated
alexm
commented
Aci Aci
alexm
commented
myOptions myOptions
|
|||||||
return result[0]['COUNT(ish.id)'] > 0;
|
return result[0]['countItemOlder'] > 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Els 3(parking, shelvingFkOut, itemFk) poden ser null a la vega? O faria falta al menys uno?
Per si fera falta ficar un if(!parking && !shelvingFkOut && !itemFk) return throw new UserError(...)
Posat