summaryrefslogtreecommitdiff
path: root/list_stock.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-09 11:15:23 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-09 11:15:23 +0100
commit1de8f2f90284c375449326285f0b87e5e700a0c8 (patch)
treef5d0d33b7229f4094ae30563b3b7d6ec4b934ea7 /list_stock.php
parenta838a2d3963738b2e9bc496b31e078ead79d4a43 (diff)
downloadstock-1de8f2f90284c375449326285f0b87e5e700a0c8.tar.gz
stock-1de8f2f90284c375449326285f0b87e5e700a0c8.tar.bz2
stock-1de8f2f90284c375449326285f0b87e5e700a0c8.zip
stock: PCK/SHT fractional display, movement qty summing, import qty type
Display fixes: - list_stock, list_movements, view_component: PCK stock divides by pack_size for fractional strip display; SHT shows 2 decimal places - list_movements: pack_size fetched per component for PCK display - All fractional formats use %.2f consistently StockMovement::getList component filter: - Replace INNER JOIN on xcmp with EXISTS subquery to avoid duplicate rows when a component appears multiple times in a movement BOM - cmp_qty now SUMs all matching xref rows so multi-assembly RQs show total quantity rather than silently dropping duplicate rows Movement BOM edit templates: - stockmovement/edit_xref_bom_item.tpl: proper edit form for SGL/SHT/VOL lines linking back to view_component - stockmovement/edit_xref_bompck_item.tpl: same for PCK with pack size hint Import: - ImportSimpleComponent: columns 6/7 (qty_type, qty_value) wired up; PCK/SHT/VOL writes qty xref so movement CSV imports pick up default type Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'list_stock.php')
-rw-r--r--list_stock.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/list_stock.php b/list_stock.php
index 141b187..9771d4e 100644
--- a/list_stock.php
+++ b/list_stock.php
@@ -36,6 +36,9 @@ if( $assemblyContentId ) {
FROM `{$X}liberty_xref` sup
WHERE sup.`content_id` = lc.`content_id` AND sup.`item` = '#SUP'
ORDER BY sup.`xorder`) AS part_number,
+ (SELECT FIRST 1 CAST(pk.`xkey` AS DOUBLE PRECISION)
+ FROM `{$X}liberty_xref` pk
+ WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PCK') AS pack_size,
(SELECT SUM( CASE WHEN EXISTS (
SELECT 1 FROM `{$X}liberty_xref` r
WHERE r.`content_id` = mx.`content_id` AND r.`item` IN ('TRANS','ORDER')
@@ -71,6 +74,9 @@ if( $assemblyContentId ) {
FROM `{$X}liberty_xref` sup
WHERE sup.`content_id` = lc.`content_id` AND sup.`item` = '#SUP'
ORDER BY sup.`xorder`) AS part_number,
+ (SELECT FIRST 1 CAST(pk.`xkey` AS DOUBLE PRECISION)
+ FROM `{$X}liberty_xref` pk
+ WHERE pk.`content_id` = lc.`content_id` AND pk.`item` = 'PCK') AS pack_size,
SUM( CASE WHEN EXISTS (
SELECT 1 FROM `{$X}liberty_xref` r
WHERE r.`content_id` = x.`content_id` AND r.`item` IN ('TRANS','ORDER')
@@ -112,8 +118,9 @@ foreach( $rows as $row ) {
// In BOM view show all components; in general list respect hide-zero filter
if( $assemblyContentId || !$hideZero || $level != 0 ) {
$stockList[$cid]['stock'][$row['qty_type']] = [
- 'level' => $level,
- 'bom_qty' => $row['bom_qty'] !== null ? (float)$row['bom_qty'] : null,
+ 'level' => $level,
+ 'bom_qty' => $row['bom_qty'] !== null ? (float)$row['bom_qty'] : null,
+ 'pack_size' => $row['pack_size'] !== null ? (float)$row['pack_size'] : null,
];
}
}