Skip to content

[Shopify] Import HS code and country of origin from Shopify#9320

Open
onbuyuka wants to merge 1 commit into
mainfrom
bugs/642046-import-hs-code-country-from-shopify
Open

[Shopify] Import HS code and country of origin from Shopify#9320
onbuyuka wants to merge 1 commit into
mainfrom
bugs/642046-import-hs-code-country-from-shopify

Conversation

@onbuyuka

@onbuyuka onbuyuka commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

What & why

Bug 642046 (follow-up to #632223, which added exporting HS code / country of origin to Shopify): when importing a product from Shopify to create a Business Central item, the Tariff No. and Country/Region of Origin Code were left empty. This adds the import direction.

When the shop's Sync HS Code and Country setting is enabled:

  • During import, inventoryItem.harmonizedSystemCode is fetched and mirrored (with countryCodeOfOrigin) onto the Shopify variant.
  • On item create and update, the item's Tariff No. and Country/Region of Origin Code are populated.
  • The tariff is applied only when it already exists in BC (never creates a Tariff Number). Because Shopify returns HS codes without separators (e.g. 6104.43 comes back as 610443), a separator-less code is matched to a BC Tariff Number by comparing digits (exact match first, digit comparison as a fallback).
  • The country ISO code is resolved to a BC Country/Region via the existing "Shpfy Process Order".GetCountryCode.
  • On update, an unmapped or blank Shopify value never wipes an existing value on the item.
  • Export tariff change-detection is made separator-insensitive so bidirectional shops don't get redundant pushes.

Linked work

Fixes AB#642046

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: 0 errors, no new analyzer warnings.
  • Added/updated tests:
    • ShpfyCreateItemTest: create populates HS/country (with ISO->BC country resolution); no sync when setting disabled; tariff skipped when not in BC; separator-less Shopify code matched to a dotted BC tariff; update refreshes HS/country; update preserves an existing tariff when the Shopify value is not in BC.
    • ShpfyCreateItemAPITest: end-to-end import via mocked GraphQL response (fixture updated to return the separator-less HS code as Shopify does) resolves the item to the dotted BC tariff.
  • Please run the Shopify test suite in CI / validate in a container to confirm end-to-end.

Risk & compatibility

  • Behavior is gated behind the existing Sync HS Code and Country setting; when off, there is no change.
  • No table/schema changes. Adds tabledata "Tariff Number" = r permission to Shpfy Create Item.
  • Update path is non-destructive: it won't clear an existing item value from an unmapped/blank Shopify value.
  • Export change-detection for the tariff now compares digits only; genuine HS-code changes still push to Shopify.

Populate the item's Tariff No. and Country/Region of Origin Code when
creating or updating items from Shopify products, gated on the shop's
"Sync HS Code and Country" setting.

- Fetch inventoryItem.harmonizedSystemCode and mirror it (plus
  countryCodeOfOrigin) onto the Shopify variant during import.
- Only apply the tariff when it already exists in BC (never create a
  Tariff Number). Shopify returns HS codes without separators, so a
  separator-less code is matched to a BC Tariff Number by comparing
  digits (exact match first, digit comparison as fallback).
- Resolve the country ISO code to a BC Country/Region via
  "Shpfy Process Order".GetCountryCode.
- On update, never wipe an existing value with an unmapped/blank one.
- Make export tariff change-detection separator-insensitive so
  bidirectional shops do not get redundant pushes.

Fixes AB#642046

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60cf214c-d3e4-42ed-ab60-beea16225579
@onbuyuka onbuyuka requested a review from a team July 10, 2026 16:50
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label Jul 10, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 10, 2026
@onbuyuka onbuyuka enabled auto-merge July 10, 2026 16:52
@github-actions

Copy link
Copy Markdown
Contributor

Copilot PR Review

Iteration 1 · Outcome: completed

All applicable sub-skills completed; al-upgrade-review and al-ui-review returned not-applicable (no upgrade-code or page/UI changes in the diff). No finding cleared the severity/precision bar.

Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630

Orchestrator pre-filter (13 file(s) excluded)

  • layer-disabled (knowledge) : 13 file(s)

Findings produced by the Copilot CLI agent against BCQuality at 822cae1b2771ac25f665f73369f69093bd4fd630. Reply 👎 on any inline comment to flag false positives.

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.

2 participants