Skip to content

Replace any types in API route formatInvoice/formatQuote with Prisma types #66

Description

@aruneshwisdm

Summary

The API route handlers for invoices and quotes use `any` for the `formatInvoice` and `formatQuote` helper functions, as well as for line item mapping. These should use proper Prisma-generated types.

Current code

In `apps/web/app/api/v1/invoices/from-quote/[quoteId]/route.ts` (line 12):
```typescript
function formatInvoice(inv: any) {
```

In `apps/web/app/api/v1/quotes/[id]/route.ts` (line 11):
```typescript
function formatQuote(q: Record<string, any>) {
```

In `apps/web/app/api/v1/invoices/[id]/route.ts` (line 11):
```typescript
function formatInvoice(inv: Record<string, any>) {
```

Line items in all three files also use `(li: any)`.

What to do

  1. Import the relevant Prisma types (e.g., `Invoice`, `Quote`, `InvoiceLineItem`, `QuoteLineItem`) from `@quotecraft/database`
  2. Use Prisma's generated types with the `include` relations (e.g., `Prisma.InvoiceGetPayload<{ include: { client: true; lineItems: true } }>`)
  3. Replace the `any` casts on line item maps

Files

  • `apps/web/app/api/v1/invoices/[id]/route.ts`
  • `apps/web/app/api/v1/invoices/from-quote/[quoteId]/route.ts`
  • `apps/web/app/api/v1/quotes/[id]/route.ts`

Acceptance criteria

  • All three `format*` functions use proper Prisma types instead of `any`
  • Line item `.map((li: any) => ...)` calls use proper types
  • All `eslint-disable @typescript-eslint/no-explicit-any` comments are removed
  • Build passes with `pnpm build`

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions