Remove influencer-era documentation, unused components, boilerplate assets, and ghost tiktok cron job. Add supplier invoice management, document API routes, and PWA icons. Replace boilerplate README. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
938 B
TypeScript
33 lines
938 B
TypeScript
import { createClient } from '@/lib/supabase/server'
|
|
import { NextResponse } from 'next/server'
|
|
import { generateSupplierLedger } from '@/lib/reports/supplier-ledger'
|
|
import { generateReconciliation } from '@/lib/reports/supplier-reconciliation'
|
|
|
|
export async function GET(request: Request) {
|
|
const supabase = await createClient()
|
|
|
|
const { data: { user } } = await supabase.auth.getUser()
|
|
|
|
if (!user) {
|
|
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
|
|
}
|
|
|
|
const { searchParams } = new URL(request.url)
|
|
const asOfDate = searchParams.get('as_of_date') || undefined
|
|
const periodId = searchParams.get('period_id') || undefined
|
|
|
|
const ledger = await generateSupplierLedger(user.id, asOfDate)
|
|
|
|
let reconciliation = null
|
|
if (periodId) {
|
|
reconciliation = await generateReconciliation(user.id, periodId)
|
|
}
|
|
|
|
return NextResponse.json({
|
|
data: {
|
|
ledger,
|
|
reconciliation,
|
|
},
|
|
})
|
|
}
|