-- contains two property sets, one valid and one expired
-- Differences between both sets:
-- US SAFETY_STOCK 60 -> 55
-- TRUCK_UTIL 0.8 -> 0.7


-- Set a variable to ensure consistent timestamp across both inserts
SET @current_time = DATE_SUB(NOW(), INTERVAL 1 DAY);

-- Insert an expired property_set starting 1 year ago and ending at current_time
INSERT INTO `property_set` (`start_date`, `end_date`, `state`)
VALUES (DATE_SUB(@current_time, INTERVAL 1 YEAR), @current_time, 'EXPIRED');

-- Insert a valid property_set starting at the same current_time with open end (null)
INSERT INTO `property_set` (`start_date`, `end_date`, `state`)
VALUES (@current_time, NULL, 'VALID');




INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Annual working days', 'WORKDAYS', 'INT', '{"GT": 0, "LT": 366}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Interest rate inventory [%]', 'INTEREST_RATE', 'PERCENTAGE', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'FCA fee [%]', 'FCA_FEE', 'PERCENTAGE', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Default customs duty [%]', 'TARIFF_RATE', 'PERCENTAGE', '{"GTE":0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Customs clearance fee per import & HS code', 'CUSTOM_FEE', 'CURRENCY', '{"GTE":0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Standard-Report Format', 'REPORTING', 'ENUMERATION', '{"ENUM":["MEK_B","MEK_C"]}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( '40''', 'FEU', 'BOOLEAN', '{}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( '20''', 'TEU', 'BOOLEAN', '{}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( '40''HC', 'FEU_HQ', 'BOOLEAN', '{}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Container utilization in mixed containers [%]', 'CONTAINER_UTIL', 'PERCENTAGE', '{"GTE":0,"LTE":1}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Truck utilization road transport EMEA [%]', 'TRUCK_UTIL', 'PERCENTAGE', '{"GTE":0,"LTE":1}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Max validity of container freight rates [days]', 'VALID_DAYS', 'INT', '{"GT": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Metropolition region size (diameter) [km]', 'RADIUS_REGION', 'INT', '{"GT": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Min delivery frequency / year for containtrer transports', 'FREQ_MIN', 'INT', '{"GT": 0, "LT": 366}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Max delivery frequency / year for containtrer transports', 'FREQ_MAX', 'INT', '{"GT": 0, "LT": 366}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Max load of 20'' container [kg]', 'TEU_LOAD', 'INT', '{"GT": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Max load of 40'' container [kg]', 'FEU_LOAD', 'INT', '{"GT": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Pre-carriage [EUR/kg]', 'AIR_PRECARRIAGE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Pre-carriage handling [EUR]', 'AIR_HANDLING', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Main carriage [EUR/kg]', 'AIR_MAINCARRIAGE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Hand over fee [EUR]', 'AIR_HANDOVER_FEE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Customs clearance fee [EUR]', 'AIR_CUSTOM_FEE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'On-carriage [EUR/kg]', 'AIR_ONCARRIAGE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Terminal handling fee [EUR/kg]', 'AIR_TERMINAL_FEE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'GR handling KLT [EUR/HU]', 'KLT_HANDLING', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'GR handling GLT [EUR/HU]', 'GLT_HANDLING', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'GLT/KLT booking & document handling [EUR/GR]', 'BOOKING', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'GLT release from storage [EUR/GLT release]', 'GLT_RELEASE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'KLT release from storage [EUR/KLT release]', 'KLT_RELEASE', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'GLT dispatch [EUR/GLT dispatch]', 'GLT_DISPATCH', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'KLT dispacth [EUR/KLT dispatch]', 'KLT_DISPATCH', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Repacking KLT, HU <15kg [EUR/HU]', 'KLT_REPACK_S', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Repacking KLT, HU >=15kg [EUR/HU]', 'KLT_REPACK_M', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Repacking GLT, HU <15kg [EUR/HU]', 'GLT_REPACK_S', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Repacking GLT, HU 15 - 2000kg [EUR/HU]', 'GLT_REPACK_M', 'CURRENCY', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Repacking GLT, HU > 2000kg [EUR/HU]', 'GLT_REPACK_L', 'INT', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'GLT disposal [EUR/GLT]', 'DISPOSAL', 'INT', '{"GTE": 0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Space costs / m3 per night [EUR/m3]', 'SPACE_COST', 'CURRENCY', '{"GTE": 0}');

-- ===================================================
-- INSERT Statements für system_property
-- ===================================================

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'WORKDAYS'),
           '210'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'INTEREST_RATE'),
           '0.12'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FCA_FEE'),
           '0.002'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TARIFF_RATE'),
           '0.03'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'CUSTOM_FEE'),
           '35'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'REPORTING'),
           'MEK_B'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FEU'),
           'true'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TEU'),
           'true'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FEU_HQ'),
           'true'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'CONTAINER_UTIL'),
           '0.7'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TRUCK_UTIL'),
           '0.7'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'VALID_DAYS'),
           '60'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'RADIUS_REGION'),
           '20'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FREQ_MIN'),
           '3'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FREQ_MAX'),
           '50'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TEU_LOAD'),
           '20000'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FEU_LOAD'),
           '21000'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_PRECARRIAGE'),
           '0.1'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_HANDLING'),
           '80'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_MAINCARRIAGE'),
           '3.5'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_HANDOVER_FEE'),
           '35'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_CUSTOM_FEE'),
           '45'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_ONCARRIAGE'),
           '0.2'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_TERMINAL_FEE'),
           '0.2'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_HANDLING'),
           '0.71'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_HANDLING'),
           '3.5'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'BOOKING'),
           '3.5'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_RELEASE'),
           '2.23'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_RELEASE'),
           '1.12'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_DISPATCH'),
           '1.61'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_DISPATCH'),
           '0.333'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_REPACK_S'),
           '2.08'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_REPACK_M'),
           '3.02'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_REPACK_S'),
           '3.02'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_REPACK_M'),
           '7.76'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_REPACK_L'),
           '14'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'DISPOSAL'),
           '6'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'VALID'
              AND ps.start_date <= NOW()
              AND (ps.end_date IS NULL OR ps.end_date > NOW())
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'SPACE_COST'),
           '0.26'
       );


INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'WORKDAYS'),
           '210'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'INTEREST_RATE'),
           '0.12'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FCA_FEE'),
           '0.002'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TARIFF_RATE'),
           '0.03'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'CUSTOM_FEE'),
           '35'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'REPORTING'),
           'MEK_B'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FEU'),
           'true'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TEU'),
           'true'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FEU_HQ'),
           'true'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'CONTAINER_UTIL'),
           '0.7'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TRUCK_UTIL'),
           '0.8'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'VALID_DAYS'),
           '60'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'RADIUS_REGION'),
           '20'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FREQ_MIN'),
           '3'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FREQ_MAX'),
           '50'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'TEU_LOAD'),
           '20000'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'FEU_LOAD'),
           '21000'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_PRECARRIAGE'),
           '0.1'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_HANDLING'),
           '80'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_MAINCARRIAGE'),
           '3.5'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_HANDOVER_FEE'),
           '35'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_CUSTOM_FEE'),
           '45'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_ONCARRIAGE'),
           '0.2'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'AIR_TERMINAL_FEE'),
           '0.2'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_HANDLING'),
           '0.71'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_HANDLING'),
           '3.5'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'BOOKING'),
           '3.5'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_RELEASE'),
           '2.23'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_RELEASE'),
           '1.12'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_DISPATCH'),
           '1.61'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_DISPATCH'),
           '0.333'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_REPACK_S'),
           '2.08'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'KLT_REPACK_M'),
           '3.02'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_REPACK_S'),
           '3.02'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_REPACK_M'),
           '7.76'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'GLT_REPACK_L'),
           '14'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'DISPOSAL'),
           '6'
       );

INSERT INTO system_property (property_set_id, system_property_type_id, property_value)
VALUES (
           (SELECT ps.id FROM `property_set` ps
            WHERE ps.state = 'EXPIRED'
            ORDER BY ps.start_date DESC
            LIMIT 1),
           (SELECT spt.id FROM system_property_type spt WHERE spt.external_mapping_id = 'SPACE_COST'),
           '0.26'
       );

-- =============================================================================
-- INSERT COUNTRY PROPERTY TYPES
-- =============================================================================

INSERT INTO `country_property_type`
(`name`, `external_mapping_id`, `data_type`, `validation_rule`, `is_required`)
VALUES
    ('Customs Union', 'UNION', 'TEXT', NULL, FALSE),
    ('Safety Stock  [working days]', 'SAFETY_STOCK', 'INT', '{"GTE": 0}', FALSE),
    ('Air Freight Share  [%]', 'AIR_SHARE', 'PERCENTAGE', '{"GTE": 0, "LTE": 100}', FALSE),
    ('Wage Factor [%]', 'WAGE', 'PERCENTAGE', '{"GT": 0}', FALSE);

-- =============================================================================
-- INSERT COUNTRIES
-- =============================================================================

