Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-25 18:50:57 +00:00
co-authored by renee-png
parent aae80ec936
commit 269c71a74c
2 changed files with 17 additions and 0 deletions
+6
View File
@@ -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
}
@@ -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;