Skip to content

Add unified stock transaction log (stocklog)#228

Open
logicguy1 wants to merge 4 commits intomasterfrom
stocklog
Open

Add unified stock transaction log (stocklog)#228
logicguy1 wants to merge 4 commits intomasterfrom
stocklog

Conversation

@logicguy1
Copy link
Contributor

@logicguy1 logicguy1 commented Feb 26, 2026

image image

What are the changes about?

Added a unified stock transaction log to the product card. The new page (lager/productCardIncludes/stockLog.php) collects all stock-related tables into one centralized view so users can see exactly how a product's stock level has evolved over time.

The complete stock log can also be used as an auditing tool, letting the user check if they remembered to add an item into stock, remembered to remove something from stock that was removed from inventory or something similar. (This was requested by my boss for this reason)

Changes

New file: lager/productCardIncludes/stockLog.php

  • Accessible from the product card via the existing "Log" link on the stock/location section
  • Combines four data sources into a single timeline using a UNION ALL query:
    • stocklog - manual adjustments with reason and initials
    • batch_kob - incoming stock from purchase orders (lines grouped per order)
    • batch_salg - outgoing stock from sales orders (lines grouped per order, negated)
    • regulering - physical inventory counts (posted and unposted)
  • Running balance column: reconstructed by starting from the current lagerstatus value and working backwards through each transaction
  • Duplicate suppression: batch_kob rows created as a FIFO side-effect of a manual adjustment (same quantity, within 10 seconds) are hidden since they are already represented by the stocklog entry
  • Orders with ordre_id = 0 are kept as individual rows to avoid incorrect grouping
  • Rows that net to zero after grouping are filtered out (HAVING SUM(antal) <> 0)
  • Unposted inventory counts (bogfort = false) are excluded from the running balance but still shown in the log
  • Type badges (Manuel / Indkøb / Salg / Optælling) with colour coding for quick scanning
  • Order references link directly to the relevant purchase or sales order

The page admittedly does not use the data table framework that the rest of the system has been migrated to as #214 has not been merged and a fatal error bug that the PR aimed to fix has not been resolved. If this bug does get fixed / the PR merged i will gladly update this page to use the framework.

Have you checked the following?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant