fix(medusa): order tax_rate type (#879)
* fix(order): tax_rate column should be numeric, not integer, since region.tax_rate uses numeric * chore: cleanup * fix(tax_rate): use REAL database numeric type for tax_rate column on order and region
This commit is contained in:
1 parent
80089d04d8
commit
89472b7d88
3 files changed
+76
-18
No files matched your search
@@ -0,0 +1,23 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
|
export class orderTaxRateToRealType1638543550000 implements MigrationInterface {
|
||||||
|
name = "orderTaxRateToRealType1638543550000"
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "order" ALTER COLUMN "tax_rate" TYPE REAL`
|
||||||
|
)
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "region" ALTER COLUMN "tax_rate" TYPE REAL`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "order" ALTER COLUMN "tax_rate" TYPE INTEGER`
|
||||||
|
)
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "region" ALTER COLUMN "tax_rate" TYPE NUMERIC`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -142,7 +142,7 @@ export class Order {
|
|||||||
@JoinColumn({ name: "currency_code", referencedColumnName: "code" })
|
@JoinColumn({ name: "currency_code", referencedColumnName: "code" })
|
||||||
currency: Currency
|
currency: Currency
|
||||||
|
|
||||||
@Column({ type: "int" })
|
@Column({ type: "real" })
|
||||||
tax_rate: number
|
tax_rate: number
|
||||||
|
|
||||||
@ManyToMany(() => Discount, { cascade: ["insert"] })
|
@ManyToMany(() => Discount, { cascade: ["insert"] })
|
||||||
@@ -173,29 +173,57 @@ export class Order {
|
|||||||
})
|
})
|
||||||
gift_cards: GiftCard[]
|
gift_cards: GiftCard[]
|
||||||
|
|
||||||
@OneToMany(() => ShippingMethod, (method) => method.order, {
|
@OneToMany(
|
||||||
cascade: ["insert"],
|
() => ShippingMethod,
|
||||||
})
|
method => method.order,
|
||||||
|
{
|
||||||
|
cascade: ["insert"],
|
||||||
|
}
|
||||||
|
)
|
||||||
shipping_methods: ShippingMethod[]
|
shipping_methods: ShippingMethod[]
|
||||||
|
|
||||||
@OneToMany(() => Payment, (payment) => payment.order, { cascade: ["insert"] })
|
@OneToMany(
|
||||||
|
() => Payment,
|
||||||
|
payment => payment.order,
|
||||||
|
{ cascade: ["insert"] }
|
||||||
|
)
|
||||||
payments: Payment[]
|
payments: Payment[]
|
||||||
|
|
||||||
@OneToMany(() => Fulfillment, (fulfillment) => fulfillment.order, {
|
@OneToMany(
|
||||||
cascade: ["insert"],
|
() => Fulfillment,
|
||||||
})
|
fulfillment => fulfillment.order,
|
||||||
|
{
|
||||||
|
cascade: ["insert"],
|
||||||
|
}
|
||||||
|
)
|
||||||
fulfillments: Fulfillment[]
|
fulfillments: Fulfillment[]
|
||||||
|
|
||||||
@OneToMany(() => Return, (ret) => ret.order, { cascade: ["insert"] })
|
@OneToMany(
|
||||||
|
() => Return,
|
||||||
|
ret => ret.order,
|
||||||
|
{ cascade: ["insert"] }
|
||||||
|
)
|
||||||
returns: Return[]
|
returns: Return[]
|
||||||
|
|
||||||
@OneToMany(() => ClaimOrder, (co) => co.order, { cascade: ["insert"] })
|
@OneToMany(
|
||||||
|
() => ClaimOrder,
|
||||||
|
co => co.order,
|
||||||
|
{ cascade: ["insert"] }
|
||||||
|
)
|
||||||
claims: ClaimOrder[]
|
claims: ClaimOrder[]
|
||||||
|
|
||||||
@OneToMany(() => Refund, (ref) => ref.order, { cascade: ["insert"] })
|
@OneToMany(
|
||||||
|
() => Refund,
|
||||||
|
ref => ref.order,
|
||||||
|
{ cascade: ["insert"] }
|
||||||
|
)
|
||||||
refunds: Refund[]
|
refunds: Refund[]
|
||||||
|
|
||||||
@OneToMany(() => Swap, (swap) => swap.order, { cascade: ["insert"] })
|
@OneToMany(
|
||||||
|
() => Swap,
|
||||||
|
swap => swap.order,
|
||||||
|
{ cascade: ["insert"] }
|
||||||
|
)
|
||||||
swaps: Swap[]
|
swaps: Swap[]
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
@@ -205,12 +233,19 @@ export class Order {
|
|||||||
@JoinColumn({ name: "draft_order_id" })
|
@JoinColumn({ name: "draft_order_id" })
|
||||||
draft_order: DraftOrder
|
draft_order: DraftOrder
|
||||||
|
|
||||||
@OneToMany(() => LineItem, (lineItem) => lineItem.order, {
|
@OneToMany(
|
||||||
cascade: ["insert"],
|
() => LineItem,
|
||||||
})
|
lineItem => lineItem.order,
|
||||||
|
{
|
||||||
|
cascade: ["insert"],
|
||||||
|
}
|
||||||
|
)
|
||||||
items: LineItem[]
|
items: LineItem[]
|
||||||
|
|
||||||
@OneToMany(() => GiftCardTransaction, (gc) => gc.order)
|
@OneToMany(
|
||||||
|
() => GiftCardTransaction,
|
||||||
|
gc => gc.order
|
||||||
|
)
|
||||||
gift_card_transactions: GiftCardTransaction[]
|
gift_card_transactions: GiftCardTransaction[]
|
||||||
|
|
||||||
@Column({ nullable: true, type: resolveDbType("timestamptz") })
|
@Column({ nullable: true, type: resolveDbType("timestamptz") })
|
||||||
@@ -304,7 +339,7 @@ export class Order {
|
|||||||
* currency_code:
|
* currency_code:
|
||||||
* type: string
|
* type: string
|
||||||
* tax_rate:
|
* tax_rate:
|
||||||
* type: integer
|
* type: number
|
||||||
* discounts:
|
* discounts:
|
||||||
* type: array
|
* type: array
|
||||||
* items:
|
* items:
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export class Region {
|
|||||||
@JoinColumn({ name: "currency_code", referencedColumnName: "code" })
|
@JoinColumn({ name: "currency_code", referencedColumnName: "code" })
|
||||||
currency: Currency
|
currency: Currency
|
||||||
|
|
||||||
@Column({ type: "decimal" })
|
@Column({ type: "real" })
|
||||||
tax_rate: number
|
tax_rate: number
|
||||||
|
|
||||||
@Column({ nullable: true })
|
@Column({ nullable: true })
|
||||||
|
|||||||
Reference in new issue
Block a user