Skip to content

Issue #38 — Backend: PDF Invoice Generation Provider #687

@yusuftomilola

Description

@yusuftomilola

Location: backend/src/invoices/providers/pdf-invoice.provider.ts

Description

Every invoice on ManageHub should be available as a downloadable PDF. This provider accepts an invoice (with its relations loaded) and returns a Buffer containing a formatted PDF document. The buffer is used in two places: as an email attachment (Issue #40) and as the response body for the download endpoint (Issue #39).

Use the pdfkit npm package (npm install pdfkit + npm install --save-dev @types/pdfkit) to generate the PDF programmatically. The document does not need to be elaborate — clean, readable, and professional is sufficient.

Acceptance Criteria

  • A PdfInvoiceProvider class is created at backend/src/invoices/providers/pdf-invoice.provider.ts
  • The provider exposes a generate(invoice: Invoice): Promise<Buffer> method where invoice has user, booking, and booking.workspace relations loaded
  • The generated PDF includes the following sections:
    • Header — ManageHub logo/name, "TAX INVOICE" title
    • Invoice metadata — Invoice number, issue date, payment date
    • Bill To — Member's full name and email address
    • Service details — Workspace name, plan type, start date, end date, number of seats
    • Amount summary — Subtotal, total amount in Naira (₦), status (PAID)
    • Footer — "Thank you for your business" or equivalent
  • The method returns a Buffer (not a stream) so it can be attached to emails and sent as an HTTP response
  • PdfInvoiceProvider is registered in InvoicesModule providers and exported
  • pdfkit is added to backend/package.json dependencies
  • npx tsc --noEmit passes with no errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions