Include ADDITIONAL_ITEM 'SELFPURGING' to cover instances of 'purging' where the user has selected 'NO' - i.e. the customer will carry out any required purging. Used to simplify CAVEAT text selection.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@13258 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
andrew.hardy
2009-11-03 15:08:58 +00:00
parent b9a3a321f9
commit 1110407d42
2 changed files with 352 additions and 211 deletions

View File

@@ -1,35 +1,40 @@
DECLARE REM $Id$
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';
BEGIN BEGIN
dbms_output.enable;
dbms_output.put_line('UpgradeBulkLoad: Add SELFPURGING to ADDITIONAL_ITEMS');
IF l_test_load THEN UPDATE additional_items
mip_bulk_load.g_flow_id := 102; SET description = 'No Purging Required'
ELSIF l_fat_load THEN ,lead_time = 0
mip_bulk_load.g_flow_id := 200; WHERE code = 'SELFPURGING';
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;
IF mip_bulk_load.g_flow_id IS NOT NULL THEN IF SQL%ROWCOUNT <> 0 THEN
dbms_output.put_line('UpgradeBulkLoad: Upgrade Bulk Load Not Required'); dbms_output.put_line('UpgradeBulkLoad: - Done (Update)');
--mip_bulk_load.init;
--mip_bulk_load.load_caveats;
--mip_bulk_load.report_err;
ELSE 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; 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; END;
/ /
exit exit
/

View File

