Update: 2026-05-15 04:41:45
This commit is contained in:
@@ -5,20 +5,20 @@
|
||||
|
||||
-- Add tax_amount column (calculated from tax_rate × line_total)
|
||||
ALTER TABLE invoice_lines
|
||||
ADD COLUMN IF NOT EXISTS tax_amount DECIMAL(12,3) DEFAULT 0 AFTER tax_rate;
|
||||
ADD COLUMN tax_amount DECIMAL(12,3) DEFAULT 0 AFTER tax_rate;
|
||||
|
||||
-- Add discount_amount column
|
||||
ALTER TABLE invoice_lines
|
||||
ADD COLUMN IF NOT EXISTS discount_amount DECIMAL(12,3) DEFAULT 0 AFTER tax_amount;
|
||||
ADD COLUMN discount_amount DECIMAL(12,3) DEFAULT 0 AFTER tax_amount;
|
||||
|
||||
-- Add net_total column (subtotal + tax - discount)
|
||||
ALTER TABLE invoice_lines
|
||||
ADD COLUMN IF NOT EXISTS net_total DECIMAL(12,3) DEFAULT 0 AFTER discount_amount;
|
||||
ADD COLUMN net_total DECIMAL(12,3) DEFAULT 0 AFTER discount_amount;
|
||||
|
||||
-- Add tax_category for classification
|
||||
-- standard = 16%, zero_rated = 0%, exempt = no tax, special = variable rate
|
||||
ALTER TABLE invoice_lines
|
||||
ADD COLUMN IF NOT EXISTS tax_category VARCHAR(20) DEFAULT 'standard' AFTER net_total;
|
||||
ADD COLUMN tax_category VARCHAR(20) DEFAULT 'standard' AFTER net_total;
|
||||
|
||||
-- Backfill existing data: calculate tax_amount from line_total * tax_rate
|
||||
UPDATE invoice_lines
|
||||
|
||||
Reference in New Issue
Block a user