chore(order): Paid Total and Refunded Total (#7373)

This commit is contained in:
Carlos R. L. Rodrigues
2024-05-20 15:48:57 -03:00
committed by GitHub
parent 025536e2a5
commit f57dc98c7a
24 changed files with 340 additions and 175 deletions
@@ -33,7 +33,20 @@ const CurrencyCodeIndex = createPsqlIndexStatementHelper({
columns: "currency_code",
})
const DeletedAtIndex = createPsqlIndexStatementHelper({
tableName: "order_transaction",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
const OrderIdVersionIndex = createPsqlIndexStatementHelper({
tableName: "order_transaction",
columns: ["order_id", "version"],
where: "deleted_at IS NOT NULL",
})
@Entity({ tableName: "order_transaction" })
@OrderIdVersionIndex.MikroORMIndex()
export default class Transaction {
[OptionalProps]?: OptionalLineItemProps
@@ -55,6 +68,12 @@ export default class Transaction {
})
order: Order
@Property({
columnType: "integer",
defaultRaw: "1",
})
version: number = 1
@MikroOrmBigNumberProperty()
amount: BigNumber | number
@@ -93,6 +112,10 @@ export default class Transaction {
})
updated_at: Date
@Property({ columnType: "timestamptz", nullable: true })
@DeletedAtIndex.MikroORMIndex()
deleted_at: Date | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "ordtrx")