fix(cart): Tax rate data type (#10626)
* fix(cart): tax rate data type * update test
This commit is contained in:
committed by
GitHub
parent
612eb78c9e
commit
95baacfd00
5
.changeset/famous-mugs-grow.md
Normal file
5
.changeset/famous-mugs-grow.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/cart": patch
|
||||
---
|
||||
|
||||
fix: Cart tax rate data type
|
||||
@@ -1979,7 +1979,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
||||
const taxLines = await service.setLineItemTaxLines(createdCart.id, [
|
||||
{
|
||||
item_id: itemOne.id,
|
||||
rate: 20,
|
||||
rate: 20.753,
|
||||
code: "TX",
|
||||
},
|
||||
])
|
||||
@@ -1988,7 +1988,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item_id: itemOne.id,
|
||||
rate: 20,
|
||||
rate: 20.753,
|
||||
code: "TX",
|
||||
}),
|
||||
])
|
||||
@@ -1997,7 +1997,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
||||
await service.setLineItemTaxLines(createdCart.id, [
|
||||
{
|
||||
item_id: itemOne.id,
|
||||
rate: 25,
|
||||
rate: 25.14789,
|
||||
code: "TX-2",
|
||||
},
|
||||
])
|
||||
@@ -2013,7 +2013,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
||||
tax_lines: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
item_id: itemOne.id,
|
||||
rate: 25,
|
||||
rate: 25.14789,
|
||||
code: "TX-2",
|
||||
}),
|
||||
]),
|
||||
|
||||
@@ -997,12 +997,12 @@
|
||||
},
|
||||
"rate": {
|
||||
"name": "rate",
|
||||
"type": "integer",
|
||||
"type": "real",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "integer"
|
||||
"mappedType": "float"
|
||||
},
|
||||
"provider_id": {
|
||||
"name": "provider_id",
|
||||
@@ -1537,12 +1537,12 @@
|
||||
},
|
||||
"rate": {
|
||||
"name": "rate",
|
||||
"type": "integer",
|
||||
"type": "real",
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": false,
|
||||
"mappedType": "integer"
|
||||
"mappedType": "float"
|
||||
},
|
||||
"provider_id": {
|
||||
"name": "provider_id",
|
||||
|
||||
@@ -50,9 +50,6 @@ export class Migration20241205095237 extends Migration {
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_cart_line_item_adjustment_item_id" ON "cart_line_item_adjustment" (item_id) WHERE deleted_at IS NULL;'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "cart_line_item_tax_line" alter column "rate" type integer using ("rate"::integer);'
|
||||
)
|
||||
this.addSql(
|
||||
'alter table if exists "cart_line_item_tax_line" add constraint "cart_line_item_tax_line_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade on delete cascade;'
|
||||
)
|
||||
@@ -70,10 +67,6 @@ export class Migration20241205095237 extends Migration {
|
||||
this.addSql(
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_cart_shipping_method_adjustment_shipping_method_id" ON "cart_shipping_method_adjustment" (shipping_method_id) WHERE deleted_at IS NULL;'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "cart_shipping_method_tax_line" alter column "rate" type integer using ("rate"::integer);'
|
||||
)
|
||||
this.addSql(
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_cart_shipping_method_tax_line_shipping_method_id" ON "cart_shipping_method_tax_line" (shipping_method_id) WHERE deleted_at IS NULL;'
|
||||
)
|
||||
@@ -112,9 +105,6 @@ export class Migration20241205095237 extends Migration {
|
||||
'alter table if exists "cart_line_item_adjustment" add constraint "cart_line_item_adjustment_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade;'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "cart_line_item_tax_line" alter column "rate" type numeric using ("rate"::numeric);'
|
||||
)
|
||||
this.addSql('drop index if exists "IDX_cart_line_item_tax_line_item_id";')
|
||||
this.addSql(
|
||||
'alter table if exists "cart_line_item_tax_line" add constraint "cart_line_item_tax_line_item_id_foreign" foreign key ("item_id") references "cart_line_item" ("id") on update cascade;'
|
||||
@@ -129,9 +119,6 @@ export class Migration20241205095237 extends Migration {
|
||||
'drop index if exists "IDX_cart_shipping_method_adjustment_shipping_method_id";'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "cart_shipping_method_tax_line" alter column "rate" type numeric using ("rate"::numeric);'
|
||||
)
|
||||
this.addSql(
|
||||
'drop index if exists "IDX_cart_shipping_method_tax_line_shipping_method_id";'
|
||||
)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Migration } from "@mikro-orm/migrations"
|
||||
|
||||
export class Migration20241216183049 extends Migration {
|
||||
async up(): Promise<void> {
|
||||
this.addSql(
|
||||
'alter table if exists "cart_line_item_tax_line" alter column "rate" type real using ("rate"::real);'
|
||||
)
|
||||
|
||||
this.addSql(
|
||||
'alter table if exists "cart_shipping_method_tax_line" alter column "rate" type real using ("rate"::real);'
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ const LineItemTaxLine = model
|
||||
id: model.id({ prefix: "calitxl" }).primaryKey(),
|
||||
description: model.text().nullable(),
|
||||
code: model.text(),
|
||||
rate: model.number(),
|
||||
rate: model.float(),
|
||||
provider_id: model.text().nullable(),
|
||||
metadata: model.json().nullable(),
|
||||
tax_rate_id: model.text().nullable(),
|
||||
|
||||
@@ -11,7 +11,7 @@ const ShippingMethodTaxLine = model
|
||||
id: model.id({ prefix: "casmtxl" }).primaryKey(),
|
||||
description: model.text().nullable(),
|
||||
code: model.text(),
|
||||
rate: model.number(),
|
||||
rate: model.float(),
|
||||
provider_id: model.text().nullable(),
|
||||
tax_rate_id: model.text().nullable(),
|
||||
metadata: model.json().nullable(),
|
||||
|
||||
Reference in New Issue
Block a user