feat(order): create claim and exchange (#7734)

This commit is contained in:
Carlos R. L. Rodrigues
2024-06-18 08:08:16 -03:00
committed by GitHub
parent e0b14519f1
commit cfa983001b
45 changed files with 2571 additions and 437 deletions
@@ -1,6 +1,7 @@
import { DAL } from "@medusajs/types"
import { BigNumberRawValue, DAL } from "@medusajs/types"
import {
ClaimReason,
MikroOrmBigNumberProperty,
createPsqlIndexStatementHelper,
generateEntityId,
} from "@medusajs/utils"
@@ -26,11 +27,19 @@ type OptionalLineItemProps = DAL.EntityDateColumns
const ClaimIdIndex = createPsqlIndexStatementHelper({
tableName: "order_claim_item",
columns: "claim_id",
where: "deleted_at IS NOT NULL",
})
const ItemIdIndex = createPsqlIndexStatementHelper({
tableName: "order_claim_item",
columns: "item_id",
where: "deleted_at IS NOT NULL",
})
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "order_claim_item_image",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
@Entity({ tableName: "order_claim_item" })
@@ -45,8 +54,14 @@ export default class OrderClaimItem {
})
images = new Collection<ClaimItemImage>(this)
@Enum({ items: () => ClaimReason })
reason: ClaimReason
@Enum({ items: () => ClaimReason, nullable: true })
reason: ClaimReason | null = null
@MikroOrmBigNumberProperty()
quantity: Number | number
@Property({ columnType: "jsonb" })
raw_quantity: BigNumberRawValue
@ManyToOne(() => Claim, {
columnType: "text",
@@ -76,6 +91,9 @@ export default class OrderClaimItem {
})
item: LineItem
@Property({ columnType: "boolean", default: false })
is_additional_item: boolean = false
@Property({ columnType: "text", nullable: true })
note: string
@@ -97,13 +115,19 @@ export default class OrderClaimItem {
})
updated_at: Date
@Property({ columnType: "timestamptz", nullable: true })
@DeletedAtIndex.MikroORMIndex()
deleted_at: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "ordclaimitem")
this.id = generateEntityId(this.id, "claitem")
this.claim_id = this.claim?.id
}
@OnInit()
onInit() {
this.id = generateEntityId(this.id, "ordclaimitem")
this.id = generateEntityId(this.id, "claitem")
this.claim_id = this.claim?.id
}
}