INSERT INTO `country` (`iso_code`, `region_code`, `is_deprecated`) VALUES
                                                                       ('AD', 'EMEA', FALSE),
                                                                       ('AE', 'EMEA', FALSE),
                                                                       ('AF', 'EMEA', FALSE),
                                                                       ('AG', 'LATAM', FALSE),
                                                                       ('AI', 'LATAM', FALSE),
                                                                       ('AL', 'EMEA', FALSE),
                                                                       ('AM', 'EMEA', FALSE),
                                                                       ('AO', 'EMEA', FALSE),
                                                                       ('AQ', 'EMEA', FALSE),
                                                                       ('AR', 'LATAM', FALSE),
                                                                       ('AS', 'APAC', FALSE),
                                                                       ('AT', 'EMEA', FALSE),
                                                                       ('AU', 'APAC', FALSE),
                                                                       ('AW', 'LATAM', FALSE),
                                                                       ('AX', 'EMEA', FALSE),
                                                                       ('AZ', 'EMEA', FALSE),
                                                                       ('BA', 'EMEA', FALSE),
                                                                       ('BB', 'LATAM', FALSE),
                                                                       ('BD', 'EMEA', FALSE),
                                                                       ('BE', 'EMEA', FALSE),
                                                                       ('BF', 'EMEA', FALSE),
                                                                       ('BG', 'EMEA', FALSE),
                                                                       ('BH', 'EMEA', FALSE),
                                                                       ('BI', 'EMEA', FALSE),
                                                                       ('BJ', 'EMEA', FALSE),
                                                                       ('BL', 'LATAM', FALSE),
                                                                       ('BM', 'NAM', FALSE),
                                                                       ('BN', 'APAC', FALSE),
                                                                       ('BO', 'LATAM', FALSE),
                                                                       ('BQ', 'LATAM', FALSE),
                                                                       ('BR', 'LATAM', FALSE),
                                                                       ('BS', 'LATAM', FALSE),
                                                                       ('BT', 'APAC', FALSE),
                                                                       ('BV', 'EMEA', FALSE),
                                                                       ('BW', 'EMEA', FALSE),
                                                                       ('BY', 'EMEA', FALSE),
                                                                       ('BZ', 'LATAM', FALSE),
                                                                       ('CA', 'NAM', FALSE),
                                                                       ('CC', 'APAC', FALSE),
                                                                       ('CD', 'EMEA', FALSE),
                                                                       ('CF', 'EMEA', FALSE),
                                                                       ('CG', 'EMEA', FALSE),
                                                                       ('CH', 'EMEA', FALSE),
                                                                       ('CI', 'EMEA', FALSE),
                                                                       ('CK', 'APAC', FALSE),
                                                                       ('CL', 'LATAM', FALSE),
                                                                       ('CM', 'EMEA', FALSE),
                                                                       ('CN', 'APAC', FALSE),
                                                                       ('CO', 'LATAM', FALSE),
                                                                       ('CR', 'LATAM', FALSE),
                                                                       ('CU', 'LATAM', FALSE),
                                                                       ('CV', 'EMEA', FALSE),
                                                                       ('CW', 'LATAM', FALSE),
                                                                       ('CX', 'APAC', FALSE),
                                                                       ('CY', 'EMEA', FALSE),
                                                                       ('CZ', 'EMEA', FALSE),
                                                                       ('DE', 'EMEA', FALSE),
                                                                       ('DJ', 'EMEA', FALSE),
                                                                       ('DK', 'EMEA', FALSE),
                                                                       ('DM', 'LATAM', FALSE),
                                                                       ('DO', 'LATAM', FALSE),
                                                                       ('DZ', 'EMEA', FALSE),
                                                                       ('EC', 'LATAM', FALSE),
                                                                       ('EE', 'EMEA', FALSE),
                                                                       ('EG', 'EMEA', FALSE),
                                                                       ('EH', 'EMEA', FALSE),
                                                                       ('ER', 'EMEA', FALSE),
                                                                       ('ES', 'EMEA', FALSE),
                                                                       ('ET', 'EMEA', FALSE),
                                                                       ('FI', 'EMEA', FALSE),
                                                                       ('FJ', 'APAC', FALSE),
                                                                       ('FK', 'LATAM', FALSE),
                                                                       ('FM', 'APAC', FALSE),
                                                                       ('FO', 'EMEA', FALSE),
                                                                       ('FR', 'EMEA', FALSE),
                                                                       ('GA', 'EMEA', FALSE),
                                                                       ('GB', 'EMEA', FALSE),
                                                                       ('GD', 'LATAM', FALSE),
                                                                       ('GE', 'EMEA', FALSE),
                                                                       ('GF', 'LATAM', FALSE),
                                                                       ('GG', 'EMEA', FALSE),
                                                                       ('GH', 'EMEA', FALSE),
                                                                       ('GI', 'EMEA', FALSE),
                                                                       ('GL', 'NAM', FALSE),
                                                                       ('GM', 'EMEA', FALSE),
                                                                       ('GN', 'EMEA', FALSE),
                                                                       ('GP', 'LATAM', FALSE),
                                                                       ('GQ', 'EMEA', FALSE),
                                                                       ('GR', 'EMEA', FALSE),
                                                                       ('GS', 'LATAM', FALSE),
                                                                       ('GT', 'LATAM', FALSE),
                                                                       ('GU', 'APAC', FALSE),
                                                                       ('GW', 'EMEA', FALSE),
                                                                       ('GY', 'LATAM', FALSE),
                                                                       ('HK', 'APAC', FALSE),
                                                                       ('HM', 'APAC', FALSE),
                                                                       ('HN', 'LATAM', FALSE),
                                                                       ('HR', 'EMEA', FALSE),
                                                                       ('HT', 'LATAM', FALSE),
                                                                       ('HU', 'EMEA', FALSE),
                                                                       ('ID', 'APAC', FALSE),
                                                                       ('IE', 'EMEA', FALSE),
                                                                       ('IL', 'EMEA', FALSE),
                                                                       ('IM', 'EMEA', FALSE),
                                                                       ('IN', 'APAC', FALSE),
                                                                       ('IO', 'APAC', FALSE),
                                                                       ('IQ', 'EMEA', FALSE),
                                                                       ('IR', 'EMEA', FALSE),
                                                                       ('IS', 'EMEA', FALSE),
                                                                       ('IT', 'EMEA', FALSE),
                                                                       ('JE', 'EMEA', FALSE),
                                                                       ('JM', 'LATAM', FALSE),
                                                                       ('JO', 'EMEA', FALSE),
                                                                       ('JP', 'APAC', FALSE),
                                                                       ('KE', 'EMEA', FALSE),
                                                                       ('KG', 'EMEA', FALSE),
                                                                       ('KH', 'APAC', FALSE),
                                                                       ('KI', 'APAC', FALSE),
                                                                       ('KM', 'EMEA', FALSE),
                                                                       ('KN', 'LATAM', FALSE),
                                                                       ('KP', 'APAC', FALSE),
                                                                       ('KR', 'APAC', FALSE),
                                                                       ('KW', 'EMEA', FALSE),
                                                                       ('KY', 'LATAM', FALSE),
                                                                       ('KZ', 'EMEA', FALSE),
                                                                       ('LA', 'APAC', FALSE),
                                                                       ('LB', 'EMEA', FALSE),
                                                                       ('LC', 'LATAM', FALSE),
                                                                       ('LI', 'EMEA', FALSE),
                                                                       ('LK', 'APAC', FALSE),
                                                                       ('LR', 'EMEA', FALSE),
                                                                       ('LS', 'EMEA', FALSE),
                                                                       ('LT', 'EMEA', FALSE),
                                                                       ('LU', 'EMEA', FALSE),
                                                                       ('LV', 'EMEA', FALSE),
                                                                       ('LY', 'EMEA', FALSE),
                                                                       ('MA', 'EMEA', FALSE),
                                                                       ('MC', 'EMEA', FALSE),
                                                                       ('MD', 'EMEA', FALSE),
                                                                       ('ME', 'EMEA', FALSE),
                                                                       ('MF', 'LATAM', FALSE),
                                                                       ('MG', 'EMEA', FALSE),
                                                                       ('MH', 'APAC', FALSE),
                                                                       ('MK', 'EMEA', FALSE),
                                                                       ('ML', 'EMEA', FALSE),
                                                                       ('MM', 'APAC', FALSE),
                                                                       ('MN', 'APAC', FALSE),
                                                                       ('MO', 'APAC', FALSE),
                                                                       ('MP', 'APAC', FALSE),
                                                                       ('MQ', 'LATAM', FALSE),
                                                                       ('MR', 'EMEA', FALSE),
                                                                       ('MS', 'LATAM', FALSE),
                                                                       ('MT', 'EMEA', FALSE),
                                                                       ('MU', 'EMEA', FALSE),
                                                                       ('MV', 'APAC', FALSE),
                                                                       ('MW', 'EMEA', FALSE),
                                                                       ('MX', 'LATAM', FALSE),
                                                                       ('MY', 'APAC', FALSE),
                                                                       ('MZ', 'EMEA', FALSE),
                                                                       ('NA', 'EMEA', FALSE),
                                                                       ('NC', 'APAC', FALSE),
                                                                       ('NE', 'EMEA', FALSE),
                                                                       ('NF', 'APAC', FALSE),
                                                                       ('NG', 'EMEA', FALSE),
                                                                       ('NI', 'LATAM', FALSE),
                                                                       ('NL', 'EMEA', FALSE),
                                                                       ('NO', 'EMEA', FALSE),
                                                                       ('NP', 'APAC', FALSE),
                                                                       ('NR', 'APAC', FALSE),
                                                                       ('NU', 'APAC', FALSE),
                                                                       ('NZ', 'APAC', FALSE),
                                                                       ('OM', 'EMEA', FALSE),
                                                                       ('PA', 'LATAM', FALSE),
                                                                       ('PE', 'LATAM', FALSE),
                                                                       ('PF', 'APAC', FALSE),
                                                                       ('PG', 'APAC', FALSE),
                                                                       ('PH', 'APAC', FALSE),
                                                                       ('PK', 'APAC', FALSE),
                                                                       ('PL', 'EMEA', FALSE),
                                                                       ('PM', 'NAM', FALSE),
                                                                       ('PN', 'APAC', FALSE),
                                                                       ('PR', 'LATAM', FALSE),
                                                                       ('PS', 'EMEA', FALSE),
                                                                       ('PT', 'EMEA', FALSE),
                                                                       ('PW', 'APAC', FALSE),
                                                                       ('PY', 'LATAM', FALSE),
                                                                       ('QA', 'EMEA', FALSE),
                                                                       ('RE', 'EMEA', FALSE),
                                                                       ('RO', 'EMEA', FALSE),
                                                                       ('RS', 'EMEA', FALSE),
                                                                       ('RU', 'EMEA', FALSE),
                                                                       ('RW', 'EMEA', FALSE),
                                                                       ('SA', 'EMEA', FALSE),
                                                                       ('SB', 'APAC', FALSE),
                                                                       ('SC', 'EMEA', FALSE),
                                                                       ('SD', 'EMEA', FALSE),
                                                                       ('SE', 'EMEA', FALSE),
                                                                       ('SG', 'APAC', FALSE),
                                                                       ('SH', 'EMEA', FALSE),
                                                                       ('SI', 'EMEA', FALSE),
                                                                       ('SJ', 'EMEA', FALSE),
                                                                       ('SK', 'EMEA', FALSE),
                                                                       ('SL', 'EMEA', FALSE),
                                                                       ('SM', 'EMEA', FALSE),
                                                                       ('SN', 'EMEA', FALSE),
                                                                       ('SO', 'EMEA', FALSE),
                                                                       ('SR', 'LATAM', FALSE),
                                                                       ('SS', 'EMEA', FALSE),
                                                                       ('ST', 'EMEA', FALSE),
                                                                       ('SV', 'LATAM', FALSE),
                                                                       ('SX', 'LATAM', FALSE),
                                                                       ('SY', 'EMEA', FALSE),
                                                                       ('SZ', 'EMEA', FALSE),
                                                                       ('TC', 'LATAM', FALSE),
                                                                       ('TD', 'EMEA', FALSE),
                                                                       ('TF', 'EMEA', FALSE),
                                                                       ('TG', 'EMEA', FALSE),
                                                                       ('TH', 'APAC', FALSE),
                                                                       ('TJ', 'EMEA', FALSE),
                                                                       ('TK', 'APAC', FALSE),
                                                                       ('TL', 'APAC', FALSE),
                                                                       ('TM', 'EMEA', FALSE),
                                                                       ('TN', 'EMEA', FALSE),
                                                                       ('TO', 'APAC', FALSE),
                                                                       ('TR', 'EMEA', FALSE),
                                                                       ('TT', 'LATAM', FALSE),
                                                                       ('TV', 'APAC', FALSE),
                                                                       ('TW', 'APAC', FALSE),
                                                                       ('TZ', 'EMEA', FALSE),
                                                                       ('UA', 'EMEA', FALSE),
                                                                       ('UG', 'EMEA', FALSE),
                                                                       ('UM', 'APAC', FALSE),
                                                                       ('US', 'NAM', FALSE),
                                                                       ('UY', 'LATAM', FALSE),
                                                                       ('UZ', 'EMEA', FALSE),
                                                                       ('VA', 'EMEA', FALSE),
                                                                       ('VC', 'LATAM', FALSE),
                                                                       ('VE', 'LATAM', FALSE),
                                                                       ('VG', 'LATAM', FALSE),
                                                                       ('VI', 'LATAM', FALSE),
                                                                       ('VN', 'APAC', FALSE),
                                                                       ('VU', 'APAC', FALSE),
                                                                       ('WF', 'APAC', FALSE),
                                                                       ('WS', 'APAC', FALSE),
                                                                       ('YE', 'EMEA', FALSE),
                                                                       ('YT', 'EMEA', FALSE),
                                                                       ('ZA', 'EMEA', FALSE),
                                                                       ('ZM', 'EMEA', FALSE),
                                                                       ('ZW', 'EMEA', FALSE),
                                                                       ('XK', 'EMEA', FALSE);

