Invoice Generation - Migz93/3dq GitHub Wiki

Invoice Generation

3DQ provides a powerful invoicing system that generates HTML invoices directly from your quotes. This guide explains how to use the invoice generation features.

Invoice Types

3DQ offers two types of invoices:

  1. Client Invoice: A customer-facing invoice showing the summary and final price. This invoice hides internal cost details and focuses on the final price the customer will pay.

  2. Internal Invoice: A detailed invoice showing all cost breakdowns and a full financial summary. This is useful for your internal records and financial analysis.

Generating Invoices

To generate an invoice from a saved quote:

  1. Navigate to the Quotes section in the sidebar
  2. Find and click on the quote you want to invoice
  3. In the quote view page, you'll find two invoice buttons:
    • Generate Client Invoice
    • Generate Internal Invoice
  4. Click the appropriate button based on your needs
  5. The invoice will open in a new browser tab as an HTML document

Invoice Features

Client Invoice

The client invoice includes:

  • Your company name and branding
  • Quote number and date
  • Customer name
  • Project title
  • Quantity of items
  • Summary of items (filament, hardware, etc.)
  • Per-unit costs (when quantity > 1)
  • Subtotal
  • Markup (not labeled as such, incorporated into the prices)
  • Discount (if applicable)
  • Tax (if configured and greater than zero)
  • Final total
  • Print/Save as PDF button (hidden when printing)

Internal Invoice

The internal invoice includes everything in the client invoice, plus:

  • Detailed cost breakdowns for each component
  • Raw material costs before markup
  • Printer depreciation costs
  • Power usage costs
  • Labor costs with time breakdowns
  • Per-unit costs and quantity multiplier effects
  • Markup percentage and amount
  • Full financial summary

Printing and Saving Invoices

Both invoice types include a "Print/Save as PDF" button that is hidden when actually printing. To save an invoice as a PDF:

  1. Generate the invoice (client or internal)
  2. Click the "Print/Save as PDF" button
  3. In the print dialog:
    • Select "Save as PDF" as the destination (or your browser's equivalent)
    • Click "Save"

The invoice is designed with print-specific CSS that ensures:

  • Proper table borders
  • Appropriate header background colors
  • No "Print/Save as PDF" button when printing
  • Proper page breaks

Customizing Invoices

The invoices automatically use your company name from the settings. To customize your invoices:

  1. Navigate to the Settings page
  2. Update your company name
  3. Set your preferred currency symbol
  4. Configure your tax rate (if applicable)
  5. Set your accent color (used in invoice headers)

Tax Calculation

If you have configured a tax rate greater than zero in the settings, the invoices will:

  1. Calculate tax based on the amount after markup and discount
  2. Display the tax amount as a separate line item
  3. Include tax in the final total

The tax calculation follows this formula:

tax_amount = (total_after_discount) * (tax_rate / 100)

Technical Implementation

The invoices are generated on the backend:

  • Route: GET /api/quotes/:id/invoice/:type
  • The backend fetches all quote data and constructs a complete HTML string with embedded CSS
  • The frontend opens this HTML in a new browser tab
⚠️ **GitHub.com Fallback** ⚠️