@@ -213,10 +213,12 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
PROCEDURE pl(p_in VARCHAR2 PROCEDURE pl(p_in VARCHAR2
,p_line IN NUMBER DEFAULT NULL) IS ,p_line IN NUMBER DEFAULT NULL) IS
BEGIN BEGIN
$IF mip_debug_constants.debugging OR mip_debug_constants.quotation $THEN mip_debug.pl(p_unit => $$PLSQL_UNIT $IF mip_debug_constants.debugging OR mip_debug_constants.quotation $THEN
mip_debug.pl(p_unit => $$PLSQL_UNIT
,p_line => p_line ,p_line => p_line
,p_in => p_in); ,p_in => p_in);
$END NULL; $END
NULL;
END pl; END pl;
PROCEDURE add_quote_reason(p_enqu_id IN enquiries.id%TYPE PROCEDURE add_quote_reason(p_enqu_id IN enquiries.id%TYPE
@@ -237,7 +239,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,1 ,1
,239) ,239)
,p_internal_or_external ,p_internal_or_external
,qure_seq.NEXTVAL); ,qure_seq.nextval);
EXCEPTION EXCEPTION
WHEN OTHERS THEN WHEN OTHERS THEN
pl('add_quote_reason:' || SQLERRM pl('add_quote_reason:' || SQLERRM
@@ -264,7 +266,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,p_qust_code ,p_qust_code
,p_event_date ,p_event_date
,p_description ,p_description
,quev_seq.NEXTVAL); ,quev_seq.nextval);
pl('add_quote_event:exit' pl('add_quote_event:exit'
,$$PLSQL_LINE); ,$$PLSQL_LINE);
END add_quote_event; END add_quote_event;
@@ -285,7 +287,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,p_enst_code ,p_enst_code
,p_event_date ,p_event_date
,p_description ,p_description
,enev_seq.NEXTVAL); ,enev_seq.nextval);
END add_enquiry_event; END add_enquiry_event;
PROCEDURE add_quote_role(p_qute_id IN quotes.id%TYPE 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 FROM v_current_quote_status
WHERE qute_id = p_qute_id; 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; l_quote_deleted := FALSE;
p_message := 'Unable to delete quote ' || p_qute_id || p_message := 'Unable to delete quote ' || p_qute_id ||
' as it has a status of ' || INITCAP(l_qust_code); ' 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; WHERE qute_id = p_qute_id;
DELETE FROM apex_application_files aaf DELETE FROM apex_application_files aaf
WHERE aaf.NAME IN (SELECT uri WHERE aaf.name IN (SELECT uri
FROM documents docu FROM documents docu
,document_roles doro ,document_roles doro
WHERE doro.qute_id = p_qute_id 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 FOR cur_quote IN (SELECT v.qute_id
FROM v_current_quote_status v FROM v_current_quote_status v
,quotes q ,quotes q
WHERE v.qust_code IN ('AV', 'SELECTED') WHERE v.qust_code IN ('AV'
,'SELECTED')
AND v.qute_id = q.id AND v.qute_id = q.id
AND q.valid_until < l_current_date) LOOP AND q.valid_until < l_current_date) LOOP
@@ -629,7 +633,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,created_on ,created_on
,created_by) ,created_by)
VALUES VALUES
(qute_seq.NEXTVAL (qute_seq.nextval
,p_manual_or_automatic ,p_manual_or_automatic
,p_enqu_id ,p_enqu_id
,trunc(SYSDATE) ,trunc(SYSDATE)
@@ -730,8 +734,8 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
END mark_enquiry_invalid; END mark_enquiry_invalid;
FUNCTION get_system_configuration_value(p_parameter IN system_configuration.parameter%TYPE) FUNCTION get_system_configuration_value(p_parameter IN system_configuration.parameter%TYPE)
RETURN system_configuration.VALUE%TYPE IS RETURN system_configuration.value%TYPE IS
l_value system_configuration.VALUE%TYPE; l_value system_configuration.value%TYPE;
BEGIN BEGIN
SELECT VALUE SELECT VALUE
INTO l_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'; RETURN 'SYSTEM_CONFIGURATION ERROR - PARAMETER ''' || p_parameter || ''' NOT FOUND';
END get_system_configuration_value; 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 BEGIN
RETURN get_system_configuration_value('EMAIL_ADDRESS_MANUAL_QUOTE'); RETURN get_system_configuration_value('EMAIL_ADDRESS_MANUAL_QUOTE');
END get_manual_quote_recipient; END get_manual_quote_recipient;
FUNCTION get_automatic_quote_recipient FUNCTION get_automatic_quote_recipient
RETURN system_configuration.VALUE%TYPE IS RETURN system_configuration.value%TYPE IS
BEGIN BEGIN
RETURN get_system_configuration_value('EMAIL_ADDRESS_AUTOMATIC_QUOTE'); RETURN get_system_configuration_value('EMAIL_ADDRESS_AUTOMATIC_QUOTE');
END get_automatic_quote_recipient; 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 BEGIN
RETURN get_system_configuration_value('EMAIL_ADDRESS_SUPPORT'); RETURN get_system_configuration_value('EMAIL_ADDRESS_SUPPORT');
END get_support_recipient; 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 BEGIN
RETURN get_system_configuration_value('EMAIL_ADDRESS_INTERNAL_USER'); RETURN get_system_configuration_value('EMAIL_ADDRESS_INTERNAL_USER');
END get_internal_user_recipient; 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 BEGIN
RETURN 'WEBMIP ' || v('SYSTEM_ENVIRONMENT'); RETURN 'WEBMIP ' || v('SYSTEM_ENVIRONMENT');
END get_system_name; END get_system_name;
FUNCTION get_customer_support_telephone FUNCTION get_customer_support_telephone
RETURN system_configuration.VALUE%TYPE IS RETURN system_configuration.value%TYPE IS
BEGIN BEGIN
RETURN get_system_configuration_value('TELEPHONE_CUSTOMER_SUPPORT'); RETURN get_system_configuration_value('TELEPHONE_CUSTOMER_SUPPORT');
@@ -834,7 +838,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,l_doc_details.content ,l_doc_details.content
FROM documents docu FROM documents docu
,apex_application_files wff ,apex_application_files wff
WHERE docu.uri = wff.NAME WHERE docu.uri = wff.name
AND docu.id = l_docu_id; AND docu.id = l_docu_id;
pl('l_doc_details.content.length=' || pl('l_doc_details.content.length=' ||
@@ -864,12 +868,12 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
pl('open_body:entry'); pl('open_body:entry');
dbms_lob.createtemporary(lob_loc => g_email_plain_body dbms_lob.createtemporary(lob_loc => g_email_plain_body
,cache => TRUE); ,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); ,open_mode => dbms_lob.lob_readwrite);
dbms_lob.createtemporary(lob_loc => g_email_html_body dbms_lob.createtemporary(lob_loc => g_email_html_body
,cache => TRUE); ,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); ,open_mode => dbms_lob.lob_readwrite);
dbms_lob.writeappend(g_email_html_body dbms_lob.writeappend(g_email_html_body
,LENGTH('<html><body>') ,LENGTH('<html><body>')
@@ -1456,12 +1460,12 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,p_mandatory_checks => l_mandatory_checks ,p_mandatory_checks => l_mandatory_checks
,p_enquiry_is_ready => l_enquiry_is_ready); ,p_enquiry_is_ready => l_enquiry_is_ready);
l_idx := l_mandatory_checks.FIRST; l_idx := l_mandatory_checks.first;
LOOP LOOP
EXIT WHEN l_idx IS NULL; EXIT WHEN l_idx IS NULL;
pl(l_mandatory_checks(l_idx) pl(l_mandatory_checks(l_idx)
.field_name || ':' || l_mandatory_checks(l_idx).error_message); .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 LOOP;
RETURN l_enquiry_is_ready; RETURN l_enquiry_is_ready;
@@ -1478,7 +1482,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
IF NOT IF NOT
mip_enquiries_helper.check_mandatory(p_rec => p_rec mip_enquiries_helper.check_mandatory(p_rec => p_rec
,p_mandatory_checks => l_mandatory_checks) THEN ,p_mandatory_checks => l_mandatory_checks) THEN
l_idx := l_mandatory_checks.FIRST; l_idx := l_mandatory_checks.first;
LOOP LOOP
EXIT WHEN l_idx IS NULL; EXIT WHEN l_idx IS NULL;
INSERT INTO validation_results INSERT INTO validation_results
@@ -1489,7 +1493,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
(p_rec.id (p_rec.id
,l_mandatory_checks(l_idx).field_name ,l_mandatory_checks(l_idx).field_name
,l_mandatory_checks(l_idx).error_message); ,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 LOOP;
END IF; END IF;
@@ -1540,13 +1544,12 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,p_mandatory_checks => l_mandatory_checks ,p_mandatory_checks => l_mandatory_checks
,p_enquiry_is_ready => l_enquiry_is_ready); ,p_enquiry_is_ready => l_enquiry_is_ready);
l_idx := l_mandatory_checks.FIRST; l_idx := l_mandatory_checks.first;
LOOP LOOP
EXIT WHEN l_idx IS NULL; EXIT WHEN l_idx IS NULL;
l_mandatory_messages := l_mandatory_checks(l_idx) l_mandatory_messages := l_mandatory_checks(l_idx).field_name || ':' || l_mandatory_checks(l_idx)
.field_name || ':' || .error_message;
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 LOOP;
RETURN l_mandatory_messages; RETURN l_mandatory_messages;
@@ -1749,7 +1752,9 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
-- get existing meter details -- get existing meter details
l_rec_metr_details := get_existing_metr_details(p_enqu); 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; l_manual_or_automatic_quote := gc_manual_quote;
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,'Site Survey is required for OFMAT of an existing ' || ,'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 -- processing an enquiry that has not passed the tripartite agreement
-- infers a processing error -- infers a processing error
IF NOT l_valid THEN IF NOT l_valid THEN
l_idx := l_tab_messages.FIRST; l_idx := l_tab_messages.first;
LOOP LOOP
EXIT WHEN l_idx IS NULL; EXIT WHEN l_idx IS NULL;
l_return := l_return || l_tab_messages(l_idx); 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 LOOP;
END IF; END IF;
@@ -1808,13 +1813,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
-- processing an enquiry that has not passed the tripartite agreement -- processing an enquiry that has not passed the tripartite agreement
-- infers a processing error -- infers a processing error
IF NOT l_valid THEN IF NOT l_valid THEN
l_idx := l_tab_messages.FIRST; l_idx := l_tab_messages.first;
LOOP LOOP
EXIT WHEN l_idx IS NULL; EXIT WHEN l_idx IS NULL;
add_quote_reason(p_enqu_id => p_enqu_id add_quote_reason(p_enqu_id => p_enqu_id
,p_reason => l_tab_messages(l_idx) ,p_reason => l_tab_messages(l_idx)
,p_internal_or_external => gc_external_reason); ,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; END LOOP;
mark_enquiry_invalid(p_enqu_id); mark_enquiry_invalid(p_enqu_id);
@@ -1835,7 +1840,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,$$PLSQL_LINE); ,$$PLSQL_LINE);
p_manual_or_automatic_quote := gc_automatic_quote; 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; p_manual_or_automatic_quote := gc_manual_quote;
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,'Enquiry type is ''' || ,'Enquiry type is ''' ||
@@ -1908,7 +1914,10 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
END IF; END IF;
IF p_enqu.existing_convertor = 'YES' 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; p_manual_or_automatic_quote := gc_manual_quote;
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,'Convertor is present.' ,'Convertor is present.'
@@ -1916,7 +1925,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
END IF; END IF;
IF p_enqu.existing_logger = 'YES' 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; p_manual_or_automatic_quote := gc_manual_quote;
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,'Logger is present.' ,'Logger is present.'
@@ -1934,8 +1944,12 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,gc_external_reason); ,gc_external_reason);
END IF; END IF;
IF p_enqu.enty_code IN ('OFMAT', 'EXCHANGE', 'STD EXCHANGE', 'REMOVE', IF p_enqu.enty_code IN ('OFMAT'
'STD REMOVE', 'ADVERSARIAL') ,'EXCHANGE'
,'STD EXCHANGE'
,'REMOVE'
,'STD REMOVE'
,'ADVERSARIAL')
AND p_enqu.existing_metr_code IS NULL AND p_enqu.existing_metr_code IS NULL
AND (p_enqu.existing_mesc_code IS NULL OR AND (p_enqu.existing_mesc_code IS NULL OR
p_enqu.existing_mesc_code = 'OTHER' OR p_enqu.existing_mesc_code = 'OTHER' OR
@@ -2168,7 +2182,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,selling_price ,selling_price
,cost_price ,cost_price
,delivery_cost ,delivery_cost
,cost.ROWID ,cost.rowid
,svcp.code AS svcp_code ,svcp.code AS svcp_code
FROM v_laco cost FROM v_laco cost
,service_pressures svcp ,service_pressures svcp
@@ -2322,8 +2336,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
p_enqu.enty_code p_enqu.enty_code
,$$PLSQL_LINE); ,$$PLSQL_LINE);
cout_assert.istrue(p_enqu.enty_code IN cout_assert.istrue(p_enqu.enty_code IN
('INSTALL', 'STD INSTALL', 'EXCHANGE', ('INSTALL'
'CAPACITY CHANGE', 'STD EXCHANGE') ,'STD INSTALL'
,'EXCHANGE'
,'CAPACITY CHANGE'
,'STD EXCHANGE')
,'Attempted to produce an install or exchange quote for enquiry of type ' || ,'Attempted to produce an install or exchange quote for enquiry of type ' ||
p_enqu.enty_code); p_enqu.enty_code);
@@ -2331,12 +2348,14 @@ 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 (' || ,'Attempted to produce an install, exchange or change of capacity quote for enquiry for a installation postcode (' ||
p_enqu.install_postcode || ') without a region.'); 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 add_quote_reason(p_enqu.id
,p_reason => 'Attempting an automatic installation quote for ' || ,p_reason => 'Attempting an automatic installation quote for ' ||
p_enqu.id || '.' p_enqu.id || '.'
,p_internal_or_external => gc_internal_reason); ,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 add_quote_reason(p_enqu.id
,p_reason => 'Attempting an automatic exchange quote for ' || ,p_reason => 'Attempting an automatic exchange quote for ' ||
p_enqu.id || '.' p_enqu.id || '.'
@@ -2432,6 +2451,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,NULL AS purging_cost_price ,NULL AS purging_cost_price
,NULL AS purging_delivery_cost ,NULL AS purging_delivery_cost
,NULL AS purging_lead_time ,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 FROM (SELECT modu.code
,modu.metr_code ,modu.metr_code
,modu.hou_code ,modu.hou_code
@@ -2504,8 +2528,14 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
l_this_is_automatic_quote := FALSE; l_this_is_automatic_quote := FALSE;
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,p_reason => 'Unable to find selling price for module ' || ,p_reason => 'Unable to find selling price for module ' ||
l_rec_module.modu_code || CASE l_rec_module.modu_code ||
l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.' CASE l_regi_code
WHEN NULL THEN
''
ELSE
' for region code ' ||
l_regi_code
END || '.'
,p_internal_or_external => gc_internal_reason); ,p_internal_or_external => gc_internal_reason);
END IF; END IF;
@@ -2517,7 +2547,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
l_this_is_automatic_quote := FALSE; l_this_is_automatic_quote := FALSE;
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,p_reason => 'Unable to find lead time for module ' || ,p_reason => 'Unable to find lead time for module ' ||
l_rec_module.modu_code || '. (' || l_rec_module.modu_code ||
'. (' ||
get_lead_time_desc(p_enty_code => p_enqu.enty_code get_lead_time_desc(p_enty_code => p_enqu.enty_code
,p_mety_code => p_enqu.existing_mety_code ,p_mety_code => p_enqu.existing_mety_code
,p_svcp_code => p_enqu.required_svcp_code ,p_svcp_code => p_enqu.required_svcp_code
@@ -2545,8 +2576,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
', Meter Size Code:' || ', Meter Size Code:' ||
l_rec_module.mesc_code || l_rec_module.mesc_code ||
', Service Pressure Code:' || ', Service Pressure Code:' ||
p_enqu.required_svcp_code || CASE p_enqu.required_svcp_code ||
l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.' CASE l_regi_code
WHEN NULL THEN
''
ELSE
' for region code ' || l_regi_code
END || '.'
,p_internal_or_external => gc_internal_reason); ,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; l_rec_module.purging_lead_time := NULL;
END IF; 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 */ /* Lifting gear required UNLESS LP Diaphragm */
IF NOT (l_rec_module.mety_code = 'DIAPHRAGM' AND IF NOT (l_rec_module.mety_code = 'DIAPHRAGM' AND
l_rec_module.laco_svcpt_code = 'LP') THEN l_rec_module.laco_svcpt_code = 'LP') THEN
@@ -2750,7 +2796,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,p_enqu.enty_code ,p_enqu.enty_code
,l_rec_module.laco_mety_code ,l_rec_module.laco_mety_code
@@ -2775,7 +2821,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,delivery_price ,delivery_price
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,l_rec_module.modu_code ,l_rec_module.modu_code
,l_rec_module.qmax ,l_rec_module.qmax
@@ -2797,7 +2843,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,delivery_price ,delivery_price
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,l_rec_module.hou_code ,l_rec_module.hou_code
,l_rec_module.hou_cost_price ,l_rec_module.hou_cost_price
@@ -2816,7 +2862,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,delivery_price ,delivery_price
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,l_rec_module.bas_code ,l_rec_module.bas_code
,l_rec_module.bas_cost_price ,l_rec_module.bas_cost_price
@@ -2836,7 +2882,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'AMR' ,'AMR'
,l_rec_module.amr_cost_price ,l_rec_module.amr_cost_price
@@ -2857,7 +2903,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'EMS' ,'EMS'
,l_rec_module.ems_cost_price ,l_rec_module.ems_cost_price
@@ -2878,7 +2924,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'BYPASS' ,'BYPASS'
,l_rec_module.bypass_cost_price ,l_rec_module.bypass_cost_price
@@ -2888,7 +2934,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,'AQI'); ,'AQI');
END IF; 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 OR p_enqu.enty_code = 'ADVERSARIAL' THEN
INSERT INTO quote_items INSERT INTO quote_items
(id (id
@@ -2900,7 +2947,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'PURGING' ,'PURGING'
,l_rec_module.purging_cost_price ,l_rec_module.purging_cost_price
@@ -2910,6 +2957,27 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,'AQI'); ,'AQI');
END IF; 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 IF l_rec_module.lifting_gear_selling_price IS NOT NULL THEN
INSERT INTO quote_items INSERT INTO quote_items
@@ -2922,7 +2990,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'LIFTING GEAR' ,'LIFTING GEAR'
,l_rec_module.lifting_gear_cost_price ,l_rec_module.lifting_gear_cost_price
@@ -2983,7 +3051,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
BEGIN BEGIN
pl('produce_install_quotes' pl('produce_install_quotes'
,$$PLSQL_LINE); ,$$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 ' || ,'Attempted to produce an installation quote for enquiry of type ' ||
p_enqu.enty_code); p_enqu.enty_code);
@@ -3008,7 +3077,9 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
BEGIN BEGIN
pl('produce_exchange_quotes:entry:' || p_enqu.enty_code pl('produce_exchange_quotes:entry:' || p_enqu.enty_code
,$$PLSQL_LINE); ,$$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 ' || ,'Attempted to produce an exchange quote for enquiry of type ' ||
p_enqu.enty_code); p_enqu.enty_code);
@@ -3062,6 +3133,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
l_quote_document VARCHAR2(240); l_quote_document VARCHAR2(240);
l_lifting_gear_costs t_rec_additional_costs; l_lifting_gear_costs t_rec_additional_costs;
l_purging_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_required_qmax NUMBER;
l_existing_rec_metr_details t_rec_metr_details; l_existing_rec_metr_details t_rec_metr_details;
BEGIN BEGIN
@@ -3069,8 +3141,11 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
p_enqu.enty_code p_enqu.enty_code
,$$PLSQL_LINE); ,$$PLSQL_LINE);
cout_assert.istrue(p_enqu.enty_code IN cout_assert.istrue(p_enqu.enty_code IN
('REMOVE', 'STD REMOVE', 'ADVERSARIAL', 'OFMAT', ('REMOVE'
'ALTERATION') ,'STD REMOVE'
,'ADVERSARIAL'
,'OFMAT'
,'ALTERATION')
,'Attempted to produce a labour-only quote for enquiry of type ' || ,'Attempted to produce a labour-only quote for enquiry of type ' ||
p_enqu.enty_code); p_enqu.enty_code);
@@ -3084,8 +3159,10 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,p_reason => 'Attempting an automatic labour quote for ' || ,p_reason => 'Attempting an automatic labour quote for ' ||
p_enqu.id || '.' || 'Enquiry Code=' || p_enqu.id || '.' ||
p_enqu.enty_code || ', SVCP ' || 'Enquiry Code=' ||
p_enqu.enty_code ||
', SVCP ' ||
p_enqu.required_svcp_code || p_enqu.required_svcp_code ||
', Meter Type Code=' || ', Meter Type Code=' ||
l_existing_rec_metr_details.mety_code || l_existing_rec_metr_details.mety_code ||
@@ -3107,8 +3184,13 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
', Meter Size Code:' || ', Meter Size Code:' ||
l_existing_rec_metr_details.mesc_code || l_existing_rec_metr_details.mesc_code ||
', Service Pressure Code:' || ', Service Pressure Code:' ||
p_enqu.required_svcp_code || CASE p_enqu.required_svcp_code ||
l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.' CASE l_regi_code
WHEN NULL THEN
''
ELSE
' for region code ' || l_regi_code
END || '.'
,p_internal_or_external => gc_internal_reason); ,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; l_purging_costs.lead_time := NULL;
END IF; 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 */ /* Lifting gear required UNLESS LP Diaphragm */
IF NOT (l_existing_rec_metr_details.mety_code = 'DIAPHRAGM' AND IF NOT (l_existing_rec_metr_details.mety_code = 'DIAPHRAGM' AND
l_labour_costs.svcpt_code = 'LP') THEN l_labour_costs.svcpt_code = 'LP') THEN
@@ -3213,7 +3306,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,p_enqu.enty_code ,p_enqu.enty_code
,l_labour_costs.svcpt_code ,l_labour_costs.svcpt_code
@@ -3236,7 +3329,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'LIFTING GEAR' ,'LIFTING GEAR'
,l_lifting_gear_costs.cost_price ,l_lifting_gear_costs.cost_price
@@ -3246,7 +3339,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,'AQI'); ,'AQI');
END IF; END IF;
IF p_enqu.purging_required IN ('TM', 'FC') THEN IF p_enqu.purging_required IN ('TM'
,'FC') THEN
INSERT INTO quote_items INSERT INTO quote_items
(id (id
,qute_id ,qute_id
@@ -3257,7 +3351,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'PURGING' ,'PURGING'
,l_purging_costs.cost_price ,l_purging_costs.cost_price
@@ -3267,6 +3361,30 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,'AQI'); ,'AQI');
END IF; 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 -- Generate the quote PDF
l_quote_document := mip_quotation_document.generate_quote_pdf(p_quote_id => l_qute_id); l_quote_document := mip_quotation_document.generate_quote_pdf(p_quote_id => l_qute_id);
add_quote_reason(p_enqu_id => p_enqu.id add_quote_reason(p_enqu_id => p_enqu.id
@@ -3305,7 +3423,9 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,$$PLSQL_LINE); ,$$PLSQL_LINE);
cout_assert.istrue(p_enqu.enty_code IN 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 ' || ,'Attempted to produce a removal quote for enquiry of type ' ||
p_enqu.enty_code); p_enqu.enty_code);
produce_labour_only_quotes(p_enqu => p_enqu produce_labour_only_quotes(p_enqu => p_enqu
@@ -3387,8 +3507,19 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
add_quote_reason(p_enqu.id add_quote_reason(p_enqu.id
,p_reason => 'Attempting an automatic addon quote for ' || ,p_reason => 'Attempting an automatic addon quote for ' ||
p_enqu.id || '.' || CASE p_enqu.id || '.' ||
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 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); ,p_internal_or_external => gc_internal_reason);
l_this_is_automatic_quote := TRUE; l_this_is_automatic_quote := TRUE;
@@ -3532,7 +3663,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,delivery_price ,delivery_price
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,p_enqu.enty_code ,p_enqu.enty_code
,p_enqu.existing_mety_code ,p_enqu.existing_mety_code
@@ -3556,7 +3687,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,p_enqu.enty_code ,p_enqu.enty_code
,p_enqu.existing_mety_code ,p_enqu.existing_mety_code
@@ -3581,7 +3712,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,p_enqu.enty_code ,p_enqu.enty_code
,p_enqu.existing_mety_code ,p_enqu.existing_mety_code
@@ -3593,7 +3724,8 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,'AQI'); ,'AQI');
END IF; 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 OR p_enqu.enty_code = 'ADVERSARIAL' THEN
INSERT INTO quote_items INSERT INTO quote_items
(id (id
@@ -3605,7 +3737,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,'PURGING' ,'PURGING'
,l_purging_costs.cost_price ,l_purging_costs.cost_price
@@ -3626,7 +3758,7 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
,lead_time ,lead_time
,quit_type) ,quit_type)
VALUES VALUES
(quit_seq.NEXTVAL (quit_seq.nextval
,l_qute_id ,l_qute_id
,l_lifting_gear_costs.adit_code ,l_lifting_gear_costs.adit_code
,l_lifting_gear_costs.cost_price ,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 cout_assert.istrue(p_manual_or_automatic_quote = gc_automatic_quote
,p_message => 'Attempted to produce automatic quote for enquiry marked as manual only'); ,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 produce_install_quotes(p_enqu => p_enqu
,p_rfq_prty_id => p_rfq_prty_id ,p_rfq_prty_id => p_rfq_prty_id
,p_owner_prty_id => p_owner_prty_id ,p_owner_prty_id => p_owner_prty_id
,p_manual_or_automatic_quote => p_manual_or_automatic_quote); ,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 produce_exchange_quotes(p_enqu => p_enqu
,p_rfq_prty_id => p_rfq_prty_id ,p_rfq_prty_id => p_rfq_prty_id
,p_owner_prty_id => p_owner_prty_id ,p_owner_prty_id => p_owner_prty_id
,p_manual_or_automatic_quote => p_manual_or_automatic_quote); ,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 produce_removal_quotes(p_enqu => p_enqu
,p_rfq_prty_id => p_rfq_prty_id ,p_rfq_prty_id => p_rfq_prty_id
,p_owner_prty_id => p_owner_prty_id ,p_owner_prty_id => p_owner_prty_id