-- =============================================================================
-- INSERT COUNTRY PROPERTIES
-- =============================================================================

INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'VALID'
       AND ps.start_date <= NOW()
       AND (ps.end_date IS NULL OR ps.end_date > NOW())
     ORDER BY ps.start_date DESC
     LIMIT 1),
    'EU'
FROM `country` c, `country_property_type` cpt
WHERE c.iso_code IN ('AT', 'BE', 'BG', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK')
  AND cpt.external_mapping_id = 'UNION';

-- Safety Stock Properties
INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'VALID'
       AND ps.start_date <= NOW()
       AND (ps.end_date IS NULL OR ps.end_date > NOW())
     ORDER BY ps.start_date DESC
     LIMIT 1),
    CASE c.iso_code
        WHEN 'AD' THEN '15'
        WHEN 'AE' THEN '20'
        WHEN 'AF' THEN '30'
        WHEN 'AG' THEN '55'
        WHEN 'AI' THEN '55'
        WHEN 'AL' THEN '15'
        WHEN 'AM' THEN '15'
        WHEN 'AO' THEN '15'
        WHEN 'AQ' THEN '55'
        WHEN 'AR' THEN '55'
        WHEN 'AS' THEN '55'
        WHEN 'AT' THEN '10'
        WHEN 'AU' THEN '55'
        WHEN 'AW' THEN '55'
        WHEN 'AZ' THEN '15'
        WHEN 'BA' THEN '15'
        WHEN 'BB' THEN '55'
        WHEN 'BD' THEN '30'
        WHEN 'BE' THEN '10'
        WHEN 'BF' THEN '15'
        WHEN 'BG' THEN '10'
        WHEN 'BH' THEN '20'
        WHEN 'BI' THEN '15'
        WHEN 'BJ' THEN '15'
        WHEN 'BL' THEN '55'
        WHEN 'BM' THEN '55'
        WHEN 'BN' THEN '55'
        WHEN 'BO' THEN '55'
        WHEN 'BQ' THEN '55'
        WHEN 'BR' THEN '55'
        WHEN 'BS' THEN '55'
        WHEN 'BT' THEN '55'
        WHEN 'BV' THEN '55'
        WHEN 'BW' THEN '15'
        WHEN 'BY' THEN '15'
        WHEN 'BZ' THEN '55'
        WHEN 'CA' THEN '55'
        WHEN 'CC' THEN '55'
        WHEN 'CD' THEN '15'
        WHEN 'CF' THEN '15'
        WHEN 'CG' THEN '15'
        WHEN 'CH' THEN '10'
        WHEN 'CI' THEN '15'
        WHEN 'CK' THEN '55'
        WHEN 'CL' THEN '55'
        WHEN 'CM' THEN '15'
        WHEN 'CN' THEN '55'
        WHEN 'CO' THEN '55'
        WHEN 'CR' THEN '55'
        WHEN 'CU' THEN '55'
        WHEN 'CV' THEN '15'
        WHEN 'CW' THEN '55'
        WHEN 'CX' THEN '55'
        WHEN 'CY' THEN '10'
        WHEN 'CZ' THEN '10'
        WHEN 'DE' THEN '10'
        WHEN 'DJ' THEN '15'
        WHEN 'DK' THEN '10'
        WHEN 'DM' THEN '55'
        WHEN 'DO' THEN '55'
        WHEN 'DZ' THEN '15'
        WHEN 'EC' THEN '55'
        WHEN 'EE' THEN '10'
        WHEN 'EG' THEN '15'
        WHEN 'EH' THEN '15'
        WHEN 'ER' THEN '15'
        WHEN 'ES' THEN '10'
        WHEN 'ET' THEN '15'
        WHEN 'FI' THEN '10'
        WHEN 'FJ' THEN '55'
        WHEN 'FK' THEN '55'
        WHEN 'FM' THEN '55'
        WHEN 'FO' THEN '10'
        WHEN 'FR' THEN '10'
        WHEN 'GA' THEN '15'
        WHEN 'GB' THEN '10'
        WHEN 'GD' THEN '55'
        WHEN 'GE' THEN '15'
        WHEN 'GF' THEN '55'
        WHEN 'GG' THEN '10'
        WHEN 'GH' THEN '15'
        WHEN 'GI' THEN '10'
        WHEN 'GL' THEN '55'
        WHEN 'GM' THEN '15'
        WHEN 'GN' THEN '15'
        WHEN 'GP' THEN '55'
        WHEN 'GQ' THEN '15'
        WHEN 'GR' THEN '10'
        WHEN 'GS' THEN '55'
        WHEN 'GT' THEN '55'
        WHEN 'GU' THEN '55'
        WHEN 'GW' THEN '15'
        WHEN 'GY' THEN '55'
        WHEN 'HK' THEN '55'
        WHEN 'HM' THEN '55'
        WHEN 'HN' THEN '55'
        WHEN 'HR' THEN '10'
        WHEN 'HT' THEN '55'
        WHEN 'HU' THEN '10'
        WHEN 'ID' THEN '55'
        WHEN 'IE' THEN '10'
        WHEN 'IL' THEN '15'
        WHEN 'IM' THEN '10'
        WHEN 'IN' THEN '55'
        WHEN 'IO' THEN '55'
        WHEN 'IQ' THEN '30'
        WHEN 'IR' THEN '30'
        WHEN 'IS' THEN '10'
        WHEN 'IT' THEN '10'
        WHEN 'JE' THEN '10'
        WHEN 'JM' THEN '55'
        WHEN 'JO' THEN '15'
        WHEN 'JP' THEN '55'
        WHEN 'KE' THEN '15'
        WHEN 'KG' THEN '15'
        WHEN 'KH' THEN '55'
        WHEN 'KI' THEN '55'
        WHEN 'KM' THEN '15'
        WHEN 'KN' THEN '55'
        WHEN 'KP' THEN '55'
        WHEN 'KR' THEN '55'
        WHEN 'KW' THEN '20'
        WHEN 'KY' THEN '55'
        WHEN 'KZ' THEN '15'
        WHEN 'LA' THEN '55'
        WHEN 'LB' THEN '15'
        WHEN 'LC' THEN '55'
        WHEN 'LI' THEN '10'
        WHEN 'LK' THEN '55'
        WHEN 'LR' THEN '15'
        WHEN 'LS' THEN '15'
        WHEN 'LT' THEN '10'
        WHEN 'LU' THEN '10'
        WHEN 'LV' THEN '10'
        WHEN 'LY' THEN '15'
        WHEN 'MA' THEN '15'
        WHEN 'MC' THEN '10'
        WHEN 'MD' THEN '15'
        WHEN 'ME' THEN '15'
        WHEN 'MF' THEN '55'
        WHEN 'MG' THEN '15'
        WHEN 'MH' THEN '55'
        WHEN 'MK' THEN '15'
        WHEN 'ML' THEN '15'
        WHEN 'MM' THEN '55'
        WHEN 'MN' THEN '55'
        WHEN 'MO' THEN '55'
        WHEN 'MP' THEN '55'
        WHEN 'MQ' THEN '55'
        WHEN 'MR' THEN '15'
        WHEN 'MS' THEN '55'
        WHEN 'MT' THEN '10'
        WHEN 'MU' THEN '15'
        WHEN 'MV' THEN '55'
        WHEN 'MW' THEN '15'
        WHEN 'MX' THEN '55'
        WHEN 'MY' THEN '55'
        WHEN 'MZ' THEN '15'
        WHEN 'NA' THEN '15'
        WHEN 'NC' THEN '55'
        WHEN 'NE' THEN '15'
        WHEN 'NF' THEN '55'
        WHEN 'NG' THEN '15'
        WHEN 'NI' THEN '55'
        WHEN 'NL' THEN '10'
        WHEN 'NO' THEN '10'
        WHEN 'NP' THEN '55'
        WHEN 'NR' THEN '55'
        WHEN 'NU' THEN '55'
        WHEN 'NZ' THEN '55'
        WHEN 'OM' THEN '20'
        WHEN 'PA' THEN '55'
        WHEN 'PE' THEN '55'
        WHEN 'PF' THEN '55'
        WHEN 'PG' THEN '55'
        WHEN 'PH' THEN '55'
        WHEN 'PK' THEN '30'
        WHEN 'PL' THEN '10'
        WHEN 'PM' THEN '55'
        WHEN 'PN' THEN '55'
        WHEN 'PR' THEN '55'
        WHEN 'PS' THEN '15'
        WHEN 'PT' THEN '10'
        WHEN 'PW' THEN '55'
        WHEN 'PY' THEN '55'
        WHEN 'QA' THEN '20'
        WHEN 'RE' THEN '15'
        WHEN 'RO' THEN '10'
        WHEN 'RS' THEN '15'
        WHEN 'RU' THEN '15'
        WHEN 'RW' THEN '15'
        WHEN 'SA' THEN '20'
        WHEN 'SB' THEN '55'
        WHEN 'SC' THEN '15'
        WHEN 'SD' THEN '15'
        WHEN 'SE' THEN '10'
        WHEN 'SG' THEN '55'
        WHEN 'SH' THEN '15'
        WHEN 'SI' THEN '10'
        WHEN 'SJ' THEN '10'
        WHEN 'SK' THEN '10'
        WHEN 'SL' THEN '15'
        WHEN 'SM' THEN '10'
        WHEN 'SN' THEN '15'
        WHEN 'SO' THEN '15'
        WHEN 'SR' THEN '55'
        WHEN 'SS' THEN '15'
        WHEN 'ST' THEN '15'
        WHEN 'SV' THEN '55'
        WHEN 'SX' THEN '55'
        WHEN 'SY' THEN '15'
        WHEN 'SZ' THEN '15'
        WHEN 'TC' THEN '55'
        WHEN 'TD' THEN '15'
        WHEN 'TF' THEN '55'
        WHEN 'TG' THEN '15'
        WHEN 'TH' THEN '55'
        WHEN 'TJ' THEN '15'
        WHEN 'TK' THEN '55'
        WHEN 'TL' THEN '55'
        WHEN 'TM' THEN '15'
        WHEN 'TN' THEN '15'
        WHEN 'TO' THEN '55'
        WHEN 'TR' THEN '15'
        WHEN 'TT' THEN '55'
        WHEN 'TV' THEN '55'
        WHEN 'TW' THEN '55'
        WHEN 'TZ' THEN '15'
        WHEN 'UA' THEN '15'
        WHEN 'UG' THEN '15'
        WHEN 'UM' THEN '55'
        WHEN 'US' THEN '55'
        WHEN 'UY' THEN '55'
        WHEN 'UZ' THEN '15'
        WHEN 'VA' THEN '10'
        WHEN 'VC' THEN '55'
        WHEN 'VE' THEN '55'
        WHEN 'VG' THEN '55'
        WHEN 'VI' THEN '55'
        WHEN 'VN' THEN '55'
        WHEN 'VU' THEN '55'
        WHEN 'WF' THEN '55'
        WHEN 'WS' THEN '55'
        WHEN 'YE' THEN '30'
        WHEN 'YT' THEN '15'
        WHEN 'ZA' THEN '15'
        WHEN 'ZM' THEN '15'
        WHEN 'ZW' THEN '15'
        WHEN 'XK' THEN '15'
        WHEN 'BQ' THEN '55'
        END
