Commit a3176f2b authored by dpawar's avatar dpawar

update function and credit policy insert


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93515 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c9f26629
......@@ -342,16 +342,47 @@ update transetup set edit_expr = 'or spl_sales_por_hdr.wf_status in(''R'')' wher
insert into gencodes (FLD_NAME,MOD_NAME,FLD_VALUE,DESCR,SH_DESCR,CHG_DATE,CHG_USER,CHG_TERM,ACTIVE,UDF_STR1,UDF_STR2,UDF_STR3)
values ('REAS_CODE','W_MISC_DRCR_RCP_DR','PODDBTNOTE','POD DEBIT NOTE CHARGES ','PODCHRG',SYSDATE,'BASE','BASE','Y','3616','C421',null);
insert into itemser_cr_policy (ITEM_SER,CR_POLICY,APPLY_TYPE,POLICY_TYPE,DESCR,TITLE,CHG_DATE,CHG_USER,CHG_TERM,APPLY_TIME,
CONSIDER_PBO,POLICY_SQL,POLICY_INPUT,POLICY_RESULT,POLICY_CONDITION,MAIL_OPTION)
values ('NT','P91','M','U','POD CREDIT POLICY','POD CREDIT POLICY',sysdate,'BASE','BASE','S','N','SELECT fn_pod_chk(?,?) FROM DUAL','cust_code,site_code','0','=',null);
delete from itemser_cr_policy where cr_policy = 'P93';
INSERT INTO itemser_cr_policy (item_ser,
cr_policy,
apply_type,
policy_type,
descr,
title,
chg_date,
chg_user,
chg_term,
apply_time,
consider_pbo,
policy_sql,
policy_input,
policy_result,
policy_condition,
mail_option)
VALUES (
'NT ',
'P93',
'M',
'U',
'POD CREDIT POLICY',
'POD CREDIT POLICY',
sysdate,
'm',
'm',
'S',
'N',
'SELECT fn_pod_chk(?) FROM DUAL',
'sale_order',
'1',
'=',
NULL);
commit;
--Function
create or replace
Function fn_pod_chk ( ls_custCodeBill in char, ls_siteCode in char)
Function fn_pod_chk ( as_saleorder in sorder.sale_order%type)
RETURN number IS
TYPE InvCurTyp IS REF CURSOR;
inv_cur InvCurTyp;
cnumber number;
......@@ -360,15 +391,27 @@ Function fn_pod_chk ( ls_custCodeBill in char, ls_siteCode in char)
pod_cnt number;
ls_invoiceid char(10);
ls_sql_stmt varchar2(3000);
BEGIN
ls_custCodeBill customer.cust_code%type;
ls_siteCode site.site_code%type;
BEGIN
cnumber := 0;
begin
select var_value into inv_type_list from disparm where var_name = 'POD_INV_TYPE' and prd_code = '999999';
select replace(inv_type_list,',',''',''') into inv_type_list FROM DUAL;
inv_type_list := '''' || inv_type_list || '''';
exception when others then
return 1;
end;
begin
select '''' || replace(inv_type_list,',',''',''') || '''' into inv_type_list FROM DUAL;
exception when others then
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;
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';
......@@ -378,13 +421,15 @@ BEGIN
-- cursor for multiple invoices against passed cust_code
OPEN inv_cur FOR ls_sql_stmt USING ls_custCodeBill, ls_siteCode;
-- Fetch rows from result set one at a time:
LOOP
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;
exception when others then
return 1;
end;
if pod_cnt = 0 then
cnumber := 1;
exit;
......@@ -392,14 +437,14 @@ BEGIN
cnumber := 0;
end if;
END LOOP;
-- Close cursor:
CLOSE inv_cur;
exception when others then
return 1;
end;
return cnumber;
END;
/
--end function
-- 7-Aug-2013
......
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