Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map customer code to a metadata field in the Taxes App #1189

Conversation

peelar
Copy link
Member

@peelar peelar commented Feb 1, 2024

Context

Taxes App synchronizes a group of fields from Saleor to an AvaTax transaction. Some of these fields are used to determine the tax value (e.g. the customer code).

The general approach is to use the Saleor field that matches the purpose of the AvaTax field the most. However, users sometimes want to override that value with their own. This usually comes into play when multiple other systems (where e.g. one system manages the customers) collaborate on the tax calculation.

Scope of the PR

  • Refactored the app to use UserFragment everywhere
  • Added new logic to resolving AvaTax customer code. The app now tries to read it from metadata. If not found, it falls back to the user id. When no user id is found, it falls back to the dummy value (as AvaTax docs suggest).

Checklist

Note

This PR isn't breaking. If the metadata field is not found, the app will fall back as usual. We will add the migrations next week.

Copy link

changeset-bot bot commented Feb 1, 2024

🦋 Changeset detected

Latest commit: 4313ea0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
taxes Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Feb 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
saleor-app-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 1, 2024 2:44pm
saleor-app-taxes ✅ Ready (Inspect) Visit Preview Feb 1, 2024 2:44pm
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
saleor-app-cms ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-crm ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-data-importer ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-emails-and-messages ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-invoices ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-klaviyo ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-products-feed ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-segment ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm
saleor-app-slack ⬜️ Ignored (Inspect) Visit Preview Feb 1, 2024 2:44pm

@lkostrowski
Copy link
Member

Please remember about the docs (or add in issue to update them later)

@@ -27,6 +27,7 @@ export class AvataxEntityTypeMatcher {
return result.value?.[0].code || this.returnFallback();
}

// Now that we get the customer code from user metadata, maybe we should get the entity code from the same place?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: should it be marked as TODO?

@krzysztofwolski krzysztofwolski merged commit 6b8eb17 into main Feb 1, 2024
19 checks passed
@krzysztofwolski krzysztofwolski deleted the del-59-map-customer-code-to-a-custom-field-in-the-taxes-app branch February 1, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants