Files
medusa-store/packages/modules/payment/src/models/refund.ts
Riqwan Thamir 7ae1d80380 feat(dashboard,types,js-sdk,payment): ability to refund payment in order page (#8385)
* feat(dashboard,types,js-sdk,payment): ability to refund payment in order page

* chore: use confirmation variant for capture payment

* chore: change refund design accords to figma

* chore: move to js-sdk + currency input
2024-08-01 19:13:41 +02:00

76 lines
1.5 KiB
TypeScript

import { BigNumberRawValue } from "@medusajs/types"
import {
BigNumber,
MikroOrmBigNumberProperty,
generateEntityId,
} from "@medusajs/utils"
import {
BeforeCreate,
Entity,
ManyToOne,
OnInit,
PrimaryKey,
Property,
Rel,
} from "@mikro-orm/core"
import Payment from "./payment"
@Entity({ tableName: "refund" })
export default class Refund {
@PrimaryKey({ columnType: "text" })
id: string
@MikroOrmBigNumberProperty()
amount: BigNumber | number
@Property({ columnType: "jsonb" })
raw_amount: BigNumberRawValue
@ManyToOne(() => Payment, {
onDelete: "cascade",
index: "IDX_refund_payment_id",
fieldName: "payment_id",
})
payment!: Rel<Payment>
@Property({ columnType: "text", nullable: true })
payment_id: string
@Property({
onCreate: () => new Date(),
columnType: "timestamptz",
defaultRaw: "now()",
})
created_at: Date
@Property({
onCreate: () => new Date(),
columnType: "timestamptz",
defaultRaw: "now()",
})
updated_at: Date
@Property({
columnType: "timestamptz",
nullable: true,
index: "IDX_refund_deleted_at",
})
deleted_at: Date | null = null
@Property({ columnType: "text", nullable: true })
created_by: string | null = null
@Property({ columnType: "jsonb", nullable: true })
metadata: Record<string, unknown> | null = null
@BeforeCreate()
onCreate() {
this.id = generateEntityId(this.id, "ref")
}
@OnInit()
onInit() {
this.id = generateEntityId(this.id, "ref")
}
}