1 import { model } from "@medusajs/framework/utils"
2 import LineItem from "./line-item"
3
4 /**
5 * A tax line applied to a cart line item.
6 */
7 const LineItemTaxLine = model
8 .define(
9 {
10 name: "LineItemTaxLine",
11 tableName: "cart_line_item_tax_line",
12 },
13 {
14 id: model.id({ prefix: "calitxl" }).primaryKey(),
15 /**
16 * The description of the tax line.
17 */
18 description: model.text().nullable(),
19 /**
20 * The code of the tax line.
21 */
22 code: model.text(),
23 /**
24 * The rate of the tax line.
25 */
26 rate: model.float(),
27 /**
28 * The ID of the associated tax provider.
29 */
30 provider_id: model.text().nullable(),
31 /**
32 * Holds custom data in key-value pairs.
33 */
34 metadata: model.json().nullable(),
35 /**
36 * Holds data returned by the tax provider in key-value pairs.
37 *
38 * @since 2.17.3
39 */
40 data: model.json().nullable(),
41 /**
42 * The ID of the associated tax rate.
43 */
44 tax_rate_id: model.text().nullable(),
45 /**
46 * The associated line item.
47 */
48 item: model.belongsTo(() => LineItem, {
49 mappedBy: "tax_lines",
50 }),
51 }
52 )
53 .indexes([
54 {
55 name: "IDX_line_item_tax_line_tax_rate_id",
56 on: ["tax_rate_id"],
57 where: "deleted_at IS NULL AND tax_rate_id IS NOT NULL",
58 },
59 {
60 name: "IDX_cart_line_item_tax_line_item_id",
61 on: ["item_id"],
62 where: "deleted_at IS NULL",
63 },
64 ])
65
66 export default LineItemTaxLine