feat: refs #6276 test sale_getFromSectorCollection
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Jorge Penadés 2024-01-23 08:39:30 +01:00
parent efb8bc46c6
commit dcf6232c14
5 changed files with 32 additions and 33 deletions

View File

@ -3707,9 +3707,8 @@ INSERT INTO `vn`.`machine` (`plate`, `maker`, `model`, `warehouseFk`, `departmen
('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442); ('RE-003', 'IRON', 'JPH-24', 60, 23, 'ELECTRIC TOW', 'Drag cars', 2020, 103, 442);
INSERT INTO vn.machineWorker(workerFk,machineFk,inTimed) INSERT INTO vn.machineWorker(workerFk,machineFk,inTimed) VALUES (104,1,'2001-01-01 10:00:00.00.000');
VALUES (104,1,'2001-01-01 10:00:00.00.000');
UPDATE vn.buy UPDATE vn.buy SET itemOriginalFk = 1 WHERE id = 1;
SET itemOriginalFk = 1
WHERE id = 1; UPDATE vn.saleTracking SET stateFk = 26 WHERE id = 5;

View File

@ -349,5 +349,6 @@
"Este estado no existe": "Este estado no existe", "Este estado no existe": "Este estado no existe",
"The line could not be marked": "No se ha podido marcar la línea", "The line could not be marked": "No se ha podido marcar la línea",
"No se ha podido marcar la línea": "No se ha podido marcar la línea", "No se ha podido marcar la línea": "No se ha podido marcar la línea",
"The sale can not be tracked": "La línea no puede ser rastreada" "The sale can not be tracked": "La línea no puede ser rastreada",
"La línea no puede ser rastreada": "La línea no puede ser rastreada"
} }

View File

@ -1,5 +1,5 @@
const {models} = require('vn-loopback/server/server'); const {models} = require('vn-loopback/server/server');
fdescribe('saleTracking mark()', () => { describe('saleTracking mark()', () => {
const saleFk = 1; const saleFk = 1;
const originalQuantity = 10; const originalQuantity = 10;
const code = 'PREPARED'; const code = 'PREPARED';

View File

@ -25,36 +25,12 @@ module.exports = Self => {
}); });
Self.getFromSectorCollection = async(ctx, sectorCollectionFk, sectorFk, options) => { Self.getFromSectorCollection = async(ctx, sectorCollectionFk, sectorFk, options) => {
const myOptions = {};
const userId = ctx.req.accessToken.userId; const userId = ctx.req.accessToken.userId;
const myOptions = {userId};
if (typeof options == 'object') Object.assign(myOptions, options); if (typeof options == 'object') Object.assign(myOptions, options);
const sales = await Self.rawSql('CALL sectorCollection_getSale(?)', [sectorCollectionFk], myOptions); const [sales] = await Self.rawSql('CALL sectorCollection_getSale(?)', [sectorCollectionFk], myOptions);
/* const sales = await Self.rawSql(
`SELECT s.ticketFk,
s.itemFk,
i.longName,
itemPackingTypeFk,
subName,
s.quantity,
w.code workerCode,
sgd.saleFk,
iss.quantity pickedQuantity,
c.salesPersonFk
FROM vn.sale s
JOIN item i ON i.id = s.itemFk
JOIN saleGroupDetail sgd ON sgd.saleFk = s.id
JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk
JOIN saleTracking st ON st.saleFk = s.id
JOIN state stt ON stt.id = st.stateFk AND stt.code = 'PREVIOUS_PREPARATION'
JOIN worker w ON w.id = st.workerFk
JOIN ticket t ON t.id= s.ticketFk
JOIN client c ON c.id=t.clientFk
LEFT JOIN itemShelvingSaleSum iss ON iss.saleFk = s.id
WHERE scsg.sectorCollectionFk = ?
AND st.workerFk = ?;`, [sectorCollectionFk, userId]); */
const itemShelvings = []; const itemShelvings = [];
for (let sale of sales) { for (let sale of sales) {

View File

@ -0,0 +1,23 @@
const {models} = require('vn-loopback/server/server');
describe('sale getFromSectorCollection()', () => {
const sectorCollectionFk = 1;
const sectorFk = 1;
beforeAll(async() => {
ctx = {
req: {
headers: {origin: 'http://localhost'},
accessToken: {userId: 40}
}
};
});
it('should find an item and a shelving', async() => {
const options = {};
const itemShelvings = await models.Sale.getFromSectorCollection(ctx, sectorCollectionFk, sectorFk, options);
expect(itemShelvings.length).toEqual(1);
expect(itemShelvings[0].carros.length).toEqual(1);
});
});