Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
aae80ec936
commit
269c71a74c
@@ -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;
|
||||
Reference in New Issue
Block a user