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
@@ -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;