#6964 _ itemOlder #2197
Labels
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: verdnatura/salix#2197
Loading…
Reference in New Issue
No description provided.
Delete Branch "6964_itemOlder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +36,4 @@
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
const result = await Self.rawSql(`
SELECT COUNT(ish.id)
Millor fiquem un alias al cam
@ -0,0 +37,4 @@
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
const result = await Self.rawSql(`
SELECT COUNT(ish.id)
FROM vn.itemShelving ish
Tabulació
@ -0,0 +45,4 @@
LEFT JOIN vn.parking p ON p.id = s.parkingFk
WHERE ish.shelvingFk = ?
)sub ON sub.itemFK = ish.itemFk
JOIN vn.shelving s ON s.code = ish.shelvingFk
Tabulació
@ -0,0 +52,4 @@
AND (ish.shelvingFk <> ? OR ? IS NULL)
AND (ish.itemFk <> ? OR ? IS NULL)`,
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
return result[0]['COUNT(ish.id)'] > 0;
Si li poses el alias aci hi ha que canviarlo
@ -0,0 +34,4 @@
}
});
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
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
@ -0,0 +51,4 @@
AND (p.code <> ? OR ? IS NULL)
AND (ish.shelvingFk <> ? OR ? IS NULL)
AND (ish.itemFk <> ? OR ? IS NULL)`,
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
falta gastar la transaccio (...shelvingFkOut, itemFk, itemFk], options)
Llevat options
Es ficarlo sino no gastarà la transaccio
L'he posat però no veia que fera falta...
@ -0,0 +53,4 @@
AND (p.code <> ? OR ? IS NULL)
AND (ish.shelvingFk <> ? OR ? IS NULL)
AND (ish.itemFk <> ? OR ? IS NULL)`,
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk]);
Aci
@ -0,0 +5,4 @@
it('should return false because there are not older items', async() => {
const shelvingFkIn = 'GVC';
const shelvingFkOut = 'HEJ';
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, shelvingFkOut);
Al cridar a la funcio hi ha que seguir el mateix ordre que dalt (
async(shelvingFkIn, parking, shelvingFkOut, itemFk, options
)Per tant seria
await models.ItemShelving.hasItemOlder(shelvingFkIn, null, shelvingFkOut)
@ -0,0 +33,4 @@
await itemShelvingBefore.updateAttributes({
itemFk: itemFk
});
const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking);
Aci deuries gastar la transaccio
await models.ItemShelving.hasItemOlder(shelvingFkIn, parking, null, null, myOptions)
Ací si que veig que faltava posar myOptions perquè faig més accions
6964_itemOlderto #6964 _ itemOlder@ -0,0 +36,4 @@
});
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving');
Faltaria la traduccion
Afegida
@ -0,0 +35,4 @@
}
});
Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => {
@ -0,0 +53,4 @@
AND (p.code <> ? OR ? IS NULL)
AND (ish.shelvingFk <> ? OR ? IS NULL)
AND (ish.itemFk <> ? OR ? IS NULL)`,
[shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk], options);
myOptions
@ -0,0 +32,4 @@
const itemShelvingBefore = await models.ItemShelving.findOne(filter, myOptions);
await itemShelvingBefore.updateAttributes({
itemFk: itemFk
});
, myOptions
@ -0,0 +31,4 @@
try {
const itemShelvingBefore = await models.ItemShelving.findOne(filter, myOptions);
await itemShelvingBefore.updateAttributes({
itemFk: itemFk
, myOptions
Tot lo demes okay
@ -0,0 +22,4 @@
},
{
arg: 'itemFk',
type: 'int',
He buscat y type int no ho hem gastat mai,
Seria
type: 'integer',
vaig mesclant llenguatges :-)
@ -0,0 +46,4 @@
SELECT COUNT(ish.id) countItemOlder
FROM vn.itemShelving ish
JOIN (
SELECT ish.itemFk, created,shelvingFk, p.code
en la subconsulta el p.code y el LEFT JOIN vn.parking p ON p.id = s.parkingFk sirven para algo??
Llevat