2021-03-29 13:31:00 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
|
|
|
|
|
|
|
|
describe('item_getBalance()', () => {
|
2021-03-31 05:54:50 +00:00
|
|
|
it(`should return the item balance ordered by alert level`, async() => {
|
2021-03-29 13:31:00 +00:00
|
|
|
let stmts = [];
|
|
|
|
|
|
|
|
let params = {
|
2023-09-20 06:12:07 +00:00
|
|
|
itemFk: 1,
|
|
|
|
warehouseFk: 1
|
2021-03-29 13:31:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const conn = await app.models.Item.dataSource.connector;
|
|
|
|
|
2023-09-20 06:12:07 +00:00
|
|
|
stmts.push(new ParameterizedSQL('CALL vn.item_getBalance(?, ?, NULL)', [
|
2021-03-29 13:31:00 +00:00
|
|
|
params.warehouseFk,
|
|
|
|
params.itemFk
|
|
|
|
]));
|
|
|
|
|
|
|
|
let sql = ParameterizedSQL.join(stmts, ';');
|
|
|
|
let result = await conn.executeStmt(sql);
|
|
|
|
let itemBalance = result[0];
|
|
|
|
|
2021-03-31 05:54:50 +00:00
|
|
|
expect(itemBalance[0].alertLevel).toBeGreaterThanOrEqual(itemBalance[1].alertLevel);
|
|
|
|
expect(itemBalance[1].alertLevel).toBeGreaterThanOrEqual(itemBalance[2].alertLevel);
|
|
|
|
expect(itemBalance[2].alertLevel).toBeGreaterThanOrEqual(itemBalance[3].alertLevel);
|
|
|
|
expect(itemBalance[3].alertLevel).toBeGreaterThanOrEqual(itemBalance[4].alertLevel);
|
|
|
|
expect(itemBalance[4].alertLevel).toBeGreaterThanOrEqual(itemBalance[5].alertLevel);
|
|
|
|
expect(itemBalance[5].alertLevel).toBeGreaterThanOrEqual(itemBalance[6].alertLevel);
|
2021-03-29 13:31:00 +00:00
|
|
|
});
|
|
|
|
});
|