-- VAT system migration
-- Add vat column to orders
ALTER TABLE orders ADD COLUMN vat DECIMAL(10, 3) DEFAULT 0.000 AFTER discount;

-- Update order_type ENUM to include takeaway
ALTER TABLE orders MODIFY COLUMN order_type ENUM('dine-in', 'delivery', 'drive-thru', 'takeaway') DEFAULT 'takeaway';

-- Add vat_percent to products
ALTER TABLE products ADD COLUMN vat_percent DECIMAL(5, 2) DEFAULT 0.00 AFTER price;

-- Add stock_quantity and promo fields to products
ALTER TABLE products ADD COLUMN stock_quantity INT DEFAULT 0;
ALTER TABLE products ADD COLUMN promo_discount_percent DECIMAL(5, 2) DEFAULT 0.00;
ALTER TABLE products ADD COLUMN promo_date_from DATE DEFAULT NULL;
ALTER TABLE products ADD COLUMN promo_date_to DATE DEFAULT NULL;

-- Add vat fields to order_items
ALTER TABLE order_items ADD COLUMN vat_percent DECIMAL(5, 2) DEFAULT 0.00 AFTER unit_price;
ALTER TABLE order_items ADD COLUMN vat_amount DECIMAL(10, 3) DEFAULT 0.000 AFTER vat_percent;

-- Add vat_number to company_settings
ALTER TABLE company_settings ADD COLUMN vat_number VARCHAR(50) DEFAULT NULL;