fix: Tax region + rates clean up (#9279)

What
- Require `code` on Tax Rates
- Update dashboard to account for non-nullable code on Tax Rates

- Include `automatic_taxes` in API Route response

Closes CC-524 CC-525
This commit is contained in:
Oli Juhl
2024-09-29 12:25:33 +02:00
committed by GitHub
parent 0efbcd2344
commit 1b4372ae71
23 changed files with 121 additions and 45 deletions

View File

@@ -246,7 +246,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"nullable": false,
"mappedType": "float"
},
"code": {
@@ -255,7 +255,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"nullable": false,
"mappedType": "text"
},
"name": {

View File

@@ -0,0 +1,18 @@
import { Migration } from "@mikro-orm/migrations"
export class Migration20240924114005 extends Migration {
async up(): Promise<void> {
this.addSql(
`UPDATE "tax_rate" SET code = 'default' WHERE code IS NULL;`
)
this.addSql(
`ALTER TABLE IF EXISTS "tax_rate" ALTER COLUMN "code" SET NOT NULL;`
)
}
async down(): Promise<void> {
this.addSql(
`ALTER TABLE IF EXISTS "tax_rate" ALTER COLUMN "code" DROP NOT NULL;`
)
}
}

View File

@@ -61,8 +61,8 @@ export default class TaxRate {
rate: number | null = null
@Searchable()
@Property({ columnType: "text", nullable: true })
code: string | null = null
@Property({ columnType: "text" })
code: string
@Searchable()
@Property({ columnType: "text" })