7199-devToTest_2316 #2287
|
@ -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 => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
|
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
|
||||||
|
if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving');
|
||||||
const result = await Self.rawSql(`
|
const result = await Self.rawSql(`
|
||||||
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)
|
||||||
AND (ish.itemFk <> ? OR ? IS NULL)`,
|
AND (ish.itemFk <> ? OR ? IS NULL)`,
|
||||||
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
|
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
|
||||||
return result[0]['COUNT(ish.id)'] > 0;
|
return result[0]['countItemOlder'] > 0;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue