feat(pipeline): 9→7 stage refactor + v1.1 hardening wave
Replaces the legacy 9-stage pipeline with 7 canonical stages
(enquiry → qualified → eoi → reservation → deposit_paid → contract →
nurturing) plus three doc sub-status columns (eoi_doc_status,
reservation_doc_status, contract_doc_status) that track sent/signed
within a single stage instead of branching it.
Schema (migration 0062):
- interests gains assigned_to, deposit_expected_amount/currency,
three doc-status columns, two documenso-id columns, and
date_reservation_signed.
- New tables: qualification_criteria (per-port admin-configurable),
interest_qualifications (per-interest state), payments (deposit /
balance / refund records keyed to interest + client).
- Default qualification criteria seeded for every existing port.
- Dummy-data UPDATEs collapse Sent/Signed pairs and 'completed' into
the new stage + doc-status + outcome shape.
Migration 0063 adds interest_contact_log.voice_transcript and
template_used columns for v1.1-A/B (quick-template buttons + voice
transcription via Web Speech API).
v1.1 phase work bundled here:
- A/B: Quick-template buttons (Call / Visit / Email) + mic toggle on
the contact-log compose dialog (useVoiceTranscription hook).
- C: berth-rules-engine wraps state writes in pg_advisory_xact_lock
with an idempotent re-read; emits rule_evaluated audit traces.
- D: Documenso webhook: reservation/contract sub-status stamping
moved out of the PDF-download try-block so a download failure
no longer swallows the stamp. New integration test coverage.
- E: /admin/qualification-criteria CRUD page + admin component.
- F: default_new_interest_owner exposed in System Settings.
- G: recentActivityCount + active_engagement deal-pulse signal
surfaced as a chip on interests + hot-deals card.
- H: interest_assigned notification on assignedTo change (skips
self-assign, uses a dedupe key).
Plus the supporting components: AssignedToChip, DealPulseChip,
PaymentsSection, QualificationChecklist, MultiEoiChip,
SkipAheadBanner, WonStatusPanel, InterestBerthStatusBanner,
SupplementalInfoRequestButton, UserPicker.
Tests: 1370/1370 vitest pass (added deal-health unit suite +
expanded constants/validators/pipeline-transitions coverage). tsc
clean, eslint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,59 +1,66 @@
|
||||
import type { FilterDefinition } from '@/components/shared/filter-bar';
|
||||
import { EXPENSE_CATEGORIES, formatEnum } from '@/lib/constants';
|
||||
|
||||
export const expenseFilterDefinitions: FilterDefinition[] = [
|
||||
{
|
||||
key: 'search',
|
||||
label: 'Search',
|
||||
type: 'text',
|
||||
placeholder: 'Search by establishment or description...',
|
||||
},
|
||||
{
|
||||
key: 'category',
|
||||
label: 'Category',
|
||||
type: 'multi-select',
|
||||
options: EXPENSE_CATEGORIES.map((c) => ({
|
||||
label: formatEnum(c),
|
||||
value: c,
|
||||
})),
|
||||
},
|
||||
{
|
||||
key: 'paymentStatus',
|
||||
label: 'Payment Status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: 'Unpaid', value: 'unpaid' },
|
||||
{ label: 'Paid', value: 'paid' },
|
||||
{ label: 'Partial', value: 'partial' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'dateFrom',
|
||||
label: 'Date From',
|
||||
type: 'text',
|
||||
placeholder: 'YYYY-MM-DD',
|
||||
},
|
||||
{
|
||||
key: 'dateTo',
|
||||
label: 'Date To',
|
||||
type: 'text',
|
||||
placeholder: 'YYYY-MM-DD',
|
||||
},
|
||||
{
|
||||
key: 'currency',
|
||||
label: 'Currency',
|
||||
type: 'text',
|
||||
placeholder: 'e.g. USD, EUR',
|
||||
},
|
||||
{
|
||||
key: 'tripLabel',
|
||||
label: 'Trip / event',
|
||||
type: 'text',
|
||||
placeholder: 'e.g. Palm Beach 2026',
|
||||
},
|
||||
{
|
||||
key: 'includeArchived',
|
||||
label: 'Include Archived',
|
||||
type: 'boolean',
|
||||
},
|
||||
];
|
||||
/**
|
||||
* Build the filter-bar definitions. Categories accept the resolved
|
||||
* per-port vocabulary list when callers can fetch it; otherwise the
|
||||
* shipped defaults are used. Kept as a function so the page can read
|
||||
* `/api/v1/vocabularies` on mount and reactively rebuild.
|
||||
*/
|
||||
export function buildExpenseFilterDefinitions(
|
||||
categories: readonly string[] = EXPENSE_CATEGORIES,
|
||||
): FilterDefinition[] {
|
||||
return [
|
||||
{
|
||||
key: 'search',
|
||||
label: 'Search',
|
||||
type: 'text',
|
||||
placeholder: 'Search by establishment or description...',
|
||||
},
|
||||
{
|
||||
key: 'category',
|
||||
label: 'Category',
|
||||
type: 'multi-select',
|
||||
options: categories.map((c) => ({ label: formatEnum(c), value: c })),
|
||||
},
|
||||
{
|
||||
key: 'paymentStatus',
|
||||
label: 'Payment Status',
|
||||
type: 'select',
|
||||
options: [
|
||||
{ label: 'Unpaid', value: 'unpaid' },
|
||||
{ label: 'Paid', value: 'paid' },
|
||||
{ label: 'Partial', value: 'partial' },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'dateFrom',
|
||||
label: 'Date From',
|
||||
type: 'date',
|
||||
},
|
||||
{
|
||||
key: 'dateTo',
|
||||
label: 'Date To',
|
||||
type: 'date',
|
||||
},
|
||||
{
|
||||
key: 'currency',
|
||||
label: 'Currency',
|
||||
type: 'currency',
|
||||
},
|
||||
{
|
||||
key: 'tripLabel',
|
||||
label: 'Trip / event',
|
||||
type: 'text',
|
||||
placeholder: 'e.g. Palm Beach 2026',
|
||||
},
|
||||
{
|
||||
key: 'includeArchived',
|
||||
label: 'Include Archived',
|
||||
type: 'boolean',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** Default list used by SSR / non-vocab-aware consumers. */
|
||||
export const expenseFilterDefinitions: FilterDefinition[] = buildExpenseFilterDefinitions();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { AlertTriangle, Loader2, Upload, X } from 'lucide-react';
|
||||
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -22,6 +22,7 @@ import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetFooter } from '@/com
|
||||
import { CurrencyInput } from '@/components/shared/currency-input';
|
||||
import { CurrencySelect } from '@/components/shared/currency-select';
|
||||
import { TripLabelCombobox } from '@/components/expenses/trip-label-combobox';
|
||||
import { UserPicker } from '@/components/shared/user-picker';
|
||||
import { apiFetch } from '@/lib/api/client';
|
||||
import type { z } from 'zod';
|
||||
import { createExpenseSchema, type CreateExpenseInput } from '@/lib/validators/expenses';
|
||||
@@ -42,6 +43,17 @@ interface ExpenseFormDialogProps {
|
||||
export function ExpenseFormDialog({ open, onOpenChange, expense }: ExpenseFormDialogProps) {
|
||||
const queryClient = useQueryClient();
|
||||
const isEdit = !!expense;
|
||||
|
||||
// Per-port vocabulary override for expense categories. Falls back to
|
||||
// the shipped EXPENSE_CATEGORIES constant when /api/v1/vocabularies
|
||||
// hasn't loaded yet or returns malformed data — keeps the picker
|
||||
// populated during the first render.
|
||||
const { data: vocab } = useQuery<{ data: Record<string, readonly string[]> }>({
|
||||
queryKey: ['vocabularies'],
|
||||
queryFn: () => apiFetch('/api/v1/vocabularies'),
|
||||
staleTime: 5 * 60_000,
|
||||
});
|
||||
const categoryList = vocab?.data?.expense_categories ?? EXPENSE_CATEGORIES;
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [uploadedReceipt, setUploadedReceipt] = useState<UploadedReceipt | null>(null);
|
||||
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
||||
@@ -253,7 +265,7 @@ export function ExpenseFormDialog({ open, onOpenChange, expense }: ExpenseFormDi
|
||||
<SelectValue placeholder="Select category" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{EXPENSE_CATEGORIES.map((cat) => (
|
||||
{categoryList.map((cat) => (
|
||||
<SelectItem key={cat} value={cat}>
|
||||
{formatEnum(cat)}
|
||||
</SelectItem>
|
||||
@@ -285,7 +297,14 @@ export function ExpenseFormDialog({ open, onOpenChange, expense }: ExpenseFormDi
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="payer">Payer</Label>
|
||||
<Input id="payer" placeholder="Who paid?" {...register('payer')} />
|
||||
<UserPicker
|
||||
value={(watch('payer') as string | undefined) ?? null}
|
||||
onChange={(v) => setValue('payer', v ?? '', { shouldDirty: true })}
|
||||
placeholder="Who paid?"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Pick a teammate or choose “Other…” to type any name.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
|
||||
Reference in New Issue
Block a user