select * from ( select cfr.bp_code,max(cfr.max_overdue_days)max_overdue_days from con_contract_ifrs9 cfr where cfr.period_day=${@period_name} and cfr.max_overdue_days>0 group by cfr.bp_code)v
and tt.transaction_date <= to_date(${@calc_date},'yyyy-mm-dd')
and tt.deposit_trans_type ='rent_deposit'
and tt.source_type is not null
and tt.company_id=${/session/@company_id}
and (exists (
(select 1
from exp_emp_assign_e_v ee
where ee.user_id = ${/session/@user_id}
and ee.unit_id not in (1565,1552,1564,1551,1559,1547,1560,1545,1546,1568,1566,1570,1550,1569,1555,1571,1558)
and ee.unit_id=(SELECT h.unit_id FROM hls_bp_master h WHERE h.bp_id=tt.bp_id)
and ${/session/@role_id} in (select v.role_id from sys_role_vl v where v.role_code in ('0018','0019')) ) )
or (${/session/@role_id} not in (select v.role_id from sys_role_vl v where v.role_code in ('0018','0019')) ))
and ((decode(${/session/@user_id}, 10600, 1, 2) = 1
and exists (select 1 from hls_bp_master hb where hb.bp_id = tt.bp_id
and hb.bp_code in ('D00000028','D00000035','D00000016','D00000021','D00000039','D00000025','D00000034','D00000017','D00000018','D00000024','D00000032','D00000009','D00000012','D00000014','D00000015','D00000023')) )
or (decode(${/session/@user_id}, 10600, 1, 2) = 2))
and ((nvl(tt.transaction_amount, 0) - nvl(tt.write_off_amount, 0) -
<!-- and exists (select 1 from hls_bp_master hb where hb.bp_id = t1.bp_id-->
<!-- and hb.bp_code in ('D00000028','D00000035','D00000016','D00000021','D00000039','D00000025','D00000034','D00000017','D00000018','D00000024','D00000032','D00000009','D00000012','D00000014','D00000015','D00000023')) )-->
<!-- or (decode(${/session/@user_id}, 10600, 1, 2) = 2) )"/>-->
var brwt = new BookmarksReplaceWithText($instance('leaf.database.service.IDatabaseServiceFactory'), $instance('uncertain.ocm.IObjectRegistry'), $ctx.getData());