feat(promotion, dashboard, core-flows, cart, types, utils, medusa): tax inclusive promotions (#12412)

* feat: tax inclusive promotions

* feat: add a totals test case

* feat: add integration test

* chore: changeset

* fix: typo

* chore: refactor

* fix: tests

* fix: rest of buyget action tests

* fix: cart spec

* chore: expand integration test with item level totals

* feat: add a few more test cases

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Frane PolićandOli Juhl authored and GitHub committed 2025-06-12 15:07:11 +02:00
1 parent 08de1f54e4
commit 2621f00bb0
29 files changed
+1091 -24

No files matched your search

@@ -332,6 +332,16 @@
"default": "false",
"mappedType": "boolean"
},
"is_tax_inclusive": {
"name": "is_tax_inclusive",
"type": "boolean",
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": false,
"default": "false",
"mappedType": "boolean"
},
"type": {
"name": "type",
"type": "text",
@@ -0,0 +1,15 @@
import { Migration } from "@mikro-orm/migrations"
export class Migration20250508081510 extends Migration {
override async up(): Promise<void> {
this.addSql(
`alter table if exists "promotion" add column if not exists "is_tax_inclusive" boolean not null default false;`
)
}
override async down(): Promise<void> {
this.addSql(
`alter table if exists "promotion" drop column if exists "is_tax_inclusive";`
)
}
}
@@ -8,6 +8,7 @@ const Promotion = model
id: model.id({ prefix: "promo" }).primaryKey(),
code: model.text().searchable(),
is_automatic: model.boolean().default(false),
is_tax_inclusive: model.boolean().default(false),
type: model.enum(PromotionUtils.PromotionType).index("IDX_promotion_type"),
status: model
.enum(PromotionUtils.PromotionStatus)
@@ -164,6 +164,7 @@ function applyPromotionToItems(
item_id: item.id,
amount,
code: promotion.code!,
is_tax_inclusive: promotion.is_tax_inclusive,
})
} else if (isTargetShippingMethod) {
computedActions.push({