
INSERT INTO mod_maintenance_technical_offers 
(customer_id, offer_number, status, contract_type, visit_count, visit_frequency, execution_time, execution_time_unit, description, created_by, created_at, updated_at)
VALUES 
(1, 'TO-2026-00001', 'approved', '[\"annual\"]', 12, 'monthly', 1, 'year', 'Test annual maintenance', 1, NOW(), NOW()),
(1, 'TO-2026-00002', 'pending_pricing', '[\"quarterly\"]', 4, 'quarterly', 6, 'month', 'Test quarterly maintenance', 1, NOW(), NOW());

INSERT INTO mod_maintenance_price_offers
(technical_offer_id, customer_id, offer_number, visit_cost, discount_percentage, spare_parts_policy, subtotal, tax_percentage, tax_amount, total, offer_validity_date, payment_method, status, version_number, is_latest_version, created_by, created_at, updated_at)
VALUES
(1, 1, 'PO-2026-00001', 500.00, 0.00, 'Client pays', 6000.00, 15.00, 900.00, 6900.00, '2026-03-31', 'Bank transfer', 'pending_pricing', 1, 0, 1, NOW(), NOW()),
(1, 1, 'PO-2026-00002', 450.00, 10.00, 'Included in contract', 5400.00, 15.00, 810.00, 6210.00, '2026-04-30', 'Deferred', 'pending_customer_approval', 1, 1, 1, NOW(), NOW()),
(1, 1, 'PO-2026-00001-V2', 550.00, 5.00, 'Client pays', 6600.00, 15.00, 990.00, 7590.00, '2026-03-31', 'Bank transfer', 'pending_pricing', 2, 1, 1, NOW(), NOW());

UPDATE mod_maintenance_price_offers SET parent_offer_id = (SELECT id FROM (SELECT id FROM mod_maintenance_price_offers WHERE offer_number = 'PO-2026-00001') AS t) WHERE offer_number = 'PO-2026-00001-V2';

SELECT id, offer_number, status, version_number, is_latest_version, parent_offer_id FROM mod_maintenance_price_offers;
SELECT id, offer_number, status FROM mod_maintenance_technical_offers;
