-- Add VAT to stock items
ALTER TABLE stock_items ADD COLUMN vat_rate DECIMAL(5,2) DEFAULT 0.00;

-- Add VAT details to invoices
ALTER TABLE invoices ADD COLUMN vat_amount DECIMAL(15,2) DEFAULT 0.00;
ALTER TABLE invoices ADD COLUMN total_with_vat DECIMAL(15,2) DEFAULT 0.00;

-- Create settings table for company profile
CREATE TABLE IF NOT EXISTS settings (
    `key` VARCHAR(50) PRIMARY KEY,
    `value` TEXT,
    `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Seed initial company profile
INSERT INTO settings (`key`, `value`) VALUES 
('company_name', 'My Tech Company'),
('company_logo', ''),
('vat_number', ''),
('cr_number', ''),
('company_address', ''),
('company_phone', ''),
('vat_enabled', '1'),
('default_vat_rate', '15.00')
ON DUPLICATE KEY UPDATE `key`=`key`;
