fix: replace it.warehouseFk by userConfig.warehouseFk
gitea/salix/pipeline/head This commit is unstable Details

This commit is contained in:
Vicent Llopis 2022-07-29 12:22:03 +02:00
parent 7bf9a8c100
commit 605da52286
2 changed files with 7 additions and 2 deletions

View File

@ -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 JOIN itemType it ON it.id = i.typeFk AND lb.warehouse_id = ${userConfig.warehouseFk}
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

View File

@ -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,7 +182,7 @@ 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 LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = ${userConfig.warehouseFk}
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`