#6964 _ itemOlder #2197

Merged
sergiodt merged 26 commits from 6964_itemOlder into dev 2024-04-04 14:18:20 +00:00
2 changed files with 45 additions and 0 deletions
Showing only changes of commit 09923d2509 - Show all commits

View File

@ -0,0 +1,44 @@
module.exports = Self => {
Self.remoteMethod('hasItemOlder', {
description: 'Get boolean if any item of the shelving has older created in another shelving ',
accessType: 'WRITE',
accepts: [{
arg: 'shelvingFk',
type: 'string',
required: true,
description: 'Shelving code'
},
{
arg: 'parking',
type: 'string',
required: true,
description: 'Parking code'
}],
returns: {
type: 'boolean',
root: true
},
http: {
path: `/hasItemOlder`,
verb: 'GET'
}
});
sergiodt marked this conversation as resolved Outdated
Outdated
Review

He buscat y type int no ho hem gastat mai,
Seria type: 'integer',

He buscat y type int no ho hem gastat mai, Seria `type: 'integer',`

vaig mesclant llenguatges :-)

vaig mesclant llenguatges :-)
Self.hasItemOlder = async(shelvingFk, parking, options) => {
const result = await Self.rawSql(`
SELECT COUNT(ish.id)
FROM vn.itemShelving ish
JOIN (
SELECT ish.itemFk, created,shelvingFk, p.code
FROM vn.itemShelving ish
JOIN vn.shelving s ON ish.shelvingFk = s.code
JOIN vn.parking p ON p.id = s.parkingFk
WHERE ish.shelvingFk = ?
)sub ON sub.itemFK = ish.itemFk
sergiodt marked this conversation as resolved Outdated
Outdated
Review

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(...)

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

Posat
JOIN vn.shelving s ON s.code = ish.shelvingFk
sergiodt marked this conversation as resolved
Review
    const myOptions = {};

    if (typeof options == 'object')
        Object.assign(myOptions, options);
const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options);
JOIN vn.parking p ON p.id = s.parkingFk
sergiodt marked this conversation as resolved Outdated

Millor fiquem un alias al cam

Millor fiquem un alias al cam
Review

Faltaria la traduccion

Faltaria la traduccion
Review

Afegida

Afegida
WHERE ish.shelvingFk <> ? AND sub.created > ish.created AND p.code <> ?`,
sergiodt marked this conversation as resolved Outdated

Tabulació

Tabulació
[shelvingFk, shelvingFk, parking]);
return result[0]['COUNT(ish.id)'] > 0;
};
};

View File

@ -2,4 +2,5 @@ module.exports = Self => {
require('../methods/item-shelving/deleteItemShelvings')(Self);
require('../methods/item-shelving/upsertItem')(Self);
require('../methods/item-shelving/getInventory')(Self);
require('../methods/item-shelving/hasItemOlder')(Self);
};