Skip to content

Comments

[Shopify] Configurable Return Processing#6722

Open
GediminasGaubys wants to merge 1 commit intomicrosoft:mainfrom
GediminasGaubys:dev/aan/refundreturnorder
Open

[Shopify] Configurable Return Processing#6722
GediminasGaubys wants to merge 1 commit intomicrosoft:mainfrom
GediminasGaubys:dev/aan/refundreturnorder

Conversation

@GediminasGaubys
Copy link
Contributor

Implementation Description - Configurable Return Processing

Summary

This PR introduces a shop-level configuration to determine whether Shopify returns are processed as Credit Memos or Return Orders in Business Central. The implementation uses an interface-based strategy pattern for extensibility, updates UI labels for clarity, and includes test coverage for Return Order creation.

Changes

New Functionality:

  1. Shop-Level Configuration:

    • Added "Process Returns As" field to Shpfy Shop table (field 136, enum type).
    • Added corresponding field to Shpfy Shop Card page.
  2. Strategy Pattern Implementation:

    • Created Shpfy IProcess Returns As interface with GetTargetDocumentType() method.
    • Created Shpfy Process Returns As enum (ID 30180) implementing the interface.
    • Enum values:
      • Credit Memo (value 0): Implementation = Shpfy Process Credit Memo codeunit
      • Return Order (value 1): Implementation = Shpfy Process Return Order codeunit
  3. Implementation Codeunits:

    • Shpfy Process Credit Memo (ID 30236): Returns Sales Document Type::"Credit Memo".
    • Shpfy Process Return Order (ID 30422): Returns Sales Document Type::"Return Order".
  4. Refund Processing Logic Update:

    • Modified ShpfyRetRefProcCrMemo codeunit CreateSalesDocument procedure.
    • Retrieves the shop configuration and uses the interface to determine the document type.
  5. UI Updates for Clarity:

    • Shpfy Refund Page: Changed action caption from "Create Credit Memo" to "Create Sales Document".
    • Shpfy Refunds Page: Changed action caption from "Create Credit Memo" to "Create Sales Document".
    • Changed the action image from CreateCreditMemo to CreateDocument.
    • Updated Enum caption: "Auto Create Credit Memo" → "Auto Create Sales Document".

Architecture Benefits:

  • Extensibility: Interface-based design allows partners to add custom document types.
  • Flexibility: Shop-level configuration provides per-shop control over return handling.
  • Clarity: UI updates make it clear that document type varies based on configuration.
  • Maintainability: Strategy pattern centralizes document type logic.

Prerequisites:

  • Shopify Connector must be configured with valid shop credentials.
  • Shop setting "Process Returns As" determines the document type for all returns in that shop.
  • BC number series for both Credit Memos and Return Orders should be configured.

Tests

Modified ShpfyOrderRefundTest codeunit with enhanced coverage:

  1. Code Quality Improvements:

    • Fixed typo: ResetProccesOnRefundResetProcessOnRefund (4 occurrences).
  2. New Test: Return Order Creation:

    • UnitTestCreateReturnOrder(): Validates Return Order creation from Shopify refund.
    • Configures shop with Process Returns As = "Return Order".
    • Verifies SalesHeader."Document Type" = "Return Order".
    • Ensures interface-based routing works correctly.

Fixes #

Introduces a shop-level setting to choose whether returns are processed as Credit Memo or Return Order, improving flexibility for refund handling.

Updates UI labels and tooltips for clarity, and refactors processing logic to use the new enum and interface pattern.

Expands test coverage to validate Return Order creation from refunds.
@GediminasGaubys GediminasGaubys requested a review from a team as a code owner February 18, 2026 08:56
@github-actions github-actions bot added AL: Apps (W1) Add-on apps for W1 From Fork Pull request is coming from a fork labels Feb 18, 2026
@github-actions
Copy link

Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed. Use that pattern for every issue you want to link.

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 From Fork Pull request is coming from a fork

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants