Commit b1c75a12 authored by ssurve's avatar ssurve

POD function modified code updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@94156 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8454eeca
...@@ -66,16 +66,17 @@ values( 'INVOICE_ID','W_PROOF_OF_DELIVERY','SELECT INVOICE_ID,TRAN_DATE,FIN_ENTI ...@@ -66,16 +66,17 @@ values( 'INVOICE_ID','W_PROOF_OF_DELIVERY','SELECT INVOICE_ID,TRAN_DATE,FIN_ENTI
commit; commit;
-- Function -- -- POD Function start --
create or replace Function fn_pod_chk ( as_saleorder in sorder.sale_order%type) create or replace
Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
RETURN number IS RETURN number IS
TYPE InvCurTyp IS REF CURSOR; TYPE InvCurTyp IS REF CURSOR;
TYPE DtlCurTyp IS REF CURSOR; TYPE DtlCurTyp IS REF CURSOR;
TYPE ItemCurTyp IS REF CURSOR; TYPE ItemCurTyp IS REF CURSOR;
inv_cur InvCurTyp; inv_cur InvCurTyp;
cnumber number; cnumber number ;
inv_type varchar2(3); inv_type varchar2(3);
inv_type_list varchar2(600); inv_type_list varchar2(600);
pod_cnt number; pod_cnt number;
...@@ -100,6 +101,7 @@ create or replace Function fn_pod_chk ( as_saleorder in sorder.sale_order%type) ...@@ -100,6 +101,7 @@ create or replace Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
-- 29-Nov-2013 -- 29-Nov-2013
curr_date varchar2(2); curr_date varchar2(2);
curr_mon varchar2(2);
curr_yr varchar2(2); curr_yr varchar2(2);
invoice_mnth varchar2(2); invoice_mnth varchar2(2);
begin_date varchar2(8); begin_date varchar2(8);
...@@ -107,36 +109,23 @@ create or replace Function fn_pod_chk ( as_saleorder in sorder.sale_order%type) ...@@ -107,36 +109,23 @@ create or replace Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
BEGIN BEGIN
cnumber := 0; cnumber := 0;
begin begin
select var_value into inv_type_list from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999'; select '''' || replace(var_value,',',' '',''') || ' ''' into inv_type_list from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999';
exception when others then
return 1;
end;
begin
select '''' || replace(inv_type_list,',',''',''') || '''' into inv_type_list FROM DUAL;
exception when others then exception when others then
return 1; return -1;
end; end;
begin begin
--select site_code, cust_code__bil into ls_siteCode, ls_custCodeBill FROM sorder where sale_order = as_saleorder and order_type in(inv_type_list); --select site_code, cust_code__bil into ls_siteCode, ls_custCodeBill FROM sorder where sale_order = as_saleorder and order_type in(inv_type_list);
select site_code, cust_code__bil, item_ser into ls_siteCode, ls_custCodeBill, ls_itemSerSO FROM sorder where sale_order = as_saleorder and order_type in(select '''' || replace(var_value,',',''',''') || '''' from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999'); --select site_code, cust_code__bil, item_ser into ls_siteCode, ls_custCodeBill, ls_itemSerSO FROM sorder where sale_order = as_saleorder and order_type in(select '''' || replace(var_value,',',''',''') || '''' from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999');
select site_code, cust_code__bil, item_ser into ls_siteCode, ls_custCodeBill, ls_itemSerSO FROM sorder where sale_order = as_saleorder and order_type in('DM ','IS ');
exception when NO_DATA_FOUND then exception when NO_DATA_FOUND then
return 0; return 0;
end; end;
-- Code to check credit policy defined for item series in regsrd with sale order item series
--begin
--select count(1) into itemSerCnt from itemser_cr_policy where item_ser = ls_itemSerSO;
--exception when NO_DATA_FOUND then
--return 0;
--end;
--inv_type_list := '''' || inv_type_list || '''';
--ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = ''' || ls_custCodeBill ||''' and site_code = ''' || ls_siteCode ||''' and inv_type in ('||inv_type_list||') and sysdate - conf_date > 29';
-- commented as per new requirement
--ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :ls_custCodeBill and site_code = :ls_siteCode and inv_type in ('||inv_type_list||') and sysdate - conf_date > 29';
-- @ Sandesh : Following logic will decide invoice table conf_date range for which POD entry needs to checked -- @ Sandesh : Following logic will decide invoice table conf_date range for which POD entry needs to checked
-- If current date is 31 then it will read invoices from previous month's 1st day to 30th day of previous month -- If current date is 31 then it will read invoices from previous month's 1st day to 30th day of previous month
-- For e.g. assuming current date is 31-Dec-2013 then invoices will between 1-Nov-2013 to 30-Nov-2013 -- For e.g. assuming current date is 31-Dec-2013 then invoices will between 1-Nov-2013 to 30-Nov-2013
...@@ -144,67 +133,86 @@ BEGIN ...@@ -144,67 +133,86 @@ BEGIN
-- For e.g. assuming current date is 30-Dec-2013 then invoices will between 1-Oct-2013 to 30-Oct-2013 -- For e.g. assuming current date is 30-Dec-2013 then invoices will between 1-Oct-2013 to 30-Oct-2013
begin begin
select to_char(sysdate, 'DD'),to_char(sysdate, 'YY') into curr_date,curr_yr FROM DUAL; select to_char(sysdate, 'DD'),to_char(sysdate, 'MM'),to_char(sysdate, 'YY') into curr_date,curr_mon,curr_yr FROM DUAL;
if curr_date = '31' then if curr_date = '31' then
select to_char(sysdate, 'MM')-1 into invoice_mnth FROM DUAL; select to_char(sysdate, 'MM')-1 into invoice_mnth FROM DUAL;
if curr_mon = '01' then
select to_char(sysdate, 'YY')-1 into curr_yr FROM DUAL;
invoice_mnth := '12';
else
invoice_mnth := ''|| curr_mon -1 ;
end if;
elsif curr_date >= '1' and curr_date <='30' then elsif curr_date >= '1' and curr_date <='30' then
select to_char(sysdate, 'MM')-2 into invoice_mnth FROM DUAL; select to_char(sysdate, 'MM')-2 into invoice_mnth FROM DUAL;
if curr_mon = '01' then
select to_char(sysdate, 'YY')-1 into curr_yr FROM DUAL;
invoice_mnth := '11';
elsif curr_mon = '02' then
select to_char(sysdate, 'YY')-1 into curr_yr FROM DUAL;
invoice_mnth := '12';
else
invoice_mnth := ''||curr_mon -2 ;
end if;
end if; end if;
begin_date := '1-'||invoice_mnth||'-'||curr_yr; begin_date := '1-'||invoice_mnth||'-'||curr_yr;
end_date := '30-'||invoice_mnth||'-'||curr_yr; end_date := '30-'||invoice_mnth||'-'||curr_yr;
exception when others then exception when others then
return 1; return -1;
end; end;
--ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :ls_custCodeBill and site_code = :ls_siteCode and inv_type in ('||inv_type_list||') and conf_date between '''|| to_date(begin_date) ||''' and '''|| to_date(end_date) ;
-- Error if no co --ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :ls_custCodeBill and site_code = :ls_siteCode and inv_type in (''DM '') and conf_date between '''|| to_date(begin_date) ||''' and '''|| to_date(end_date) ||'''' ;
ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = :ls_custCodeBill and site_code = :ls_siteCode and inv_type in ('||inv_type_list||') and conf_date between '''|| to_date(begin_date) ||''' and '''|| to_date(end_date) ; ls_sql_stmt := 'select invoice_id from invoice where cust_code__bil = '''||ls_custCodeBill||''' and site_code = '''||ls_siteCode||''' and inv_type in (''DM '') and conf_date between '''|| to_date(begin_date) ||''' and '''|| to_date(end_date) ||'''' ;
dbms_output.put_line('sql - ' || ls_sql_stmt);
begin begin
-- cursor for multiple invoices against passed cust_code -- cursor for multiple invoices against passed cust_code
OPEN inv_cur FOR ls_sql_stmt USING ls_custCodeBill, ls_siteCode; OPEN inv_cur FOR ls_sql_stmt ;--USING ls_custCodeBill, ls_siteCode;
-- Fetch rows from result set one at a time: -- Fetch rows from result set one at a time:
LOOP LOOP
FETCH inv_cur INTO ls_invoiceid; FETCH inv_cur INTO ls_invoiceid;
EXIT WHEN inv_cur%NOTFOUND; EXIT WHEN inv_cur%NOTFOUND;
begin begin
select count(1) into pod_cnt from spl_sales_por_hdr where invoice_id = ls_invoiceid and confirmed='Y'; select count(1) into pod_cnt from spl_sales_por_hdr where invoice_id = ls_invoiceid and confirmed='Y';
exception when others then exception when others then
return 1; return -2;
end; end;
--dbms_output.put_line('pod_cnt - ' || pod_cnt);
if pod_cnt = 0 then if pod_cnt = 0 then
cnumber := 1; cnumber := 1;
exit;
return cnumber;
--exit
else else
-- Logic for partial POD entries starts here -- Logic for partial POD entries starts here
hdr_sql_stmt := 'select tran_id from spl_sales_por_hdr where invoice_id = :ls_invoiceid and confirmed = ''Y'' and wf_status <> ''R'' '; hdr_sql_stmt := 'select tran_id from spl_sales_por_hdr where invoice_id = '''||ls_invoiceid||''' and confirmed = ''Y'' and wf_status <> ''R'' ';
--dbms_output.put_line('hdr_sql_stmt - ' || hdr_sql_stmt);
begin begin
open dtl_cur for hdr_sql_stmt USING ls_invoiceid; open dtl_cur for hdr_sql_stmt;-- USING ls_invoiceid;
LOOP LOOP
FETCH dtl_cur INTO ls_podtranid; FETCH dtl_cur INTO ls_podtranid;
EXIT WHEN dtl_cur%NOTFOUND; EXIT WHEN dtl_cur%NOTFOUND;
begin begin
dtl_sql_stmt := 'select line_no,item_code,quantity__inv into lineno,itemcode,invqty from spl_sales_por_det where tran_id = :ls_podtranid'; dtl_sql_stmt := 'select line_no,item_code,quantity__inv into lineno,itemcode,invqty from spl_sales_por_det where tran_id = '''||ls_podtranid||'''';
dbms_output.put_line('dtl_sql_stmt - ' || dtl_sql_stmt);
begin begin
open item_cur for dtl_sql_stmt USING ls_podtranid; open item_cur for dtl_sql_stmt;-- USING ls_podtranid;
LOOP LOOP
FETCH item_cur INTO ls_podtranid,itemcode,lineno,inv_qty; FETCH item_cur INTO ls_podtranid,itemcode,lineno,inv_qty;
EXIT WHEN item_cur%NOTFOUND; EXIT WHEN item_cur%NOTFOUND;
...@@ -213,15 +221,15 @@ BEGIN ...@@ -213,15 +221,15 @@ BEGIN
if podqty_sum < inv_qty then if podqty_sum < inv_qty then
cnumber :=1; cnumber :=1;
--return cnumber; return cnumber;
exit; --exit;
end if; end if;
END LOOP; END LOOP;
CLOSE item_cur; CLOSE item_cur;
end; end;
exception when others then exception when others then
return 1; return -1;
end; end;
END LOOP; END LOOP;
CLOSE dtl_cur; CLOSE dtl_cur;
...@@ -235,12 +243,13 @@ BEGIN ...@@ -235,12 +243,13 @@ BEGIN
-- Close cursor: -- Close cursor:
CLOSE inv_cur; CLOSE inv_cur;
exception when others then exception when others then
return 1; return -1;
end; end;
return cnumber; return cnumber;
END; END;
/
-- POD Function ends here
--added cross-update sql [13/12/13] --added cross-update sql [13/12/13]
update obj_forms set cross_update_expr='[debit_note_amt]',expr_fld_info='[2..D.debit_note_amt]',target_fld_info='[1.1.D.debit_note_amt]' update obj_forms set cross_update_expr='[debit_note_amt]',expr_fld_info='[2..D.debit_note_amt]',target_fld_info='[1.1.D.debit_note_amt]'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment