| '||caco_utilities.get_module_text(1145)||' | '); htp.p(''||caco_utilities.get_cust_name||' | '); htp.p('|
|---|---|---|
| '||caco_utilities.get_module_text(3552)||' | '); htp.p(''||g_cont_num||' | '); htp.p('|
| '||caco_utilities.get_module_text(1142)||' | '|| ''); -- htp.p(wsgjsl.calbutton(field_name => 'gasday', p_calbut => htf.img(curl => caco_system.images_path || 'lov.gif', calign => 'TOP', cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER'), p_form => 'forms[1]', field_format => g_date_format, p_field_prompt => caco_utilities.get_module_text(1142))); -- htp.p(' | |
| '||caco_utilities.get_module_text(2484)||' | '|| ''); htp.p(' | '); -- htp.p(wsgjsl.calbutton(field_name => 'p_gasday_start', p_calbut => htf.img(curl => caco_system.images_path || 'lov.gif', calign => 'TOP', cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER'), p_form => 'forms[1]', field_format => g_date_format, p_field_prompt => caco_utilities.get_module_text(1142))); -- htp.p(' |
| '||caco_utilities.get_module_text(2485)||' | '); htp.p(' | '); -- htp.p(wsgjsl.calbutton(field_name => 'p_gasday_end', p_calbut => htf.img(curl => caco_system.images_path || 'lov.gif', calign => 'TOP', cattributes => 'ALT="List Values" WIDTH=18 HEIGHT=22 BORDER'), p_form => 'forms[1]', field_format => g_date_format, p_field_prompt => caco_utilities.get_module_text(1142))); htp.p(' |
| '||cate.name||' | '; END IF; -- l_tab_head_2 := l_tab_head_2 || ''||cate.units||' | '; -- END IF; -- END LOOP; -- IF get_spte_name(g_cont_id) IN (UPPER(g_spte_single),UPPER(g_spte_smulti)) THEN -- l_tab_head_1 := '|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| '||l_tab_head_1||' | ||||||||||
| '||caco_utilities.get_module_text(2113)||' | '||caco_utilities.get_module_text(2023)||' | '||l_tab_head_2||'|||||||||
| '||l_tab_head_1||' | ||||||||||
| '||caco_utilities.get_module_text(2113)||' | '||caco_utilities.get_module_text(2023)||' | '||caco_utilities.get_module_text(1142)||' | '||l_tab_head_2||'||||||||
| '||conp.code||' | '||conp.name||' | '; -- ELSIF get_spte_name(g_cont_id) = UPPER(g_spte_multi) THEN -- l_tab_line := '|||||||||
| '||conp.code||' | '||conp.name||' | '||' | '; -- ELSE -- l_tab_line := '||||||||
| '||conp.name||' | '||conp.code||' | '||' | '; -- END IF; -- -- For all sites -- FOR conp_coca IN (SELECT coca.coca_id ,cate.display_cond ,cate.units ,cate.name FROM contract_categories coca ,categories cate WHERE cate.cate_id = coca.cate_id AND coca.cont_id = g_cont_id ORDER BY coca.display_sequence ) LOOP -- --htp.p(''); -- l_MJ_coca_id := 0; -- -- check to see if this is a m3/day volume category and we have a non-zero cv value -- IF conp_coca.units IN ('m3/day','m3/nap') AND l_cv > 0 THEN -- -- check to see if we have an equivalent energy category in the contract -- OPEN cu_MJ_cate(conp_coca.name); FETCH cu_MJ_cate INTO l_MJ_coca_id; IF cu_MJ_cate%NOTFOUND THEN l_MJ_coca_id := 0; END IF; CLOSE cu_MJ_cate; -- END IF; -- IF conp_coca.display_cond = 'AL' THEN -- -- check to see if we need to put an onchange js call to calculate the energy -- IF l_MJ_coca_id > 0 THEN -- l_tab_line := l_tab_line || ''||' | '; -- ELSE -- l_tab_line := l_tab_line || ''||' | '; -- END IF; -- ELSIF conp_coca.display_cond = 'SH' THEN -- -- this is a short day category -- IF l_num_hours = 23 THEN -- IF l_only_short_day THEN -- NULL; -- ELSE -- l_tab_line := l_tab_line || ''||''||' | '; -- END IF; -- ELSE -- -- check to see if we need to put an onchange js call to calculate the energy -- IF l_MJ_coca_id > 0 THEN -- l_tab_line := l_tab_line || ''||' | '; -- ELSE -- l_tab_line := l_tab_line || ''||' | '; -- END IF; -- END IF; -- ELSIF conp_coca.display_cond = 'LO' THEN -- -- this is a long day category -- IF l_num_hours = '25' THEN -- -- check to see if we need to put an onchange js call to calculate the energy -- IF l_MJ_coca_id > 0 THEN -- l_tab_line := l_tab_line || ''||' | '; -- ELSE -- l_tab_line := l_tab_line || ''||' | '; -- END IF; -- ELSIF l_cont_long_day THEN -- l_tab_line := l_tab_line || ''||''||' | '; -- ELSE -- NULL; -- END IF; -- END IF; -- END LOOP; -- l_tab_line := l_tab_line || '
'||caco_utilities.get_module_text(3810)||'
'); -- END IF; -- caco_system.footer(p_closebody => TRUE); -- -- re-initialise the tables with empty tables in case they've been used -- g_nomi_tab := g_empty_nomi_tab; g_nnpcv_tab := g_empty_nnpcv_tab; -- g_cell_error := g_empty_cell_error; g_row_error := g_empty_row_error; -- END page_foot; -- FUNCTION pdecode ( p_decode_string IN VARCHAR2 ) RETURN VARCHAR2 IS -- l_return VARCHAR2(4000); -- BEGIN -- EXECUTE IMMEDIATE 'SELECT '||p_decode_string||' FROM DUAL' into l_return; -- RETURN l_return; -- EXCEPTION WHEN OTHERS THEN htp.p(sqlerrm||p_decode_string); RETURN NULL; END pdecode; -- PROCEDURE get_cont_id ( p_cust_id IN customers.cust_id%TYPE , p_contract_number IN contracts.contract_number%TYPE ) IS -- BEGIN -- BEGIN -- SELECT cont.cont_id ,cont.contract_number ,cont.valid_from ,cont.valid_until INTO g_cont_id ,g_cont_num ,g_cont_start_date ,g_cont_end_date FROM contracts cont WHERE cont.cust_id = p_cust_id AND cont.status = 'O' AND cont.contract_number = p_contract_number AND rownum < 2; -- EXCEPTION WHEN OTHERS THEN -- BEGIN SELECT cont_id ,contract_number ,valid_from ,valid_until INTO g_cont_id ,g_cont_num ,g_cont_start_date ,g_cont_end_date FROM (SELECT cont.cont_id ,cont.contract_number ,cont.valid_from ,cont.valid_until FROM contracts cont WHERE cont.cust_id = p_cust_id AND cont.status = 'O' AND cont.contract_number = NVL(p_contract_number,cont.contract_number) ORDER BY cont.valid_from ) WHERE rownum < 2; EXCEPTION WHEN OTHERS THEN -- -- g_cont_id := NULL; g_cont_num := NULL; END; -- END; -- END get_cont_id; -- -- Public -- PROCEDURE calendar(z_field_name IN VARCHAR2 ,z_caller_url IN VARCHAR2 ,z_field_value IN VARCHAR2 DEFAULT NULL ,z_field_format IN VARCHAR2 DEFAULT NULL ,z_field_prompt IN VARCHAR2 DEFAULT NULL) IS -- field_caption VARCHAR2(2000); -- BEGIN -- IF z_field_prompt IS NULL THEN -- field_caption := initcap(REPLACE(SUBSTR(z_field_name ,3 ,LENGTH(z_field_name) - 2) ,'_' ,' ')); -- ELSE -- field_caption := initcap(REPLACE(z_field_prompt ,'_' ,' ')); -- END IF; -- wsgl.registerurl(g_package_name || '.calendar'); wsgl.addurlparam('Z_FIELD_NAME' ,z_field_name); wsgl.addurlparam('Z_CALLER_URL' ,z_caller_url); -- IF wsgl.notlowercase THEN RETURN; END IF; -- wsgl.output_calendar(z_field_name ,z_field_value ,z_field_format ,wsgl.msggettext(123 ,wsglm.dsp128_cal_caption ,field_caption) ,NULL ,g_package_name ,'Close' ,TRUE ,'DD-MON-RRRR'); -- wsgl.output_calendar(z_field_name ,z_field_value ,z_field_format ,wsgl.msggettext(123 ,wsglm.dsp128_cal_caption ,field_caption) ,NULL ,g_package_name ,'Close' ,FALSE ,'DD-MON-RRRR'); -- EXCEPTION WHEN OTHERS THEN wsgl.displaymessage(wsgl.mess_exception ,SQLERRM ,'' ,NULL ,g_package_name || '.calendar'); END calendar; -- PROCEDURE format_cal_date(z_field_name IN VARCHAR2 ,z_field_format IN VARCHAR2 ,DAY IN VARCHAR2 ,MONTH IN VARCHAR2 ,YEAR IN VARCHAR2) IS -- field_caption VARCHAR2(2000) := initcap(REPLACE(SUBSTR(z_field_name ,3 ,LENGTH(z_field_name) - 2) ,'_' ,' ')); l_day VARCHAR2(15) := DAY; -- PROCEDURE output_format_cal_js(page_header IN VARCHAR2 ,body_attributes IN VARCHAR2 ,chosen_date IN VARCHAR2 ,field_format IN VARCHAR2) IS -- -- Copied from WSGL -- the_date DATE := to_date(chosen_date ,'DD-MONTH-YYYY'); -- BEGIN -- wsgl.openpagehead(page_header); wsgl.closepagehead; wsgl.openpagebody(FALSE ,p_attributes => body_attributes); htp.p(''); wsgl.closepagebody; -- END output_format_cal_js; BEGIN -- IF l_day = '0' THEN l_day := '01'; END IF; -- output_format_cal_js(wsgl.msggettext(123 ,wsglm.dsp128_cal_caption ,field_caption) ,NULL ,l_day || '-' || MONTH || '-' || YEAR ,z_field_format); -- END format_cal_date; -- PROCEDURE noms_js IS BEGIN -- owa_util.mime_header('application/x-javascript' ,TRUE); -- htp.p(' function showtr(trid)'); htp.p(' {'); htp.p(' obj = document.getElementsByTagName(''TR'');'); htp.p(' for (i=0; i'); htp.p('
'); htp.p(''); l_cust_id := caco_utilities.get_cust_id; FOR f IN (SELECT * FROM (SELECT n.IDENTIFIER ,c.contract_number ,wsgl.gettext(caco_utilities.cgrefmeaning('STATUS' ,n.status)) AS status ,TO_CHAR(MIN(ncv.gas_day) ,g_date_format) AS start_day ,TO_CHAR(MAX(ncv.gas_day) ,g_date_format) AS end_day FROM nominations n ,contracts c ,nom_net_point_cat_vals ncv WHERE c.cont_id IN (SELECT cont2.cont_id FROM contracts cont2 CONNECT BY PRIOR cont2.prev_cont_id = cont2.cont_id START WITH cont2.cont_id = g_cont_id) AND c.cust_id = l_cust_id AND n.cont_id = c.cont_id AND n.nomi_id = ncv.nomi_id AND (n.IDENTIFIER LIKE z_filter OR z_filter IS NULL) GROUP BY n.IDENTIFIER ,c.contract_number ,caco_utilities.cgrefmeaning('STATUS' ,n.status) ORDER BY MIN(ncv.gas_day) DESC ,2) WHERE ROWNUM < 50) LOOP -- IF lb_first THEN -- -- Print table header - we have some data -- htp.p('
| Identifier | Contract Number | Status | Start Date | End Date |
|---|---|---|---|---|
| ' || f.IDENTIFIER || ' | ' || f.contract_number || ' | ' || f.status || ' | ' || f.start_day || ' | ' || f.end_day || ' |
'); -- END nomination_lov; -- PROCEDURE redisplay (p_contract IN VARCHAR2 DEFAULT NULL ,p_nomination IN VARCHAR2 DEFAULT NULL ,p_spreadsheet IN VARCHAR2 DEFAULT NULL ,p_rb IN VARCHAR2 DEFAULT 1 ) IS BEGIN -- --caco_debug.putline('-----redisplay'); -- g_cont_num := p_contract; -- nom_header(p_contract => p_contract ,p_nomination => p_nomination ,p_spreadsheet => p_spreadsheet ,p_rb => p_rb ); -- END redisplay; -- PROCEDURE submit_nomination ( val IN owa_util.vc_arr , gasday IN owa_util.vc_arr , coca IN owa_util.vc_arr , conp IN owa_util.vc_arr , cv IN owa_util.vc_arr , cont_id IN contracts.cont_id%TYPE , action IN VARCHAR2 DEFAULT NULL , p_gasday_start IN VARCHAR2 DEFAULT NULL , p_gasday_end IN VARCHAR2 DEFAULT NULL ) IS -- -- Parameters are short intentionally -- l_message VARCHAR2(1000); l_mess_type VARCHAR2(1000); l_sub_list caco_utilities.g_t_substitution_list; -- e_ude EXCEPTION; l_date DATE; -- l_nomi_id nominations.nomi_id%TYPE; -- lr_cell_error gr_cell_error; -- l_nomi_details VARCHAR2(4000); l_timestamp DATE; l_letter VARCHAR2(4000); -- l_c_nnpcv_tab efno_confirmations.nnpcv_tab; l_rule_results BOOLEAN := TRUE; -- l_cnp_count NUMBER; -- l_idx NUMBER := NULL; -- l_rcve_b4_start NUMBER := 0; -- Contract receive before start -- l_multi_day_iter NUMBER := 7; -- l_num_format VARCHAR2(50); -- l_tot_perc_split NUMBER := 0; -- -- dbms_lock values -- l_noms_lock NUMBER; l_noms_release NUMBER; -- -- local variables for input array manipulation for multi day noms l_val owa_util.vc_arr; l_gasday owa_util.vc_arr; l_gd DATE; l_nom_days NUMBER := 0; l_i NUMBER := 0; l_r NUMBER := 0; val_i NUMBER := 0; val_r NUMBER := 0; -- -- array to contain val array contents with no thousand separators l_val_no_thou_sep owa_util.vc_arr; -- l_loop_counter NUMBER := 1; l_coca_id NUMBER; -- CURSOR cu_coca(c_disp_cond IN categories.display_cond%TYPE) IS SELECT coca.coca_id FROM contract_categories coca ,categories cate WHERE cate.cate_id = coca.cate_id AND coca.cont_id = g_cont_id AND cate.display_cond = c_disp_cond; -- BEGIN -- --caco_debug.putline('-----submit_nomination'); -- -- Security check -- IF caco_security.security_check(p_package_name => g_package_name) THEN -- -- Attempt to lock nominations table caco_debug.putline('Entered default_values'); -- l_noms_lock := dbms_lock.request(id => 128 ,lockmode => 6 ,timeout => 180); caco_debug.putline('default_values DBMS_LOCK id 128 request value l_noms_lock is ' || l_noms_lock); -- IF l_noms_lock = 0 THEN BEGIN -- -- Set the initial error point -- g_error_point := 'A005'; -- -- 02/12/09 SP Modification to multi-day nominations -- Manipulate the input arrays for single-multi day nominations to simulate noms entered -- for each day. -- l_nom_days := (to_date(p_gasday_end,g_date_format) - to_date(p_gasday_start,g_date_format))+1; -- /* caco_debug.putline('p_gasday_start: '||p_gasday_start); caco_debug.putline('p_gasday_end: '||p_gasday_end); caco_debug.putline('l_nom_days: '||l_nom_days); display_vc_arr('val before',val); display_vc_arr('gasday before',gasday);*/ -- -- remove thousand separators from val array -- l_val_no_thou_sep := caco_utilities.thousand_separated_to_char(val); --IF p_gasday_start IS NOT NULL AND p_gasday_end IS NOT NULL THEN IF get_spte_name(cont_id) = UPPER(g_spte_smulti) THEN FOR r IN 1..conp.count LOOP l_gd := to_date(p_gasday_start,g_date_format); --caco_debug.putline('l_gd1: '||l_gd); FOR i IN 1..l_nom_days LOOP -- enter values in the gasday array --caco_debug.putline('l_gd: '||l_gd); l_i := l_i + 1; l_gasday(l_i) := to_char(l_gd,g_date_format); l_gd := l_gd + 1; END LOOP; END LOOP; -- IF l_val_no_thou_sep.COUNT > 0 THEN FOR r IN 1..conp.COUNT LOOP FOR i IN 1..l_nom_days LOOP FOR y IN 1..coca.COUNT LOOP val_r := val_i + y; l_r := l_r + 1; -- enter values in the values array l_val(l_r) := l_val_no_thou_sep(val_r); END LOOP; END LOOP; val_i := val_i + coca.COUNT; END LOOP; END IF; ELSE -- must be single day or multiple day nomination l_val := l_val_no_thou_sep; l_gasday := gasday; END IF; -- /* display_vc_arr('val after',l_val); display_vc_arr('gasday after',l_gasday);*/ -- -- Anonymous block to handle exceptions -- IF action IN (caco_utilities.get_module_text(1149/* Verify */), caco_utilities.get_module_text(840/* Insert */)) THEN -- -- Nomination Identifier looks OK, set it globally -- g_error_point := 'A015'; -- -- Now validate the details, set the global -- g_error_point := 'A025'; -- g_gas_days := l_gasday; -- -- Pre-populate the arrays based on screen values without any validation -- so earlier validation failures do not 'wipe-out' screen values. -- g_error_point := 'A035'; -- -- Check the number of categories and sites is in the same ballpark as the number of values supplied (multiplication factor) -- IF MOD(l_val.COUNT,(conp.COUNT*coca.COUNT))=0 THEN -- -- only proceed if balanced, otherwise, how would we know... -- g_error_point := 'A036'; -- FOR i IN 1..l_val.COUNT LOOP -- -- Pre-populate the variables in case of any errors -- g_error_point := 'A037'; -- g_nnpcv_tab(i).conp_id := conp(TRUNC((i-1)/(coca.COUNT*(l_val.COUNT/(conp.COUNT*coca.COUNT))))+1); g_error_point := 'A038'; g_nnpcv_tab(i).coca_id := coca(MOD((i-1),coca.COUNT)+1); g_error_point := 'A039'; g_nnpcv_tab(i).value := l_val(i); -- END LOOP; -- END IF; -- g_error_point := 'A045'; -- -- Verify the nomination -- IF cont_id IS NOT NULL THEN -- -- Ensure that we have a contract before proceeding -- g_error_point := 'A095'; -- get_cont_id(p_cont_id => cont_id); -- -- Get the "Receive Before Start" parameter for the contract l_rcve_b4_start := get_receive_before_start(g_cont_id); -- g_error_point := 'A115'; -- IF get_spte_name(g_cont_id) = UPPER(g_spte_single) THEN -- -- Looking at a single gas day -- IF g_gas_days(1) IS NULL THEN -- l_sub_list(1) := caco_utilities.get_module_text(1142); -- caco_utilities.get_exception_message(p_exception_number => -20506 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- g_error_point := 'A120'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A125'; -- BEGIN -- l_date := TO_DATE(g_gas_days(1), g_date_format); -- EXCEPTION -- WHEN OTHERS THEN -- l_sub_list(1) := g_gas_days(1); -- caco_utilities.get_exception_message(p_exception_number => -20102 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- g_error_point := 'A130'; -- RAISE e_ude; -- END; -- g_error_point := 'A135'; -- -- Established it is a valid date, but is it in the correct timeframe? -- IF l_date < g_target_date -1 THEN -- l_sub_list(1) := TO_CHAR(l_date, g_date_format); l_sub_list(2) := TO_CHAR(g_target_date, g_date_format); -- caco_utilities.get_exception_message(p_exception_number => -20509 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- g_error_point := 'A140'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A145'; -- -- Check date against contract range -- IF NOT check_cont_date ( p_cont_id => g_cont_id , p_date => l_date , p_message => l_message ) THEN -- g_error_point := 'A150'; -- RAISE e_ude; -- END IF; -- -- Check the date against the "Receive Before Start" parameter -- IF ( l_date - TRUNC(SYSDATE) ) > l_rcve_b4_start THEN -- -- it is too early to nominate for this gas day. caco_utilities.get_exception_message(p_exception_number => -20527 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); g_error_point := 'A152'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A155'; -- -- Check the gate closure -- IF NOT check_gate_closure ( p_cont_id => g_cont_id , p_date => l_date , p_message => l_message ) THEN -- g_error_point := 'A160'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A165'; -- ELSIF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN -- -- Looking at multiple gas days -- g_error_point := 'A167'; -- SELECT COUNT(*) INTO l_cnp_count FROM cont_network_points conp ,network_points nepo WHERE conp.cont_id = g_cont_id AND conp.nepo_id = nepo.nepo_id AND ((nepo.nepo_type = 'V' AND efno_contracts.emo_contract(g_cont_id) = 'Y') OR (nepo.nepo_type IN ('N','X') AND efno_contracts.emo_contract(g_cont_id) = 'N')); -- g_target_date := TO_DATE(p_gasday_start, g_date_format); g_target_date_end := TO_DATE(p_gasday_end, g_date_format); -- IF g_target_date < g_cont_start_date THEN -- -- Target date is less than the start of the contract...what to do? -- l_multi_day_iter := l_multi_day_iter - MOD(7-(TO_CHAR(g_cont_start_date,'D')-g_day_at_start_of_week),7)+1; -- g_target_date := g_cont_start_date; -- END IF; -- /* IF g_cont_end_date - g_target_date < TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')) THEN -- -- End of contract occurs during week, shorten the days displayed -- l_multi_day_iter := l_multi_day_iter - (TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')-(g_cont_end_date - g_target_date)))+1; -- IF l_multi_day_iter < 0 THEN -- l_multi_day_iter := 0; -- END IF; -- END IF; */ -- IF MOD(l_gasday.COUNT, l_cnp_count) <> 0 THEN -- -- The same number of days should be specified for each network point -- l_sub_list(1) := caco_utilities.get_module_text(1142); -- caco_utilities.get_exception_message(p_exception_number => -20506 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- FOR i IN 1..(TO_NUMBER(l_multi_day_iter) * l_cnp_count) LOOP -- g_row_error(i) := l_message; -- END LOOP; -- g_error_point := 'A170'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A175'; -- FOR i IN 1..l_gasday.COUNT LOOP -- -- Check each date is a valid date -- BEGIN -- l_date := TO_DATE(g_gas_days(i), g_date_format); -- EXCEPTION -- WHEN OTHERS THEN -- l_sub_list(1) := g_gas_days(i); -- caco_utilities.get_exception_message(p_exception_number => -20102 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- g_row_error(i) := l_message; -- g_error_point := 'A180'; -- RAISE e_ude; -- END; -- g_error_point := 'A185'; -- -- Check date is in the future -- IF l_date < g_target_date -1 THEN -- l_sub_list(1) := TO_CHAR(l_date, g_date_format); l_sub_list(2) := TO_CHAR(g_target_date+(i-1), g_date_format); -- caco_utilities.get_exception_message(p_exception_number => -20509 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); g_row_error(i) := l_message; -- g_error_point := 'A190'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A195'; -- -- Check date against contract range -- IF NOT check_cont_date ( p_cont_id => g_cont_id , p_date => l_date , p_message => l_message ) THEN -- g_row_error(i) := l_message; -- g_error_point := 'A200'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A205'; -- -- Check the gate closure -- IF NOT check_gate_closure ( p_cont_id => g_cont_id , p_date => l_date , p_message => l_message ) THEN -- g_row_error(i) := l_message; -- g_error_point := 'A210'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A215'; -- -- Check date sequence -- IF MOD(i-1, g_gas_days.COUNT/l_cnp_count) > 0 THEN -- -- If we're not looking at the first date -- IF TO_DATE(g_gas_days(i), g_date_format) -1 <> TO_DATE(g_gas_days(i-1), g_date_format) THEN -- caco_utilities.get_exception_message(p_exception_number => -20510 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); g_row_error(i) := l_message; -- g_error_point := 'A220'; -- RAISE e_ude; -- END IF; -- END IF; -- -- Check the date against the "Receive Before Start" parameter -- IF ( l_date - TRUNC(SYSDATE) ) > l_rcve_b4_start THEN -- -- it is too early to nominate for this gas day. caco_utilities.get_exception_message(p_exception_number => -20527 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); g_row_error(i) := l_message; -- g_error_point := 'A222'; -- RAISE e_ude; -- END IF; -- -- g_error_point := 'A225'; -- END LOOP; -- -- If a multi-day range contains a long/short day and the contract -- has a long/short day category and the contract is using the single-multi day input format -- then output an error/warning l_loop_counter := (g_target_date_end - g_target_date) +1; IF l_loop_counter > 1 AND get_spte_name(cont_id) = UPPER(g_spte_smulti) THEN -- check for long day category OPEN cu_coca('LO'); FETCH cu_coca INTO l_coca_id; IF cu_coca%FOUND THEN FOR i IN 1..l_loop_counter LOOP -- -- check for long day IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 25 THEN l_message := wsgl.msggettext(p_msgno => NULL ,p_dflttext => caco_utilities.get_module_text(3935) ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); -- g_error_message := display_message( p_type => WSGL.MESS_ERROR , p_mess => l_message ); RAISE e_ude; END IF; END LOOP; END IF; CLOSE cu_coca; -- -- check for short day category OPEN cu_coca('SH'); FETCH cu_coca INTO l_coca_id; IF cu_coca%FOUND THEN FOR i IN 1..l_loop_counter LOOP -- -- check for short day IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 23 THEN l_message := wsgl.msggettext(p_msgno => NULL ,p_dflttext => caco_utilities.get_module_text(3936) ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); -- g_error_message := display_message( p_type => WSGL.MESS_ERROR , p_mess => l_message ); RAISE e_ude; END IF; END LOOP; END IF; CLOSE cu_coca; END IF; ELSE -- -- Looking at something else? -- NULL; -- END IF; -- g_error_point := 'A227'; -- -- Dates look OK, move on to numbers -- IF MOD(l_val.COUNT,(conp.COUNT*coca.COUNT))=0 THEN --id.COUNT = val.COUNT THEN -- -- Now go through the values - this way we can redisplay any errors -- FOR i IN 1..l_val.COUNT LOOP -- IF l_val(i) IS NULL THEN -- l_sub_list(1) := caco_utilities.get_module_text(2022); -- caco_utilities.get_exception_message(p_exception_number => -20506 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- lr_cell_error.conp_id := g_nnpcv_tab(i).conp_id; lr_cell_error.coca_id := g_nnpcv_tab(i).coca_id; lr_cell_error.iteration := CEIL(i/(l_val.COUNT/l_gasday.COUNT)); lr_cell_error.message := l_message; -- g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; -- g_error_point := 'A230'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A235'; -- BEGIN -- -- Anon block to check for numeric conversion -- g_nnpcv_tab(i).value := TO_NUMBER(REPLACE(l_val(i),',','')); -- EXCEPTION WHEN OTHERS THEN -- caco_utilities.get_exception_message(p_exception_number => -20511 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- lr_cell_error.conp_id := g_nnpcv_tab(i).conp_id; lr_cell_error.coca_id := g_nnpcv_tab(i).coca_id; lr_cell_error.iteration := CEIL(i/(l_val.COUNT/l_gasday.COUNT)); lr_cell_error.message := l_message; -- g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; -- g_error_point := 'A240'; -- RAISE e_ude; -- END; -- -- Check number format -- g_error_point := 'A241'; -- IF INSTR(TO_CHAR(g_nnpcv_tab(i).value),'.') > 0 THEN -- -- Number entered has a decimal, lets check it's within range, lookup format -- g_error_point := 'A242'; -- l_num_format := NULL; -- SELECT c.number_format INTO l_num_format FROM categories c ,contract_categories cc WHERE c.cate_id = cc.cate_id AND cc.coca_id = g_nnpcv_tab(i).coca_id; -- -- Now compare the number formats -- IF (LENGTH(TO_CHAR(g_nnpcv_tab(i).value)) - INSTR(TO_CHAR(g_nnpcv_tab(i).value),'.')) > (LENGTH(l_num_format) - INSTR(l_num_format||'.','.')) THEN -- -- Number of decimals in supplied format greater than number of decimals in format mask -- g_error_point := 'A243'; -- l_message := display_message(p_type => WSGL.MESS_ERROR ,p_mess => NVL(l_message ,caco_utilities.get_module_text(p_text_number => 2240 ) ) ); l_message := caco_utilities.get_module_text(p_text_number => 2240 ); -- lr_cell_error.conp_id := g_nnpcv_tab(i).conp_id; lr_cell_error.coca_id := g_nnpcv_tab(i).coca_id; --lr_cell_error.iteration := CEIL(i/(val.COUNT/gasday.COUNT)); IF MOD(CEIL(i/(l_val.count/l_gasday.count)),(l_gasday.count/l_cnp_count)) = 0 THEN -- -- MOD returns zero when I'd like # of gasdays -- lr_cell_error.iteration := (l_gasday.count/l_cnp_count); ELSE -- -- otherwise, works OK -- lr_cell_error.iteration := MOD(CEIL(i/(l_val.count/l_gasday.count)),(l_gasday.count/l_cnp_count)); END IF; lr_cell_error.message := l_message; -- g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; -- RAISE e_ude; -- END IF; -- END IF; -- g_error_point := 'A245'; -- -- Have validated gas days already -- IF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN -- g_nnpcv_tab(i).gas_day := TO_DATE(l_gasday(CEIL(i/(l_val.COUNT/l_gasday.COUNT))),g_date_format); -- ELSE -- g_nnpcv_tab(i).gas_day := TO_DATE(l_gasday(1), g_date_format); -- END IF; -- g_error_point := 'A246'; -- END LOOP; -- IF get_spte_name(g_cont_id) IN (UPPER(g_spte_multi),UPPER(g_spte_smulti)) THEN -- g_target_date_end := g_nnpcv_tab(g_nnpcv_tab.LAST).gas_day; -- END IF; -- g_error_point := 'A247'; -- ELSE -- -- Identifiers and values not balanced -- g_error_point := 'A248'; -- l_message := display_message(p_type => WSGL.MESS_ERROR ,p_mess => NVL(l_message ,caco_utilities.get_module_text(p_text_number => 2330 ) ) ); -- FOR i IN 1..TO_NUMBER(cout_system_configuration.get_configuration_item('G_MULTI_DAY_NOM_DAYS')) LOOP -- g_row_error(i) := l_message; -- END LOOP; -- g_error_point := 'A250'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A251'; -- ELSE -- -- Null Contract, raise error -- g_error_point := 'A255'; -- l_sub_list(1) := caco_utilities.get_module_text(2137); -- caco_utilities.get_exception_message(p_exception_number => -20506 ,p_message => l_message ,p_exme_type => l_mess_type ,p_substitution_list => l_sub_list ,p_language => caco_utilities.get_syus_lang ); -- g_error_point := 'A260'; -- RAISE e_ude; -- END IF; -- g_error_point := 'A270'; -- -- Because rules are based on data in the nominations table, we need to insert it here... -- DBMS_TRANSACTION.SAVEPOINT(g_cont_id); -- -- Insert the nomination header -- INSERT INTO nominations ( status , identifier , cont_id ) VALUES ( 'A' , 1 , g_cont_id ) RETURNING nomi_id INTO l_nomi_id; -- UPDATE nominations SET identifier = l_nomi_id WHERE nomi_id = l_nomi_id; -- g_error_point := 'A280'; -- l_nomi_details := 'NOM:'||l_nomi_id||' ID:'||l_nomi_id||' CONT:'||g_cont_id||'DETAILS:'; -- -- check if it is an entry mandatory offer contract IF efno_contracts.emo_contract(g_cont_id) = 'Y' THEN -- OPEN c_tot_perc_split(g_cont_id); FETCH c_tot_perc_split INTO l_tot_perc_split; CLOSE c_tot_perc_split; -- IF l_tot_perc_split = 0 THEN IF caco_utilities.user_has_EFT_admin = 'Y' THEN -- Percentage split contract parameters have not been set up correctly l_message := caco_utilities.get_module_text(3917); ELSE -- A more customer friendly error message.. -- An error has occurred in validating this nomination. Please contact support. l_message := caco_utilities.get_module_text(3923); END IF; g_error_point := 'A282'; RAISE e_ude; END IF; -- FOR nnpcv_idx IN g_nnpcv_tab.FIRST..g_nnpcv_tab.LAST LOOP -- -- check that it is a virtual network point IF efno_contracts.virtual_nepo(g_nnpcv_tab(nnpcv_idx).conp_id) THEN -- insert a record for each non virtual network point assigned to the contract -- using the virtual nepo nominated values and percentage split parameter FOR i IN c_conp(g_cont_id) LOOP -- INSERT INTO nom_net_point_cat_vals ( value , gas_day , coca_id , nomi_id , conp_id ) VALUES ( ROUND((i.perc_split/l_tot_perc_split)*g_nnpcv_tab(nnpcv_idx).value) , g_nnpcv_tab(nnpcv_idx).gas_day , g_nnpcv_tab(nnpcv_idx).coca_id , l_nomi_id , i.conp_id ); END LOOP; ELSE -- Nominations for Entry Manadatory Offer Contracts must be against a virtual network point l_message := caco_utilities.get_module_text(3916); g_error_point := 'A285'; RAISE e_ude; END IF; -- END LOOP; -- END IF; -- FOR nnpcv_idx IN g_nnpcv_tab.FIRST..g_nnpcv_tab.LAST LOOP -- -- Would only use forall if it wasn't for pls-00436... -- -- g_error_point := 'A290'; -- INSERT INTO nom_net_point_cat_vals ( value , gas_day , coca_id , nomi_id , conp_id ) VALUES ( g_nnpcv_tab(nnpcv_idx).value , g_nnpcv_tab(nnpcv_idx).gas_day , g_nnpcv_tab(nnpcv_idx).coca_id , l_nomi_id , g_nnpcv_tab(nnpcv_idx).conp_id ); -- l_nomi_details := SUBSTR(l_nomi_details||' Day:'||g_nnpcv_tab(nnpcv_idx).gas_day||' Cat:'||g_nnpcv_tab(nnpcv_idx).coca_id||' Net:'||g_nnpcv_tab(nnpcv_idx).conp_id||' Val:'||g_nnpcv_tab(nnpcv_idx).value ,1 ,4000 ); -- END LOOP; -- -- g_error_point := 'A300'; -- -- Now enact the rules -- l_rule_results := efno_nominations.rule_loops( l_nomi_id , g_cont_id , l_message , l_c_nnpcv_tab ); -- g_error_point := 'A310'; -- -- Check the status of the rules -- IF l_rule_results THEN -- g_error_point := 'A320'; -- -- questionable results -- IF l_message IS NULL THEN -- l_message := caco_utilities.get_module_text(2270); -- END IF; -- l_idx := l_c_nnpcv_tab.FIRST; -- g_error_point := 'A330'; -- FOR i IN 1..l_c_nnpcv_tab.COUNT LOOP -- g_error_point := 'A331'; -- IF l_c_nnpcv_tab(l_idx).in_error THEN -- g_error_point := 'A332'; -- lr_cell_error.conp_id := l_c_nnpcv_tab(l_idx).conp_id; lr_cell_error.coca_id := l_c_nnpcv_tab(l_idx).coca_id; lr_cell_error.iteration := return_index(l_c_nnpcv_tab(l_idx).gas_day, l_gasday); lr_cell_error.message := l_message; -- -- Now add to the end of the stack -- g_cell_error(NVL(g_cell_error.COUNT,0)+1) := lr_cell_error; -- END IF; -- l_idx := l_c_nnpcv_tab.NEXT(l_idx); -- END LOOP; -- -- Raise as an error -- g_error_point := 'A350'; -- RAISE e_ude; -- END IF; -- -- Now determine what we should be doing, be it verify or insert -- IF action = caco_utilities.get_module_text(1149/*Verify*/) THEN -- g_error_point := 'A360'; -- -- We do not want to save it, rollback. -- DBMS_TRANSACTION.ROLLBACK_SAVEPOINT(g_cont_id); -- l_message := caco_utilities.get_module_text( p_text_number => 2341 ); -- g_error_message := display_message( p_type => WSGL.MESS_SUCCESS , p_mess => l_message ); -- END IF; -- IF action IN (caco_utilities.get_module_text(840/* Insert */)) THEN -- g_error_point := 'A370'; -- -- Update existing nominations to inactive -- l_idx := g_nnpcv_tab.COUNT; -- not sure why we can't imbed this in the SQL below, but we can't -- UPDATE nominations nomi SET nomi.status = 'I' WHERE nomi.cont_id = g_cont_id AND nomi.nomi_id <> l_nomi_id AND EXISTS ( SELECT NULL FROM nom_net_point_cat_vals nnpcv WHERE nnpcv.nomi_id = nomi.nomi_id AND nnpcv.gas_day BETWEEN g_nnpcv_tab(1).gas_day AND g_nnpcv_tab(l_idx).gas_day ) AND NOT EXISTS ( SELECT NULL FROM nom_net_point_cat_vals nnpcv WHERE nnpcv.nomi_id = nomi.nomi_id AND nnpcv.gas_day NOT BETWEEN g_nnpcv_tab(1).gas_day AND g_nnpcv_tab(l_idx).gas_day ); -- g_error_point := 'A371'; -- -- Timestamp -- l_timestamp := timestamp_nomi ( p_nomi_id => l_nomi_id , p_nomi_details => l_nomi_details ); -- g_error_point := 'A372'; -- -- Notification -- l_letter := send_nom_notification ( p_cust_id => g_cust_id , p_nomi_identifier => l_nomi_id , p_gas_day_start => g_nnpcv_tab(1).gas_day , p_gas_day_end => g_nnpcv_tab(g_nnpcv_tab.COUNT).gas_day , p_timestamp => l_timestamp ); -- g_error_point := 'A373'; -- -- Create confimation -- INSERT INTO confirmations ( confirmation_type , confirmation_sent , confirmation , nomi_id , confirmation_text , approved ) VALUES ( 'NO' , l_timestamp , NULL -- will add later , l_nomi_id , l_letter , 'Y' ); -- g_error_point := 'A374'; -- -- Save Spreadsheet -- IF NVL(cout_system_configuration.get_configuration_item('G_SAVE_NOM_TEMPLATE'),'Y') = 'Y' THEN -- amfr_excel.get_template(p_id => g_cont_id ,p_type => amfr_excel.gc_nomination ,p_nomi_conf_id => l_nomi_id ,p_mode => 'INSERT' ); -- END IF; -- g_error_point := 'A375'; -- l_message := caco_utilities.get_module_text( p_text_number => 2342 ); -- g_error_message := display_message( p_type => WSGL.MESS_SUCCESS , p_mess => l_message ); -- END IF; -- ELSE -- -- We must be changing the date, keep existing data -- get_cont_id(cont_id); -- g_error_point := 'A376'; -- IF l_gasday.COUNT > 0 THEN -- g_target_date := TO_DATE(l_gasday(1),g_date_format); -- END IF; -- IF p_gasday_start IS NOT NULL THEN -- g_target_date := TO_DATE(p_gasday_start,g_date_format); -- END IF; -- g_target_date_end := GREATEST(GREATEST(TO_DATE(NVL(p_gasday_end, g_target_date),g_date_format), g_target_date),(TO_DATE(p_gasday_start,g_date_format) + (TO_DATE(l_gasday(l_gasday.COUNT), g_date_format)-TO_DATE(l_gasday(1),g_date_format)))); -- g_error_point := 'A377'; -- FOR i IN 1..l_val.COUNT LOOP -- g_nnpcv_tab(i).value := l_val(i); g_nnpcv_tab(i).gas_day := TO_DATE(l_gasday(CEIL(i/(l_val.count/l_gasday.count))),g_date_format); -- IF MOD(i,coca.COUNT) = 0 THEN g_nnpcv_tab(i).coca_id := coca(coca.COUNT); ELSE g_nnpcv_tab(i).coca_id := coca(MOD(i,coca.COUNT)); END IF; -- g_nnpcv_tab(i).conp_id := conp(CEIL(CEIL(i/coca.COUNT)/((TO_DATE(l_gasday(l_gasday.COUNT), g_date_format)+1)-TO_DATE(l_gasday(1),g_date_format)))); -- END LOOP; -- g_target_date_end := TO_DATE(p_gasday_end, g_date_format); -- --display_nnpcv_tab(g_nnpcv_tab); -- -- If a multi-day range contains a long/short day and the contract -- has a long/short day category and the contract is using the single-multi day input format -- then output an error/warning l_loop_counter := (g_target_date_end - g_target_date) +1; IF l_loop_counter > 1 AND get_spte_name(cont_id) = UPPER(g_spte_smulti) THEN -- check for long day category OPEN cu_coca('LO'); FETCH cu_coca INTO l_coca_id; IF cu_coca%FOUND THEN FOR i IN 1..l_loop_counter LOOP -- -- check for long day IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 25 THEN l_message := wsgl.msggettext(p_msgno => NULL ,p_dflttext => caco_utilities.get_module_text(3935) ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); -- g_error_message := display_message( p_type => WSGL.MESS_ERROR , p_mess => l_message ); EXIT; END IF; END LOOP; END IF; CLOSE cu_coca; -- -- check for short day category OPEN cu_coca('SH'); FETCH cu_coca INTO l_coca_id; IF cu_coca%FOUND THEN FOR i IN 1..l_loop_counter LOOP -- -- check for short day IF cout_dates.hours_in_gas_day(g_target_date + (i-1)) = 23 THEN l_message := wsgl.msggettext(p_msgno => NULL ,p_dflttext => caco_utilities.get_module_text(3936) ,p_subst1 => to_char(g_target_date + (i-1),g_date_format)); -- g_error_message := display_message( p_type => WSGL.MESS_ERROR , p_mess => l_message ); EXIT; END IF; END LOOP; END IF; CLOSE cu_coca; END IF; -- END IF; -- EXCEPTION WHEN OTHERS THEN -- -- Rollback the transaction just in case... -- BEGIN DBMS_TRANSACTION.ROLLBACK_SAVEPOINT(g_cont_id); EXCEPTION WHEN OTHERS THEN NULL; END; -- g_error_message := display_message(p_type => WSGL.MESS_ERROR ,p_mess => NVL(l_message ,caco_utilities.get_module_text(p_text_number => 2330 ) ) ); -- cout_err.report_and_go(p_exception_number => sqlcode ,p_exception_message => g_error_point||' : '||sqlerrm ); -- END; -- -- release lock on nominations table -- l_noms_release := dbms_lock.release(id => 128); caco_debug.putline('default_values DBMS_LOCK id 128 release value l_noms_release is ' || l_noms_release); END IF; -- -- Now verified, let us rebuild the screen -- redisplay ( p_contract => g_cont_num ); -- END IF; -- security check -- END submit_nomination; -- PROCEDURE startup IS BEGIN -- -- Startup the screen with the contract for the target date -- -- nom_header( p_contract => g_cont_num ); --caco_debug.putline('-----startup'); -- nom_header( p_contract => NULL ); -- END startup; -- FUNCTION get_exception_message( p_exception_number IN NUMBER ) RETURN VARCHAR2 IS -- l_return VARCHAR2(1000); l_type VARCHAR2(1000); -- BEGIN -- caco_utilities.get_exception_message(p_exception_number => p_exception_number ,p_message => l_return ,p_exme_type => l_type ); -- RETURN l_return; -- END get_exception_message; -- /** -- FUNCTION about -- Returns the version number and VSS header for this package -- -- %return The version number and VSS header for this package */ FUNCTION about RETURN VARCHAR2 IS BEGIN RETURN(g_package_name || chr(10) || g_revision || chr(10) || g_header); END about; -- BEGIN -- -- Initialisation -- --caco_debug.putline('-----Initialisation'); -- gc_no_data_found := get_exception_message(-20521); gc_missing_details := get_exception_message(-20516); gc_invalid_file_format := get_exception_message(-20517); gc_no_cont_found := get_exception_message(-20518); gc_nom_id_null := get_exception_message(-20519); gc_dup_nom_identifier := get_exception_message(-20520); -- g_day_at_start_of_week := cout_system_configuration.get_configuration_item('G_DAY_AT_START_OF_WEEK'); -- IF g_cust_id IS NULL THEN -- g_cust_id := caco_utilities.get_cust_id; -- END IF; -- IF g_cust_id IS NOT NULL THEN -- get_cont_id ( p_contract_number => g_cont_num , p_cust_id => g_cust_id ); -- IF in_a_renom_window(p_gas_day => g_gas_day ,p_window_time => g_active_time) THEN -- -- In a renomination window -- g_target_date := g_gas_day; -- ELSE -- -- Not in renom window, default to gasday + offset -- g_target_date := g_gas_day + NVL(cout_system_configuration.get_configuration_item('G_NOM_DATE_OFFSET'),1); -- END IF; -- g_target_date := GREATEST(g_target_date, g_cont_start_date); g_target_date_end := g_target_date; -- /*caco_debug.putline('g_target_date: '||to_char(g_target_date,g_date_format)); caco_debug.putline('g_gas_day: '||to_char(g_gas_day,g_date_format)); caco_debug.putline('g_cust_id: '||g_cust_id); caco_debug.putline('g_cont_start_date: '||to_char(g_cont_start_date,g_date_format));*/ -- END IF; -- END efnow098$; /