Skip to content

parts table: supplier and supplier part number columns - #1574

Merged
jbtronics merged 6 commits into
Part-DB:masterfrom
samyk:supplier-column
Oct 10, 2026
Merged

jbtronics merged 6 commits into
Part-DB:masterfrom
samyk:supplier-column

Conversation

@samyk

@samyk samyk commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

The parts table could show the stock at a supplier, but not which suppliers a part has or their order numbers, and it could not be sorted by either.

This adds two columns, both hidden by default so the stock table is unchanged:

  • Supplier: the distinct supplier names from the part's order details, comma-separated, each linked to that supplier's parts list (like the category and manufacturer columns).
  • Supplier part number: the non-empty supplier part numbers, comma-separated, with the supplier name as tooltip. A number links to the supplier product URL (new tab) when that URL is http(s).

Both are available in the column chooser and in the default-columns setting (supplier, supplier_part_number in TABLE_PARTS_DEFAULT_COLUMNS; documented in docs/configuration.md).

Both sort server-side in the filter query, by NATSORT(MIN(_suppliers.name)) and NATSORT(MIN(NULLIF(_orderdetails.supplierpartnr, ''))), using the existing _orderdetails/_suppliers join and group-by-part, as the storage location column does. Parts without a supplier (or with only empty numbers) sort last in both directions. The detail query fetch-joins orderdetails.supplier, so rendering does not lazy-load suppliers.

Tested on sqlite with ~18k parts and ~18k order details: sorting by either column takes about the same time as sorting by name. MySQL and PostgreSQL run in CI but the new sort was not exercised there by hand.

Notes for review:

  • NULLs-last is done with a two-expression orderField (a CASE WHEN MIN(...) IS NULL followed by the NATSORT one), relying on the adapter appending the direction to the last expression only. Happy to move that into an explicit order-by if you prefer.
  • When a list is already restricted on the order details join (e.g. a supplier's own parts list), the sort uses the minimum over the matching order details only.
  • The BOM table was left alone.

samyk added 2 commits October 3, 2026 14:12
The suppliers of a part and their part numbers were only visible on the
part's info page, so a parts list could neither show nor be sorted by
where something was bought.

Both columns are hidden by default and can be enabled in the column
chooser or via the default columns setting (supplier,
supplier_part_number). They are sorted in the filter query by the first
supplier name / part number of the part, using the same aggregated join
as the storage location column. Parts without a supplier (or with only
empty part numbers) are kept at the end in both directions, as the
DBMS disagree on where NULLs are sorted.

The suppliers are fetch-joined in the detail query, so rendering the
columns does not trigger a query per supplier.
@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.36585% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.47%. Comparing base (a7f2d49) to head (2e7e85f).

Files with missing lines Patch % Lines
src/DataTables/Helpers/PartDataTableHelper.php 78.57% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1574   +/-   ##
=========================================
  Coverage     64.46%   64.47%           
- Complexity    10210    10217    +7     
=========================================
  Files           762      762           
  Lines         32711    32752   +41     
=========================================
+ Hits          21087    21116   +29     
- Misses        11624    11636   +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jbtronics
jbtronics merged commit c6778cd into Part-DB:master Oct 10, 2026
15 checks passed
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.

2 participants