summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-30 10:17:40 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-30 10:17:40 +0100
commitfa2f5d190457ab0f44965f1b10d4f3c188107687 (patch)
tree0b85563b2846fb80c9e70f1cdd7e966a654c8890
parentaa6c564000b1268dc7e9af7a4c0b8c101d1ff1e3 (diff)
downloadstock-fa2f5d190457ab0f44965f1b10d4f3c188107687.tar.gz
stock-fa2f5d190457ab0f44965f1b10d4f3c188107687.tar.bz2
stock-fa2f5d190457ab0f44965f1b10d4f3c188107687.zip
list_movements: sign REQN/PBLD qty negative, show net total in Qty headerHEADmaster
When filtered by part_content_id, outbound movements (REQN, PBLD) now display with a leading minus sign. The Qty column header shows the net stock balance across all movements for the part, consistent with view_component stock levels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--list_movements.php16
-rw-r--r--templates/list_movements.tpl6
2 files changed, 19 insertions, 3 deletions
diff --git a/list_movements.php b/list_movements.php
index ddb2b1c..0a09f3e 100644
--- a/list_movements.php
+++ b/list_movements.php
@@ -74,4 +74,20 @@ $gBitSmarty->assign( 'partSize', $partSize );
$gBitSmarty->assign( 'filterUserId', $filterUserId );
$gBitSmarty->assign( 'filterUserName', $filterUserName );
+$partQtyNet = null;
+if( $partContentId ) {
+ $partQtyNet = $gBitDb->getOne(
+ "SELECT SUM( CASE WHEN r.`item` IN ('REQN','PBLD')
+ THEN -CAST(x.`xkey` AS DOUBLE PRECISION)
+ ELSE CAST(x.`xkey` AS DOUBLE PRECISION) END )
+ FROM `".BIT_DB_PREFIX."liberty_xref` x
+ JOIN `".BIT_DB_PREFIX."liberty_xref` r
+ ON r.`content_id` = x.`content_id` AND r.`item` IN ('REQN','PBLD','TRANS','ORDER')
+ WHERE x.`xref` = ? AND x.`item` IN ('SGL','PRT','SHT','VOL')",
+ [ $partContentId ]
+ );
+ $partQtyNet = $partQtyNet !== null ? (float)$partQtyNet : null;
+}
+$gBitSmarty->assign( 'partQtyNet', $partQtyNet );
+
$gBitSystem->display( 'bitpackage:stock/list_movements.tpl', 'Movements', [ 'display_mode' => 'list' ] );
diff --git a/templates/list_movements.tpl b/templates/list_movements.tpl
index ec9f4fa..fecafb0 100644
--- a/templates/list_movements.tpl
+++ b/templates/list_movements.tpl
@@ -48,7 +48,7 @@
<tr>
<th>{smartlink ititle="Reference" isort="title" icontrol=$listInfo}</th>
<th>{tr}Type{/tr}</th>
- {if $partContentId}<th class="text-right">{tr}Qty{/tr}</th>{/if}
+ {if $partContentId}<th class="text-right">{tr}Qty{/tr}{if $partQtyNet !== null} ({$partQtyNet|string_format:"%.0f"}){/if}</th>{/if}
<th>{smartlink ititle="Ordered" isort="ref_start_date" ifile="list_movements.php" ipackage="stock" icontrol=$listInfo}</th>
<th>{smartlink ititle="Received" isort="event_time" ifile="list_movements.php" ipackage="stock" icontrol=$listInfo}</th>
<th>{smartlink ititle="Date" isort="created_desc" icontrol=$listInfo}</th>
@@ -63,9 +63,9 @@
<td>{$mov.ref_type|escape|default:'—'}</td>
{if $partContentId}
{if $partType eq 'assembly'}
- <td class="text-right">{$mov.part_qty|string_format:"%.0f"}</td>
+ <td class="text-right">{if $mov.ref_type eq 'REQN' or $mov.ref_type eq 'PBLD'}-{/if}{$mov.part_qty|string_format:"%.0f"}</td>
{else}
- <td class="text-right">{if $mov.part_qty_type eq 'PRT' && $partSize > 0}{math equation="q/p" q=$mov.part_qty p=$partSize format="%.2f"}{elseif $mov.part_qty_type eq 'SHT'}{$mov.part_qty|string_format:"%.2f"}{else}{$mov.part_qty|string_format:"%.0f"}{/if} {$mov.part_qty_type|escape}</td>
+ <td class="text-right">{if $mov.ref_type eq 'REQN' or $mov.ref_type eq 'PBLD'}-{/if}{if $mov.part_qty_type eq 'PRT' && $partSize > 0}{math equation="q/p" q=$mov.part_qty p=$partSize format="%.2f"}{elseif $mov.part_qty_type eq 'SHT'}{$mov.part_qty|string_format:"%.2f"}{else}{$mov.part_qty|string_format:"%.0f"}{/if} {$mov.part_qty_type|escape}</td>
{/if}
{/if}
<td>{if $mov.ref_start_date}{$mov.ref_start_date|bit_short_date}{else}—{/if}</td>