made some minor changes, initialized varrays so that the quote_data record could collect data. Also made some changes to the main data collection routine as AH's quote_items table doesn't get populated with some of the stuff it expects (now getting this data from the enquiry table). Started on the build_detailed_pdf function it will now build the first 2 and a half pages of the quotation as a pdf in the testpdf table

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3112 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
PriestJ
2008-01-02 18:35:58 +00:00
parent e80c00df53
commit 53df2a260d

View File

@@ -19,15 +19,15 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
(quote_ref NUMBER,
transaction_ref VARCHAR2(80),
mprn number(30),
supplier_address address,
supplier_address address := address(null,null,null,null,null,null,null),
current_date DATE,
agent_first_name varchar2(80),
site_address address,
site_address address := address(null,null,null,null,null,null,null),
mam varchar2(80),
quote_works works,
quote_works works := works(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
lead_time number,
total_cost number,
quote_costs costs,
quote_costs costs := costs(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
house_length number,
house_depth number,
house_height number,
@@ -36,14 +36,14 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
base_depth number,
base_height number,
outlet_termninal_size number,
quote_caveats caveats,
quote_caveats caveats := caveats(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null),
liquid_damage_day number,
liquid_damage_cap number,
base_dimensions dimensions,
base_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null),
base_diagram number,
house_dimensions dimensions,
house_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null),
house_diagram number,
module_dimensions dimensions,
module_dimensions dimensions := dimensions(null,null,null,null,null,null,null,null,null,null),
module_reference varchar2(80),
module_diagram number,
requested_qmax number,
@@ -69,12 +69,12 @@ CREATE OR REPLACE PACKAGE mip_quotation_document IS
-- Public function and procedure declarations
-- function <FunctionName>(<Parameter> <Datatype>) return <Datatype>;
function get_mam(p_region_code varchar2) return varchar2;
function get_module_row(p_code number) return modules%ROWTYPE;
function get_module_row(p_code varchar2) return modules%ROWTYPE;
function get_max_lead_time(p_quoteid number) return number;
FUNCTION determine_caveats(p_enquiryid in number) RETURN BOOLEAN;
procedure set_quote_items_data (p_quote_data in out quote_data, p_quoteid number, p_enqu_row enquiries%ROWTYPE);
FUNCTION get_detailed_quote_data(p_quoteid in number) RETURN quote_data;
FUNCTION generate_detailed_quote_pdf(get_detailed_quote_data in number) RETURN BOOLEAN;
FUNCTION generate_detailed_quote_pdf(p_quote_data in quote_data) RETURN BOOLEAN;
FUNCTION build_detailed_quote(p_enquiryid in number) RETURN BOOLEAN;
END mip_quotation_document;
/
@@ -127,7 +127,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
%param p_code - the code of the module you want to get a record of.
%return modules row of the supplied module code
*/
function get_module_row(p_code number) return modules%ROWTYPE is
function get_module_row(p_code varchar2) return modules%ROWTYPE is
l_module_row modules%ROWTYPE;
CURSOR c_get_module(cp_module_code varchar2) IS
SELECT *
@@ -293,7 +293,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_module_row modules%ROWTYPE;
--Additional Items
l_add_item_row additional_items%ROWTYPE;
l_works works; --list of works for the quote
l_works works := works(null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null); --list of works for the quote
l_addons varchar(300); --list of addons for the quote
l_housing_row housings%ROWTYPE;
l_base_row bases%ROWTYPE;
@@ -403,37 +403,37 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
p_quote_data.module_qmax := l_meter_row.qmax;
p_quote_data.module_qmin := l_meter_row.qmin;
when 'LQI' then --labour item (job type)
--get type of enquiry to display as works type
IF NOT c_get_enquiry_type%ISOPEN THEN
OPEN c_get_enquiry_type(quote_item_rec.enty_code);
END IF;
FETCH c_get_enquiry_type
INTO l_enqu_type_row;
CLOSE c_get_enquiry_type;
l_works(1) := 'Works Type: '||l_enqu_type_row.description;
--get service pressure
l_works(2) := 'Service Pressure: '|| quote_item_rec.svcpt_code;
--get existing meter if appropriate
if l_quote_item_row.enty_code <>'INSTALL' or l_quote_item_row.enty_code <>'STD INSTALL' then
l_works(4) := 'Existing Meter Type: '|| p_enqu_row.existing_mesc_code ||', '|| p_enqu_row.existing_meter_model;
end if;
if l_quote_item_row.enty_code <> 'OFMAT' or l_quote_item_row.enty_code <> 'ADVERSARIAL'then
l_total_cost := p_quote_data.total_cost;
if l_total_cost <= 1000 then
p_quote_data.liquid_damage_day := 20;
p_quote_data.liquid_damage_cap := 200;
else
p_quote_data.liquid_damage_day := (l_total_cost/100)*2.5;
p_quote_data.liquid_damage_cap := (l_total_cost/100)*25;
end if;
end if;
end case;
END LOOP;
--get type of enquiry to display as works type
IF NOT c_get_enquiry_type%ISOPEN THEN
OPEN c_get_enquiry_type(p_enqu_row.enty_code);
END IF;
FETCH c_get_enquiry_type
INTO l_enqu_type_row;
CLOSE c_get_enquiry_type;
l_works(1) := 'Works Type: '||l_enqu_type_row.description;
--get service pressure
l_works(2) := 'Service Pressure: '|| p_enqu_row.required_svcp_code; --may need to get this from quote items table instead
--get existing meter if appropriate
if l_quote_item_row.enty_code <>'INSTALL' or l_quote_item_row.enty_code <>'STD INSTALL' then
l_works(4) := 'Existing Meter Type: '|| p_enqu_row.existing_mesc_code ||', '|| p_enqu_row.existing_meter_model;
end if;
if l_quote_item_row.enty_code <> 'OFMAT' or l_quote_item_row.enty_code <> 'ADVERSARIAL'then
l_total_cost := p_quote_data.total_cost;
if l_total_cost <= 1000 then
p_quote_data.liquid_damage_day := 20;
p_quote_data.liquid_damage_cap := 200;
else
p_quote_data.liquid_damage_day := (l_total_cost/100)*2.5;
p_quote_data.liquid_damage_cap := (l_total_cost/100)*25;
end if;
end if;
--
--add up all the addons and format the string
l_works(5) := 'Add-Ons: '|| l_addons;
@@ -570,7 +570,7 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
l_quote_data.site_address(5) := l_enqu_row.install_postcode;
--need to find out how to get the mam
l_quote_data.mam := get_mam(mip_regions.get_region_for_postcode(l_enqu_row.install_postcode));
l_quote_data.mam := '<need to write routine to get mam>';
--l_quote_data.mam := '<need to write routine to get mam>';
l_quote_data.lead_time := get_max_lead_time(l_quote_row.id);
l_quote_data.total_cost := get_total_cost(l_quote_row.id);
l_quote_data.requested_qmax := l_enqu_row.qmax;
@@ -589,9 +589,110 @@ CREATE OR REPLACE PACKAGE BODY mip_quotation_document IS
%param p_quote_data - the data to build into the quote.
%param possibly a few more params to get the required data in
*/
FUNCTION generate_detailed_quote_pdf(get_detailed_quote_data in number) RETURN BOOLEAN is
FUNCTION generate_detailed_quote_pdf(p_quote_data in quote_data) RETURN BOOLEAN is
l_blob blob;
l_indent number := 31.7;
l_vertical_offset number := 30;
l_font varchar2(40) := 'Arial';
l_contracts_text varchar2(500);
l_big_text varchar2(9000);
begin
null;
-- Get the blob from somewhere
--Simple example to retrieve and use template:
-- Initialize PDF
plpdf.init;
plpdf.NewPage;
-- Slap on our data
plpdf.SetLeftMargin(31.7);
plpdf.SetRightMargin(31.7);
plpdf.SetTopMargin(25.4);
plpdf.SetPrintFont(l_font,null,7);
-- Set header stuff up
plpdf.PrintText(140,10,'4 Abbotts Lane ');
plpdf.PrintText(140,13,'Coventry');
plpdf.PrintText(140,16,'CV1 4AY');
plpdf.PrintText(170,10,'T +44 (0) 24 7628 6000');
plpdf.PrintText(170,13,'F +44 (0) 24 7628 6022');
plpdf.PrintText(170,16,'www.nationalgrid.com');
-- And Footer stuff
plpdf.PrintText(50,280,'National Grid Metering is the trading name for National Grid Metering Ltd.');
plpdf.PrintText(50,283,'Registered Office: 1-3 Strand, London, WCZN 5EH. Registered in England and Wales, No. 3705992');
plpdf.SetPrintFont(l_font,null,10); -- big text please
plpdf.PrintText(l_indent,l_vertical_offset+10,'National Grid Metering''s Ref: '|| to_char(p_quote_data.quote_ref));
plpdf.PrintText(l_indent,l_vertical_offset+14,'Customer Reference: '|| p_quote_data.transaction_ref);
plpdf.PrintText(l_indent,l_vertical_offset+18,'MPRN: '|| to_char(p_quote_data.mprn));
plpdf.PrintText(l_indent,l_vertical_offset+26,p_quote_data.supplier_address(1));
plpdf.PrintText(l_indent,l_vertical_offset+30,p_quote_data.supplier_address(2));
plpdf.PrintText(l_indent,l_vertical_offset+34,p_quote_data.supplier_address(3));
plpdf.PrintText(l_indent,l_vertical_offset+38,p_quote_data.supplier_address(4));
plpdf.PrintText(l_indent,l_vertical_offset+42,p_quote_data.supplier_address(5));
plpdf.PrintText(l_indent,l_vertical_offset+46,p_quote_data.supplier_address(6));
plpdf.PrintText(l_indent,l_vertical_offset+50,p_quote_data.supplier_address(7));
plpdf.PrintText(l_indent,l_vertical_offset+58,'Date: '||p_quote_data.current_date);
plpdf.PrintText(l_indent,l_vertical_offset+66,'Quotation Contact: Customer Services Team 1');
plpdf.PrintText(l_indent,l_vertical_offset+70,'Telephone Number: 02476 286 320');
plpdf.PrintText(l_indent,l_vertical_offset+74,'Fax Number: 02476 286 044');
plpdf.PrintText(l_indent,l_vertical_offset+78,'E-mail address: iandcrequests1@uk.ngrid.com');
plpdf.PrintText(l_indent,l_vertical_offset+90,'Dear '|| p_quote_data.agent_first_name); --agent first name
plpdf.SetPrintFont(l_font,'B',10); --set bold
plpdf.PrintText(l_indent,l_vertical_offset+98,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address
plpdf.SetPrintFont(l_font,null,10); --unset bold
l_contracts_text :='I am pleased to provide you with a quotation for works in accordance with the '||p_quote_data.mam;--mam
l_contracts_text := l_contracts_text||' General Conditions of Contract for Transactional Meter Works not Exceeding 7 Bar.';
plpdf.SetCurrentY(l_vertical_offset+106);
plpdf.PrintFlowingText(6,l_contracts_text);
plpdf.LineBreak;
plpdf.LineBreak;
l_big_text := 'This quotation is produced on the basis that, the information provided in the request is correct. Your acceptance of the quotation will be taken to mean that you also accept that the stated assumptions are correct. If it is later determined, by either party prior to works commencing on site, that any stated assumption is significantly incorrect, National Grid Metering will determine whether the quotation shall be varied or withdrawn. Works will only then commence if any variation is agreed in line with the relevant General Conditions of Contract.';
plpdf.PrintFlowingText(6,l_big_text);
plpdf.LineBreak;
plpdf.LineBreak;
l_big_text := 'To accept the quotation please submit a work request via IX, as outlined in the Rainbow Manual, or complete the enclosed Acceptance Form and return it to the above National Grid Metering office.';
plpdf.PrintFlowingText(6,l_big_text);
plpdf.LineBreak;
plpdf.LineBreak;
l_big_text := 'Please note that this quotation is valid for 90 days from the date specified in the quotation. Please use National Grid Metering''s Reference, which is at the top of the letter, on any future correspondence relating to this request.';
plpdf.PrintFlowingText(6,l_big_text);
plpdf.LineBreak;
plpdf.LineBreak;
plpdf.PrintFlowingText(6,'If you have any queries, please contact the team on the number above');
plpdf.LineBreak;
plpdf.LineBreak;
plpdf.PrintFlowingText(6,'Yours sincerely');
plpdf.PrintText(l_indent,l_vertical_offset+230,'David Harper');
plpdf.PrintText(l_indent,l_vertical_offset+234,'I&C Technical Manager');
plpdf.PrintText(l_indent,l_vertical_offset+238,'National Grid Metering');
----Das page one complete
plpdf.NewPage;
plpdf.SetPrintFont(l_font,'B',10); --set bold
plpdf.PrintText(l_indent,l_vertical_offset+10,'QUOTATION');
plpdf.SetPrintFont(l_font,null,10); --unset bold
plpdf.PrintText(l_indent,l_vertical_offset+18,'National Grid Metering''s Ref: '|| to_char(p_quote_data.quote_ref));
plpdf.PrintText(l_indent,l_vertical_offset+22,'Customer Reference: '|| p_quote_data.transaction_ref);
plpdf.PrintText(l_indent,l_vertical_offset+30,'Date: '||p_quote_data.current_date);
plpdf.SetPrintFont(l_font,'B',10); --set bold
plpdf.PrintText(l_indent,l_vertical_offset+38,'Re: '||p_quote_data.site_address(1)||', '||p_quote_data.site_address(2)||', '||p_quote_data.site_address(3)||', '||p_quote_data.site_address(4)||', '||p_quote_data.site_address(5)||', '||p_quote_data.site_address(6)||', '||p_quote_data.site_address(7)); --site address
plpdf.SetPrintFont(l_font,'U',10); --set underline
plpdf.PrintText(l_indent,l_vertical_offset+48,'Full Description of Works to be carried out by National Grid Metering:');
plpdf.SetPrintFont(l_font,'B',10); --set bold
plpdf.PrintText(l_indent,l_vertical_offset+56, p_quote_data.quote_works(1));
plpdf.PrintText(l_indent,l_vertical_offset+60, p_quote_data.quote_works(2));
plpdf.PrintText(l_indent,l_vertical_offset+64, p_quote_data.quote_works(3));
plpdf.PrintText(l_indent,l_vertical_offset+68, p_quote_data.quote_works(4));
plpdf.PrintText(l_indent,l_vertical_offset+72, p_quote_data.quote_works(5));
plpdf.PrintText(l_indent,l_vertical_offset+76, p_quote_data.quote_works(6));
plpdf.SetPrintFont(l_font,null,10); --unset bold
plpdf.PrintText(l_indent,l_vertical_offset+90, 'Indicative Lead Time from Acceptance to Physical Commencement: ');
plpdf.SetPrintFont(l_font,'B',10); --set bold
plpdf.PrintText(140,l_vertical_offset+90, p_quote_data.lead_time||' working days');
--get our beautiful pdf into the local var l_blob
plpdf.SendDoc(l_blob);
--punt the created pdf into the testpdf table
insert into testpdf (id, pdf_report)
values (11, l_blob);
return true;
end generate_detailed_quote_pdf;
FUNCTION build_detailed_quote(p_enquiryid in number) RETURN BOOLEAN is