feat(payment): PaymentCollection CRUD (#6124)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
export const defaultPaymentCollectionData = [
|
||||
{
|
||||
id: "pay-col-id-1",
|
||||
amount: 100,
|
||||
region_id: "region-id-1",
|
||||
currency_code: "usd",
|
||||
},
|
||||
{
|
||||
id: "pay-col-id-2",
|
||||
amount: 200,
|
||||
region_id: "region-id-1",
|
||||
currency_code: "usd",
|
||||
},
|
||||
{
|
||||
id: "pay-col-id-3",
|
||||
amount: 300,
|
||||
region_id: "region-id-2",
|
||||
currency_code: "usd",
|
||||
},
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
import { CreatePaymentCollectionDTO } from "@medusajs/types"
|
||||
import { SqlEntityManager } from "@mikro-orm/postgresql"
|
||||
|
||||
import { PaymentCollection } from "../../../src/models"
|
||||
import { defaultPaymentCollectionData } from "./data"
|
||||
|
||||
export * from "./data"
|
||||
|
||||
export async function createPaymentCollections(
|
||||
manager: SqlEntityManager,
|
||||
paymentCollectionData: CreatePaymentCollectionDTO[] = defaultPaymentCollectionData
|
||||
): Promise<PaymentCollection[]> {
|
||||
const collections: PaymentCollection[] = []
|
||||
|
||||
for (let data of paymentCollectionData) {
|
||||
let collection = manager.create(PaymentCollection, data)
|
||||
|
||||
await manager.persistAndFlush(collection)
|
||||
}
|
||||
|
||||
return collections
|
||||
}
|
||||
Reference in New Issue
Block a user