[releases/28.x] [Shopify] Make codeunit 30272 "Shpfy Update Price Source" public#9664
Open
onbuyuka wants to merge 1 commit into
Open
[releases/28.x] [Shopify] Make codeunit 30272 "Shpfy Update Price Source" public#9664onbuyuka wants to merge 1 commit into
onbuyuka wants to merge 1 commit into
Conversation
## Problem
Partners cannot customize the Shopify connector's price calculation
logic because codeunit 30272 `"Shpfy Update Price Source"` has `Access =
Internal`.
The pricing flow in codeunit 30182 `"Shpfy Product Price Calc."`
publishes `OnBeforeCalculateUnitPrice` with an `IsHandled` pattern,
which partners can subscribe to. Setting `Handled := true` lets them
fully replace the price calculation. However, replicating the default
logic requires `BindSubscription` on codeunit 30272 to ensure the
pricing engine gets the correct currency, VAT, and discount settings
from the Shopify Shop configuration. Because 30272 is `Internal`,
partners cannot reference it as a type for `Bind`/`UnbindSubscription`.
## Fix
Change `Access = Internal` to `Access = Public` on codeunit 30272
`"Shpfy Update Price Source"`. One-line change.
## Why this is safe
- The codeunit only reads non-sensitive Shop configuration: `Currency
Code`, `Allow Line Disc.`, `Prices Including VAT`, `VAT Bus. Posting Gr.
(Price)`.
- It has `EventSubscriberInstance = Manual`, so making it public does
not auto-activate any subscriptions — partners must explicitly
`BindSubscription`.
- The `internal` getters on codeunit 30182 (`GetCurrencyCode`,
`GetAllowLineDisc`, `GetPricesIncludingVAT`, `GetVATBusPostingGroup`)
remain internal — partners can only use this codeunit indirectly via the
existing bind/unbind pattern.
- Only 3 references exist outside its own file: the permission set, a
local variable declaration in 30182, and bind/unbind calls in 30182.
## Partner scenario
```al
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Shpfy Product Events", 'OnBeforeCalculateUnitPrice', '', true, false)]
local procedure MyPriceCalc(...; var Handled: Boolean)
var
ShpfyUpdatePriceSource: Codeunit "Shpfy Update Price Source";
begin
BindSubscription(ShpfyUpdatePriceSource);
// Replicate CalcPrice logic with their customization
UnbindSubscription(ShpfyUpdatePriceSource);
Handled := true;
end;
```
Fixes
[AB#638340](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/638340)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Backport of bug #638340 to releases/28.x.
Fixes AB#643242
Original PR: #8587