Quotes

Financial quotes for renovation work — unified lifecycle entity covering pre-win vendor cost quotes and post-win execution. Quotes track line items and funding allocations, and are the R1 mirror of the HubSpot Quote object (0-14) — not Deals (HubSpot Deal = R1 Project).

Pivot (2026-05): post-win execution no longer lives on quote-owned phase tables (quote_phases/quote_phase_tasks are gone). Won quotes hand over to workflow packages (workflow_packages.sourceQuoteId) — see Workflows and the contractor-engagement rebuild (spec 2026-05-09-contractor-engagement-rebuild-design.md, handover redesign 2026-05-29-workflow-package-handover-redesign-design.md).

Source Files

LayerPath
Schemabackend/src/db/schema.ts
Routesbackend/src/routes/quotes.ts, backend/src/routes/workflow/quotes.ts
Servicebackend/src/services/quote-service.ts, backend/src/services/quote-finance-service.ts
Sync Configbackend/src/services/hubspot/sync-engine/entity-configs.ts (quoteConfig)
Pagesfrontend/src/pages/Quotes.tsx
Componentsfrontend/src/components/quotes/
Queriesfrontend/src/lib/queries/quoteQueries.ts

Database Tables

TablePurpose
quotesMain entity — project, contact, amounts, status, HubSpot sync, billing aggregates
quote_line_itemsIndividual cost items with quantities, unit prices, component type, productId FK to Products
quote_skill_assignmentsSkill/trade assignments for quote execution
quote_ab_snapshotsA/B comparison snapshots for quote versioning
quote_department_responsibilitiesDepartment responsibility assignments per quote
quote_line_item_funding_measuresLinks line items to Funding Applications measures
quote_line_item_funding_loansLinks line items to funding loans
component_quote_linksLinks Building Components to quote line items
funding_quote_allocationsDistributes funding across quotes (with approval workflow)

Key Fields

FieldTypeNotes
projectIduuid FKParent project (cascade delete)
buildingIduuid FKParent building
contactIduuid FKVendor/supplier contact
statusenumdraft, sent, declined, accepted, in_progress, completed, cancelled, submitted, under_review, approved, rejected, expired, awarded, superseded
totalAmount / netAmount / taxAmountdecimal(12,2)Money: decimal strings + Big.js via @shared/money (spec 2026-04-24-money-arithmetic-bigjs-design.md)
taxRatedecimalDefault 0.19 (German VAT)
discountPercentage, skontoPercentagedecimalDiscount and early-payment terms
templateId / templateVersionuuid FK / intWorkflows template binding for the post-win lifecycle
replacesQuoteIduuid FKSelf-referential for quote replacement/versioning
contractValue / billedTotal / paidTotal / openTotalintegerDenormalized billing aggregates (maintained by lib/billing/billing-aggregates)
hubspotIdvarcharHubSpot vendor ID — sync round-tripping only
recordOwnerContactIduuid FKRead-only HubSpot owner mirror → Contacts; sync layer is sole writer

HubSpot Sync

quoteConfig mirrors the HubSpot Quote object (0-14). projectId/buildingId/contactId are association-only columns: the sync’s pre-sync hook resolves them from the quote’s associated Deal/Contact, so the FK relationships come from HubSpot associations, not properties. Internal references always join on quotes.id (UUID PK), never hubspotId.

Quote Change Flows

Replacing an accepted quote (Angebotsänderung) is first-class (spec 2026-05-12-quote-change-rebuild-design.md):

  • The new quote points at its predecessor via replacesQuoteId; the old quote moves to superseded.
  • The affected workflow package re-points and bumps its version; the diff is journaled in scope_change_log (triggerQuoteId, previousQuoteId, typed ScopeDiff with work-done warnings) — see Workflows.

Relationships

Quote *──1 Project
Quote *──1 Building
Quote *──1 Contact (vendor)
Quote 1──* Quote Line Items ──1 Product (optional)
Quote 1──* Quote Skill Assignments / A/B Snapshots / Department Responsibilities
Quote Line Items *──* Building Components (via component_quote_links)
Quote *──* Funding Applications (via funding_quote_allocations)
Quote 1──* Invoices (captured contractor invoices, optional source link)
Quote 1──* Workflow Packages (sourceQuoteId — post-win execution)
Quote ──> replacesQuoteId (self, quote change)

Frontend Components

ComponentPurpose
QuoteFormCreate/edit quote with financial details
QuoteLineItemsTableManage individual line items
QuotesListList view with filtering and sorting
BuildingQuotesListQuotes scoped to a building
InlineQuotesTable / InlineQuoteRowCompact inline display within other views
LinkFundingApplicationsDialogLink quotes to Funding Applications
CreateQuoteWithProjectDialogQuick-create quote with project selection

Features

  • Line items management with quantities, unit prices, component type mapping, and Products references
  • Funding allocation linking line items to Funding Applications measures and loans
  • Component linking connecting quote line items to Building Components
  • A/B snapshots for comparing quote versions side-by-side
  • Skill assignments tracking which trades/skills are needed for execution
  • Post-win handover to workflow packages (one package per won quote)
  • Quote change with supersession + scope-change journaling
  • Skonto/discount terms with deadlines (German early-payment convention)
  • Billing aggregates denormalized from the billing module (Invoices)

Projects | Buildings | Invoices | Funding Applications | Building Components | Products | Contacts | Workflows | Financial Calculations | HubSpot Integration | Database Architecture