MIP_ENQUIRY.pck - address back-end of #439.

mip_quotation.pck - address back-end of #442.

mip_security.pck - track CGI environment variables as part of #454.

mip_quotation.pck - store files with the correct flow_id;

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@4733 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2008-04-07 15:25:13 +00:00
parent e9a95704c2
commit 759f63c635
4 changed files with 504 additions and 211 deletions

View File

@@ -4,6 +4,8 @@ CREATE OR REPLACE PACKAGE mip_quotation IS
-- Created : 15/11/2007 11:27:58
-- Purpose : Handle life-cycle of quotations
TYPE t_tab_messages IS TABLE OF VARCHAR2(240);
/** Determines whether the given enquiry is ready to quote for
i.e. have all the mandatory fields been completed
@@ -116,6 +118,32 @@ CREATE OR REPLACE PACKAGE mip_quotation IS
PROCEDURE lapse_quotes_job;
/** Delete a quote
%param p_qute_id id of the quote to be deleted
%param p_message reason for not deleting quote
%return boolean
{*} TRUE - quote has been deleted
{*} FALSE or UNKNOWN - quote has not been deleted
*/
FUNCTION delete_quote(p_qute_id IN quotes.id%TYPE
,p_message OUT VARCHAR2) RETURN BOOLEAN;
/** Delete a quote
%param p_qute_id id of the quote to be deleted
%return reason for not deleting quote
*/
FUNCTION delete_quote(p_qute_id IN quotes.id%TYPE) RETURN VARCHAR2;
/** Delete all quotes associated with an enquiry
%param p_enqu_id id of the quote to be deleted
%param p_message reason for not deleting quote
%return boolean
{*} TRUE - all quotes have been deleted
{*} FALSE or UNKNOWN - quotes have not been deleted
*/
FUNCTION delete_quotes_for_enquiry(p_enqu_id IN enquiries.id%TYPE
,p_message OUT VARCHAR2) RETURN BOOLEAN;
/** Return a message if the Tripartite agreement is broached
%param p_rec record containing enquiry details to be checked
%return message is the agreement was broached
@@ -194,6 +222,33 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
/* $END*/
END pl;
PROCEDURE add_quote_reason(p_enqu_id IN enquiries.id%TYPE
,p_reason IN VARCHAR2 --quote_reasoning.reason%TYPE
,p_internal_or_external IN quote_reasoning.internal_or_external%TYPE) IS
BEGIN
pl('add_quote_reason:' || p_enqu_id || ':' || p_reason
,$$PLSQL_LINE);
BEGIN
INSERT INTO quote_reasoning
(enqu_id
,reason
,internal_or_external
,id)
VALUES
(p_enqu_id
,substr(p_reason
,1
,239)
,p_internal_or_external
,qure_seq.NEXTVAL);
EXCEPTION
WHEN OTHERS THEN
pl('add_quote_reason:' || SQLERRM
,$$PLSQL_LINE);
RAISE;
END;
END add_quote_reason;
PROCEDURE add_quote_event(p_qute_id IN quotes.id%TYPE
,p_qust_code quote_statuses.code%TYPE
,p_description quote_events.description%TYPE DEFAULT NULL
@@ -380,6 +435,150 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
END select_quote;
FUNCTION delete_quote(p_qute_id IN quotes.id%TYPE
,p_message OUT VARCHAR2) RETURN BOOLEAN IS
l_qust_code quote_statuses.code%TYPE;
l_quote_deleted BOOLEAN;
l_enqu_id enquiries.id%TYPE;
TYPE t_rowid IS TABLE OF ROWID;
l_rowid t_rowid := t_rowid();
BEGIN
pl('delete_quote:entry:' || p_qute_id
,$$PLSQL_LINE);
BEGIN
SELECT enqu_id
INTO l_enqu_id
FROM quotes
WHERE id = p_qute_id;
EXCEPTION
WHEN no_data_found THEN
NULL;
END;
cout_assert.isnotnull(p_value => l_enqu_id
,p_message => 'Unable to find quote ' || p_qute_id);
SELECT qust_code
INTO l_qust_code
FROM v_current_quote_status
WHERE qute_id = p_qute_id;
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);
ELSE
--
-- delete all associations with this quote
--
DELETE FROM quote_events
WHERE qute_id = p_qute_id;
DELETE FROM apex_application_files aaf
WHERE aaf.NAME IN (SELECT uri
FROM documents docu
,document_roles doro
WHERE doro.qute_id = p_qute_id
AND doro.docu_id = docu.id
AND docu.docu_type = 'INDO');
DELETE FROM document_events doev
WHERE doev.docu_id IN
(SELECT docu_id
FROM document_roles doro
WHERE doro.qute_id = p_qute_id);
-- document roles knows which files should be deleted
-- through a FK
-- 1. Gather the rowids of the documents first,
-- 2. Remove the document role
-- 3. Remove the associated document
SELECT ROWID BULK COLLECT
INTO l_rowid
FROM documents
WHERE id IN (SELECT docu_id
FROM document_roles
WHERE qute_id = p_qute_id);
DELETE FROM document_roles doro
WHERE doro.qute_id = p_qute_id;
FORALL l_idx IN INDICES OF l_rowid
DELETE FROM documents
WHERE ROWID = l_rowid(l_idx);
DELETE FROM quote_items
WHERE qute_id = p_qute_id;
DELETE FROM quote_roles
WHERE qute_id = p_qute_id;
--
-- record that the quote was deleted
--
add_quote_reason(p_enqu_id => l_enqu_id
,p_reason => 'QUOTE ' || p_qute_id ||
' DELETED BY REQUEST'
,p_internal_or_external => gc_internal_reason);
--
-- delete the quote itself
--
DELETE FROM quotes
WHERE id = p_qute_id;
l_quote_deleted := TRUE;
END IF;
pl('delete_quote:exit:' || p_qute_id || ':' || CASE l_quote_deleted WHEN TRUE THEN
'TRUE' ELSE 'FALSE' END
,$$PLSQL_LINE);
RETURN(l_quote_deleted = TRUE);
EXCEPTION
WHEN OTHERS THEN
cout_err.report_and_stop;
END delete_quote;
FUNCTION delete_quote(p_qute_id IN quotes.id%TYPE) RETURN VARCHAR2 IS
l_dummy BOOLEAN;
l_message VARCHAR2(240);
BEGIN
pl('delete_quote(msg):entry:' || p_qute_id);
l_dummy := delete_quote(p_qute_id => p_qute_id
,p_message => l_message);
pl('delete_quote(msg):exit:' || l_message);
RETURN(l_message);
END delete_quote;
FUNCTION delete_quotes_for_enquiry(p_enqu_id IN enquiries.id%TYPE
,p_message OUT VARCHAR2) RETURN BOOLEAN IS
l_quotes_deleted BOOLEAN := TRUE;
BEGIN
pl('delete_quotes_for_enquiry:entry:' || p_enqu_id
,$$PLSQL_LINE);
FOR l_quote IN (SELECT id
FROM quotes
WHERE enqu_id = p_enqu_id) LOOP
IF NOT delete_quote(p_qute_id => l_quote.id
,p_message => p_message) THEN
l_quotes_deleted := FALSE;
EXIT;
END IF;
END LOOP;
pl('delete_quotes_for_enquiry:' || CASE l_quotes_deleted WHEN TRUE THEN
'TRUE' ELSE 'FALSE' END
,$$PLSQL_LINE);
RETURN(l_quotes_deleted = TRUE);
END delete_quotes_for_enquiry;
PROCEDURE lapse_quotes_job IS
l_current_date DATE := trunc(SYSDATE);
BEGIN
@@ -1335,33 +1534,6 @@ RECEIVED AT THIS ADDRESS CANNOT BE RESPONDED TO.');
END return_mandatory_messages;
PROCEDURE add_quote_reason(p_enqu_id IN enquiries.id%TYPE
,p_reason IN VARCHAR2 --quote_reasoning.reason%TYPE
,p_internal_or_external IN quote_reasoning.internal_or_external%TYPE) IS
BEGIN
pl('add_quote_reason:' || p_enqu_id || ':' || p_reason
,$$PLSQL_LINE);
BEGIN
INSERT INTO quote_reasoning
(enqu_id
,reason
,internal_or_external
,id)
VALUES
(p_enqu_id
,substr(p_reason
,1
,239)
,p_internal_or_external
,qure_seq.NEXTVAL);
EXCEPTION
WHEN OTHERS THEN
pl('add_quote_reason:' || SQLERRM
,$$PLSQL_LINE);
RAISE;
END;
END add_quote_reason;
FUNCTION get_u_meter_size(p_qmax IN NUMBER)
RETURN meter_size_codes.code%TYPE IS
l_meter_size_code meter_size_codes.code%TYPE;