Commit 1ebcb8b9 authored by ssurve's avatar ssurve

Partial POD logic


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93646 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 16f63ec2
...@@ -384,6 +384,9 @@ create or replace ...@@ -384,6 +384,9 @@ create or replace
Function fn_pod_chk ( as_saleorder in sorder.sale_order%type) 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 ItemCurTyp IS REF CURSOR;
inv_cur InvCurTyp; inv_cur InvCurTyp;
cnumber number; cnumber number;
inv_type varchar2(3); inv_type varchar2(3);
...@@ -393,7 +396,17 @@ Function fn_pod_chk ( as_saleorder in sorder.sale_order%type) ...@@ -393,7 +396,17 @@ Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
ls_sql_stmt varchar2(3000); ls_sql_stmt varchar2(3000);
ls_custCodeBill customer.cust_code%type; ls_custCodeBill customer.cust_code%type;
ls_siteCode site.site_code%type; ls_siteCode site.site_code%type;
hdr_sql_stmt varchar2(3000);
dtl_sql_stmt varchar2(3000);
podqty_sum number;
inv_qty number;
dtl_cur DtlCurTyp;
item_cur ItemCurTyp;
ls_podtranid char(10);
itemcode char(10);
lineno number;
BEGIN BEGIN
cnumber := 0; cnumber := 0;
begin begin
...@@ -407,18 +420,20 @@ BEGIN ...@@ -407,18 +420,20 @@ BEGIN
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; --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);
exception when others then select site_code, cust_code__bil into ls_siteCode, ls_custCodeBill FROM sorder where sale_order = as_saleorder and order_type in('DM','IS');
return 1; exception when NO_DATA_FOUND then
return 0;
end; end;
--inv_type_list := '''' || inv_type_list || ''''; --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'; --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';
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';
--dbms_output.put_line('sql - ' || ls_sql_stmt);
--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:
...@@ -426,14 +441,61 @@ BEGIN ...@@ -426,14 +441,61 @@ BEGIN
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; 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 1;
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; exit;
else else
-- 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'' ';
--dbms_output.put_line('hdr_sql_stmt - ' || hdr_sql_stmt);
begin
open dtl_cur for hdr_sql_stmt USING ls_invoiceid;
LOOP
FETCH dtl_cur INTO ls_podtranid;
EXIT WHEN dtl_cur%NOTFOUND;
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';
dbms_output.put_line('dtl_sql_stmt - ' || dtl_sql_stmt);
begin
open item_cur for dtl_sql_stmt USING ls_podtranid;
LOOP
FETCH item_cur INTO ls_podtranid,itemcode,lineno,inv_qty;
EXIT WHEN item_cur%NOTFOUND;
select sum(quantity__resale) into podqty_sum from spl_sales_por_det where tran_id = ls_podtranid and item_code = itemcode;
if podqty_sum < inv_qty then
cnumber :=1;
--return cnumber;
exit;
end if;
END LOOP;
CLOSE item_cur;
end;
exception when others then
return 1;
end;
END LOOP;
CLOSE dtl_cur;
end;
-- Logic for partial POD entries ends here
cnumber := 0; cnumber := 0;
end if; end if;
END LOOP; END LOOP;
...@@ -442,7 +504,8 @@ BEGIN ...@@ -442,7 +504,8 @@ BEGIN
exception when others then exception when others then
return 1; return 1;
end; end;
return cnumber;
return cnumber;
END; END;
/ /
--end function --end function
......
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