|
1
|
import { ClaimType, model } from "@medusajs/framework/utils" |
|
2
|
import { OrderClaimItem } from "./claim-item" |
|
3
|
import { Order } from "./order" |
|
4
|
import { OrderShipping } from "./order-shipping-method" |
|
5
|
import { Return } from "./return" |
|
6
|
import { OrderTransaction } from "./transaction" |
|
7
|
|
|
8
|
const _OrderClaim = model |
|
9
|
.define("OrderClaim", { |
|
10
|
id: model.id({ prefix: "claim" }).primaryKey(), |
|
11
|
order_version: model.number(), |
|
12
|
display_id: model.autoincrement(), |
|
13
|
type: model.enum(ClaimType), |
|
14
|
no_notification: model.boolean().nullable(), |
|
15
|
refund_amount: model.bigNumber().nullable(), |
|
16
|
created_by: model.text().nullable(), |
|
17
|
canceled_at: model.dateTime().nullable(), |
|
18
|
metadata: model.json().nullable(), |
|
19
|
order: model.hasOne<() => typeof Order>(() => Order, { |
|
20
|
mappedBy: undefined, |
|
21
|
foreignKey: true, |
|
22
|
}), |
|
23
|
return: model |
|
24
|
.hasOne<() => typeof Return>(() => Return, { |
|
25
|
mappedBy: undefined, |
|
26
|
foreignKey: true, |
|
27
|
}) |
|
28
|
.nullable(), |
|
29
|
additional_items: model.hasMany<() => typeof OrderClaimItem>( |
|
30
|
() => OrderClaimItem, |
|
31
|
{ |
|
32
|
mappedBy: "claim", |
|
33
|
} |
|
34
|
), |
|
35
|
claim_items: model.hasMany<() => typeof OrderClaimItem>( |
|
36
|
() => OrderClaimItem, |
|
37
|
{ |
|
38
|
mappedBy: "claim", |
|
39
|
} |
|
40
|
), |
|
41
|
shipping_methods: model.hasMany<() => typeof OrderShipping>( |
|
42
|
() => OrderShipping, |
|
43
|
{ |
|
44
|
mappedBy: "claim", |
|
45
|
} |
|
46
|
), |
|
47
|
transactions: model.hasMany<() => typeof OrderTransaction>( |
|
48
|
() => OrderTransaction, |
|
49
|
{ |
|
50
|
mappedBy: "claim", |
|
51
|
} |
|
52
|
), |
|
53
|
}) |
|
54
|
.cascades({ |
|
55
|
delete: ["additional_items", "claim_items", "transactions"], |
|
56
|
}) |
|
57
|
.indexes([ |
|
58
|
{ |
|
59
|
name: "IDX_order_claim_display_id", |
|
60
|
on: ["display_id"], |
|
61
|
unique: false, |
|
62
|
where: "deleted_at IS NULL", |
|
63
|
}, |
|
64
|
{ |
|
65
|
name: "IDX_order_claim_deleted_at", |
|
66
|
on: ["deleted_at"], |
|
67
|
unique: false, |
|
68
|
where: "deleted_at IS NOT NULL", |
|
69
|
}, |
|
70
|
{ |
|
71
|
name: "IDX_order_claim_order_id", |
|
72
|
on: ["order_id"], |
|
73
|
unique: false, |
|
74
|
where: "deleted_at IS NULL", |
|
75
|
}, |
|
76
|
{ |
|
77
|
name: "IDX_order_claim_return_id", |
|
78
|
on: ["return_id"], |
|
79
|
unique: false, |
|
80
|
where: "return_id IS NOT NULL AND deleted_at IS NULL", |
|
81
|
}, |
|
82
|
]) |
|
83
|
|
|
84
|
export const OrderClaim = _OrderClaim |