4291-delete_it.warehouseFk #1035
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE `vn`.`itemType` CHANGE `transaction` transaction__ tinyint(4) DEFAULT 0 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemType` CHANGE location location__ varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL;
|
||||||
|
ALTER TABLE `vn`.`itemType` CHANGE hasComponents hasComponents__ tinyint(1) DEFAULT 1 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemType` CHANGE warehouseFk warehouseFk__ smallint(6) unsigned DEFAULT 60 NOT NULL;
|
||||||
|
ALTER TABLE `vn`.`itemType` CHANGE compression compression__ decimal(5,2) DEFAULT 1.00 NULL;
|
|
@ -146,7 +146,9 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory
|
||||||
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||||
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||||
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
|
||||||
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
|
(13, 'Inventory', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0),
|
||||||
|
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
|
||||||
|
|
||||||
|
|
||||||
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
|
INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`)
|
||||||
VALUES
|
VALUES
|
||||||
|
@ -795,14 +797,14 @@ INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
|
||||||
('warm', 'Warm', 'Warm'),
|
('warm', 'Warm', 'Warm'),
|
||||||
('cool', 'Cool', 'Cool');
|
('cool', 'Cool', 'Cool');
|
||||||
|
|
||||||
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`)
|
INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `life`, `workerFk`, `isPackaging`, `temperatureFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0, 'cool'),
|
(1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool'),
|
||||||
(2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0, 'cool'),
|
(2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool'),
|
||||||
(3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0, 'cool'),
|
(3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool'),
|
||||||
(4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1, 'warm'),
|
(4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm'),
|
||||||
(5, 'CON', 'Container', 3, 1, NULL, 35, 1, 'warm'),
|
(5, 'CON', 'Container', 3, NULL, 35, 1, 'warm'),
|
||||||
(6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0, 'warm');
|
(6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm');
|
||||||
|
|
||||||
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
|
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
|
||||||
VALUES
|
VALUES
|
||||||
|
|
|
@ -148,6 +148,8 @@ module.exports = Self => {
|
||||||
stmt = new ParameterizedSQL(`CALL cache.visible_refresh(@calc_id, FALSE, ?)`, [warehouse.id]);
|
stmt = new ParameterizedSQL(`CALL cache.visible_refresh(@calc_id, FALSE, ?)`, [warehouse.id]);
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
date.setHours(0, 0, 0, 0);
|
date.setHours(0, 0, 0, 0);
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
|
@ -201,7 +203,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN cache.visible v ON v.item_id = lb.item_id
|
LEFT JOIN cache.visible v ON v.item_id = lb.item_id
|
||||||
AND v.calc_id = @calc_id
|
AND v.calc_id = @calc_id
|
||||||
JOIN item i ON i.id = lb.item_id
|
JOIN item i ON i.id = lb.item_id
|
||||||
JOIN itemType it ON it.id = i.typeFk AND lb.warehouse_id = it.warehouseFk
|
JOIN itemType it ON it.id = i.typeFk AND lb.warehouse_id = ?
|
||||||
JOIN buy b ON b.id = lb.buy_id
|
JOIN buy b ON b.id = lb.buy_id
|
||||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||||
LEFT JOIN itemType t ON t.id = i.typeFk
|
LEFT JOIN itemType t ON t.id = i.typeFk
|
||||||
|
@ -209,7 +211,7 @@ module.exports = Self => {
|
||||||
LEFT JOIN origin ori ON ori.id = i.originFk
|
LEFT JOIN origin ori ON ori.id = i.originFk
|
||||||
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
|
LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
|
||||||
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||||
, [date]);
|
, [userConfig.warehouseFk, date]);
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
|
|
|
@ -9,7 +9,8 @@ describe('Buy editLatestsBuys()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
search: 'Ranged weapon longbow 2m'
|
search: 'Ranged weapon longbow 2m'
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [original] = await models.Buy.latestBuysFilter(ctx, null, options);
|
const [original] = await models.Buy.latestBuysFilter(ctx, null, options);
|
||||||
|
@ -40,7 +41,8 @@ describe('Buy editLatestsBuys()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
filter: filter
|
filter: filter
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const field = 'size';
|
const field = 'size';
|
||||||
|
|
|
@ -9,7 +9,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
search: 'Ranged weapon longbow 2m'
|
search: 'Ranged weapon longbow 2m'
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -33,7 +34,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
id: 1
|
id: 1
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -57,7 +59,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
tags: [
|
tags: [
|
||||||
{tagFk: 27, value: '2m'}
|
{tagFk: 27, value: '2m'}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -79,7 +82,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
categoryFk: 1
|
categoryFk: 1
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -101,7 +105,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
typeFk: 2
|
typeFk: 2
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -123,7 +128,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
active: true
|
active: true
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -145,7 +151,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
active: false
|
active: false
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -167,7 +174,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
visible: true
|
visible: true
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -189,7 +197,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
visible: false
|
visible: false
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -211,7 +220,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
floramondo: true
|
floramondo: true
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -233,7 +243,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
floramondo: false
|
floramondo: false
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -255,7 +266,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
salesPersonFk: 35
|
salesPersonFk: 35
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -277,7 +289,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
description: 'Increases block'
|
description: 'Increases block'
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -299,7 +312,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
supplierFk: 1
|
supplierFk: 1
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
@ -328,7 +342,8 @@ describe('Entry latests buys filter()', () => {
|
||||||
args: {
|
args: {
|
||||||
from: from,
|
from: from,
|
||||||
to: to
|
to: to
|
||||||
}
|
},
|
||||||
|
req: {accessToken: {userId: 1}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||||
|
|
|
@ -86,6 +86,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
Self.filter = async(ctx, filter, options) => {
|
Self.filter = async(ctx, filter, options) => {
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
|
const models = Self.app.models;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
if (typeof options == 'object')
|
if (typeof options == 'object')
|
||||||
|
@ -140,6 +141,8 @@ module.exports = Self => {
|
||||||
|
|
||||||
filter = mergeFilters(filter, {where});
|
filter = mergeFilters(filter, {where});
|
||||||
|
|
||||||
|
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
||||||
|
|
||||||
const stmts = [];
|
const stmts = [];
|
||||||
const stmt = new ParameterizedSQL(
|
const stmt = new ParameterizedSQL(
|
||||||
`SELECT
|
`SELECT
|
||||||
|
@ -179,11 +182,11 @@ module.exports = Self => {
|
||||||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||||
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 = ?
|
||||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||||
LEFT JOIN entry e ON e.id = b.entryFk
|
LEFT JOIN entry e ON e.id = b.entryFk
|
||||||
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||||
);
|
, [userConfig.warehouseFk]);
|
||||||
|
|
||||||
if (ctx.args.tags) {
|
if (ctx.args.tags) {
|
||||||
let i = 1;
|
let i = 1;
|
||||||
|
|
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
||||||
{
|
{
|
||||||
relation: 'itemType',
|
relation: 'itemType',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'name', 'workerFk', 'warehouseFk'],
|
fields: ['id', 'name', 'workerFk'],
|
||||||
include: [{
|
include: [{
|
||||||
relation: 'worker',
|
relation: 'worker',
|
||||||
scope: {
|
scope: {
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = Self => {
|
||||||
include: [
|
include: [
|
||||||
{relation: 'itemType',
|
{relation: 'itemType',
|
||||||
scope: {
|
scope: {
|
||||||
fields: ['id', 'name', 'workerFk', 'warehouseFk'],
|
fields: ['id', 'name', 'workerFk'],
|
||||||
include: [{
|
include: [{
|
||||||
relation: 'worker',
|
relation: 'worker',
|
||||||
scope: {
|
scope: {
|
||||||
|
|
|
@ -7,7 +7,7 @@ describe('item filter()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const ctx = {args: {filter: filter, search: 1}};
|
const ctx = {args: {filter: filter, search: 1}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
|
@ -26,7 +26,7 @@ describe('item filter()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const ctx = {args: {filter: filter, search: 4444444444}};
|
const ctx = {args: {filter: filter, search: 4444444444}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(1);
|
expect(result.length).toEqual(1);
|
||||||
|
@ -49,7 +49,7 @@ describe('item filter()', () => {
|
||||||
limit: 8
|
limit: 8
|
||||||
};
|
};
|
||||||
const tags = [{value: 'medical box', tagFk: 58}];
|
const tags = [{value: 'medical box', tagFk: 58}];
|
||||||
const ctx = {args: {filter: filter, typeFk: 5, tags: tags}};
|
const ctx = {args: {filter: filter, typeFk: 5, tags: tags}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(2);
|
||||||
|
@ -67,7 +67,7 @@ describe('item filter()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const ctx = {args: {filter: filter, isFloramondo: true}};
|
const ctx = {args: {filter: filter, isFloramondo: true}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(3);
|
expect(result.length).toEqual(3);
|
||||||
|
@ -86,7 +86,7 @@ describe('item filter()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const ctx = {args: {filter: filter, buyerFk: 16}};
|
const ctx = {args: {filter: filter, buyerFk: 16}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(2);
|
||||||
|
@ -106,7 +106,7 @@ describe('item filter()', () => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const filter = {};
|
const filter = {};
|
||||||
const ctx = {args: {filter: filter, supplierFk: 1}};
|
const ctx = {args: {filter: filter, supplierFk: 1}, req: {accessToken: {userId: 1}}};
|
||||||
const result = await models.Item.filter(ctx, filter, options);
|
const result = await models.Item.filter(ctx, filter, options);
|
||||||
|
|
||||||
expect(result.length).toEqual(2);
|
expect(result.length).toEqual(2);
|
||||||
|
|
|
@ -34,11 +34,6 @@
|
||||||
"model": "Worker",
|
"model": "Worker",
|
||||||
"foreignKey": "workerFk"
|
"foreignKey": "workerFk"
|
||||||
},
|
},
|
||||||
"warehouse": {
|
|
||||||
"type": "belongsTo",
|
|
||||||
"model": "Warehouse",
|
|
||||||
"foreignKey": "warehouseFk"
|
|
||||||
},
|
|
||||||
"category": {
|
"category": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "ItemCategory",
|
"model": "ItemCategory",
|
||||||
|
|
Loading…
Reference in New Issue