Skip to content

[Shopify] Fix Order Totals factbox opening an unrelated sales order for a linked posted invoice - #10307

Open
Onat Buyukakkus (onbuyuka) wants to merge 2 commits into
mainfrom
bugs/647019-order-totals-factbox
Open

[Shopify] Fix Order Totals factbox opening an unrelated sales order for a linked posted invoice#10307
Onat Buyukakkus (onbuyuka) wants to merge 2 commits into
mainfrom
bugs/647019-order-totals-factbox

Conversation

@onbuyuka

@onbuyuka Onat Buyukakkus (onbuyuka) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What & why

On the Shopify Orders page, the Order Totals factbox (page 30172) was not document-type aware. The Sales Document No. drill-down always opened the Sales Order page, and the factbox resolved totals only from the open Sales Header. When the linked document was an invoice — or the order had already been posted — this opened an unrelated sales order and could display stale totals, because the open header no longer exists but Sales Invoice No. still held the old number.

This change resolves the sales document through the same Shpfy Doc. Link To Doc. link table that the Linked Documents factbox uses, so the factbox stays correct after posting:

  • Resolution prefers Posted Sales Invoice → open Sales Invoice → open Sales Order, with a fallback to the header fields for legacy orders processed before the link table existed.
  • Totals are computed per document type — open documents via CalculateSalesTotals, posted invoices via CalculatePostedSalesInvoiceTotals.
  • The Sales Document No. drill-down now dispatches through the Shpfy IOpenBCDocument interface (opens the correct open order / open invoice / posted invoice), and the Number of Lines drill-down is type-aware (Sales Lines vs Posted Sales Invoice Lines).
  • When no document resolves, the section is cleared instead of retaining stale values.

Linked work

Fixes AB#647019

How I validated this

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

  • Built the Shopify Connector app locally (al_build) — package generated, 0 errors, no new analyzer warnings.
  • Added a new test codeunit ShpfyOrderTotalsFBTest (139587, Order Handling/) with 9 tests:
    • Resolution + navigation for open sales order, open sales invoice, and posted sales invoice, asserting the resolved Sales Document No., Excl./Incl. VAT, VAT, Number of Lines, Prices Including VAT, and Currency Code.
    • Number of Lines drill-down opens Sales Lines (open) and Posted Sales Invoice Lines (posted).
    • Values are cleared when the linked document no longer resolves.
    • General factbox coverage that previously had none: the Shopify vs Presentment totals sections and their visibility toggle, and the Shopify Order No. drill-down.
  • Ran the tests in a BC environment; this surfaced a test-isolation issue (a random Shopify Order Id colliding with a leftover document link in the shared database), now fixed by drawing a hermetic Shopify Order Id with no existing header or link.

Risk & compatibility

  • UI-only behavior change to a display-only factbox; no schema, API, or permission changes.
  • Navigation now uses the actual linked document type; totals for posted invoices are read from the posted invoice header. No upgrade/data impact.
  • The fallback to Sales Order No. / Sales Invoice No. preserves behavior for orders created before the document link table was populated.

…or a linked posted invoice

The Order Totals factbox (page 30172) was not document-type aware: the
Sales Document No. drill-down always opened the Sales Order page, and totals
were resolved only from the open Sales Header. After posting, the open header
is gone but the factbox retained stale document values.

Resolve the sales document through the Shpfy Doc. Link To Doc. link table
(same source as the Linked Documents factbox), preferring the posted invoice,
then open invoice, then open order, with a fallback to the header fields for
legacy orders. Totals are computed per document type (open vs posted), the
Sales Document No. and Number of Lines drill-downs are now type-aware, and the
section is cleared when no document resolves.

Adds regression + general factbox coverage in a new test codeunit.

Fixes AB#647019

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f09314b6-9542-408a-97ee-8a92b1f83c46
@onbuyuka
Onat Buyukakkus (onbuyuka) requested a review from a team August 17, 2026 13:22
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Aug 17, 2026
@github-actions github-actions Bot added the Integration GitHub request for Integration area label Aug 17, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Aug 17, 2026
The var parameter SalesDocumentNo in ResolveSalesDocument/FindLinkedDocument
collided with the page control of the same name, producing new AA0245 warnings
that fail the AL-Go build. Rename the parameter to ResolvedDocumentNo.

Verified with CodeCop (base.ruleset): the two AA0245 warnings are gone.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f09314b6-9542-408a-97ee-8a92b1f83c46
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 Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant