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
Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
RETURN number IS
TYPE InvCurTyp IS REF CURSOR;
TYPE DtlCurTyp IS REF CURSOR;
TYPE ItemCurTyp IS REF CURSOR;
inv_cur InvCurTyp;
cnumber number;
inv_type varchar2(3);
......@@ -394,6 +397,16 @@ Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
ls_custCodeBill customer.cust_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
cnumber := 0;
begin
......@@ -407,12 +420,14 @@ BEGIN
return 1;
end;
begin
select site_code, cust_code__bil into ls_siteCode, ls_custCodeBill FROM sorder where sale_order = as_saleorder;
exception when others then
return 1;
--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('DM','IS');
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';
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);
......@@ -426,14 +441,61 @@ BEGIN
FETCH inv_cur INTO ls_invoiceid;
EXIT WHEN inv_cur%NOTFOUND;
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
return 1;
end;
--dbms_output.put_line('pod_cnt - ' || pod_cnt);
if pod_cnt = 0 then
cnumber := 1;
exit;
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;
end if;
END LOOP;
......@@ -442,6 +504,7 @@ BEGIN
exception when others then
return 1;
end;
return cnumber;
END;
/
......
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