FROM `country` c, `country_property_type` cpt
WHERE cpt.external_mapping_id = 'SAFETY_STOCK';

-- Air Freight Share Properties (all countries have 0%)
INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'VALID'
       AND ps.start_date <= NOW()
       AND (ps.end_date IS NULL OR ps.end_date > NOW())
     ORDER BY ps.start_date DESC
     LIMIT 1),
    '0'
FROM `country` c, `country_property_type` cpt
WHERE cpt.external_mapping_id = 'AIR_SHARE';

-- Wage Factor Properties (only for countries with defined values)
INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'VALID'
       AND ps.start_date <= NOW()
       AND (ps.end_date IS NULL OR ps.end_date > NOW())
     ORDER BY ps.start_date DESC
     LIMIT 1),
    CASE c.iso_code
        WHEN 'AT' THEN '0.99'
        WHEN 'BE' THEN '1.14'
        WHEN 'BG' THEN '0.23'
        WHEN 'CZ' THEN '0.44'
        WHEN 'DE' THEN '1.00'
        WHEN 'DK' THEN '1.16'
        WHEN 'EE' THEN '0.60'
        WHEN 'ES' THEN '0.90'
        WHEN 'FI' THEN '1.02'
        WHEN 'FR' THEN '1.05'
        WHEN 'GR' THEN '0.35'
        WHEN 'HR' THEN '0.31'
        WHEN 'HU' THEN '0.35'
        WHEN 'IE' THEN '0.97'
        WHEN 'IT' THEN '0.72'
        WHEN 'LT' THEN '0.36'
        WHEN 'LU' THEN '1.31'
        WHEN 'LV' THEN '0.33'
        WHEN 'MT' THEN '0.41'
        WHEN 'NL' THEN '1.05'
        WHEN 'PL' THEN '0.27'
        WHEN 'PT' THEN '0.41'
        WHEN 'RO' THEN '0.27'
        WHEN 'SE' THEN '0.94'
        WHEN 'SI' THEN '0.62'
        WHEN 'SK' THEN '0.42'
        END
