Skip to content

[Shopify] Allow third-party extensions to skip auto-balance remaining amount on refunds#6717

Merged
onbuyuka merged 1 commit intomainfrom
bugs/621978-ShpfySkipAutoBalanceRefunds
Feb 19, 2026
Merged

[Shopify] Allow third-party extensions to skip auto-balance remaining amount on refunds#6717
onbuyuka merged 1 commit intomainfrom
bugs/621978-ShpfySkipAutoBalanceRefunds

Conversation

@onbuyuka
Copy link
Copy Markdown
Contributor

@onbuyuka onbuyuka commented Feb 18, 2026

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 of SkipBalancing.

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 in ShpfyRefundProcessEvents.

Fixes AB#621978

@onbuyuka onbuyuka requested a review from a team as a code owner February 18, 2026 01:17
@github-actions github-actions bot added the AL: Apps (W1) Add-on apps for W1 label Feb 18, 2026
@onbuyuka onbuyuka enabled auto-merge (squash) February 18, 2026 01:17
@onbuyuka onbuyuka changed the title Shopify: Allow third-party extensions to skip auto-balance remaining amount on refunds [Shopify] Allow third-party extensions to skip auto-balance remaining amount on refunds Feb 18, 2026
@github-actions github-actions bot added this to the Version 28.0 milestone Feb 18, 2026
@onbuyuka onbuyuka merged commit 5e212a5 into main Feb 19, 2026
86 of 88 checks passed
@onbuyuka onbuyuka deleted the bugs/621978-ShpfySkipAutoBalanceRefunds branch February 19, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants