Conversation
…ng auto-balance calculation
AndreiPanko
approved these changes
Feb 18, 2026
mynjj
approved these changes
Feb 19, 2026
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
When creating a sales document from a Shopify refund, the connector automatically adds a balancing line to reconcile the difference between the total refunded amount from Shopify and the sum of the individual sales lines. While this is correct for most scenarios, some third-party extensions need to disable this auto-balance because they handle refund line amounts differently or manage the reconciliation themselves.
Changes
ShpfyRefundProcessEvents.Codeunit.al - Added a new
[IntegrationEvent]:OnBeforeCreateSalesLinesFromRemainingAmount(RefundHeader, var SalesHeader, var SkipBalancing)ShpfyCreateSalesDocRefund.Codeunit.al - Fire the event inside
CreateSalesLinesFromRemainingAmount, after the rounding line is created but before the balancing logic runs. The rounding line (which comes from Shopify) is always created regardless ofSkipBalancing.Why an event instead of an interface
The interface + enum pattern in this codebase (e.g.,
Shpfy IReturnRefund Process,Shpfy Stock Calculation,Shpfy ICustomer Mapping) is designed for strategy choices with multiple meaningful implementations - different stock calculation methods, different customer mapping strategies, etc. The auto-balance behavior is fundamentally binary: you either want it or you don't. Creating an interface, an extensible enum, and a default implementation codeunit for a single on/off toggle would be overengineered. Furthermore, without a Shop table field to persist the enum value, we would need an event anyway to swap the implementation at runtime (like the GraphQL pattern), which means the interface adds complexity on top of the event rather than replacing it. A single integration event keeps the change minimal, predictable, and consistent with the existing extensibility points already inShpfyRefundProcessEvents.Fixes AB#621978