removed niches model, relations and its usages
This commit is contained in:
parent
0b331c4026
commit
e6bc856b35
|
@ -112,8 +112,6 @@ module.exports = Self => {
|
||||||
return {'it.workerFk': value};
|
return {'it.workerFk': value};
|
||||||
case 'origin':
|
case 'origin':
|
||||||
return {'ori.code': value};
|
return {'ori.code': value};
|
||||||
case 'niche':
|
|
||||||
return {'ip.code': value};
|
|
||||||
case 'intrastat':
|
case 'intrastat':
|
||||||
return {'intr.description': value};
|
return {'intr.description': value};
|
||||||
}
|
}
|
||||||
|
@ -148,8 +146,7 @@ module.exports = Self => {
|
||||||
ic.name AS category,
|
ic.name AS category,
|
||||||
intr.description AS intrastat,
|
intr.description AS intrastat,
|
||||||
b.grouping,
|
b.grouping,
|
||||||
b.packing,
|
b.packing
|
||||||
ip.code AS niche, @visibleCalc
|
|
||||||
FROM item i
|
FROM item i
|
||||||
LEFT JOIN itemType it ON it.id = i.typeFk
|
LEFT JOIN itemType it ON it.id = i.typeFk
|
||||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
|
@ -159,8 +156,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN producer pr ON pr.id = i.producerFk
|
LEFT JOIN producer pr ON pr.id = i.producerFk
|
||||||
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 = it.warehouseFk
|
LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = it.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 ip ON ip.itemFk = i.id AND ip.warehouseFk = it.warehouseFk`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
|
|
|
@ -92,19 +92,11 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
promises.push(models.ItemBotanical.find(filter, myOptions));
|
promises.push(models.ItemBotanical.find(filter, myOptions));
|
||||||
|
|
||||||
// Niches
|
|
||||||
filter = {
|
|
||||||
where: {itemFk: id},
|
|
||||||
include: {relation: 'warehouse'}
|
|
||||||
};
|
|
||||||
promises.push(models.ItemNiche.find(filter, myOptions));
|
|
||||||
|
|
||||||
let res = await Promise.all(promises);
|
let res = await Promise.all(promises);
|
||||||
|
|
||||||
summary.item = res[0];
|
summary.item = res[0];
|
||||||
summary.tags = res[1];
|
summary.tags = res[1];
|
||||||
[summary.botanical] = res[2];
|
[summary.botanical] = res[2];
|
||||||
summary.niches = res[3];
|
|
||||||
|
|
||||||
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('item getSummary()', () => {
|
describe('item getSummary()', () => {
|
||||||
it('should return summary with item, tags, botanical, niches, available and visible defined ', async() => {
|
it('should return summary with item, tags, botanical, available and visible defined ', async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ describe('item getSummary()', () => {
|
||||||
expect(keys).toContain('item');
|
expect(keys).toContain('item');
|
||||||
expect(keys).toContain('tags');
|
expect(keys).toContain('tags');
|
||||||
expect(keys).toContain('botanical');
|
expect(keys).toContain('botanical');
|
||||||
expect(keys).toContain('niches');
|
|
||||||
expect(keys).toContain('available');
|
expect(keys).toContain('available');
|
||||||
expect(keys).toContain('visible');
|
expect(keys).toContain('visible');
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,6 @@
|
||||||
"ItemLog": {
|
"ItemLog": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
"ItemNiche": {
|
|
||||||
"dataSource": "vn"
|
|
||||||
},
|
|
||||||
"ItemPlacement": {
|
"ItemPlacement": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
const UserError = require('vn-loopback/util/user-error');
|
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.rewriteDbError(function(err) {
|
|
||||||
if (err.code === 'ER_DUP_ENTRY')
|
|
||||||
return new UserError(`The warehouse can't be repeated`);
|
|
||||||
return err;
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -1,42 +0,0 @@
|
||||||
{
|
|
||||||
"name": "ItemNiche",
|
|
||||||
"base": "Loggable",
|
|
||||||
"log": {
|
|
||||||
"model": "ItemLog",
|
|
||||||
"relation": "item",
|
|
||||||
"showField": "code"
|
|
||||||
},
|
|
||||||
"options": {
|
|
||||||
"mysql": {
|
|
||||||
"table": "itemPlacement"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "Number",
|
|
||||||
"id": 1,
|
|
||||||
"description": "Identifier"
|
|
||||||
},
|
|
||||||
"warehouseFk": {
|
|
||||||
"type": "Number",
|
|
||||||
"description": "Identifier"
|
|
||||||
},
|
|
||||||
"code": {
|
|
||||||
"type": "String",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"relations": {
|
|
||||||
"item": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "Item",
|
|
||||||
"foreignKey": "itemFk"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "Warehouse",
|
|
||||||
"foreignKey": "warehouseFk",
|
|
||||||
"required": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -196,11 +196,6 @@
|
||||||
"model": "ItemTaxCountry",
|
"model": "ItemTaxCountry",
|
||||||
"foreignKey": "itemFk"
|
"foreignKey": "itemFk"
|
||||||
},
|
},
|
||||||
"itemNiche": {
|
|
||||||
"type": "hasMany",
|
|
||||||
"model": "ItemNiche",
|
|
||||||
"foreignKey": "itemFk"
|
|
||||||
},
|
|
||||||
"packaging": {
|
"packaging": {
|
||||||
"type": "hasOne",
|
"type": "hasOne",
|
||||||
"model": "Packaging",
|
"model": "Packaging",
|
||||||
|
|
Loading…
Reference in New Issue