fix(cart): Tax rate data type (#10626)
* fix(cart): tax rate data type * update test
This commit is contained in:
1 parent
612eb78c9e
commit
95baacfd00
7 files changed
+28
-23
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/cart": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Cart tax rate data type
|
||||||
+4
-4
@@ -1979,7 +1979,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
|||||||
const taxLines = await service.setLineItemTaxLines(createdCart.id, [
|
const taxLines = await service.setLineItemTaxLines(createdCart.id, [
|
||||||
{
|
{
|
||||||
item_id: itemOne.id,
|
item_id: itemOne.id,
|
||||||
rate: 20,
|
rate: 20.753,
|
||||||
code: "TX",
|
code: "TX",
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
@@ -1988,7 +1988,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
|||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
item_id: itemOne.id,
|
item_id: itemOne.id,
|
||||||
rate: 20,
|
rate: 20.753,
|
||||||
code: "TX",
|
code: "TX",
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
@@ -1997,7 +1997,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
|||||||
await service.setLineItemTaxLines(createdCart.id, [
|
await service.setLineItemTaxLines(createdCart.id, [
|
||||||
{
|
{
|
||||||
item_id: itemOne.id,
|
item_id: itemOne.id,
|
||||||
rate: 25,
|
rate: 25.14789,
|
||||||
code: "TX-2",
|
code: "TX-2",
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
@@ -2013,7 +2013,7 @@ moduleIntegrationTestRunner<ICartModuleService>({
|
|||||||
tax_lines: expect.arrayContaining([
|
tax_lines: expect.arrayContaining([
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
item_id: itemOne.id,
|
item_id: itemOne.id,
|
||||||
rate: 25,
|
rate: 25.14789,
|
||||||
code: "TX-2",
|
code: "TX-2",
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@@ -997,12 +997,12 @@
|
|||||||
},
|
},
|
||||||
"rate": {
|
"rate": {
|
||||||
"name": "rate",
|
"name": "rate",
|
||||||
"type": "integer",
|
"type": "real",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "integer"
|
"mappedType": "float"
|
||||||
},
|
},
|
||||||
"provider_id": {
|
"provider_id": {
|
||||||
"name": "provider_id",
|
"name": "provider_id",
|
||||||
@@ -1537,12 +1537,12 @@
|
|||||||
},
|
},
|
||||||
"rate": {
|
"rate": {
|
||||||
"name": "rate",
|
"name": "rate",
|
||||||
"type": "integer",
|
"type": "real",
|
||||||
"unsigned": false,
|
"unsigned": false,
|
||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"mappedType": "integer"
|
"mappedType": "float"
|
||||||
},
|
},
|
||||||
"provider_id": {
|
"provider_id": {
|
||||||
"name": "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;'
|
'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(
|
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;'
|
'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(
|
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;'
|
'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(
|
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;'
|
'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;'
|
'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('drop index if exists "IDX_cart_line_item_tax_line_item_id";')
|
||||||
this.addSql(
|
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;'
|
'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";'
|
'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(
|
this.addSql(
|
||||||
'drop index if exists "IDX_cart_shipping_method_tax_line_shipping_method_id";'
|
'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(),
|
id: model.id({ prefix: "calitxl" }).primaryKey(),
|
||||||
description: model.text().nullable(),
|
description: model.text().nullable(),
|
||||||
code: model.text(),
|
code: model.text(),
|
||||||
rate: model.number(),
|
rate: model.float(),
|
||||||
provider_id: model.text().nullable(),
|
provider_id: model.text().nullable(),
|
||||||
metadata: model.json().nullable(),
|
metadata: model.json().nullable(),
|
||||||
tax_rate_id: model.text().nullable(),
|
tax_rate_id: model.text().nullable(),
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const ShippingMethodTaxLine = model
|
|||||||
id: model.id({ prefix: "casmtxl" }).primaryKey(),
|
id: model.id({ prefix: "casmtxl" }).primaryKey(),
|
||||||
description: model.text().nullable(),
|
description: model.text().nullable(),
|
||||||
code: model.text(),
|
code: model.text(),
|
||||||
rate: model.number(),
|
rate: model.float(),
|
||||||
provider_id: model.text().nullable(),
|
provider_id: model.text().nullable(),
|
||||||
tax_rate_id: model.text().nullable(),
|
tax_rate_id: model.text().nullable(),
|
||||||
metadata: model.json().nullable(),
|
metadata: model.json().nullable(),
|
||||||
|
|||||||
Reference in new issue
Block a user