Feat(order): order changes (#6614)
This is a PR to keep them relatively small. Very likely changes, validations and other features will be added. What: Basic methods to cancel, confirm or decline order changes Apply order changes to modify and create a new version of an order Things related to calculation, Order and Item totals are not covered in this PR. Properties won't match with definition, etc. Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
e4acde1aa2
commit
43399c8d0d
@@ -12,11 +12,11 @@ import {
|
||||
Enum,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
OneToMany,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import { OneToMany } from "typeorm"
|
||||
import Order from "./order"
|
||||
import OrderChangeAction from "./order-change-action"
|
||||
|
||||
@@ -64,8 +64,8 @@ export default class OrderChange {
|
||||
@VersionIndex.MikroORMIndex()
|
||||
version: number
|
||||
|
||||
@OneToMany(() => OrderChangeAction, (action) => action.order_change_id, {
|
||||
cascade: [Cascade.REMOVE],
|
||||
@OneToMany(() => OrderChangeAction, (action) => action.order_change, {
|
||||
cascade: [Cascade.PERSIST],
|
||||
})
|
||||
actions = new Collection<OrderChangeAction>(this)
|
||||
|
||||
@@ -77,7 +77,7 @@ export default class OrderChange {
|
||||
|
||||
@Enum({ items: () => OrderChangeStatus, default: OrderChangeStatus.PENDING })
|
||||
@OrderChangeStatusIndex.MikroORMIndex()
|
||||
status: OrderChangeStatus
|
||||
status: OrderChangeStatus = OrderChangeStatus.PENDING
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
internal_note: string | null = null
|
||||
@@ -92,7 +92,7 @@ export default class OrderChange {
|
||||
columnType: "timestamptz",
|
||||
nullable: true,
|
||||
})
|
||||
requested_at?: Date
|
||||
requested_at: Date | null = null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
confirmed_by: string | null = null // customer or user ID
|
||||
@@ -101,7 +101,7 @@ export default class OrderChange {
|
||||
columnType: "timestamptz",
|
||||
nullable: true,
|
||||
})
|
||||
confirmed_at?: Date
|
||||
confirmed_at: Date | null = null
|
||||
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
declined_by: string | null = null // customer or user ID
|
||||
|
||||
Reference in New Issue
Block a user