1 import { model } from "@medusajs/framework/utils"
2 import LineItem from "./line-item"
3
4 const LineItemAdjustment = model
5 .define(
6 { name: "LineItemAdjustment", tableName: "cart_line_item_adjustment" },
7 {
8 id: model.id({ prefix: "caliadj" }).primaryKey(),
9 description: model.text().nullable(),
10 code: model.text().nullable(),
11 amount: model.bigNumber(),
12 is_tax_inclusive: model.boolean().default(false),
13 provider_id: model.text().nullable(),
14 promotion_id: model.text().nullable(),
15 metadata: model.json().nullable(),
16 item: model.belongsTo(() => LineItem, {
17 mappedBy: "adjustments",
18 }),
19 }
20 )
21 .indexes([
22 {
23 name: "IDX_line_item_adjustment_promotion_id",
24 on: ["promotion_id"],
25 where: "deleted_at IS NULL AND promotion_id IS NOT NULL",
26 },
27 {
28 name: "IDX_cart_line_item_adjustment_item_id",
29 on: ["item_id"],
30 where: "deleted_at IS NULL",
31 },
32 ])
33 .checks([(columns) => `${columns.amount} >= 0`])
34
35 export default LineItemAdjustment