jl_br_ar_ass_appln_id_popl
AFTER INSERT ON ar_receivable_applications_all
FOR EACH ROW
Type
AFTER EACH ROW
Event
INSERT
Column
When
new.status = 'APP'
AND ((sys_context('JG','JGZZ_COUNTRY_CODE') in ('BR'))
OR (to_char(new.org_id) <> nvl(sys_context('JG','JGZZ_ORG_ID'),'XX')))
Referencing
REFERENCING NEW AS NEW OLD AS OLD
Body
declare
l_country_code VARCHAR2(100);
cursor c_adj is
select adjustment_id
from ar_adjustments
where associated_cash_receipt_id = :NEW.cash_receipt_id
and associated_application_id IS NULL;
--
adj_rec c_adj%ROWTYPE;
--
begin
IF (to_char(:new.org_id) <> nvl(sys_context('JG','JGZZ_ORG_ID'),'XX')) THEN
l_country_code := JG_ZZ_SHARED_PKG.GET_COUNTRY(:new.org_id,NULL,NULL);
JG_CONTEXT.name_value('JGZZ_COUNTRY_CODE',l_country_code);
JG_CONTEXT.name_value('JGZZ_ORG_ID',to_char(:new.org_id));
END IF;
IF (sys_context('JG','JGZZ_COUNTRY_CODE') = 'BR') THEN
open c_adj;
loop
fetch c_adj into adj_rec;
EXIT when c_adj%NOTFOUND;
update ar_adjustments
set associated_application_id = :NEW.receivable_application_id WHERE adjustment_id = adj_rec.adjustment_id;
end loop;
close c_adj;
END IF;
end jl_br_ar_ass_appln_id_popl;