
-- ===================================================
-- INSERT Statements für system_property_type
-- Mapping: external mapping id -> external_mapping_id
--          Description -> name
-- ===================================================

INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Reference route segment start node mapping id', 'START_REF', 'TEXT', '{}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Reference route segment end node mapping id', 'END_REF', 'TEXT', '{}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'The historically highest rate for the reference route segment for 40ft containers [EUR]', 'RISK_REF', 'CURRENCY', '{"GT":0}');
INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'The historically lowest rate for the reference route segment for 40ft containers [EUR]', 'CHANCE_REF', 'CURRENCY', '{"GT":0}');

INSERT INTO system_property_type ( name, external_mapping_id, data_type, validation_rule) VALUES ( 'Payment terms [days]', 'PAYMENT_TERMS', 'INT', '{}');

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 ( 'Max load of a truck [kg]', 'TRUCK_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
-- Verwendung von Subqueries für dynamische ID-Ermittlung
-- ===================================================

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 = 'PAYMENT_TERMS'),
           '30'
       );

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 = 'START_REF'),
           'CNXMN'
       );

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 = 'END_REF'),
           'DEHAM'
       );

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 = 'RISK_REF'),
           '20000.00'
       );

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 = 'CHANCE_REF'),
           '1000.00'
       );


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 = '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 = '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 = 'TRUCK_LOAD'),
           '25000'
       );

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.2630136986'
       );