feat(billing): partner payout-ledger generation (worker + operator trigger)
Add BillingService.generatePayouts: idempotent per-partner/month/currency snapshot of gross MRR x marginPct into Payout rows (never rewrites a paid row), plus platformPayouts(). A PayoutWorker generates the current month daily (and on boot; PAYOUTS_AUTOGEN=false to disable). Operator endpoints GET /billing/payouts + POST /billing/payouts/generate, an operator payouts ledger table with a Generate button, and the proxy routes. The partner Payouts tab now shows real data.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import { platformApi } from '~~/server/utils/platform-api'
|
||||
|
||||
// Platform-wide partner-payout ledger. Operator-only.
|
||||
export default defineEventHandler(async (event) => platformApi(event, '/billing/payouts'))
|
||||
@@ -0,0 +1,8 @@
|
||||
import { platformApi } from '~~/server/utils/platform-api'
|
||||
|
||||
// Force a payout-ledger generation run. Optional ?period=YYYY-MM. Operator-only.
|
||||
export default defineEventHandler(async (event) => {
|
||||
const period = getQuery(event).period
|
||||
const qs = period ? `?period=${encodeURIComponent(String(period))}` : ''
|
||||
return platformApi(event, `/billing/payouts/generate${qs}`, { method: 'POST' })
|
||||
})
|
||||
Reference in New Issue
Block a user