feat(tax,types): Add method to retrieve a Tax Module Provider's service (#13784)

## Summary

**What** — What changes are introduced in this PR?

Add a method in the Tax Module's servie to retrieve a provider by its ID.

**Why** — Why are these changes relevant or necessary?  

The Tax Module Provider could be used for use cases other than calculating tax lines. For example, Avalara supports importing products to manage product-specific taxes. However, it's not possible right now to listen to the `product.created` event and create the product in Avalara with its provider. Instead, you'll have to create a separate module that also connects to Avalara and resolve it in the subsriber.

This also matches the pattern in the Analytics Module, which allows retrieving the underlying provider.

**How** — How have these changes been implemented?

Add a `getProvider` method to the Tax Module's service and its interface.

**Testing** — How have these changes been tested, or how can the reviewer test the feature?

Added integration test for the method.

---

## Examples

Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.  
This helps with documentation and ensures maintainers can quickly understand and verify the change.

```ts
const avalaraProvider = taxModuleService.getProvider("tp_avalara_avalara")
```

---

## Checklist

Please ensure the following before requesting a review:

- [x] I have added a **changeset** for this PR
    - Every non-breaking change should be marked as a **patch**
    - To add a changeset, run `yarn changeset` and follow the prompts
- [x] The changes are covered by relevant **tests**
- [x] I have verified the code works as intended locally
- [ ] I have linked the related issue(s) if applicable

---

## Additional Context

Add any additional context, related issues, or references that might help the reviewer understand this PR.
This commit is contained in:
Shahed Nasser
2025-10-20 19:18:48 +03:00
committed by GitHub
parent 516f5a3896
commit 150aa50397
4 changed files with 30 additions and 0 deletions

View File

@@ -1177,6 +1177,12 @@ moduleIntegrationTestRunner<ITaxModuleService>({
}),
])
})
it("should retrieve a tax module provider's service", async () => {
const providerService = service.getProvider("tp_system")
expect(providerService).toBeDefined()
expect(providerService.getIdentifier()).toEqual("system")
})
})
},
})

View File

@@ -508,6 +508,10 @@ export default class TaxModuleService
return taxLines
}
getProvider(providerId: string): ITaxProvider {
return this.taxProviderService_.retrieveProvider(providerId)
}
private async getTaxLinesFromProvider(
providerId: string,
items: ItemWithRates[],