feat(order): create claim and exchange (#7734)
This commit is contained in:
@@ -14,11 +14,8 @@ import {
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import Claim from "./claim"
|
||||
import Exchange from "./exchange"
|
||||
import LineItem from "./line-item"
|
||||
import Order from "./order"
|
||||
import Return from "./return"
|
||||
|
||||
type OptionalLineItemProps = DAL.EntityDateColumns
|
||||
|
||||
@@ -28,24 +25,6 @@ const OrderIdIndex = createPsqlIndexStatementHelper({
|
||||
where: "deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
const ReturnIdIndex = createPsqlIndexStatementHelper({
|
||||
tableName: "order_item",
|
||||
columns: "return_id",
|
||||
where: "return_id IS NOT NULL AND deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
const ExchangeIdIndex = createPsqlIndexStatementHelper({
|
||||
tableName: "order_item",
|
||||
columns: ["exchange_id"],
|
||||
where: "exchange_id IS NOT NULL AND deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
const ClaimIdIndex = createPsqlIndexStatementHelper({
|
||||
tableName: "order_item",
|
||||
columns: ["claim_id"],
|
||||
where: "claim_id IS NOT NULL AND deleted_at IS NOT NULL",
|
||||
})
|
||||
|
||||
const OrderVersionIndex = createPsqlIndexStatementHelper({
|
||||
tableName: "order_item",
|
||||
columns: ["version"],
|
||||
@@ -85,51 +64,6 @@ export default class OrderItem {
|
||||
})
|
||||
order: Order
|
||||
|
||||
@ManyToOne({
|
||||
entity: () => Return,
|
||||
mapToPk: true,
|
||||
fieldName: "return_id",
|
||||
columnType: "text",
|
||||
nullable: true,
|
||||
})
|
||||
@ReturnIdIndex.MikroORMIndex()
|
||||
return_id: string | null = null
|
||||
|
||||
@ManyToOne(() => Return, {
|
||||
persist: false,
|
||||
})
|
||||
return: Return
|
||||
|
||||
@ManyToOne({
|
||||
entity: () => Exchange,
|
||||
mapToPk: true,
|
||||
fieldName: "exchange_id",
|
||||
columnType: "text",
|
||||
nullable: true,
|
||||
})
|
||||
@ExchangeIdIndex.MikroORMIndex()
|
||||
exchange_id: string | null
|
||||
|
||||
@ManyToOne(() => Exchange, {
|
||||
persist: false,
|
||||
})
|
||||
exchange: Exchange
|
||||
|
||||
@ManyToOne({
|
||||
entity: () => Claim,
|
||||
mapToPk: true,
|
||||
fieldName: "claim_id",
|
||||
columnType: "text",
|
||||
nullable: true,
|
||||
})
|
||||
@ClaimIdIndex.MikroORMIndex()
|
||||
claim_id: string | null
|
||||
|
||||
@ManyToOne(() => Claim, {
|
||||
persist: false,
|
||||
})
|
||||
claim: Claim
|
||||
|
||||
@Property({ columnType: "integer" })
|
||||
@OrderVersionIndex.MikroORMIndex()
|
||||
version: number
|
||||
@@ -216,9 +150,6 @@ export default class OrderItem {
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "orditem")
|
||||
this.order_id ??= this.order?.id
|
||||
this.return_id ??= this.return?.id
|
||||
this.exchange_id ??= this.exchange?.id
|
||||
this.claim_id ??= this.claim?.id
|
||||
this.item_id ??= this.item?.id
|
||||
this.version ??= this.order?.version
|
||||
}
|
||||
@@ -227,9 +158,6 @@ export default class OrderItem {
|
||||
onInit() {
|
||||
this.id = generateEntityId(this.id, "orditem")
|
||||
this.order_id ??= this.order?.id
|
||||
this.return_id ??= this.return?.id
|
||||
this.exchange_id ??= this.exchange?.id
|
||||
this.claim_id ??= this.claim?.id
|
||||
this.item_id ??= this.item?.id
|
||||
this.version ??= this.order?.version
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user