feat(core-flows,medusa,types): add automatic-taxes to region + generate tax lines endpoint (#6667)

what:

- endpoint to generate tax lines
- update workflows to force calculate tax lines with a flag
- added automatic_taxes to region
This commit is contained in:
Riqwan Thamir authored and GitHub committed 2024-03-12 14:36:22 +00:00
1 parent 87e63c024e
commit c3c4f49fc2
14 files changed
+296 -12

No files matched your search

@@ -34,6 +34,7 @@ describe("Region Module Service", () => {
const createdRegion = await service.create({
name: "Europe",
currency_code: "EUR",
automatic_taxes: false,
})
expect(createdRegion).toEqual(
@@ -42,6 +43,7 @@ describe("Region Module Service", () => {
name: "Europe",
currency_code: "eur",
countries: [],
automatic_taxes: false,
})
)
@@ -75,6 +77,7 @@ describe("Region Module Service", () => {
id: region.id,
name: "North America",
currency_code: "usd",
automatic_taxes: true,
countries: [
expect.objectContaining({
display_name: "Canada",
@@ -148,6 +151,7 @@ describe("Region Module Service", () => {
name: "Americas",
currency_code: "MXN",
countries: ["us", "mx"],
automatic_taxes: false,
})
const latestRegion = await service.retrieve(createdRegion.id, {
@@ -158,6 +162,7 @@ describe("Region Module Service", () => {
id: createdRegion.id,
name: "Americas",
currency_code: "mxn",
automatic_taxes: false,
})
expect(latestRegion.countries.map((c) => c.iso_2)).toEqual(["mx", "us"])
})
@@ -20,9 +20,10 @@ ALTER TABLE "region" DROP CONSTRAINT IF EXISTS "FK_3bdd5896ec93be2f1c62a3309a5";
ALTER TABLE "region" DROP CONSTRAINT IF EXISTS "FK_91f88052197680f9790272aaf5b";
${generatePostgresAlterColummnIfExistStatement(
"region",
["tax_rate", "gift_cards_taxable", "automatic_taxes", "includes_tax"],
["tax_rate", "gift_cards_taxable", "includes_tax"],
"DROP NOT NULL"
)}
ALTER TABLE "region" ADD COLUMN IF NOT EXISTS "automatic_taxes" BOOLEAN NOT NULL DEFAULT TRUE;
CREATE INDEX IF NOT EXISTS "IDX_region_deleted_at" ON "region" ("deleted_at") WHERE "deleted_at" IS NOT NULL;
-- Create or update "region_country" table
CREATE TABLE IF NOT EXISTS "region_country" (
+3 -1
View File
@@ -6,7 +6,6 @@ import {
Entity,
Filter,
Index,
ManyToOne,
OnInit,
OneToMany,
OptionalProps,
@@ -31,6 +30,9 @@ export default class Region {
@Property({ columnType: "text" })
currency_code: string
@Property({ columnType: "boolean" })
automatic_taxes = true
@OneToMany(() => Country, (country) => country.region)
countries = new Collection<Country>(this)