Updated mip_regions.pck to include a reference to the source information.

mip_quotation.pck now able to produce 'module' part of install quotes - missing labour costs.
gen_mandatory.prc modified to pass more of the 'condition' information into the application.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3060 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2007-12-21 17:34:08 +00:00
parent 54625dcb9f
commit d79dcfa1fe
3 changed files with 116 additions and 97 deletions

View File

@@ -55,14 +55,9 @@ BEGIN
add_sql(l_sql
,' ,table_name');
add_sql(l_sql
,' ,substr(diri.' ||
REPLACE(l_enty.code
,' '
,'_'));
add_sql(l_sql
,' ,1');
add_sql(l_sql
,' ,1)');
,' ,diri.' || REPLACE(l_enty.code
,' '
,'_'));
add_sql(l_sql
,' ,diri.description');
add_sql(l_sql

View File

@@ -4,12 +4,29 @@ CREATE OR REPLACE PACKAGE mip_quotation IS
-- Created : 15/11/2007 11:27:58
-- Purpose : Handle life-cycle of quotations
/** Determines whether the given enquiry is ready to quote for
i.e. have all the mandatory fields been completed
%param p_id the id of the enquiry to be checked
%return TRUE if the enquiry can be quoted for
*/
FUNCTION ready_for_quote(p_id IN enquiries.id%TYPE) RETURN BOOLEAN;
/** Determines whether the given enquiry is ready to quote for
i.e. have all the mandatory fields been completed
%param p_id the id of the enquiry to be checked
%p_mandatory_checks contains reasons for the enquiry *not* being ready to quote for
%p_quote_is_ready TRUE if the enquiry can be quoted for
*/
PROCEDURE ready_for_quote(p_id IN enquiries.id%TYPE
,p_mandatory_checks OUT mip_mandatory.t_mandatory_checks
,p_quote_is_ready OUT BOOLEAN);
/** Generate quotes in response to a 'request for quote' against an enquiry
%param p_id the id of the enquiry to be checked
*/
PROCEDURE produce_quotes(p_id IN enquiries.id%TYPE);
END mip_quotation;
/
@@ -243,7 +260,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
OR regi_code IS NULL
ORDER BY 1) cost
,additional_items adit
WHERE adit.code = cost.adit_code
WHERE adit.code = cost.adit_code(+)
AND rownum < 2;
RETURN l_rec_costs;
@@ -259,7 +276,6 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
l_this_is_automatic_quote BOOLEAN;
l_regi_code regions.code%TYPE := mip_regions.get_region_for_postcode(p_enqu.install_postcode);
l_qute_id quotes.id%TYPE;
l_item_sequence NUMBER;
l_aico_costs t_rec_additional_item_costs;
BEGIN
cout_assert.istrue(p_enqu.enty_code IN ('INSTALL', 'STD INSTALL')
@@ -325,107 +341,95 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,selling_price
,cost_price
,delivery_cost
FROM (SELECT decode(regi_code
,l_regi_code
,1
,999) AS accuracy
FROM (SELECT row_number() over(PARTITION BY modu_code ORDER BY(decode(regi_code, l_regi_code, 1, 999))) AS accuracy
,modu_code
,selling_price
,cost_price
,delivery_cost
,ROWID
FROM v_moco cost
WHERE SYSDATE BETWEEN
cost.effective_from AND
cost.effective_to
AND regi_code =
l_regi_code
OR regi_code IS NULL
ORDER BY 1)
WHERE rownum < 2) cost
OR regi_code IS NULL)
WHERE accuracy <= 1) cost
WHERE modu.code = cost.modu_code(+)) modu
,(SELECT hou.code
,cost_price
,(SELECT code
,selling_price
,cost_price
,delivery_cost
FROM housings hou
,(SELECT hou_code
,selling_price
,cost_price
,delivery_cost
FROM (SELECT decode(regi_code
,l_regi_code
,1
,999) AS accuracy
FROM (SELECT row_number() over(PARTITION BY hou_code ORDER BY(decode(regi_code, l_regi_code, 1, 999))) AS accuracy
,hou_code
,selling_price
,cost_price
,delivery_cost
,ROWID
FROM v_hoco cost
WHERE SYSDATE BETWEEN
cost.effective_from AND
cost.effective_to
AND regi_code =
l_regi_code
OR regi_code IS NULL
ORDER BY 1)
WHERE rownum < 2) cost
OR regi_code IS NULL)
WHERE accuracy <= 1) cost
WHERE hou.code = cost.hou_code(+)) hou
,(SELECT bas.code
,cost_price
,(SELECT code
,selling_price
,cost_price
,delivery_cost
FROM bases bas
,(SELECT bas_code
,selling_price
,cost_price
,delivery_cost
FROM (SELECT decode(regi_code
,l_regi_code
,1
,999) AS accuracy
FROM (SELECT row_number() over(PARTITION BY bas_code ORDER BY(decode(regi_code, l_regi_code, 1, 999))) AS accuracy
,bas_code
,selling_price
,cost_price
,delivery_cost
,ROWID
FROM v_baco cost
WHERE SYSDATE BETWEEN
cost.effective_from AND
cost.effective_to
AND regi_code =
l_regi_code
OR regi_code IS NULL
ORDER BY 1)
WHERE rownum < 2) cost
WHERE bas.code = cost.bas_code) bas
OR regi_code IS NULL)
WHERE accuracy <= 1) cost
WHERE bas.code = cost.bas_code(+)) bas
,(SELECT metr.code
,metr.qmax
,metr.qmin
,metr.qnom
,cost_price
,selling_price
,cost_price
,delivery_cost
FROM meters metr
,(SELECT metr_code
,selling_price
,cost_price
,delivery_cost
FROM (SELECT decode(regi_code
,l_regi_code
,1
,999) AS accuracy
FROM (SELECT row_number() over(PARTITION BY metr_code ORDER BY(decode(regi_code, l_regi_code, 1, 999))) AS accuracy
,metr_code
,selling_price
,cost_price
,delivery_cost
,ROWID
FROM v_meco cost
WHERE SYSDATE BETWEEN
cost.effective_from AND
cost.effective_to
AND regi_code =
l_regi_code
OR regi_code IS NULL
ORDER BY 1)
WHERE rownum < 2) cost
OR regi_code IS NULL)
WHERE accuracy <= 1) cost
WHERE metr.code = cost.metr_code(+)) metr
WHERE modu.svcp_code = p_enqu.required_svcp_code
AND modu.outlet_pressure =
@@ -446,7 +450,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
add_quote_reason(p_enqu.id
,p_reason => 'Considering module : ' ||
l_rec_module.modu_code
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
--
-- check whether we have the required prices
-- if we do not, then we may need to produce a manual quote
@@ -455,30 +459,32 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
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 || '.'
,p_internal_or_external => g_external_reason);
l_rec_module.modu_code || CASE
l_regi_code WHEN NULL THEN '' ELSE ' for region code ' || l_regi_code END || '.'
,p_internal_or_external => g_internal_reason);
END IF;
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 || '.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
/* Meters do not have a price, they are rented
IF l_rec_module.metr_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 meter ' ||
l_rec_module.metr_code || '.'
,p_internal_or_external => g_external_reason);
END IF;
,p_internal_or_external => g_internal_reason);
END IF;*/
IF p_enqu.base_required = 'YES'
AND 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_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
IF p_enqu.housing_required = 'YES'
AND l_rec_module.hou_selling_price IS NULL THEN
@@ -486,7 +492,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
add_quote_reason(p_enqu.id
,p_reason => 'Unable to find selling price for housing ' ||
l_rec_module.hou_code || '.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
IF p_enqu.amr_required = 'YES' THEN
l_aico_costs := get_aico(p_adit_code => 'AMR'
@@ -499,13 +505,13 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
l_this_is_automatic_quote := FALSE;
add_quote_reason(p_enqu.id
,p_reason => 'Unable to find selling price for AMR.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_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_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
END IF;
IF p_enqu.ems_required = 'YES' THEN
@@ -519,13 +525,13 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
l_this_is_automatic_quote := FALSE;
add_quote_reason(p_enqu.id
,p_reason => 'Unable to find selling price for EMS.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_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_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
END IF;
IF p_enqu.bypass_required = 'YES' THEN
@@ -539,13 +545,13 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
l_this_is_automatic_quote := FALSE;
add_quote_reason(p_enqu.id
,p_reason => 'Unable to find selling price for BYPASS.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_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_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
END IF;
@@ -559,13 +565,13 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
l_this_is_automatic_quote := FALSE;
add_quote_reason(p_enqu.id
,p_reason => 'Unable to find selling price for LOGGER.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
IF l_rec_module.logger_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 LOGGER.'
,p_internal_or_external => g_external_reason);
,p_internal_or_external => g_internal_reason);
END IF;
END IF;
@@ -578,13 +584,17 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,qute_type
,enqu_id
,valid_from
,valid_until)
,valid_until
,created_on
,created_by)
VALUES
(qute_seq.NEXTVAL
,'AQ' -- automatic quote
,p_enqu.id
,trunc(SYSDATE)
,trunc(SYSDATE + 90))
,trunc(SYSDATE + 90)
,SYSDATE
,USER)
RETURNING id INTO l_qute_id;
INSERT INTO quote_events
@@ -596,136 +606,143 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation IS
,'INP' -- In Progress
,l_qute_id);
l_item_sequence := 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,modu_code
,cost_price
,selling_price
,delivery_price)
,delivery_price
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,l_rec_module.modu_code
,l_rec_module.modu_cost_price
,l_rec_module.modu_selling_price
,l_rec_module.modu_delivery_cost);
,l_rec_module.modu_delivery_cost
,'MQI');
IF l_rec_module.hou_code IS NOT NULL THEN
l_item_sequence := l_item_sequence + 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,hou_code
,cost_price
,selling_price
,delivery_price)
,delivery_price
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,l_rec_module.hou_code
,l_rec_module.hou_cost_price
,l_rec_module.hou_selling_price
,l_rec_module.hou_delivery_cost);
,l_rec_module.hou_delivery_cost
,'HQI');
END IF;
IF l_rec_module.bas_code IS NOT NULL THEN
l_item_sequence := l_item_sequence + 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,bas_code
,cost_price
,selling_price
,delivery_price)
,delivery_price
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,l_rec_module.bas_code
,l_rec_module.bas_cost_price
,l_rec_module.bas_selling_price
,l_rec_module.bas_delivery_cost);
,l_rec_module.bas_delivery_cost
,'BQI');
END IF;
IF p_enqu.amr_required = 'YES' THEN
l_item_sequence := l_item_sequence + 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,adit_code
,cost_price
,selling_price
,delivery_price
,lead_time)
,lead_time
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,'AMR'
,l_rec_module.amr_cost_price
,l_rec_module.amr_selling_price
,l_rec_module.amr_delivery_cost
,l_rec_module.amr_lead_time);
,l_rec_module.amr_lead_time
,'AQI');
END IF;
IF p_enqu.ems_required = 'YES' THEN
l_item_sequence := l_item_sequence + 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,adit_code
,cost_price
,selling_price
,delivery_price
,lead_time)
,lead_time
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,'EMS'
,l_rec_module.ems_cost_price
,l_rec_module.ems_selling_price
,l_rec_module.ems_delivery_cost
,l_rec_module.ems_lead_time);
,l_rec_module.ems_lead_time
,'AQI');
END IF;
IF p_enqu.bypass_required = 'YES' THEN
l_item_sequence := l_item_sequence + 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,adit_code
,cost_price
,selling_price
,delivery_price
,lead_time)
,lead_time
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,'BYPASS'
,l_rec_module.bypass_cost_price
,l_rec_module.bypass_selling_price
,l_rec_module.bypass_delivery_cost
,l_rec_module.bypass_lead_time);
,l_rec_module.bypass_lead_time
,'AQI');
END IF;
IF p_enqu.logger_required = 'YES' THEN
l_item_sequence := l_item_sequence + 1;
INSERT INTO quote_items
(item_sequence
(id
,qute_id
,adit_code
,cost_price
,selling_price
,delivery_price
,lead_time)
,lead_time
,quit_type)
VALUES
(l_item_sequence
(quit_seq.NEXTVAL
,l_qute_id
,'LOGGER'
,l_rec_module.logger_cost_price
,l_rec_module.logger_selling_price
,l_rec_module.logger_delivery_cost
,l_rec_module.logger_lead_time);
,l_rec_module.logger_lead_time
,'AQI');
END IF;
END IF; -- automatic quote

View File

@@ -25,6 +25,13 @@ END mip_regions;
/
CREATE OR REPLACE PACKAGE BODY mip_regions IS
/*
**
* Postcode format based on the UK Government Data Standards Catalogue
* http://www.govtalk.gov.uk/gdsc/html/frames/Postcode.htm
**
*/
/** Attempts to determine whether general the format the given string to match a standard postcode format
%param p_string the string whose format is to be checked