feat(tax): add tax provider support (#6492)
**What** - Adds Tax Provider model - Adds loader to get Tax Provider from module options - Adds System Tax provider which forwards tax rates as is
This commit is contained in:
@@ -33,7 +33,7 @@ export interface TaxRateDTO {
|
||||
/**
|
||||
* The ID of the user that created the Tax Rate.
|
||||
*/
|
||||
created_by: string
|
||||
created_by: string | null
|
||||
}
|
||||
|
||||
export interface FilterableTaxRateProps
|
||||
@@ -138,7 +138,7 @@ export interface TaxCalculationContext {
|
||||
}
|
||||
|
||||
interface TaxLineDTO {
|
||||
rate_id: string
|
||||
rate_id?: string
|
||||
rate: number | null
|
||||
code: string | null
|
||||
name: string
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./common"
|
||||
export * from "./mutations"
|
||||
export * from "./service"
|
||||
export * from "./provider"
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
ItemTaxLineDTO,
|
||||
ShippingTaxLineDTO,
|
||||
TaxCalculationContext,
|
||||
TaxRateDTO,
|
||||
TaxableItemDTO,
|
||||
TaxableShippingDTO,
|
||||
} from "./common"
|
||||
|
||||
/**
|
||||
* A shipping method and the tax rates configured to apply to the
|
||||
* shipping method.
|
||||
*/
|
||||
export type ShippingTaxCalculationLine = {
|
||||
/**
|
||||
* The shipping method to calculate taxes for.
|
||||
*/
|
||||
shipping_line: TaxableShippingDTO
|
||||
/**
|
||||
* The rates applicable on the shipping method.
|
||||
*/
|
||||
rates: TaxRateDTO[]
|
||||
}
|
||||
|
||||
/**
|
||||
* A line item and the tax rates configured to apply to the
|
||||
* product contained in the line item.
|
||||
*/
|
||||
export type ItemTaxCalculationLine = {
|
||||
/**
|
||||
* The line item to calculate taxes for.
|
||||
*/
|
||||
line_item: TaxableItemDTO
|
||||
/**
|
||||
* The rates applicable on the item.
|
||||
*/
|
||||
rates: TaxRateDTO[]
|
||||
}
|
||||
|
||||
export interface ITaxProvider {
|
||||
getIdentifier(): string
|
||||
|
||||
getTaxLines(
|
||||
itemLines: ItemTaxCalculationLine[],
|
||||
shippingLines: ShippingTaxCalculationLine[],
|
||||
context: TaxCalculationContext
|
||||
): Promise<(ItemTaxLineDTO | ShippingTaxLineDTO)[]>
|
||||
}
|
||||
@@ -95,7 +95,7 @@ export interface ITaxModuleService extends IModuleService {
|
||||
): Promise<TaxRateRuleDTO[]>
|
||||
|
||||
getTaxLines(
|
||||
item: (TaxableItemDTO | TaxableShippingDTO)[],
|
||||
items: (TaxableItemDTO | TaxableShippingDTO)[],
|
||||
calculationContext: TaxCalculationContext,
|
||||
sharedContext?: Context
|
||||
): Promise<(ItemTaxLineDTO | ShippingTaxLineDTO)[]>
|
||||
|
||||
Reference in New Issue
Block a user