From 269c71a74c507df000e396e1f52aa2c7a059bb09 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 25 Apr 2026 18:50:57 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/integrations/supabase/types.ts | 6 ++++++ ...425185053_96ee636e-66fc-4cd1-98ec-a96801a73c96.sql | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 supabase/migrations/20260425185053_96ee636e-66fc-4cd1-98ec-a96801a73c96.sql diff --git a/src/integrations/supabase/types.ts b/src/integrations/supabase/types.ts index c8784fe..c52fcac 100644 --- a/src/integrations/supabase/types.ts +++ b/src/integrations/supabase/types.ts @@ -1652,7 +1652,9 @@ export type Database = { external_id: string | null id: string invoice_id: string | null + quantity: number receipt_storage_path: string | null + unit_price: number updated_at: string user_id: string } @@ -1667,7 +1669,9 @@ export type Database = { external_id?: string | null id?: string invoice_id?: string | null + quantity?: number receipt_storage_path?: string | null + unit_price?: number updated_at?: string user_id: string } @@ -1682,7 +1686,9 @@ export type Database = { external_id?: string | null id?: string invoice_id?: string | null + quantity?: number receipt_storage_path?: string | null + unit_price?: number updated_at?: string user_id?: string } diff --git a/supabase/migrations/20260425185053_96ee636e-66fc-4cd1-98ec-a96801a73c96.sql b/supabase/migrations/20260425185053_96ee636e-66fc-4cd1-98ec-a96801a73c96.sql new file mode 100644 index 0000000..7e3097d --- /dev/null +++ b/supabase/migrations/20260425185053_96ee636e-66fc-4cd1-98ec-a96801a73c96.sql @@ -0,0 +1,11 @@ +-- Add quantity and unit_price columns to expenses for itemized billing. +-- amount remains the stored total = quantity * unit_price for backwards +-- compatibility with reports, invoices, and trust accounting. +ALTER TABLE public.expenses + ADD COLUMN IF NOT EXISTS quantity numeric NOT NULL DEFAULT 1, + ADD COLUMN IF NOT EXISTS unit_price numeric NOT NULL DEFAULT 0; + +-- Backfill: for existing rows, set unit_price = amount and quantity = 1. +UPDATE public.expenses + SET unit_price = amount, quantity = 1 + WHERE unit_price = 0 AND amount IS NOT NULL; \ No newline at end of file