Invoices

Captured contractor invoices — third-party invoices issued by contractors (typically to the customer) that RENEWA records as (1) evidence that a funded measure was delivered (ZUE / funding pass-through to BAFA/KfW) and (2) the basis for the commission RENEWA earns from the contractor. RENEWA does not owe money on these invoices.

Pivot (2026-04): invoices was deliberately kept separate from billing_invoices (RENEWA-issued invoices: customer invoices for EB/KOP deals, commission invoices). Unification was rejected — different ledgers, lifecycles, and GoBD scope; project-overview unification is a query-projection concern. See spec 2026-04-28-invoices-incoming-outgoing-separation-design.md and the billing module introduced in PR#1397. The German terms Eingangs-/Ausgangsrechnung are intentionally avoided: captured invoices are not RENEWA payables.

Source Files

LayerPath
Schemabackend/src/db/schema.ts
Routesbackend/src/routes/invoices.ts
Servicebackend/src/services/invoice-service.ts
Componentsfrontend/src/components/invoices/ (~16 files)
Queriesfrontend/src/lib/queries/invoiceQueries.ts

The RENEWA-issued side lives in the billing module: billing_invoices + ~25 satellite tables (billing_*), backend/src/routes/billing*.ts, backend/src/services/billing/.

Database Tables

TablePurpose
invoicesMain entity — project, contractor contact, amounts, payment status, dates
invoice_line_itemsIndividual billed items with description, quantity, price, component type
invoice_line_item_funding_measuresLinks line items to Funding Applications measures (BAFA/KfW pass-through)
invoice_line_item_funding_loansLinks line items to funding loans
component_invoice_linksLinks Building Components to invoice line items
funding_invoice_allocationsDistributes funding across invoices (with approval workflow)

Key Fields

FieldTypeNotes
projectIduuid FKParent project (cascade delete)
contactIduuid FKContractor contact who issued the invoice (required)
quoteIduuid FKSource quote (optional, set null on delete)
invoiceNumbervarcharInvoice identifier
totalAmount / netAmount / taxAmountdecimal(12,2)Financial totals
taxRatedecimalDefault 0.19 (German VAT)
paymentStatusenumunpaid, pending, partially_paid, paid, overdue, cancelled
paidAmount / outstandingAmountdecimalPayment tracking
discountPercentage, skontoPercentagedecimalDiscount and early-payment terms
customerPaymentConfirmationbooleanWhether customer confirmed payment

Money Handling (MANDATORY)

decimal(p,s) columns leave Drizzle as strings and stay decimal strings on the wire (never number in DTOs). Parse with fromString(...) from @shared/money, compute via Big.js (add/sub/mul/div, round(m, 2) HALF_UP), stringify back. Never Number()/parseFloat() or native arithmetic on money columns — enforced by ESLint renewa-local/no-number-on-money + quick-lint.sh. Spec: 2026-04-24-money-arithmetic-bigjs-design.md.

Relationships

Invoice *──1 Project
Invoice *──1 Contact (contractor / issuer)
Invoice *──1 Quote (source, optional)
Invoice 1──* Invoice Line Items
Invoice Line Items *──* Building Components (via component_invoice_links)
Invoice *──* Funding Applications (via funding_invoice_allocations)

Frontend Components

ComponentPurpose
InvoiceFormCreate/edit invoice with financial details
InvoiceLineItemsTableManage individual line items
InvoicesListList view with filtering and sorting
BuildingInvoicesListInvoices scoped to a building
InlineInvoicesTable / InlineInvoiceRow / InlineInvoiceExpandedRowCompact inline display
LinkFundingApplicationsDialogLink invoices to Funding Applications
CreateInvoiceWithProjectDialogQuick-create with project selection
InvoiceFileManager / InvoiceFileDropzone / InvoiceFileUploadAttach Files to invoices
InvoiceAuditLogDialogView Audit Logs for an invoice

Features

  • Evidence + commission basis — captured amounts feed project settlement and RENEWA’s commission calculation
  • Payment tracking with status lifecycle (unpaid partially_paid paid)
  • Funding allocation linking line items to Funding Applications measures and loans
  • Component linking connecting invoice line items to Building Components
  • File management via CAS Files (entity file links)
  • Audit trail via Audit Logs dialog for tracking changes
  • Skonto/discount terms with deadlines (German early-payment convention)
  • Financial overview aggregated on Buildings detail page; quote billing aggregates (contractValue, billedTotal, paidTotal, openTotal) are denormalized onto Quotes

Quotes | Projects | Buildings | Funding Applications | Building Components | Products | Contacts | Files | Financial Calculations | Audit Logs | Database Architecture