Break the admin salable quantity down by source - #40
Merged
jeanmarcos-dev merged 3 commits intoAug 3, 2026
Conversation
jeanmarcos-dev
force-pushed
the
integrate/2.4.8-admin-salable-per-source
branch
from
August 3, 2026 18:23
bf9c282 to
093f374
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The admin shows the quantity a source physically holds and the salable quantity a stock aggregates, but nothing in between. A merchant looking at Sources reporting 10 on hand and Product Salable Quantity reporting 7 has no way to tell where the missing 3 went, or which source is holding it. With source-level reservations that information exists and is exact; it was simply never exposed.
This adds the missing link: for every source of a stock, the quantity on hand, that source's reservation balance and the salable quantity they add up to.
What changes
Product form — the Product Salable Quantity section now renders one table per stock. The stock name becomes the field label and the aggregate it already reported becomes the last row of the same table, aligned under the Salable column, so the sources visibly sum to the total instead of floating beside it.
Product grid — the Salable Quantity column keeps the aggregate it shows today and gains a toggle that expands the same breakdown. The data already travels in the row, so expanding costs no request.
Sources that contribute nothing are still listed and labelled, because a zero with no explanation reads as a defect:
Including a disabled source is deliberate. A disabled source still holding stock and pending reservations is the case the indexer had to be fixed for; hiding it in the admin would reproduce the same blind spot.
How it resolves
Two services, both batch:
InventorySales/Model/SourceReservation/GetSourceAvailabilityBySkus— nets the physical source quantity against that source's reservation balance for a list of SKUs and sources, in two queries regardless of input size. It degrades to the physical quantity when source-level reservations are off, and reports the physical quantity alongside the net so a caller can show how the net was reached. It needs a source-item read that keeps out-of-stock rows (the existingGetSourceItemQuantityBySkusAndSourcesfilters them out, which cannot distinguish an empty source from one holding quantity that is not offered for sale), hence the newGetSourceItemDataBySkusAndSources.InventorySalesAdminUi/Model/GetSourceSalableQuantityData— groups the rows under the stock each source belongs to, preserving the stock's priority order, and resolves every SKU in a single availability call. The stock-to-sources resolution is memoised per call, so a grid page of 20 products over 2 stocks does 2 resolutions, not 40.AddSourceSalableQuantityBreakdownholds the part both surfaces share — which entries carry a breakdown, and the batching — so the form and the grid cannot drift apart.GetSalableQuantityDataBySkuis untouched and remains the provider of the aggregate.The grid adds two queries per page, not per row, which is lighter than the per-row pattern the neighbouring Quantity per Source column already uses.
Gates
The breakdown is skipped, and the section renders exactly as before, when:
IsSingleSourceModeInterfacewas an injected but unused dependency in both the form modifier and the grid column; it moves to the collaborator that now actually uses it.Rendering
The breakdown reuses the native
admin__dynamic-rowscell grid — the same component the Sources section above it in the same form is built from — so the two read as siblings rather than as a bespoke table dropped into the page. The nested table in the grid cell deliberately omits thedata-gridclass so a data grid is never nested inside another one;admin__dynamic-rowswas measured to supply identical computed styles.Verification
setup:di:compileon a real 2.4.8The module is byte-identical to the 2.4.9 release except the Composer constraints. End to end on a disposable 2.4.9 install with source-level reservations on (SKU
SLR-1,slr_a5 /slr_b10): baseline aggregate 15 broken down 5 + 10; a source-scoped reservation of −2 onslr_amoves the aggregate to 13 and the row to 5 / −2 / 3 whileslr_bstays 10 / 0 / 10; disablingslr_band settingslr_a's source item out of stock label both rows and zero their salable quantity while keeping the quantity on hand visible; turning source-level reservations off drops the Reservations column and degrades the salable quantity to the quantity on hand. In the grid, expanding does not navigate and issues no request.The concurrency harness is not strictly required — this change is read-only and never touches the reservation write path — but it was run because the new service lives under
InventorySales/Model/SourceReservation/.Notes
GetProductSalableQty, not something this introduces.Magento_InventorySalesAdminUigains a Composer dependency onmagento/module-inventory-salesandmagento/module-inventory-reservations-api;Magento_InventorySaleswas already in itsmodule.xmlsequence.