feat: add backend migration and API for maintenance receipt linking (refs #151)

Add receipt_document_id FK on maintenance_records, update types/repo/service
to support receipt linking on create and return document metadata on GET.
Add OCR proxy endpoint POST /api/ocr/extract/maintenance-receipt with
tier gating (maintenance.receiptScan) through full chain: routes -> controller
-> service -> client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-02-12 21:24:24 -06:00
parent 90401dc1ba
commit 88d23d2745
10 changed files with 285 additions and 7 deletions

View File

@@ -30,6 +30,12 @@ export const ocrRoutes: FastifyPluginAsync = async (
handler: ctrl.extractReceipt.bind(ctrl),
});
// POST /api/ocr/extract/maintenance-receipt - Maintenance receipt OCR extraction (Pro tier required)
fastify.post('/ocr/extract/maintenance-receipt', {
preHandler: [requireAuth, requireTier('maintenance.receiptScan')],
handler: ctrl.extractMaintenanceReceipt.bind(ctrl),
});
// POST /api/ocr/extract/manual - Manual extraction (Pro tier required)
fastify.post('/ocr/extract/manual', {
preHandler: [requireAuth, fastify.requireTier({ featureKey: 'document.scanMaintenanceSchedule' })],