feat(payment): PaymentCollection CRUD (#6124)

This commit is contained in:
Frane Polić
2024-01-22 11:04:46 +01:00
committed by GitHub
parent 3f41d818b6
commit d47e946496
11 changed files with 606 additions and 10 deletions
@@ -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
}