Add support for tax inclusivity to region and store (#7808)
This also includes rework of the currency model for the Store module. This change is breaking as existing stores won't have any supported currencies set, so users would need to go to the store settings again and choose the supported currencies there.
This commit is contained in:
@@ -28,8 +28,9 @@ export const createDefaultStoreStep = createStep(
|
||||
{
|
||||
// TODO: Revisit for a more sophisticated approach
|
||||
...data.store,
|
||||
supported_currency_codes: ["eur"],
|
||||
default_currency_code: "eur",
|
||||
supported_currencies: [
|
||||
{ currency_code: "eur", is_default: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ export * as OrderTypes from "./order"
|
||||
export * as PricingTypes from "./pricing"
|
||||
export * as ProductTypes from "./product"
|
||||
export * as PromotionTypes from "./promotion"
|
||||
export * as RegionTypes from "./region__legacy"
|
||||
export * as RegionTypes from "./region"
|
||||
export * as SalesChannelTypes from "./sales-channel"
|
||||
export * as SearchTypes from "./search"
|
||||
export * as StockLocationTypes from "./stock-location"
|
||||
|
||||
@@ -28,7 +28,6 @@ export * from "./product"
|
||||
export * from "./product-category"
|
||||
export * from "./promotion"
|
||||
export * from "./region"
|
||||
export * from "./region__legacy"
|
||||
export * from "./sales-channel"
|
||||
export * from "./search"
|
||||
export * from "./shared-context"
|
||||
|
||||
@@ -24,7 +24,6 @@ export interface RegionDTO {
|
||||
* Setting to indicate whether taxes need to be applied automatically
|
||||
*/
|
||||
automatic_taxes: boolean
|
||||
|
||||
/**
|
||||
* The countries of the region.
|
||||
*/
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* @interface
|
||||
*
|
||||
* The details of a legacy region.
|
||||
*/
|
||||
export type RegionDTO__legacy = {
|
||||
/**
|
||||
* The name of the region.
|
||||
*/
|
||||
name: string
|
||||
|
||||
/**
|
||||
* The currency code of the region.
|
||||
*/
|
||||
currency_code: string
|
||||
|
||||
/**
|
||||
* The tax rate of the region.
|
||||
*/
|
||||
tax_rate?: number
|
||||
|
||||
/**
|
||||
* The tax code of the region.
|
||||
*/
|
||||
tax_code?: string | null
|
||||
|
||||
/**
|
||||
* Whether gift cards in the region are taxable.
|
||||
*/
|
||||
gift_cards_taxable?: boolean
|
||||
|
||||
/**
|
||||
* Whether taxes should be calculated automatically in the region.
|
||||
*/
|
||||
automatic_taxes?: boolean
|
||||
|
||||
/**
|
||||
* The associated tax provider's ID.
|
||||
*/
|
||||
tax_provider_id?: string | null
|
||||
|
||||
/**
|
||||
* Holds custom data in key-value pairs.
|
||||
*/
|
||||
metadata?: Record<string, unknown>
|
||||
|
||||
/**
|
||||
* Whether prices include taxes in the region.
|
||||
*/
|
||||
includes_tax?: boolean
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./common"
|
||||
@@ -1,5 +1,36 @@
|
||||
import { BaseFilterable } from "../../dal"
|
||||
|
||||
export interface StoreCurrencyDTO {
|
||||
/**
|
||||
* The ID of the store currency.
|
||||
*/
|
||||
id: string
|
||||
/**
|
||||
* The currency code of the store currency.
|
||||
*/
|
||||
currency_code: string
|
||||
/**
|
||||
* Whether the currency is the default one for the store.
|
||||
*/
|
||||
is_default: boolean
|
||||
/**
|
||||
* The store ID associated with the currency.
|
||||
*/
|
||||
store_id: string
|
||||
/**
|
||||
* The created date of the currency
|
||||
*/
|
||||
created_at: string
|
||||
/**
|
||||
* The updated date of the currency
|
||||
*/
|
||||
updated_at: string
|
||||
/**
|
||||
* The deleted date of the currency
|
||||
*/
|
||||
deleted_at: string | null
|
||||
}
|
||||
|
||||
/**
|
||||
* The store details.
|
||||
*/
|
||||
@@ -17,12 +48,7 @@ export interface StoreDTO {
|
||||
/**
|
||||
* The supported currency codes of the store.
|
||||
*/
|
||||
supported_currency_codes: string[]
|
||||
|
||||
/**
|
||||
* The default currency code of the store.
|
||||
*/
|
||||
default_currency_code?: string
|
||||
supported_currencies?: StoreCurrencyDTO[]
|
||||
|
||||
/**
|
||||
* The associated default sales channel's ID.
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
export interface CreateStoreCurrencyDTO {
|
||||
/**
|
||||
* The currency code of the store currency.
|
||||
*/
|
||||
currency_code: string
|
||||
/**
|
||||
* Whether the currency is the default one for the store.
|
||||
*/
|
||||
is_default?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* The store to be created.
|
||||
*/
|
||||
@@ -10,12 +21,7 @@ export interface CreateStoreDTO {
|
||||
/**
|
||||
* The supported currency codes of the store.
|
||||
*/
|
||||
supported_currency_codes?: string[]
|
||||
|
||||
/**
|
||||
* The default currency code of the store.
|
||||
*/
|
||||
default_currency_code?: string
|
||||
supported_currencies?: CreateStoreCurrencyDTO[]
|
||||
|
||||
/**
|
||||
* The associated default sales channel's ID.
|
||||
@@ -41,46 +47,11 @@ export interface CreateStoreDTO {
|
||||
/**
|
||||
* The attributes in the store to be created or updated.
|
||||
*/
|
||||
export interface UpsertStoreDTO {
|
||||
export interface UpsertStoreDTO extends UpdateStoreDTO {
|
||||
/**
|
||||
* The ID of the store.
|
||||
* The ID of the store when doing an update.
|
||||
*/
|
||||
id?: string
|
||||
|
||||
/**
|
||||
* The name of the store.
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* The supported currency codes of the store.
|
||||
*/
|
||||
supported_currency_codes?: string[]
|
||||
|
||||
/**
|
||||
* The default currency code of the store.
|
||||
*/
|
||||
default_currency_code?: string
|
||||
|
||||
/**
|
||||
* The associated default sales channel's ID.
|
||||
*/
|
||||
default_sales_channel_id?: string
|
||||
|
||||
/**
|
||||
* The associated default region's ID.
|
||||
*/
|
||||
default_region_id?: string
|
||||
|
||||
/**
|
||||
* The associated default location's ID.
|
||||
*/
|
||||
default_location_id?: string
|
||||
|
||||
/**
|
||||
* Holds custom data in key-value pairs.
|
||||
*/
|
||||
metadata?: Record<string, any>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,12 +66,7 @@ export interface UpdateStoreDTO {
|
||||
/**
|
||||
* The supported currency codes of the store.
|
||||
*/
|
||||
supported_currency_codes?: string[]
|
||||
|
||||
/**
|
||||
* The default currency code of the store.
|
||||
*/
|
||||
default_currency_code?: string
|
||||
supported_currencies?: CreateStoreCurrencyDTO[]
|
||||
|
||||
/**
|
||||
* The associated default sales channel's ID.
|
||||
|
||||
@@ -20,13 +20,11 @@ export interface IStoreModuleService extends IModuleService {
|
||||
* const stores = await storeModuleService.createStores([
|
||||
* {
|
||||
* name: "Acme",
|
||||
* supported_currency_codes: ["usd", "eur"],
|
||||
* default_currency_code: "usd",
|
||||
* supported_currencies: [{ currency_code: "usd", is_default: true }, { currency_code: "eur" }],
|
||||
* },
|
||||
* {
|
||||
* name: "Acme 2",
|
||||
* supported_currency_codes: ["usd"],
|
||||
* default_currency_code: "usd",
|
||||
* supported_currencies: [{currency_code: "usd", is_default: true}],
|
||||
* },
|
||||
* ])
|
||||
*/
|
||||
@@ -45,8 +43,7 @@ export interface IStoreModuleService extends IModuleService {
|
||||
* @example
|
||||
* const store = await storeModuleService.createStores({
|
||||
* name: "Acme",
|
||||
* supported_currency_codes: ["usd", "eur"],
|
||||
* default_currency_code: "usd",
|
||||
* supported_currencies: [{ currency_code: "usd", is_default: true }, { currency_code: "eur" }],
|
||||
* })
|
||||
*/
|
||||
createStores(data: CreateStoreDTO, sharedContext?: Context): Promise<StoreDTO>
|
||||
@@ -66,8 +63,7 @@ export interface IStoreModuleService extends IModuleService {
|
||||
* },
|
||||
* {
|
||||
* name: "Acme 2",
|
||||
* supported_currency_codes: ["usd"],
|
||||
* default_currency_code: "usd",
|
||||
* supported_currencies: [{currency_code: "usd", is_default: true}],
|
||||
* },
|
||||
* ])
|
||||
*/
|
||||
@@ -124,7 +120,6 @@ export interface IStoreModuleService extends IModuleService {
|
||||
* name: ["Acme"],
|
||||
* },
|
||||
* {
|
||||
* default_currency_code: "usd",
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user