Commit cc2bb4a3 authored by pgole's avatar pgole

Updated SQL FOR CHARGE_BACK


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@104217 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 70562523
------------------------CHANGE IN EXISTING TRIGGER------------------------------------
CREATE OR REPLACE
TRIGGER TRIG_MDRCR_VAL_CB_AMT
before insert or update
on misc_drcr_rcp
referencing old as old new as new
for each row
declare
PRAGMA AUTONOMOUS_TRANSACTION; -- 03/Apr-15 add by manoharan to avoid mutating
iscb number(3);
cbnetamt number(14,3);
cbclaumamt number(14,3);
drcramt number(14,3);
ll_count number(3) := 0;
begin
if :new.sreturn_no is not null and length(trim(:new.sreturn_no)) > 0 then
select count(*) into iscb from charge_back where tran_id = :new.sreturn_no;
if iscb > 0 then
--- 03-Apr-15 manoharan during insert check already
if inserting then
begin
select count(1) into ll_count from misc_drcr_rcp where sreturn_no = :new.sreturn_no;
exception when others then
ll_count := 0;
end;
if ll_count > 0 then
raise_application_error (-20500,'Credit Note already created against the charge back');
end if;
end if;
--- 03-Apr-15 manoharan during insert check already
begin
cbnetamt := 0;
cbclaumamt := 0;
drcramt := 0;
iscb := 0;
select NVL(net_amt,0), NVL(claum_amt,0) into cbnetamt, cbclaumamt from charge_back where tran_id = :new.sreturn_no;
if cbclaumamt <= 0 then
begin
drcramt := cbnetamt;
cbclaumamt := 0;
end;
else
if cbclaumamt < cbnetamt then
drcramt := cbclaumamt;
else
drcramt := cbnetamt;
end if;
end if;
if abs(nvl(:new.amount , 0) - nvl(drcramt , 0)) > 0.999 then
begin
raise_application_error (-20500,'Credit Note Amount not same as charge back amount CB Amount: (' || drcramt || ') CN Amount: (' || :new.amount || ')');
end;
end if;
end;
end if;
end if;
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