From 33e5b7f72fbe889e4a84e27d41ab2b0cbf013c90 Mon Sep 17 00:00:00 2001 From: fPolic Date: Tue, 16 Jan 2024 12:25:24 +0100 Subject: [PATCH] fix: Payment merge --- packages/payment/src/models/payment.ts | 36 ++++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/payment/src/models/payment.ts b/packages/payment/src/models/payment.ts index 0f1b5071a0..15b6e5185a 100644 --- a/packages/payment/src/models/payment.ts +++ b/packages/payment/src/models/payment.ts @@ -14,21 +14,17 @@ import { } from "@mikro-orm/core" import { DAL } from "@medusajs/types" -import { DALUtils, generateEntityId } from "@medusajs/utils" +import { + DALUtils, + generateEntityId, + optionalNumericSerializer, +} from "@medusajs/utils" import Refund from "./refund" import Capture from "./capture" import PaymentSession from "./payment-session" import PaymentCollection from "./payment-collection" -type OptionalPaymentProps = - | "authorized_amount" - | "cart_id" - | "order_id" - | "customer_id" - | "data" - | "captured_at" - | "canceled_at" - | DAL.SoftDeletableEntityDateColumns +type OptionalPaymentProps = DAL.EntityDateColumns @Entity({ tableName: "payment" }) @Filter(DALUtils.mikroOrmSoftDeletableFilterOptions) @@ -47,9 +43,9 @@ export default class Payment { @Property({ columnType: "numeric", nullable: true, - serializer: Number, + serializer: optionalNumericSerializer, }) - authorized_amount: number | null + authorized_amount?: number | null @Property({ columnType: "text" }) currency_code: string @@ -58,16 +54,16 @@ export default class Payment { provider_id: string @Property({ columnType: "text", nullable: true }) - cart_id: string | null + cart_id?: string | null @Property({ columnType: "text", nullable: true }) - order_id: string | null + order_id?: string | null @Property({ columnType: "text", nullable: true }) - order_edit_id: string | null + order_edit_id?: string | null @Property({ columnType: "text", nullable: true }) - customer_id: string | null + customer_id?: string | null @Property({ columnType: "jsonb", nullable: true }) data?: Record | null @@ -92,19 +88,19 @@ export default class Payment { nullable: true, index: "IDX_payment_deleted_at", }) - deleted_at: Date | null + deleted_at?: Date | null @Property({ columnType: "timestamptz", nullable: true, }) - captured_at: Date | null + captured_at?: Date | null @Property({ columnType: "timestamptz", nullable: true, }) - canceled_at: Date | null + canceled_at?: Date | null @OneToMany(() => Refund, (refund) => refund.payment, { cascade: [Cascade.REMOVE], @@ -120,7 +116,7 @@ export default class Payment { index: "IDX_payment_payment_collection_id", fieldName: "payment_collection_id", }) - payment_collection!: PaymentCollection + payment_collection: PaymentCollection @OneToOne({ owner: true, fieldName: "session_id" }) session: PaymentSession