Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
This commit is contained in:
commit
0343aea2a5
|
@ -771,10 +771,10 @@ INSERT INTO `vn`.`saleTracking`(`saleFk`, `isChecked`, `created`, `originalQuant
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`)
|
INSERT INTO `vn`.`itemBarcode`(`id`, `itemFk`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1 ,1 ),
|
(1, 1, 1111111111),
|
||||||
(2, 1 ,2 ),
|
(2, 1, 2222222222),
|
||||||
(3, 1 ,3 ),
|
(3, 1, 3333333333),
|
||||||
(4, 2 ,4 );
|
(4, 2, 4444444444);
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemPlacement`(`id`, `itemFk`, `warehouseFk`, `code`)
|
INSERT INTO `vn`.`itemPlacement`(`id`, `itemFk`, `warehouseFk`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -49,13 +49,13 @@
|
||||||
<vn-input-number vn-one
|
<vn-input-number vn-one
|
||||||
label="Price"
|
label="Price"
|
||||||
field="$ctrl.zone.price"
|
field="$ctrl.zone.price"
|
||||||
min="0.00"
|
min="0"
|
||||||
step="0.10">
|
step="0.10">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
<vn-input-number vn-one
|
<vn-input-number vn-one
|
||||||
label="Bonus"
|
label="Bonus"
|
||||||
field="$ctrl.zone.bonus"
|
field="$ctrl.zone.bonus"
|
||||||
min="0.00"
|
min="0"
|
||||||
step="0.10">
|
step="0.10">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -72,7 +72,7 @@ module.exports = Self => {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'search':
|
case 'search':
|
||||||
return /^\d+$/.test(value)
|
return /^\d+$/.test(value)
|
||||||
? {'i.id': {inq: value}}
|
? {or: [{'i.id': value}, {'ib.code': value}]}
|
||||||
: {'i.name': {like: `%${value}%`}};
|
: {'i.name': {like: `%${value}%`}};
|
||||||
case 'id':
|
case 'id':
|
||||||
return {'i.id': value};
|
return {'i.id': value};
|
||||||
|
@ -89,9 +89,6 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* case 'hasVisible':
|
|
||||||
return value ? {'v.visible': {gt: 0}} : {'v.visible': {or: [{lte: 0}, {neq: null}]}}; */
|
|
||||||
|
|
||||||
filter = mergeFilters(ctx.args.filter, {where});
|
filter = mergeFilters(ctx.args.filter, {where});
|
||||||
let stmts = [];
|
let stmts = [];
|
||||||
let stmt;
|
let stmt;
|
||||||
|
@ -117,22 +114,10 @@ module.exports = Self => {
|
||||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||||
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk
|
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = t.warehouseFk
|
||||||
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
LEFT JOIN vn.buy b ON b.id = lb.buy_id
|
||||||
LEFT JOIN itemPlacement itn ON itn.itemFk = i.id AND itn.warehouseFk = t.warehouseFk`
|
LEFT JOIN itemPlacement itn ON itn.itemFk = i.id AND itn.warehouseFk = t.warehouseFk
|
||||||
|
LEFT JOIN itemBarcode ib ON ib.itemFk = i.id`
|
||||||
);
|
);
|
||||||
|
|
||||||
/* if (ctx.args.hasVisible !== undefined) {
|
|
||||||
stmts.push('CALL cache.visible_refresh(@visibleCalc, false, 1)');
|
|
||||||
stmts.push('CALL cache.visible_refresh(@visibleCalc, false, 44)');
|
|
||||||
let joinAvailable = new ParameterizedSQL(
|
|
||||||
`LEFT JOIN cache.visible v
|
|
||||||
ON v.item_id = i.id`
|
|
||||||
);
|
|
||||||
stmt.merge(joinAvailable);
|
|
||||||
} */
|
|
||||||
/* where v.visible > 0
|
|
||||||
where v.visible <= 0 OR v.visible IS NULL
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
for (const tag of ctx.args.tags) {
|
for (const tag of ctx.args.tags) {
|
||||||
|
@ -156,13 +141,10 @@ where v.visible <= 0 OR v.visible IS NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt.merge(conn.makeWhere(filter.where));
|
stmt.merge(conn.makeWhere(filter.where));
|
||||||
|
stmt.merge(`GROUP BY i.id`);
|
||||||
/* if (ctx.args.hasVisible !== undefined)
|
|
||||||
stmt.merge(`GROUP BY i.id`);
|
|
||||||
*/
|
|
||||||
stmt.merge(conn.makePagination(filter));
|
stmt.merge(conn.makePagination(filter));
|
||||||
let itemsIndex = stmts.push(stmt) - 1;
|
|
||||||
|
|
||||||
|
let itemsIndex = stmts.push(stmt) - 1;
|
||||||
let sql = ParameterizedSQL.join(stmts, ';');
|
let sql = ParameterizedSQL.join(stmts, ';');
|
||||||
let result = await conn.executeStmt(sql);
|
let result = await conn.executeStmt(sql);
|
||||||
return itemsIndex === 0 ? result : result[itemsIndex];
|
return itemsIndex === 0 ? result : result[itemsIndex];
|
||||||
|
|
|
@ -1,6 +1,22 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('item filter()', () => {
|
describe('item filter()', () => {
|
||||||
|
it('should return 1 result filtering by id', async() => {
|
||||||
|
let filter = {};
|
||||||
|
let result = await app.models.Item.filter({args: {filter: filter, search: 1}});
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
expect(result[0].id).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return 1 result filtering by barcode', async() => {
|
||||||
|
let filter = {};
|
||||||
|
let result = await app.models.Item.filter({args: {filter: filter, search: 4444444444}});
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
expect(result[0].id).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
it('should return 1 result using filter and tags', async() => {
|
it('should return 1 result using filter and tags', async() => {
|
||||||
let filter = {
|
let filter = {
|
||||||
order: 'isActive ASC, name',
|
order: 'isActive ASC, name',
|
||||||
|
|
Loading…
Reference in New Issue