FROM `country` c, `country_property_type` cpt
WHERE c.iso_code IN ('AT', 'BE', 'BG', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK')
  AND cpt.external_mapping_id = 'WAGE';

-- expired set:


INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'EXPIRED'
     ORDER BY ps.start_date DESC
     LIMIT 1),
    'EU'
FROM `country` c, `country_property_type` cpt
WHERE c.iso_code IN ('AT', 'BE', 'BG', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK')
  AND cpt.external_mapping_id = 'UNION';

-- Safety Stock Properties
INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'EXPIRED'
     ORDER BY ps.start_date DESC
     LIMIT 1),
    CASE c.iso_code
        WHEN 'AD' THEN '15'
        WHEN 'AE' THEN '20'
        WHEN 'AF' THEN '30'
        WHEN 'AG' THEN '55'
        WHEN 'AI' THEN '55'
        WHEN 'AL' THEN '15'
        WHEN 'AM' THEN '15'
        WHEN 'AO' THEN '15'
        WHEN 'AQ' THEN '55'
        WHEN 'AR' THEN '55'
        WHEN 'AS' THEN '55'
        WHEN 'AT' THEN '10'
        WHEN 'AU' THEN '55'
        WHEN 'AW' THEN '55'
        WHEN 'AZ' THEN '15'
        WHEN 'BA' THEN '15'
        WHEN 'BB' THEN '55'
        WHEN 'BD' THEN '30'
        WHEN 'BE' THEN '10'
        WHEN 'BF' THEN '15'
        WHEN 'BG' THEN '10'
        WHEN 'BH' THEN '20'
        WHEN 'BI' THEN '15'
        WHEN 'BJ' THEN '15'
        WHEN 'BL' THEN '55'
        WHEN 'BM' THEN '55'
        WHEN 'BN' THEN '55'
        WHEN 'BO' THEN '55'
        WHEN 'BQ' THEN '55'
        WHEN 'BR' THEN '55'
        WHEN 'BS' THEN '55'
        WHEN 'BT' THEN '55'
        WHEN 'BV' THEN '55'
        WHEN 'BW' THEN '15'
        WHEN 'BY' THEN '15'
        WHEN 'BZ' THEN '55'
        WHEN 'CA' THEN '55'
        WHEN 'CC' THEN '55'
        WHEN 'CD' THEN '15'
        WHEN 'CF' THEN '15'
        WHEN 'CG' THEN '15'
        WHEN 'CH' THEN '10'
        WHEN 'CI' THEN '15'
        WHEN 'CK' THEN '55'
        WHEN 'CL' THEN '55'
        WHEN 'CM' THEN '15'
        WHEN 'CN' THEN '55'
        WHEN 'CO' THEN '55'
        WHEN 'CR' THEN '55'
        WHEN 'CU' THEN '55'
        WHEN 'CV' THEN '15'
        WHEN 'CW' THEN '55'
        WHEN 'CX' THEN '55'
        WHEN 'CY' THEN '10'
        WHEN 'CZ' THEN '10'
        WHEN 'DE' THEN '10'
        WHEN 'DJ' THEN '15'
        WHEN 'DK' THEN '10'
        WHEN 'DM' THEN '55'
        WHEN 'DO' THEN '55'
        WHEN 'DZ' THEN '15'
        WHEN 'EC' THEN '55'
        WHEN 'EE' THEN '10'
        WHEN 'EG' THEN '15'
        WHEN 'EH' THEN '15'
        WHEN 'ER' THEN '15'
        WHEN 'ES' THEN '10'
        WHEN 'ET' THEN '15'
        WHEN 'FI' THEN '10'
        WHEN 'FJ' THEN '55'
        WHEN 'FK' THEN '55'
        WHEN 'FM' THEN '55'
        WHEN 'FO' THEN '10'
        WHEN 'FR' THEN '10'
        WHEN 'GA' THEN '15'
        WHEN 'GB' THEN '10'
        WHEN 'GD' THEN '55'
        WHEN 'GE' THEN '15'
        WHEN 'GF' THEN '55'
        WHEN 'GG' THEN '10'
        WHEN 'GH' THEN '15'
        WHEN 'GI' THEN '10'
        WHEN 'GL' THEN '55'
        WHEN 'GM' THEN '15'
        WHEN 'GN' THEN '15'
        WHEN 'GP' THEN '55'
        WHEN 'GQ' THEN '15'
        WHEN 'GR' THEN '10'
        WHEN 'GS' THEN '55'
        WHEN 'GT' THEN '55'
        WHEN 'GU' THEN '55'
        WHEN 'GW' THEN '15'
        WHEN 'GY' THEN '55'
        WHEN 'HK' THEN '55'
        WHEN 'HM' THEN '55'
        WHEN 'HN' THEN '55'
        WHEN 'HR' THEN '10'
        WHEN 'HT' THEN '55'
        WHEN 'HU' THEN '10'
        WHEN 'ID' THEN '55'
        WHEN 'IE' THEN '10'
        WHEN 'IL' THEN '15'
        WHEN 'IM' THEN '10'
        WHEN 'IN' THEN '55'
        WHEN 'IO' THEN '55'
        WHEN 'IQ' THEN '30'
        WHEN 'IR' THEN '30'
        WHEN 'IS' THEN '10'
        WHEN 'IT' THEN '10'
        WHEN 'JE' THEN '10'
        WHEN 'JM' THEN '55'
        WHEN 'JO' THEN '15'
        WHEN 'JP' THEN '55'
        WHEN 'KE' THEN '15'
        WHEN 'KG' THEN '15'
        WHEN 'KH' THEN '55'
        WHEN 'KI' THEN '55'
        WHEN 'KM' THEN '15'
        WHEN 'KN' THEN '55'
        WHEN 'KP' THEN '55'
        WHEN 'KR' THEN '55'
        WHEN 'KW' THEN '20'
        WHEN 'KY' THEN '55'
        WHEN 'KZ' THEN '15'
        WHEN 'LA' THEN '55'
        WHEN 'LB' THEN '15'
        WHEN 'LC' THEN '55'
        WHEN 'LI' THEN '10'
        WHEN 'LK' THEN '55'
        WHEN 'LR' THEN '15'
        WHEN 'LS' THEN '15'
        WHEN 'LT' THEN '10'
        WHEN 'LU' THEN '10'
        WHEN 'LV' THEN '10'
        WHEN 'LY' THEN '15'
        WHEN 'MA' THEN '15'
        WHEN 'MC' THEN '10'
        WHEN 'MD' THEN '15'
        WHEN 'ME' THEN '15'
        WHEN 'MF' THEN '55'
        WHEN 'MG' THEN '15'
        WHEN 'MH' THEN '55'
        WHEN 'MK' THEN '15'
        WHEN 'ML' THEN '15'
        WHEN 'MM' THEN '55'
        WHEN 'MN' THEN '55'
        WHEN 'MO' THEN '55'
        WHEN 'MP' THEN '55'
        WHEN 'MQ' THEN '55'
        WHEN 'MR' THEN '15'
        WHEN 'MS' THEN '55'
        WHEN 'MT' THEN '10'
        WHEN 'MU' THEN '15'
        WHEN 'MV' THEN '55'
        WHEN 'MW' THEN '15'
        WHEN 'MX' THEN '55'
        WHEN 'MY' THEN '55'
        WHEN 'MZ' THEN '15'
        WHEN 'NA' THEN '15'
        WHEN 'NC' THEN '55'
        WHEN 'NE' THEN '15'
        WHEN 'NF' THEN '55'
        WHEN 'NG' THEN '15'
        WHEN 'NI' THEN '55'
        WHEN 'NL' THEN '10'
        WHEN 'NO' THEN '10'
        WHEN 'NP' THEN '55'
        WHEN 'NR' THEN '55'
        WHEN 'NU' THEN '55'
        WHEN 'NZ' THEN '55'
        WHEN 'OM' THEN '20'
        WHEN 'PA' THEN '55'
        WHEN 'PE' THEN '55'
        WHEN 'PF' THEN '55'
        WHEN 'PG' THEN '55'
        WHEN 'PH' THEN '55'
        WHEN 'PK' THEN '30'
        WHEN 'PL' THEN '10'
        WHEN 'PM' THEN '55'
        WHEN 'PN' THEN '55'
        WHEN 'PR' THEN '55'
        WHEN 'PS' THEN '15'
        WHEN 'PT' THEN '10'
        WHEN 'PW' THEN '55'
        WHEN 'PY' THEN '55'
        WHEN 'QA' THEN '20'
        WHEN 'RE' THEN '15'
        WHEN 'RO' THEN '10'
        WHEN 'RS' THEN '15'
        WHEN 'RU' THEN '15'
        WHEN 'RW' THEN '15'
        WHEN 'SA' THEN '20'
        WHEN 'SB' THEN '55'
        WHEN 'SC' THEN '15'
        WHEN 'SD' THEN '15'
        WHEN 'SE' THEN '10'
        WHEN 'SG' THEN '55'
        WHEN 'SH' THEN '15'
        WHEN 'SI' THEN '10'
        WHEN 'SJ' THEN '10'
        WHEN 'SK' THEN '10'
        WHEN 'SL' THEN '15'
        WHEN 'SM' THEN '10'
        WHEN 'SN' THEN '15'
        WHEN 'SO' THEN '15'
        WHEN 'SR' THEN '55'
        WHEN 'SS' THEN '15'
        WHEN 'ST' THEN '15'
        WHEN 'SV' THEN '55'
        WHEN 'SX' THEN '55'
        WHEN 'SY' THEN '15'
        WHEN 'SZ' THEN '15'
        WHEN 'TC' THEN '55'
        WHEN 'TD' THEN '15'
        WHEN 'TF' THEN '55'
        WHEN 'TG' THEN '15'
        WHEN 'TH' THEN '55'
        WHEN 'TJ' THEN '15'
        WHEN 'TK' THEN '55'
        WHEN 'TL' THEN '55'
        WHEN 'TM' THEN '15'
        WHEN 'TN' THEN '15'
        WHEN 'TO' THEN '55'
        WHEN 'TR' THEN '15'
        WHEN 'TT' THEN '55'
        WHEN 'TV' THEN '55'
        WHEN 'TW' THEN '55'
        WHEN 'TZ' THEN '15'
        WHEN 'UA' THEN '15'
        WHEN 'UG' THEN '15'
        WHEN 'UM' THEN '55'
        WHEN 'US' THEN '60'
        WHEN 'UY' THEN '55'
        WHEN 'UZ' THEN '15'
        WHEN 'VA' THEN '10'
        WHEN 'VC' THEN '55'
        WHEN 'VE' THEN '55'
        WHEN 'VG' THEN '55'
        WHEN 'VI' THEN '55'
        WHEN 'VN' THEN '55'
        WHEN 'VU' THEN '55'
        WHEN 'WF' THEN '55'
        WHEN 'WS' THEN '55'
        WHEN 'YE' THEN '30'
        WHEN 'YT' THEN '15'
        WHEN 'ZA' THEN '15'
        WHEN 'ZM' THEN '15'
        WHEN 'ZW' THEN '15'
        WHEN 'XK' THEN '15'
        WHEN 'BQ' THEN '55'
        END
