feat(medusa,dashboard,tax): added tax rates and regions UI (#7026)
whats missing: - make rules required for overrides - conditions for other rules - populating condition reference ids with labels on update Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
1 parent
92b633d1cb
commit
00e6b21bb5
77 files changed
+3654
-104
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { Modules } from "@medusajs/modules-sdk"
|
||||
import { ModuleJoinerConfig } from "@medusajs/types"
|
||||
import { MapToConfig } from "@medusajs/utils"
|
||||
import { TaxRate, TaxRegion, TaxRateRule, TaxProvider } from "@models"
|
||||
import { TaxProvider, TaxRate, TaxRateRule, TaxRegion } from "@models"
|
||||
|
||||
export const LinkableKeys: Record<string, string> = {
|
||||
tax_rate_id: TaxRate.name,
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
import { DAL } from "@medusajs/types"
|
||||
import {
|
||||
DALUtils,
|
||||
createPsqlIndexStatementHelper,
|
||||
DALUtils,
|
||||
generateEntityId,
|
||||
Searchable,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
Filter,
|
||||
BeforeCreate,
|
||||
Cascade,
|
||||
Collection,
|
||||
Entity,
|
||||
Filter,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
OneToMany,
|
||||
OnInit,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import TaxRegion from "./tax-region"
|
||||
import TaxRateRule from "./tax-rate-rule"
|
||||
import TaxRegion from "./tax-region"
|
||||
|
||||
type OptionalTaxRateProps = DAL.SoftDeletableEntityDateColumns
|
||||
|
||||
@@ -53,9 +54,11 @@ export default class TaxRate {
|
||||
@Property({ columnType: "real", nullable: true })
|
||||
rate: number | null = null
|
||||
|
||||
@Searchable()
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
code: string | null = null
|
||||
|
||||
@Searchable()
|
||||
@Property({ columnType: "text" })
|
||||
name: string
|
||||
|
||||
@@ -66,7 +69,7 @@ export default class TaxRate {
|
||||
is_combinable = false
|
||||
|
||||
@ManyToOne(() => TaxRegion, {
|
||||
type: "text",
|
||||
columnType: "text",
|
||||
fieldName: "tax_region_id",
|
||||
mapToPk: true,
|
||||
onDelete: "cascade",
|
||||
@@ -79,7 +82,6 @@ export default class TaxRate {
|
||||
|
||||
@OneToMany(() => TaxRateRule, (rule) => rule.tax_rate, {
|
||||
cascade: ["soft-remove" as Cascade],
|
||||
persist: false,
|
||||
})
|
||||
rules = new Collection<TaxRateRule>(this)
|
||||
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import { DAL } from "@medusajs/types"
|
||||
import {
|
||||
DALUtils,
|
||||
Searchable,
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
Filter,
|
||||
BeforeCreate,
|
||||
Cascade,
|
||||
Check,
|
||||
Collection,
|
||||
Entity,
|
||||
Filter,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
OneToMany,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
OneToMany,
|
||||
ManyToOne,
|
||||
Check,
|
||||
Cascade,
|
||||
} from "@mikro-orm/core"
|
||||
import TaxRate from "./tax-rate"
|
||||
import TaxProvider from "./tax-provider"
|
||||
import TaxRate from "./tax-rate"
|
||||
|
||||
type OptionalTaxRegionProps = DAL.SoftDeletableEntityDateColumns
|
||||
|
||||
@@ -63,9 +64,14 @@ export default class TaxRegion {
|
||||
})
|
||||
provider_id: string | null = null
|
||||
|
||||
@ManyToOne(() => TaxProvider, { persist: false })
|
||||
provider: TaxProvider
|
||||
|
||||
@Searchable()
|
||||
@Property({ columnType: "text" })
|
||||
country_code: string
|
||||
|
||||
@Searchable()
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
province_code: string | null = null
|
||||
|
||||
|
||||
Reference in new issue
Block a user