refactor: Replace hardcoded billing data seeding with plugin-configurable collection overrides

- Remove `seedBillingData` function for sample data creation
- Update refunds, invoices, and payments collections to use pluginConfig for dynamic overrides
- Introduce utility functions like `extractSlug` for customizable collection slugs
- Streamline customer relation and data extractor logic across collections
This commit is contained in:
2025-09-16 00:06:18 +02:00
parent f17b4c064e
commit 0308e30ebd
10 changed files with 515 additions and 580 deletions

View File

@@ -1,6 +1,11 @@
import { CollectionConfig } from 'payload'
import { FieldsOverride } from '@/plugin/utils'
export const defaults = {
paymentsCollection: 'payments'
paymentsCollection: 'payments',
invoicesCollection: 'invoices',
refundsCollection: 'refunds',
customerRelationSlug: 'customer'
}
// Provider configurations
@@ -51,13 +56,12 @@ export interface BillingPluginConfig {
dashboard?: boolean
}
collections?: {
customerRelation?: boolean | string // false to disable, string for custom collection slug
customers?: string
invoices?: string
payments?: string
refunds?: string
invoices?: string | (Partial<CollectionConfig> & {fields?: FieldsOverride})
payments?: string | (Partial<CollectionConfig> & {fields?: FieldsOverride})
refunds?: string | (Partial<CollectionConfig> & {fields?: FieldsOverride})
}
customerInfoExtractor?: CustomerInfoExtractor // Callback to extract customer info from relationship
customerRelationSlug?: string // Customer collection slug for relationship
disabled?: boolean
providers?: {
mollie?: MollieConfig