diff --git a/Data/BulkLoad/UpgradeBulkLoad.sql b/Data/BulkLoad/UpgradeBulkLoad.sql index 04c3f0e..0a9f876 100644 --- a/Data/BulkLoad/UpgradeBulkLoad.sql +++ b/Data/BulkLoad/UpgradeBulkLoad.sql @@ -1,35 +1,40 @@ -DECLARE - l_test_load BOOLEAN := upper('&&1') = 'TEST'; - l_fat_load BOOLEAN := upper('&&1') = 'FAT'; - l_uat_load BOOLEAN := upper('&&1') = 'UAT'; - l_live_load BOOLEAN := upper('&&1') = 'LIVE'; - l_train_load BOOLEAN := upper('&&1') = 'TRAIN'; - l_dev_load BOOLEAN := upper(nvl('&&1','DEV')) = 'DEV'; - +REM $Id$ BEGIN + dbms_output.enable; + dbms_output.put_line('UpgradeBulkLoad: Add SELFPURGING to ADDITIONAL_ITEMS'); - IF l_test_load THEN - mip_bulk_load.g_flow_id := 102; - ELSIF l_fat_load THEN - mip_bulk_load.g_flow_id := 200; - ELSIF l_dev_load THEN - mip_bulk_load.g_flow_id := 155; - ELSIF l_uat_load THEN - mip_bulk_load.g_flow_id := 400; - ELSIF l_train_load THEN - mip_bulk_load.g_flow_id := 800; - END IF; + UPDATE additional_items + SET description = 'No Purging Required' + ,lead_time = 0 + WHERE code = 'SELFPURGING'; - IF mip_bulk_load.g_flow_id IS NOT NULL THEN - dbms_output.put_line('UpgradeBulkLoad: Upgrade Bulk Load Not Required'); - --mip_bulk_load.init; - --mip_bulk_load.load_caveats; - --mip_bulk_load.report_err; + IF SQL%ROWCOUNT <> 0 THEN + dbms_output.put_line('UpgradeBulkLoad: - Done (Update)'); ELSE - dbms_output.put_line('UpgradeBulkLoad: Unexpected parameter value of &&1 received'); + INSERT INTO additional_items + (code + ,description + ,lead_time) + VALUES + ('SELFPURGING' + ,'No Purging Required' + ,0); + dbms_output.put_line('UpgradeBulkLoad: - Done (Insert)'); END IF; + dbms_output.put_line('UpgradeBulkLoad: Add SELFPURGING to CAVEAT_TEXTS'); + + UPDATE caveat_texts + SET adit_code = 'SELFPURGING' + ,condition = 'NULL' + WHERE text LIKE 'Where purging of downstream%'; + + IF SQL%ROWCOUNT <> 0 THEN + dbms_output.put_line('UpgradeBulkLoad: - Done (Update)'); + ELSE + dbms_output.put_line('UpgradeBulkLoad: - Not Done (No Caveats Found)'); + END IF; END; / exit -/ + diff --git a/Modules/mip_quotation.pck b/Modules/mip_quotation.pck index 5dd2066..00dfaa7 100644 --- a/Modules/mip_quotation.pck +++ b/Modules/mip_quotation.pck @@ -213,10 +213,12 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS PROCEDURE pl(p_in VARCHAR2 ,p_line IN NUMBER DEFAULT NULL) IS BEGIN - $IF mip_debug_constants.debugging OR mip_debug_constants.quotation $THEN mip_debug.pl(p_unit => $$PLSQL_UNIT - ,p_line => p_line - ,p_in => p_in); - $END NULL; + $IF mip_debug_constants.debugging OR mip_debug_constants.quotation $THEN + mip_debug.pl(p_unit => $$PLSQL_UNIT + ,p_line => p_line + ,p_in => p_in); + $END + NULL; END pl; PROCEDURE add_quote_reason(p_enqu_id IN enquiries.id%TYPE @@ -237,7 +239,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS ,1 ,239) ,p_internal_or_external - ,qure_seq.NEXTVAL); + ,qure_seq.nextval); EXCEPTION WHEN OTHERS THEN pl('add_quote_reason:' || SQLERRM @@ -264,7 +266,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS ,p_qust_code ,p_event_date ,p_description - ,quev_seq.NEXTVAL); + ,quev_seq.nextval); pl('add_quote_event:exit' ,$$PLSQL_LINE); END add_quote_event; @@ -285,7 +287,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS ,p_enst_code ,p_event_date ,p_description - ,enev_seq.NEXTVAL); + ,enev_seq.nextval); END add_enquiry_event; PROCEDURE add_quote_role(p_qute_id IN quotes.id%TYPE @@ -464,7 +466,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS FROM v_current_quote_status WHERE qute_id = p_qute_id; - IF l_qust_code IN ('SELECTED', 'ACCEPTED') THEN + IF l_qust_code IN ('SELECTED' + ,'ACCEPTED') THEN l_quote_deleted := FALSE; p_message := 'Unable to delete quote ' || p_qute_id || ' as it has a status of ' || INITCAP(l_qust_code); @@ -477,7 +480,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS WHERE qute_id = p_qute_id; DELETE FROM apex_application_files aaf - WHERE aaf.NAME IN (SELECT uri + WHERE aaf.name IN (SELECT uri FROM documents docu ,document_roles doro WHERE doro.qute_id = p_qute_id @@ -585,7 +588,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS FOR cur_quote IN (SELECT v.qute_id FROM v_current_quote_status v ,quotes q - WHERE v.qust_code IN ('AV', 'SELECTED') + WHERE v.qust_code IN ('AV' + ,'SELECTED') AND v.qute_id = q.id AND q.valid_until < l_current_date) LOOP @@ -629,7 +633,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS ,created_on ,created_by) VALUES - (qute_seq.NEXTVAL + (qute_seq.nextval ,p_manual_or_automatic ,p_enqu_id ,trunc(SYSDATE) @@ -730,8 +734,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS END mark_enquiry_invalid; FUNCTION get_system_configuration_value(p_parameter IN system_configuration.parameter%TYPE) - RETURN system_configuration.VALUE%TYPE IS - l_value system_configuration.VALUE%TYPE; + RETURN system_configuration.value%TYPE IS + l_value system_configuration.value%TYPE; BEGIN SELECT VALUE INTO l_value @@ -747,38 +751,38 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS RETURN 'SYSTEM_CONFIGURATION ERROR - PARAMETER ''' || p_parameter || ''' NOT FOUND'; END get_system_configuration_value; - FUNCTION get_manual_quote_recipient RETURN system_configuration.VALUE%TYPE IS + FUNCTION get_manual_quote_recipient RETURN system_configuration.value%TYPE IS BEGIN RETURN get_system_configuration_value('EMAIL_ADDRESS_MANUAL_QUOTE'); END get_manual_quote_recipient; FUNCTION get_automatic_quote_recipient - RETURN system_configuration.VALUE%TYPE IS + RETURN system_configuration.value%TYPE IS BEGIN RETURN get_system_configuration_value('EMAIL_ADDRESS_AUTOMATIC_QUOTE'); END get_automatic_quote_recipient; - FUNCTION get_support_recipient RETURN system_configuration.VALUE%TYPE IS + FUNCTION get_support_recipient RETURN system_configuration.value%TYPE IS BEGIN RETURN get_system_configuration_value('EMAIL_ADDRESS_SUPPORT'); END get_support_recipient; - FUNCTION get_internal_user_recipient RETURN system_configuration.VALUE%TYPE IS + FUNCTION get_internal_user_recipient RETURN system_configuration.value%TYPE IS BEGIN RETURN get_system_configuration_value('EMAIL_ADDRESS_INTERNAL_USER'); END get_internal_user_recipient; - FUNCTION get_system_name RETURN system_configuration.VALUE%TYPE IS + FUNCTION get_system_name RETURN system_configuration.value%TYPE IS BEGIN RETURN 'WEBMIP ' || v('SYSTEM_ENVIRONMENT'); END get_system_name; FUNCTION get_customer_support_telephone - RETURN system_configuration.VALUE%TYPE IS + RETURN system_configuration.value%TYPE IS BEGIN RETURN get_system_configuration_value('TELEPHONE_CUSTOMER_SUPPORT'); @@ -834,7 +838,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS ,l_doc_details.content FROM documents docu ,apex_application_files wff - WHERE docu.uri = wff.NAME + WHERE docu.uri = wff.name AND docu.id = l_docu_id; pl('l_doc_details.content.length=' || @@ -864,12 +868,12 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS pl('open_body:entry'); dbms_lob.createtemporary(lob_loc => g_email_plain_body ,cache => TRUE); - dbms_lob.OPEN(lob_loc => g_email_plain_body + dbms_lob.open(lob_loc => g_email_plain_body ,open_mode => dbms_lob.lob_readwrite); dbms_lob.createtemporary(lob_loc => g_email_html_body ,cache => TRUE); - dbms_lob.OPEN(lob_loc => g_email_html_body + dbms_lob.open(lob_loc => g_email_html_body ,open_mode => dbms_lob.lob_readwrite); dbms_lob.writeappend(g_email_html_body ,LENGTH('') @@ -1456,12 +1460,12 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,p_mandatory_checks => l_mandatory_checks ,p_enquiry_is_ready => l_enquiry_is_ready); - l_idx := l_mandatory_checks.FIRST; + l_idx := l_mandatory_checks.first; LOOP EXIT WHEN l_idx IS NULL; pl(l_mandatory_checks(l_idx) .field_name || ':' || l_mandatory_checks(l_idx).error_message); - l_idx := l_mandatory_checks.NEXT(l_idx); + l_idx := l_mandatory_checks.next(l_idx); END LOOP; RETURN l_enquiry_is_ready; @@ -1478,7 +1482,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF NOT mip_enquiries_helper.check_mandatory(p_rec => p_rec ,p_mandatory_checks => l_mandatory_checks) THEN - l_idx := l_mandatory_checks.FIRST; + l_idx := l_mandatory_checks.first; LOOP EXIT WHEN l_idx IS NULL; INSERT INTO validation_results @@ -1489,7 +1493,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); (p_rec.id ,l_mandatory_checks(l_idx).field_name ,l_mandatory_checks(l_idx).error_message); - l_idx := l_mandatory_checks.NEXT(l_idx); + l_idx := l_mandatory_checks.next(l_idx); END LOOP; END IF; @@ -1540,13 +1544,12 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,p_mandatory_checks => l_mandatory_checks ,p_enquiry_is_ready => l_enquiry_is_ready); - l_idx := l_mandatory_checks.FIRST; + l_idx := l_mandatory_checks.first; LOOP EXIT WHEN l_idx IS NULL; - l_mandatory_messages := l_mandatory_checks(l_idx) - .field_name || ':' || - l_mandatory_checks(l_idx).error_message; - l_idx := l_mandatory_checks.NEXT(l_idx); + l_mandatory_messages := l_mandatory_checks(l_idx).field_name || ':' || l_mandatory_checks(l_idx) + .error_message; + l_idx := l_mandatory_checks.next(l_idx); END LOOP; RETURN l_mandatory_messages; @@ -1749,7 +1752,9 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); -- get existing meter details l_rec_metr_details := get_existing_metr_details(p_enqu); - IF l_rec_metr_details.mety_code IN ('ROTARY', 'TURBINE') THEN + IF l_rec_metr_details.mety_code IN + ('ROTARY' + ,'TURBINE') THEN l_manual_or_automatic_quote := gc_manual_quote; add_quote_reason(p_enqu.id ,'Site Survey is required for OFMAT of an existing ' || @@ -1781,11 +1786,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); -- processing an enquiry that has not passed the tripartite agreement -- infers a processing error IF NOT l_valid THEN - l_idx := l_tab_messages.FIRST; + l_idx := l_tab_messages.first; LOOP EXIT WHEN l_idx IS NULL; l_return := l_return || l_tab_messages(l_idx); - l_idx := l_tab_messages.NEXT(l_idx); + l_idx := l_tab_messages.next(l_idx); END LOOP; END IF; @@ -1808,13 +1813,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); -- processing an enquiry that has not passed the tripartite agreement -- infers a processing error IF NOT l_valid THEN - l_idx := l_tab_messages.FIRST; + l_idx := l_tab_messages.first; LOOP EXIT WHEN l_idx IS NULL; add_quote_reason(p_enqu_id => p_enqu_id ,p_reason => l_tab_messages(l_idx) ,p_internal_or_external => gc_external_reason); - l_idx := l_tab_messages.NEXT(l_idx); + l_idx := l_tab_messages.next(l_idx); END LOOP; mark_enquiry_invalid(p_enqu_id); @@ -1835,7 +1840,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,$$PLSQL_LINE); p_manual_or_automatic_quote := gc_automatic_quote; - IF p_enqu.enty_code IN ('OTHER', 'CHANGE CAPACITY') THEN + IF p_enqu.enty_code IN ('OTHER' + ,'CHANGE CAPACITY') THEN p_manual_or_automatic_quote := gc_manual_quote; add_quote_reason(p_enqu.id ,'Enquiry type is ''' || @@ -1908,7 +1914,10 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); END IF; IF p_enqu.existing_convertor = 'YES' - AND p_enqu.enty_code NOT IN ('REMOVE', 'STD REMOVE', 'ADVERSARIAL') THEN + AND + p_enqu.enty_code NOT IN ('REMOVE' + ,'STD REMOVE' + ,'ADVERSARIAL') THEN p_manual_or_automatic_quote := gc_manual_quote; add_quote_reason(p_enqu.id ,'Convertor is present.' @@ -1916,7 +1925,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); END IF; IF p_enqu.existing_logger = 'YES' - AND p_enqu.enty_code IN ('EXCHANGE', 'STD EXCHANGE') THEN + AND p_enqu.enty_code IN ('EXCHANGE' + ,'STD EXCHANGE') THEN p_manual_or_automatic_quote := gc_manual_quote; add_quote_reason(p_enqu.id ,'Logger is present.' @@ -1934,8 +1944,12 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,gc_external_reason); END IF; - IF p_enqu.enty_code IN ('OFMAT', 'EXCHANGE', 'STD EXCHANGE', 'REMOVE', - 'STD REMOVE', 'ADVERSARIAL') + IF p_enqu.enty_code IN ('OFMAT' + ,'EXCHANGE' + ,'STD EXCHANGE' + ,'REMOVE' + ,'STD REMOVE' + ,'ADVERSARIAL') AND p_enqu.existing_metr_code IS NULL AND (p_enqu.existing_mesc_code IS NULL OR p_enqu.existing_mesc_code = 'OTHER' OR @@ -2168,7 +2182,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,selling_price ,cost_price ,delivery_cost - ,cost.ROWID + ,cost.rowid ,svcp.code AS svcp_code FROM v_laco cost ,service_pressures svcp @@ -2322,8 +2336,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); p_enqu.enty_code ,$$PLSQL_LINE); cout_assert.istrue(p_enqu.enty_code IN - ('INSTALL', 'STD INSTALL', 'EXCHANGE', - 'CAPACITY CHANGE', 'STD EXCHANGE') + ('INSTALL' + ,'STD INSTALL' + ,'EXCHANGE' + ,'CAPACITY CHANGE' + ,'STD EXCHANGE') ,'Attempted to produce an install or exchange quote for enquiry of type ' || p_enqu.enty_code); @@ -2331,20 +2348,22 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,'Attempted to produce an install, exchange or change of capacity quote for enquiry for a installation postcode (' || p_enqu.install_postcode || ') without a region.'); - IF p_enqu.enty_code IN ('INSTALL', 'STD INSTALL') THEN + IF p_enqu.enty_code IN ('INSTALL' + ,'STD INSTALL') THEN add_quote_reason(p_enqu.id - ,p_reason => 'Attempting an automatic installation quote for ' || - p_enqu.id || '.' + ,p_reason => 'Attempting an automatic installation quote for ' || + p_enqu.id || '.' ,p_internal_or_external => gc_internal_reason); - ELSIF p_enqu.enty_code IN ('EXCHANGE', 'STD EXCHANGE') THEN + ELSIF p_enqu.enty_code IN ('EXCHANGE' + ,'STD EXCHANGE') THEN add_quote_reason(p_enqu.id - ,p_reason => 'Attempting an automatic exchange quote for ' || - p_enqu.id || '.' + ,p_reason => 'Attempting an automatic exchange quote for ' || + p_enqu.id || '.' ,p_internal_or_external => gc_internal_reason); ELSIF p_enqu.enty_code IN ('CHANGE CAPACITY') THEN add_quote_reason(p_enqu.id - ,p_reason => 'Attempting an automatic change capacity quote for ' || - p_enqu.id || '.' + ,p_reason => 'Attempting an automatic change capacity quote for ' || + p_enqu.id || '.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -2379,59 +2398,64 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); 'and required Meter Size Code ' || l_required_mesc_code END || '.'); - FOR l_rec_module IN (SELECT modu.code AS modu_code - ,modu.selling_price AS modu_selling_price - ,modu.cost_price AS modu_cost_price - ,modu.delivery_cost AS modu_delivery_cost - ,NULL AS modu_lead_time - ,modu.hou_code AS hou_code - ,modu.inlet_orientation AS modu_inlet_orientation + FOR l_rec_module IN (SELECT modu.code AS modu_code + ,modu.selling_price AS modu_selling_price + ,modu.cost_price AS modu_cost_price + ,modu.delivery_cost AS modu_delivery_cost + ,NULL AS modu_lead_time + ,modu.hou_code AS hou_code + ,modu.inlet_orientation AS modu_inlet_orientation ,modu.outlet_orientation AS modu_outlet_orientation ,modu.qmax - ,NULL AS hou_selling_price - ,NULL AS hou_cost_price - ,NULL AS hou_delivery_cost - ,modu.bas_code AS bas_code - ,NULL AS bas_selling_price - ,NULL AS bas_cost_price - ,NULL AS bas_delivery_cost - ,metr.code AS metr_code + ,NULL AS hou_selling_price + ,NULL AS hou_cost_price + ,NULL AS hou_delivery_cost + ,modu.bas_code AS bas_code + ,NULL AS bas_selling_price + ,NULL AS bas_cost_price + ,NULL AS bas_delivery_cost + ,metr.code AS metr_code ,metr.qnom - ,metr.qmax AS metr_qmax + ,metr.qmax AS metr_qmax ,metr.qmin ,metr.mesc_code ,metr.mety_code - ,NULL AS laco_mety_code - ,NULL AS laco_svcpt_code - ,NULL AS laco_mesc_code - ,NULL AS laco_selling_price - ,NULL AS laco_cost_price - ,NULL AS laco_delivery_cost - ,NULL AS amr_cost_id - ,NULL AS amr_selling_price - ,NULL AS amr_cost_price - ,NULL AS amr_delivery_cost - ,NULL AS amr_lead_time - ,NULL AS ems_cost_id - ,NULL AS ems_selling_price - ,NULL AS ems_cost_price - ,NULL AS ems_delivery_cost - ,NULL AS ems_lead_time - ,NULL AS bypass_cost_id - ,NULL AS bypass_selling_price - ,NULL AS bypass_cost_price - ,NULL AS bypass_delivery_cost - ,NULL AS bypass_lead_time - ,NULL AS lifting_gear_cost_id - ,NULL AS lifting_gear_selling_price - ,NULL AS lifting_gear_cost_price - ,NULL AS lifting_gear_delivery_cost - ,NULL AS lifting_gear_lead_time - ,NULL AS purging_cost_id - ,NULL AS purging_selling_price - ,NULL AS purging_cost_price - ,NULL AS purging_delivery_cost - ,NULL AS purging_lead_time + ,NULL AS laco_mety_code + ,NULL AS laco_svcpt_code + ,NULL AS laco_mesc_code + ,NULL AS laco_selling_price + ,NULL AS laco_cost_price + ,NULL AS laco_delivery_cost + ,NULL AS amr_cost_id + ,NULL AS amr_selling_price + ,NULL AS amr_cost_price + ,NULL AS amr_delivery_cost + ,NULL AS amr_lead_time + ,NULL AS ems_cost_id + ,NULL AS ems_selling_price + ,NULL AS ems_cost_price + ,NULL AS ems_delivery_cost + ,NULL AS ems_lead_time + ,NULL AS bypass_cost_id + ,NULL AS bypass_selling_price + ,NULL AS bypass_cost_price + ,NULL AS bypass_delivery_cost + ,NULL AS bypass_lead_time + ,NULL AS lifting_gear_cost_id + ,NULL AS lifting_gear_selling_price + ,NULL AS lifting_gear_cost_price + ,NULL AS lifting_gear_delivery_cost + ,NULL AS lifting_gear_lead_time + ,NULL AS purging_cost_id + ,NULL AS purging_selling_price + ,NULL AS purging_cost_price + ,NULL AS purging_delivery_cost + ,NULL AS purging_lead_time + ,NULL AS self_purging_cost_id + ,NULL AS self_purging_selling_price + ,NULL AS self_purging_cost_price + ,NULL AS self_purging_delivery_cost + ,NULL AS self_purging_lead_time FROM (SELECT modu.code ,modu.metr_code ,modu.hou_code @@ -2493,8 +2517,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); (modu.qmax >= l_required_qmax))) LOOP l_this_is_automatic_quote := TRUE; add_quote_reason(p_enqu.id - ,p_reason => 'Considering module : ' || - l_rec_module.modu_code + ,p_reason => 'Considering module : ' || + l_rec_module.modu_code ,p_internal_or_external => gc_internal_reason); -- -- check whether we have the required prices @@ -2503,9 +2527,15 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.modu_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for module ' || - l_rec_module.modu_code || CASE - l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.' + ,p_reason => 'Unable to find selling price for module ' || + l_rec_module.modu_code || + CASE l_regi_code + WHEN NULL THEN + '' + ELSE + ' for region code ' || + l_regi_code + END || '.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -2516,12 +2546,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.modu_lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for module ' || - l_rec_module.modu_code || '. (' || - get_lead_time_desc(p_enty_code => p_enqu.enty_code - ,p_mety_code => p_enqu.existing_mety_code - ,p_svcp_code => p_enqu.required_svcp_code - ,p_qmax => p_enqu.qmax) || ')' + ,p_reason => 'Unable to find lead time for module ' || + l_rec_module.modu_code || + '. (' || + get_lead_time_desc(p_enty_code => p_enqu.enty_code + ,p_mety_code => p_enqu.existing_mety_code + ,p_svcp_code => p_enqu.required_svcp_code + ,p_qmax => p_enqu.qmax) || ')' ,p_internal_or_external => gc_internal_reason); END IF; @@ -2545,8 +2576,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ', Meter Size Code:' || l_rec_module.mesc_code || ', Service Pressure Code:' || - p_enqu.required_svcp_code || CASE - l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.' + p_enqu.required_svcp_code || + CASE l_regi_code + WHEN NULL THEN + '' + ELSE + ' for region code ' || l_regi_code + END || '.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -2561,14 +2597,14 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.bas_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for base ' || - l_rec_module.bas_code || '.' + ,p_reason => 'Unable to find selling price for base ' || + l_rec_module.bas_code || '.' ,p_internal_or_external => gc_internal_reason); END IF; ELSE l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Module is not available with base.' + ,p_reason => 'Module is not available with base.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -2583,14 +2619,14 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.hou_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for housing ' || - l_rec_module.hou_code || '.' + ,p_reason => 'Unable to find selling price for housing ' || + l_rec_module.hou_code || '.' ,p_internal_or_external => gc_internal_reason); END IF; ELSE l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Module is not available with housing.' + ,p_reason => 'Module is not available with housing.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -2608,13 +2644,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.amr_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for AMR.' + ,p_reason => 'Unable to find selling price for AMR.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_rec_module.amr_lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for AMR.' + ,p_reason => 'Unable to find lead time for AMR.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -2631,13 +2667,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.ems_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for EMS.' + ,p_reason => 'Unable to find selling price for EMS.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_rec_module.ems_lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for EMS.' + ,p_reason => 'Unable to find lead time for EMS.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -2655,13 +2691,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.bypass_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for BYPASS.' + ,p_reason => 'Unable to find selling price for BYPASS.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_rec_module.bypass_lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for BYPASS.' + ,p_reason => 'Unable to find lead time for BYPASS.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -2683,7 +2719,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.purging_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for PURGING.' + ,p_reason => 'Unable to find selling price for PURGING.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -2698,6 +2734,16 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); l_rec_module.purging_lead_time := NULL; END IF; + -- + -- Purging to be performed by customer + -- + IF p_enqu.purging_required = 'NO' THEN + l_rec_module.self_purging_selling_price := NULL; + l_rec_module.self_purging_cost_price := NULL; + l_rec_module.self_purging_delivery_cost := NULL; + l_rec_module.self_purging_lead_time := NULL; + END IF; + /* Lifting gear required UNLESS LP Diaphragm */ IF NOT (l_rec_module.mety_code = 'DIAPHRAGM' AND l_rec_module.laco_svcpt_code = 'LP') THEN @@ -2714,13 +2760,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_rec_module.lifting_gear_selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for LIFTING GEAR.' + ,p_reason => 'Unable to find selling price for LIFTING GEAR.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_rec_module.lifting_gear_lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for LIFTING GEAR.' + ,p_reason => 'Unable to find lead time for LIFTING GEAR.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -2750,7 +2796,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,p_enqu.enty_code ,l_rec_module.laco_mety_code @@ -2775,7 +2821,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,delivery_price ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,l_rec_module.modu_code ,l_rec_module.qmax @@ -2797,7 +2843,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,delivery_price ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,l_rec_module.hou_code ,l_rec_module.hou_cost_price @@ -2816,7 +2862,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,delivery_price ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,l_rec_module.bas_code ,l_rec_module.bas_cost_price @@ -2836,7 +2882,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'AMR' ,l_rec_module.amr_cost_price @@ -2857,7 +2903,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'EMS' ,l_rec_module.ems_cost_price @@ -2878,7 +2924,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'BYPASS' ,l_rec_module.bypass_cost_price @@ -2888,7 +2934,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,'AQI'); END IF; - IF p_enqu.purging_required IN ('TM', 'FC') + IF p_enqu.purging_required IN ('TM' + ,'FC') OR p_enqu.enty_code = 'ADVERSARIAL' THEN INSERT INTO quote_items (id @@ -2900,7 +2947,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'PURGING' ,l_rec_module.purging_cost_price @@ -2910,6 +2957,27 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,'AQI'); END IF; + IF p_enqu.purging_required IN ('NO') THEN + INSERT INTO quote_items + (id + ,qute_id + ,adit_code + ,cost_price + ,selling_price + ,delivery_price + ,lead_time + ,quit_type) + VALUES + (quit_seq.nextval + ,l_qute_id + ,'SELFPURGING' + ,l_rec_module.self_purging_cost_price + ,l_rec_module.self_purging_selling_price + ,l_rec_module.self_purging_delivery_cost + ,l_rec_module.self_purging_lead_time + ,'AQI'); + END IF; + IF l_rec_module.lifting_gear_selling_price IS NOT NULL THEN INSERT INTO quote_items @@ -2922,7 +2990,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'LIFTING GEAR' ,l_rec_module.lifting_gear_cost_price @@ -2983,7 +3051,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); BEGIN pl('produce_install_quotes' ,$$PLSQL_LINE); - cout_assert.istrue(p_enqu.enty_code IN ('STD INSTALL', 'INSTALL') + cout_assert.istrue(p_enqu.enty_code IN ('STD INSTALL' + ,'INSTALL') ,'Attempted to produce an installation quote for enquiry of type ' || p_enqu.enty_code); @@ -3008,7 +3077,9 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); BEGIN pl('produce_exchange_quotes:entry:' || p_enqu.enty_code ,$$PLSQL_LINE); - cout_assert.istrue(p_enqu.enty_code IN ('EXCHANGE', 'STD EXCHANGE') + cout_assert.istrue(p_enqu.enty_code IN + ('EXCHANGE' + ,'STD EXCHANGE') ,'Attempted to produce an exchange quote for enquiry of type ' || p_enqu.enty_code); @@ -3062,6 +3133,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); l_quote_document VARCHAR2(240); l_lifting_gear_costs t_rec_additional_costs; l_purging_costs t_rec_additional_costs; + l_self_purging_costs t_rec_additional_costs; l_required_qmax NUMBER; l_existing_rec_metr_details t_rec_metr_details; BEGIN @@ -3069,8 +3141,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); p_enqu.enty_code ,$$PLSQL_LINE); cout_assert.istrue(p_enqu.enty_code IN - ('REMOVE', 'STD REMOVE', 'ADVERSARIAL', 'OFMAT', - 'ALTERATION') + ('REMOVE' + ,'STD REMOVE' + ,'ADVERSARIAL' + ,'OFMAT' + ,'ALTERATION') ,'Attempted to produce a labour-only quote for enquiry of type ' || p_enqu.enty_code); @@ -3083,14 +3158,16 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); l_existing_rec_metr_details := get_existing_metr_details(p_enqu); add_quote_reason(p_enqu.id - ,p_reason => 'Attempting an automatic labour quote for ' || - p_enqu.id || '.' || 'Enquiry Code=' || - p_enqu.enty_code || ', SVCP ' || - p_enqu.required_svcp_code || - ', Meter Type Code=' || - l_existing_rec_metr_details.mety_code || - ', Meter Size Code=' || - l_existing_rec_metr_details.mesc_code || '.' + ,p_reason => 'Attempting an automatic labour quote for ' || + p_enqu.id || '.' || + 'Enquiry Code=' || + p_enqu.enty_code || + ', SVCP ' || + p_enqu.required_svcp_code || + ', Meter Type Code=' || + l_existing_rec_metr_details.mety_code || + ', Meter Size Code=' || + l_existing_rec_metr_details.mesc_code || '.' ,p_internal_or_external => gc_internal_reason); l_labour_costs := get_laco(p_enty_code => p_enqu.enty_code @@ -3107,8 +3184,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ', Meter Size Code:' || l_existing_rec_metr_details.mesc_code || ', Service Pressure Code:' || - p_enqu.required_svcp_code || CASE - l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.' + p_enqu.required_svcp_code || + CASE l_regi_code + WHEN NULL THEN + '' + ELSE + ' for region code ' || l_regi_code + END || '.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -3128,11 +3210,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for ' || - get_lead_time_desc(p_enty_code => p_enqu.enty_code - ,p_mety_code => l_existing_rec_metr_details.mety_code - ,p_svcp_code => p_enqu.required_svcp_code - ,p_qmax => p_enqu.qmax) + ,p_reason => 'Unable to find lead time for ' || + get_lead_time_desc(p_enty_code => p_enqu.enty_code + ,p_mety_code => l_existing_rec_metr_details.mety_code + ,p_svcp_code => p_enqu.required_svcp_code + ,p_qmax => p_enqu.qmax) ,p_internal_or_external => gc_internal_reason); END IF; @@ -3148,7 +3230,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_purging_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for PURGING.' + ,p_reason => 'Unable to find selling price for PURGING.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -3164,6 +3246,17 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); l_purging_costs.lead_time := NULL; END IF; + -- + -- Purging to be carried out by customer + -- + IF p_enqu.purging_required = 'TM' + OR p_enqu.enty_code = 'ADVERSARIAL' THEN + l_self_purging_costs.selling_price := NULL; + l_self_purging_costs.cost_price := NULL; + l_self_purging_costs.delivery_cost := NULL; + l_self_purging_costs.lead_time := NULL; + END IF; + /* Lifting gear required UNLESS LP Diaphragm */ IF NOT (l_existing_rec_metr_details.mety_code = 'DIAPHRAGM' AND l_labour_costs.svcpt_code = 'LP') THEN @@ -3176,14 +3269,14 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_lifting_gear_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for LIFTING GEAR.' + ,p_reason => 'Unable to find selling price for LIFTING GEAR.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_lifting_gear_costs.lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for LIFTING GEAR.' + ,p_reason => 'Unable to find lead time for LIFTING GEAR.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -3213,7 +3306,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,p_enqu.enty_code ,l_labour_costs.svcpt_code @@ -3236,7 +3329,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'LIFTING GEAR' ,l_lifting_gear_costs.cost_price @@ -3246,7 +3339,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,'AQI'); END IF; - IF p_enqu.purging_required IN ('TM', 'FC') THEN + IF p_enqu.purging_required IN ('TM' + ,'FC') THEN INSERT INTO quote_items (id ,qute_id @@ -3257,7 +3351,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'PURGING' ,l_purging_costs.cost_price @@ -3267,6 +3361,30 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,'AQI'); END IF; + -- + -- Purging to be carried out by customer + -- + IF p_enqu.purging_required IN ('NO') THEN + INSERT INTO quote_items + (id + ,qute_id + ,adit_code + ,cost_price + ,selling_price + ,delivery_price + ,lead_time + ,quit_type) + VALUES + (quit_seq.nextval + ,l_qute_id + ,'SELFPURGING' + ,l_self_purging_costs.cost_price + ,l_self_purging_costs.selling_price + ,l_self_purging_costs.delivery_cost + ,l_self_purging_costs.lead_time + ,'AQI'); + END IF; + -- Generate the quote PDF l_quote_document := mip_quotation_document.generate_quote_pdf(p_quote_id => l_qute_id); add_quote_reason(p_enqu_id => p_enqu.id @@ -3305,7 +3423,9 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,$$PLSQL_LINE); cout_assert.istrue(p_enqu.enty_code IN - ('REMOVE', 'STD REMOVE', 'ADVERSARIAL') + ('REMOVE' + ,'STD REMOVE' + ,'ADVERSARIAL') ,'Attempted to produce a removal quote for enquiry of type ' || p_enqu.enty_code); produce_labour_only_quotes(p_enqu => p_enqu @@ -3386,9 +3506,20 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); p_enqu.install_postcode || ') without a region.'); add_quote_reason(p_enqu.id - ,p_reason => 'Attempting an automatic addon quote for ' || - p_enqu.id || '.' || CASE - p_enqu.amr_required WHEN 'YES' THEN 'AMR is required. ' END || CASE p_enqu.ems_required WHEN 'YES' THEN 'EMS is required. ' END || CASE p_enqu.bypass_required WHEN 'YES' THEN 'Bypass is required. ' END + ,p_reason => 'Attempting an automatic addon quote for ' || + p_enqu.id || '.' || + CASE p_enqu.amr_required + WHEN 'YES' THEN + 'AMR is required. ' + END || + CASE p_enqu.ems_required + WHEN 'YES' THEN + 'EMS is required. ' + END || + CASE p_enqu.bypass_required + WHEN 'YES' THEN + 'Bypass is required. ' + END ,p_internal_or_external => gc_internal_reason); l_this_is_automatic_quote := TRUE; @@ -3408,13 +3539,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_amr_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for AMR.' + ,p_reason => 'Unable to find selling price for AMR.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_amr_costs.lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for AMR.' + ,p_reason => 'Unable to find lead time for AMR.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -3427,13 +3558,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_ems_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for EMS.' + ,p_reason => 'Unable to find selling price for EMS.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_ems_costs.lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for EMS.' + ,p_reason => 'Unable to find lead time for EMS.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -3446,13 +3577,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_bypass_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for BYPASS.' + ,p_reason => 'Unable to find selling price for BYPASS.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_bypass_costs.lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for BYPASS.' + ,p_reason => 'Unable to find lead time for BYPASS.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -3469,7 +3600,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_purging_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for PURGING.' + ,p_reason => 'Unable to find selling price for PURGING.' ,p_internal_or_external => gc_internal_reason); END IF; END IF; @@ -3497,13 +3628,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); IF l_lifting_gear_costs.selling_price IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find selling price for LIFTING GEAR.' + ,p_reason => 'Unable to find selling price for LIFTING GEAR.' ,p_internal_or_external => gc_internal_reason); END IF; IF l_lifting_gear_costs.lead_time IS NULL THEN l_this_is_automatic_quote := FALSE; add_quote_reason(p_enqu.id - ,p_reason => 'Unable to find lead time for LIFTING GEAR.' + ,p_reason => 'Unable to find lead time for LIFTING GEAR.' ,p_internal_or_external => gc_internal_reason); END IF; @@ -3532,7 +3663,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,delivery_price ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,p_enqu.enty_code ,p_enqu.existing_mety_code @@ -3556,7 +3687,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,p_enqu.enty_code ,p_enqu.existing_mety_code @@ -3581,7 +3712,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,p_enqu.enty_code ,p_enqu.existing_mety_code @@ -3593,7 +3724,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,'AQI'); END IF; - IF p_enqu.purging_required IN ('TM', 'FC') + IF p_enqu.purging_required IN ('TM' + ,'FC') OR p_enqu.enty_code = 'ADVERSARIAL' THEN INSERT INTO quote_items (id @@ -3605,7 +3737,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,'PURGING' ,l_purging_costs.cost_price @@ -3626,7 +3758,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); ,lead_time ,quit_type) VALUES - (quit_seq.NEXTVAL + (quit_seq.nextval ,l_qute_id ,l_lifting_gear_costs.adit_code ,l_lifting_gear_costs.cost_price @@ -3676,17 +3808,21 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.'); cout_assert.istrue(p_manual_or_automatic_quote = gc_automatic_quote ,p_message => 'Attempted to produce automatic quote for enquiry marked as manual only'); - IF p_enqu.enty_code IN ('INSTALL', 'STD INSTALL') THEN + IF p_enqu.enty_code IN ('INSTALL' + ,'STD INSTALL') THEN produce_install_quotes(p_enqu => p_enqu ,p_rfq_prty_id => p_rfq_prty_id ,p_owner_prty_id => p_owner_prty_id ,p_manual_or_automatic_quote => p_manual_or_automatic_quote); - ELSIF p_enqu.enty_code IN ('EXCHANGE', 'STD EXCHANGE') THEN + ELSIF p_enqu.enty_code IN ('EXCHANGE' + ,'STD EXCHANGE') THEN produce_exchange_quotes(p_enqu => p_enqu ,p_rfq_prty_id => p_rfq_prty_id ,p_owner_prty_id => p_owner_prty_id ,p_manual_or_automatic_quote => p_manual_or_automatic_quote); - ELSIF p_enqu.enty_code IN ('REMOVE', 'STD REMOVE', 'ADVERSARIAL') THEN + ELSIF p_enqu.enty_code IN ('REMOVE' + ,'STD REMOVE' + ,'ADVERSARIAL') THEN produce_removal_quotes(p_enqu => p_enqu ,p_rfq_prty_id => p_rfq_prty_id ,p_owner_prty_id => p_owner_prty_id