1 import { model } from "@medusajs/framework/utils"
2 import ShippingMethod from "./shipping-method"
3
4 /**
5 * A tax line applied to a cart shipping method.
6 */
7 const ShippingMethodTaxLine = model
8 .define(
9 {
10 name: "ShippingMethodTaxLine",
11 tableName: "cart_shipping_method_tax_line",
12 },
13 {
14 id: model.id({ prefix: "casmtxl" }).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 * The ID of the associated tax rate.
33 */
34 tax_rate_id: model.text().nullable(),
35 /**
36 * Holds custom data in key-value pairs.
37 */
38 metadata: model.json().nullable(),
39 /**
40 * Holds data returned by the tax provider in key-value pairs.
41 *
42 * @since 2.17.3
43 */
44 data: model.json().nullable(),
45 /**
46 * The associated shipping method.
47 */
48 shipping_method: model.belongsTo(() => ShippingMethod, {
49 mappedBy: "tax_lines",
50 }),
51 }
52 )
53 .indexes([
54 {
55 name: "IDX_cart_shipping_method_tax_line_shipping_method_id",
56 on: ["shipping_method_id"],
57 where: "deleted_at IS NULL",
58 },
59 {
60 name: "IDX_shipping_method_tax_line_tax_rate_id",
61 on: ["tax_rate_id"],
62 where: "deleted_at IS NULL AND tax_rate_id IS NOT NULL",
63 },
64 ])
65
66 export default ShippingMethodTaxLine