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),
|
||||
(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),
|
||||
(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`)
|
||||
VALUES
|
||||
|
@ -795,14 +797,14 @@ INSERT INTO `vn`.`temperature`(`code`, `name`, `description`)
|
|||
('warm', 'Warm', 'Warm'),
|
||||
('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
|
||||
(1, 'CRI', 'Crisantemo', 2, 1, 31, 35, 0, 'cool'),
|
||||
(2, 'ITG', 'Anthurium', 1, 1, 31, 35, 0, 'cool'),
|
||||
(3, 'WPN', 'Paniculata', 2, 1, 31, 35, 0, 'cool'),
|
||||
(4, 'PRT', 'Delivery ports', 3, 1, NULL, 35, 1, 'warm'),
|
||||
(5, 'CON', 'Container', 3, 1, NULL, 35, 1, 'warm'),
|
||||
(6, 'ALS', 'Alstroemeria', 1, 1, 31, 16, 0, 'warm');
|
||||
(1, 'CRI', 'Crisantemo', 2, 31, 35, 0, 'cool'),
|
||||
(2, 'ITG', 'Anthurium', 1, 31, 35, 0, 'cool'),
|
||||
(3, 'WPN', 'Paniculata', 2, 31, 35, 0, 'cool'),
|
||||
(4, 'PRT', 'Delivery ports', 3, NULL, 35, 1, 'warm'),
|
||||
(5, 'CON', 'Container', 3, NULL, 35, 1, 'warm'),
|
||||
(6, 'ALS', 'Alstroemeria', 1, 31, 16, 0, 'warm');
|
||||
|
||||
INSERT INTO `vn`.`ink`(`id`, `name`, `picture`, `showOrder`, `hex`)
|
||||
VALUES
|
||||
|
|
|
@ -148,6 +148,8 @@ module.exports = Self => {
|
|||
stmt = new ParameterizedSQL(`CALL cache.visible_refresh(@calc_id, FALSE, ?)`, [warehouse.id]);
|
||||
stmts.push(stmt);
|
||||
|
||||
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
||||
|
||||
const date = new Date();
|
||||
date.setHours(0, 0, 0, 0);
|
||||
stmt = new ParameterizedSQL(`
|
||||
|
@ -201,7 +203,7 @@ module.exports = Self => {
|
|||
LEFT JOIN cache.visible v ON v.item_id = lb.item_id
|
||||
AND v.calc_id = @calc_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 = ?
|
||||
vicent marked this conversation as resolved
Outdated
|
||||
JOIN buy b ON b.id = lb.buy_id
|
||||
LEFT JOIN itemCategory ic ON ic.id = it.categoryFk
|
||||
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 entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR)
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||
, [date]);
|
||||
, [userConfig.warehouseFk, date]);
|
||||
|
||||
if (ctx.args.tags) {
|
||||
let i = 1;
|
||||
|
|
|
@ -9,7 +9,8 @@ describe('Buy editLatestsBuys()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
search: 'Ranged weapon longbow 2m'
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const [original] = await models.Buy.latestBuysFilter(ctx, null, options);
|
||||
|
@ -40,7 +41,8 @@ describe('Buy editLatestsBuys()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
filter: filter
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const field = 'size';
|
||||
|
|
|
@ -9,7 +9,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
search: 'Ranged weapon longbow 2m'
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -33,7 +34,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
id: 1
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -57,7 +59,8 @@ describe('Entry latests buys filter()', () => {
|
|||
tags: [
|
||||
{tagFk: 27, value: '2m'}
|
||||
]
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -79,7 +82,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
categoryFk: 1
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -101,7 +105,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
typeFk: 2
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -123,7 +128,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
active: true
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -145,7 +151,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
active: false
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -167,7 +174,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
visible: true
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -189,7 +197,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -211,7 +220,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
floramondo: true
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -233,7 +243,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
floramondo: false
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -255,7 +266,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
salesPersonFk: 35
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -277,7 +289,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
description: 'Increases block'
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -299,7 +312,8 @@ describe('Entry latests buys filter()', () => {
|
|||
const ctx = {
|
||||
args: {
|
||||
supplierFk: 1
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
@ -328,7 +342,8 @@ describe('Entry latests buys filter()', () => {
|
|||
args: {
|
||||
from: from,
|
||||
to: to
|
||||
}
|
||||
},
|
||||
req: {accessToken: {userId: 1}}
|
||||
};
|
||||
|
||||
const results = await models.Buy.latestBuysFilter(ctx, options);
|
||||
|
|
|
@ -86,6 +86,7 @@ module.exports = Self => {
|
|||
|
||||
Self.filter = async(ctx, filter, options) => {
|
||||
const conn = Self.dataSource.connector;
|
||||
const models = Self.app.models;
|
||||
const myOptions = {};
|
||||
|
||||
if (typeof options == 'object')
|
||||
|
@ -140,6 +141,8 @@ module.exports = Self => {
|
|||
|
||||
filter = mergeFilters(filter, {where});
|
||||
|
||||
const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions);
|
||||
|
||||
const stmts = [];
|
||||
const stmt = new ParameterizedSQL(
|
||||
`SELECT
|
||||
|
@ -179,11 +182,11 @@ module.exports = Self => {
|
|||
LEFT JOIN intrastat intr ON intr.id = i.intrastatFk
|
||||
LEFT JOIN producer pr ON pr.id = i.producerFk
|
||||
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 = ?
|
||||
vicent marked this conversation as resolved
Outdated
joan
commented
Se debe parametrizar con "?" para prevenir inyección SQL Se debe parametrizar con "?" para prevenir inyección SQL
|
||||
LEFT JOIN buy b ON b.id = lb.buy_id
|
||||
LEFT JOIN entry e ON e.id = b.entryFk
|
||||
LEFT JOIN supplier s ON s.id = e.supplierFk`
|
||||
);
|
||||
, [userConfig.warehouseFk]);
|
||||
|
||||
if (ctx.args.tags) {
|
||||
let i = 1;
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = Self => {
|
|||
{
|
||||
relation: 'itemType',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'workerFk', 'warehouseFk'],
|
||||
fields: ['id', 'name', 'workerFk'],
|
||||
include: [{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
|
|
|
@ -34,7 +34,7 @@ module.exports = Self => {
|
|||
include: [
|
||||
{relation: 'itemType',
|
||||
scope: {
|
||||
fields: ['id', 'name', 'workerFk', 'warehouseFk'],
|
||||
fields: ['id', 'name', 'workerFk'],
|
||||
include: [{
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
|
|
|
@ -7,7 +7,7 @@ describe('item filter()', () => {
|
|||
|
||||
try {
|
||||
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);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
|
@ -26,7 +26,7 @@ describe('item filter()', () => {
|
|||
|
||||
try {
|
||||
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);
|
||||
|
||||
expect(result.length).toEqual(1);
|
||||
|
@ -49,7 +49,7 @@ describe('item filter()', () => {
|
|||
limit: 8
|
||||
};
|
||||
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);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
@ -67,7 +67,7 @@ describe('item filter()', () => {
|
|||
|
||||
try {
|
||||
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);
|
||||
|
||||
expect(result.length).toEqual(3);
|
||||
|
@ -86,7 +86,7 @@ describe('item filter()', () => {
|
|||
|
||||
try {
|
||||
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);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
@ -106,7 +106,7 @@ describe('item filter()', () => {
|
|||
|
||||
try {
|
||||
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);
|
||||
|
||||
expect(result.length).toEqual(2);
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
"model": "Worker",
|
||||
"foreignKey": "workerFk"
|
||||
},
|
||||
"warehouse": {
|
||||
"type": "belongsTo",
|
||||
"model": "Warehouse",
|
||||
"foreignKey": "warehouseFk"
|
||||
},
|
||||
"category": {
|
||||
"type": "belongsTo",
|
||||
"model": "ItemCategory",
|
||||
|
|
Loading…
Reference in New Issue
Se debe parametrizar con "?" para prevenir inyección SQL