-- Fix sales records with NULL or zero subtotal for Product Sales Report
-- This migration updates subtotal for existing sales that were created without it

UPDATE sales 
SET subtotal = total - tax_amount - shipping_amount + discount_amount
WHERE subtotal IS NULL OR subtotal = 0;
