bmc_hub/migrations/1054_customer_invoice_fee.sql
Christian 4871dd2d9e Add comprehensive test coverage for various modules
- Introduced tests for mail templates including ranking, rendering, and attachment handling.
- Added tests for time billing selection and approval processes, ensuring proper validation and state management.
- Implemented tests for case types in JavaScript, focusing on loading and editing functionality.
- Created tests for contact mail AI integration, ensuring proper parsing and error handling.
- Developed tests for dark theme CSS contrast and loading order.
- Added tests for invoice fee service, covering various scenarios including exemptions and invalid inputs.
- Implemented vendor resource tests, ensuring proper file handling and query validation.
2026-10-08 08:58:02 +02:00

18 lines
1.1 KiB
SQL

-- Only customer defaults change; existing order/facture lines are untouched.
-- 49.00 was the legacy default, not a stored indication of a negotiated price.
ALTER TABLE customers ADD COLUMN IF NOT EXISTS invoice_fee_exempt BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE customers ALTER COLUMN invoice_fee_amount DROP NOT NULL;
ALTER TABLE customers ALTER COLUMN invoice_fee_amount DROP DEFAULT;
-- One-time conversion, guarded against reruns by the setting row.
DO $$ BEGIN
IF NOT EXISTS (SELECT 1 FROM settings WHERE key = 'invoice_fee_product_id') THEN
UPDATE customers SET invoice_fee_exempt = TRUE WHERE invoice_fee_amount = 0;
UPDATE customers SET invoice_fee_amount = NULL WHERE invoice_fee_amount = 49.00;
END IF;
END $$;
INSERT INTO settings (key, value, category, description, value_type, is_public)
VALUES ('invoice_fee_product_id', '', 'system', 'Standardvare til faktureringsgebyr', 'string', TRUE)
ON CONFLICT (key) DO NOTHING;
ALTER TABLE tmodule_order_lines ADD COLUMN IF NOT EXISTS source_type TEXT;
ALTER TABLE tmodule_order_lines ADD COLUMN IF NOT EXISTS product_id INTEGER REFERENCES products(id);