Skip to content

Store the stock a supplier has for a part, as reported by the info providers - #1538

Open
killecaptron wants to merge 2 commits into
Part-DB:masterfrom
killecaptron:orderdetail-available-amount
Open

Store the stock a supplier has for a part, as reported by the info providers#1538
killecaptron wants to merge 2 commits into
Part-DB:masterfrom
killecaptron:orderdetail-available-amount

Conversation

@killecaptron

Copy link
Copy Markdown
Contributor

Note: this builds on #1530 and contains its commit, since a new DTO field is exactly the case that
fix is about. Once #1530 is merged this branch rebases onto it and the commit disappears.

Every info provider reports how much stock a distributor has, and Part-DB throws that away. It is
one of the first things you want to know when deciding where to order, and today it means opening
the distributor's page for each offer.

An orderdetail now stores the stock the provider reported, together with the time it was retrieved
at. Both are always written as a pair: a number without its age is misleading, because provider
stock goes stale within days, and there would be no way to tell a value from this morning from one
from three months ago. For the same reason the field is not part of the orderdetail form - it is
provider data, and setAvailableAmount() takes the value and its timestamp together.

Read from Digi-Key (the stock of the selected packaging, falling back to the product's), Mouser,
Octopart, Canopy and TrustedParts. In the merger the newer value wins, unlike the other fields:
stock is volatile, so a fresher reading replaces an older one, while null - meaning "unknown" -
never overwrites a known value.

Shown in the purchase information of a part with the time it was read at, plus a column in the part
table and one in the project BOM, both hidden by default: the BOM one answers "can I build this
project right now", which is otherwise a lot of clicking.

The migration is multi-platform (MySQL, SQLite, PostgreSQL); doctrine:schema:validate reports no
difference beyond what master already reports.

killecaptron and others added 2 commits September 7, 2026 17:12
The info provider system caches the DTOs it received from a provider as
serialized objects, in a cache pool which is not part of the cache
directory and therefore survives an update of Part-DB.

Whenever a DTO class gains a property, unserializing an object which was
cached by an older version leaves that property uninitialized, so the
first access to it fails with a typed property error until the cache
happens to expire (up to four days later).

Add a version marker to every cache key of a DTO, which has to be
increased whenever the structure of the DTOs changes: old entries are
then simply never read again and expire on their own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…oviders

Most info providers tell how many parts a distributor currently has on
hand, but Part-DB threw that information away, even though it is one of
the things one wants to see when deciding where to order a part from.

Orderdetails now carry an available amount, filled by the info provider
system from Digikey, Mouser and TrustedParts. Null means the stock is
unknown, which is deliberately different from a stock of 0 ("out of
stock").

A stock is volatile and therefore only meaningful together with its age,
so the time the value was retrieved at is always stored along with it,
and shown wherever the stock is shown. For the same reason the value is
not editable by hand: it is written by the info provider system only,
and the merger keeps the newer of two values instead of the target's.

The stock is shown in the ordering information of a part, and as an
optional column in the parts table and in the project BOM.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.81081% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.40%. Comparing base (0f0ee60) to head (7908a52).

Files with missing lines Patch % Lines
src/DataTables/Helpers/PartDataTableHelper.php 42.85% 12 Missing ⚠️
...es/InfoProviderSystem/Providers/MouserProvider.php 0.00% 7 Missing ⚠️
...s/InfoProviderSystem/Providers/DigikeyProvider.php 0.00% 6 Missing ⚠️
...es/InfoProviderSystem/Providers/CanopyProvider.php 0.00% 2 Missing ⚠️
.../InfoProviderSystem/Providers/OctopartProvider.php 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1538   +/-   ##
=========================================
  Coverage     62.39%   62.40%           
- Complexity     9879     9902   +23     
=========================================
  Files           736      736           
  Lines         31779    31840   +61     
=========================================
+ Hits          19829    19870   +41     
- Misses        11950    11970   +20     

☔ 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.

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