Why do you need this change?
This is a follow-up to microsoft/ALAppExtensions#27413, which established that because Shopify subtracts committed quantities from the value Business Central sends, an app may need to compensate the exported figure. That request was accepted and resolved by exposing Shpfy Shop Location and adding the Shpfy Extended Stock Calculation interface, so compensation can be calculated per shop location.
That route does not work where a Shopify product uses unit-of-measure variants — for example a drinks item sold both as a single can and as a case of 12.
In Shpfy Inventory API.GetStock, the stock calculation implementation is called with an Item record, and the result is then divided by Qty. per Unit of Measure, resolved from ShopifyVariant."UoM Option Id". Every unit-of-measure variant of an item resolves to the same BC item and item variant, so the interface receives identical input for each variant and can only return one value for all of them.
The compensation required differs per variant. Shopify holds committed quantities per inventory item, and each variant has its own. Correcting the single-can variant means adding back only the singles on open orders; correcting the case variant means adding back only the cases, expressed in base units. Neither is expressible today, so the compensation enabled by #27413 cannot be applied at all in this configuration.
The event route is not an alternative. Shpfy Inventory Events.OnAfterCalculationStock is still internal, so it cannot be subscribed to from a dependent extension, and it carries only LocationFilter, so it could not identify the variant either. The interface is therefore the only viable vehicle, consistent with how #27413 was resolved.
This is not specific to one vertical. Any app that needs per-variant control over exported stock — unit-of-measure variants, pack sizes, allocations, channel-specific holdbacks — hits the same wall.
Describe the request
Following the pattern already established by Shpfy Extended Stock Calculation, add a further interface that also carries the Shopify variant, and have Shpfy Inventory API prefer it when implemented.
Objects affected:
src/Apps/W1/Shopify/App/src/Inventory/Interface/ShpfyVariantStockCalculation.Interface.al (new)
- Codeunit 30195
Shpfy Inventory API, call site in GetStock
Proposed interface:
interface "Shpfy Variant Stock Calculation" extends "Shpfy Extended Stock Calculation"
{
procedure GetStock(var Item: Record Item; var ShopLocation: Record "Shpfy Shop Location"; ShopifyVariant: Record "Shpfy Variant"): Decimal;
}
Proposed call site in Shpfy Inventory API.GetStock, extending the existing is / as resolution:
if StockCalculation is "Shpfy Variant Stock Calculation" then
Stock := (StockCalculation as "Shpfy Variant Stock Calculation").GetStock(Item, ShopLocation, ShopifyVariant)
else
if StockCalculation is "Shpfy Extended Stock Calculation" then
Stock := (StockCalculation as "Shpfy Extended Stock Calculation").GetStock(Item, ShopLocation)
else
Stock := StockCalculation.GetStock(Item);
Notes:
- Non-breaking. Existing implementations of
Shpfy Stock Calculation and Shpfy Extended Stock Calculation are unaffected.
- No new lookup is required.
GetStock already declares ShopifyVariant: Record "Shpfy Variant" and populates it from ShopInventory."Variant Id" before the calculation runs.
ShopifyVariant is passed by value, per the design guidance on passing records. It exposes no sensitive data.
- The returned value continues to be divided by
Qty. per Unit of Measure afterwards, which is the desired behaviour: the implementation returns a base-unit figure and the connector converts it.
- Verified against
main and releases/28.0, in src/Apps/W1/Shopify/App/src/Inventory/Codeunits/ShpfyInventoryAPI.Codeunit.al and src/Apps/W1/Shopify/App/src/Inventory/Interface/ShpfyExtendedStockCalculation.Interface.al. Nothing involved is marked Obsolete or surrounded by CLEAN tags.
- Filed here rather than in ALAppExtensions, as BCApps is now the home of the Shopify Connector.
- I am happy to provide the implementation pull request once the issue is approved.
Provide an implementation (optional)
Why do you need this change?
This is a follow-up to microsoft/ALAppExtensions#27413, which established that because Shopify subtracts committed quantities from the value Business Central sends, an app may need to compensate the exported figure. That request was accepted and resolved by exposing
Shpfy Shop Locationand adding theShpfy Extended Stock Calculationinterface, so compensation can be calculated per shop location.That route does not work where a Shopify product uses unit-of-measure variants — for example a drinks item sold both as a single can and as a case of 12.
In
Shpfy Inventory API.GetStock, the stock calculation implementation is called with anItemrecord, and the result is then divided byQty. per Unit of Measure, resolved fromShopifyVariant."UoM Option Id". Every unit-of-measure variant of an item resolves to the same BC item and item variant, so the interface receives identical input for each variant and can only return one value for all of them.The compensation required differs per variant. Shopify holds committed quantities per inventory item, and each variant has its own. Correcting the single-can variant means adding back only the singles on open orders; correcting the case variant means adding back only the cases, expressed in base units. Neither is expressible today, so the compensation enabled by #27413 cannot be applied at all in this configuration.
The event route is not an alternative.
Shpfy Inventory Events.OnAfterCalculationStockis stillinternal, so it cannot be subscribed to from a dependent extension, and it carries onlyLocationFilter, so it could not identify the variant either. The interface is therefore the only viable vehicle, consistent with how #27413 was resolved.This is not specific to one vertical. Any app that needs per-variant control over exported stock — unit-of-measure variants, pack sizes, allocations, channel-specific holdbacks — hits the same wall.
Describe the request
Following the pattern already established by
Shpfy Extended Stock Calculation, add a further interface that also carries the Shopify variant, and haveShpfy Inventory APIprefer it when implemented.Objects affected:
src/Apps/W1/Shopify/App/src/Inventory/Interface/ShpfyVariantStockCalculation.Interface.al(new)Shpfy Inventory API, call site inGetStockProposed interface:
Proposed call site in
Shpfy Inventory API.GetStock, extending the existingis/asresolution:Notes:
Shpfy Stock CalculationandShpfy Extended Stock Calculationare unaffected.GetStockalready declaresShopifyVariant: Record "Shpfy Variant"and populates it fromShopInventory."Variant Id"before the calculation runs.ShopifyVariantis passed by value, per the design guidance on passing records. It exposes no sensitive data.Qty. per Unit of Measureafterwards, which is the desired behaviour: the implementation returns a base-unit figure and the connector converts it.mainandreleases/28.0, insrc/Apps/W1/Shopify/App/src/Inventory/Codeunits/ShpfyInventoryAPI.Codeunit.alandsrc/Apps/W1/Shopify/App/src/Inventory/Interface/ShpfyExtendedStockCalculation.Interface.al. Nothing involved is markedObsoleteor surrounded byCLEANtags.Provide an implementation (optional)