Skip to content

Commit eee729c

Browse files
authored
Merge pull request #86 from abdedarghal111/fixTotalProductStock
fix: showing global product stock on ReportProducto
2 parents 5b3a045 + 613167a commit eee729c

4 files changed

Lines changed: 18 additions & 10 deletions

File tree

Model/Join/AlbaranClienteProducto.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ protected function getSQLFrom(): string
3535
return static::MAIN_TABLE
3636
. ' LEFT JOIN variantes ON ' . static::MAIN_TABLE . '.referencia = variantes.referencia'
3737
. ' LEFT JOIN productos ON variantes.idproducto = productos.idproducto'
38-
. ' LEFT JOIN albaranescli ON albaranescli.idalbaran = lineasalbaranescli.idalbaran';
38+
. ' LEFT JOIN albaranescli ON albaranescli.idalbaran = lineasalbaranescli.idalbaran'
39+
. ' LEFT JOIN stocks ON stocks.referencia = ' . static::MAIN_TABLE . '.referencia'
40+
. ' AND stocks.codalmacen = ' . static::DOC_TABLE . '.codalmacen';
3941
}
4042
}

Model/Join/AlbaranProveedorProducto.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ protected function getSQLFrom(): string
3535
return static::MAIN_TABLE
3636
. ' LEFT JOIN variantes ON ' . static::MAIN_TABLE . '.referencia = variantes.referencia'
3737
. ' LEFT JOIN productos ON variantes.idproducto = productos.idproducto'
38-
. ' LEFT JOIN albaranesprov ON albaranesprov.idalbaran = lineasalbaranesprov.idalbaran';
38+
. ' LEFT JOIN albaranesprov ON albaranesprov.idalbaran = lineasalbaranesprov.idalbaran'
39+
. ' LEFT JOIN stocks ON stocks.referencia = ' . static::MAIN_TABLE . '.referencia'
40+
. ' AND stocks.codalmacen = ' . static::DOC_TABLE . '.codalmacen';
3941
}
4042
}

Model/Join/FacturaClienteProducto.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,29 @@ protected function getFields(): array
5050
'idproducto' => static::MAIN_TABLE . '.idproducto',
5151
'precio' => 'variantes.precio',
5252
'referencia' => static::MAIN_TABLE . '.referencia',
53-
'stockfis' => 'variantes.stockfis'
53+
'stockfis' => 'stocks.cantidad'
5454
];
5555
}
5656

5757
protected function getGroupFields(): string
5858
{
5959
return static::DOC_TABLE . '.codalmacen, ' . static::MAIN_TABLE . '.idproducto, '
6060
. static::MAIN_TABLE . '.referencia, productos.codfabricante, productos.codfamilia, variantes.coste, '
61-
. 'productos.descripcion, variantes.precio, variantes.stockfis';
61+
. 'productos.descripcion, variantes.precio, stocks.cantidad';
6262
}
6363

6464
protected function getSQLFrom(): string
6565
{
6666
return static::MAIN_TABLE
6767
. ' LEFT JOIN variantes ON ' . static::MAIN_TABLE . '.referencia = variantes.referencia'
6868
. ' LEFT JOIN productos ON variantes.idproducto = productos.idproducto'
69-
. ' LEFT JOIN facturascli ON facturascli.idfactura = lineasfacturascli.idfactura';
69+
. ' LEFT JOIN facturascli ON facturascli.idfactura = lineasfacturascli.idfactura'
70+
. ' LEFT JOIN stocks ON stocks.referencia = ' . static::MAIN_TABLE . '.referencia'
71+
. ' AND stocks.codalmacen = ' . static::DOC_TABLE . '.codalmacen';
7072
}
7173

7274
protected function getTables(): array
7375
{
74-
return [static::MAIN_TABLE, 'productos', 'variantes'];
76+
return [static::MAIN_TABLE, 'productos', 'variantes', 'stocks'];
7577
}
7678
}

Model/Join/FacturaProveedorProducto.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,29 @@ protected function getFields(): array
4949
'idproducto' => static::MAIN_TABLE . '.idproducto',
5050
'precio' => 'variantes.precio',
5151
'referencia' => static::MAIN_TABLE . '.referencia',
52-
'stockfis' => 'variantes.stockfis'
52+
'stockfis' => 'stocks.cantidad'
5353
];
5454
}
5555

5656
protected function getGroupFields(): string
5757
{
5858
return static::DOC_TABLE . '.codalmacen, ' . static::MAIN_TABLE . '.idproducto, '
5959
. static::MAIN_TABLE . '.referencia, productos.codfabricante, productos.codfamilia, variantes.coste, '
60-
. 'productos.descripcion, variantes.precio, variantes.stockfis';
60+
. 'productos.descripcion, variantes.precio, stocks.cantidad';
6161
}
6262

6363
protected function getSQLFrom(): string
6464
{
6565
return static::MAIN_TABLE
6666
. ' LEFT JOIN variantes ON ' . static::MAIN_TABLE . '.referencia = variantes.referencia'
6767
. ' LEFT JOIN productos ON variantes.idproducto = productos.idproducto'
68-
. ' LEFT JOIN facturasprov ON facturasprov.idfactura = lineasfacturasprov.idfactura';
68+
. ' LEFT JOIN facturasprov ON facturasprov.idfactura = lineasfacturasprov.idfactura'
69+
. ' LEFT JOIN stocks ON stocks.referencia = ' . static::MAIN_TABLE . '.referencia'
70+
. ' AND stocks.codalmacen = ' . static::DOC_TABLE . '.codalmacen';
6971
}
7072

7173
protected function getTables(): array
7274
{
73-
return [static::MAIN_TABLE, 'productos', 'variantes'];
75+
return [static::MAIN_TABLE, 'productos', 'variantes', 'stocks'];
7476
}
7577
}

0 commit comments

Comments
 (0)