FROM `country` c, `country_property_type` cpt
WHERE cpt.external_mapping_id = 'SAFETY_STOCK';

-- Air Freight Share Properties (all countries have 0%)
INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'EXPIRED'
     ORDER BY ps.start_date DESC
     LIMIT 1),
    '0'
FROM `country` c, `country_property_type` cpt
WHERE cpt.external_mapping_id = 'AIR_SHARE';

-- Wage Factor Properties (only for countries with defined values)
INSERT INTO `country_property`
(`country_id`, `country_property_type_id`, `property_set_id`, `property_value`)
SELECT
    c.id,
    cpt.id,
    (SELECT ps.id FROM `property_set` ps
     WHERE ps.state = 'EXPIRED'
     ORDER BY ps.start_date DESC
     LIMIT 1),
    CASE c.iso_code
        WHEN 'AT' THEN '99'
        WHEN 'BE' THEN '114'
        WHEN 'BG' THEN '23'
        WHEN 'CZ' THEN '44'
        WHEN 'DE' THEN '100'
        WHEN 'DK' THEN '116'
        WHEN 'EE' THEN '60'
        WHEN 'ES' THEN '90'
        WHEN 'FI' THEN '102'
        WHEN 'FR' THEN '105'
        WHEN 'GR' THEN '35'
        WHEN 'HR' THEN '31'
        WHEN 'HU' THEN '35'
        WHEN 'IE' THEN '97'
        WHEN 'IT' THEN '72'
        WHEN 'LT' THEN '36'
        WHEN 'LU' THEN '131'
        WHEN 'LV' THEN '33'
        WHEN 'MT' THEN '41'
        WHEN 'NL' THEN '105'
        WHEN 'PL' THEN '27'
        WHEN 'PT' THEN '41'
        WHEN 'RO' THEN '27'
        WHEN 'SE' THEN '94'
        WHEN 'SI' THEN '62'
        WHEN 'SK' THEN '42'
        END
FROM `country` c, `country_property_type` cpt
WHERE c.iso_code IN ('AT', 'BE', 'BG', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK')
  AND cpt.external_mapping_id = 'WAGE';
