And ccc.due_amount > nvl(ccc.received_amount, 0)) As business_due_times, -- 营业逾期期数
(Select Max(ccc.overdue_max_days)
From con_contract_cashflow ccc
Where ccc.contract_id = cc.contract_id
And ccc.cf_item = 1
And ccc.cf_status = 'RELEASE'
And ccc.cf_direction <> 'NONCASH'
And nvl(ccc.overdue_status, 'N') = 'Y'
And ccc.due_amount > nvl(ccc.received_amount, 0)) As business_due_days, -- 营业逾期天数
(Select Count(1)
From con_contract_cashflow ccc
Where ccc.contract_id = cc.contract_id
And ccc.cf_item = 1
And ccc.cf_status = 'RELEASE'
And ccc.cf_direction <> 'NONCASH'
And nvl(ccc.overdue_status, 'N') = 'Y'
And ccc.due_amount >
nvl((Select Sum(nvl(gwo.write_off_amount, 0))
From gld_write_off gwo
Where gwo.reversed_flag = 'N'
And gwo.contract_id = ccc.contract_id
And gwo.times = ccc.times
And gwo.cf_item = ccc.cf_item),
0)) As account_due_times, -- 会计逾期期数
(Select floor(Sysdate - Min(ccc.due_date))
From con_contract_cashflow ccc
Where ccc.contract_id = cc.contract_id
--modify by shen 不统计留购价
And ccc.cf_item In (1)
And ccc.cf_status = 'RELEASE'
And trunc(ccc.due_date) <= trunc(Sysdate)
And ccc.due_amount >
nvl((Select Sum(nvl(gwo.write_off_amount, 0))
From gld_write_off gwo
Where gwo.reversed_flag = 'N'
And gwo.contract_id = ccc.contract_id
And gwo.times = ccc.times
And gwo.cf_item = ccc.cf_item),
0)) As account_due_days -- 会计逾期天数
FROM con_contract cc
WHERE
EXISTS (SELECT 1
EXISTS(SELECT 1
FROM con_contract_cashflow ccw
WHERE ccw.contract_id = cc.contract_id
AND TRUNC(ccw.due_date)<=TRUNC(SYSDATE)
AND ccw.due_amount>nvl(ccw.received_amount, 0)
AND TRUNC(ccw.due_date) <= TRUNC(SYSDATE)
AND ccw.due_amount > nvl(ccw.received_amount, 0)
AND ccw.write_off_flag <> 'FULL'
And ccw.overdue_status = 'Y'
AND ccw.cf_status = 'RELEASE'
AND ccw.cf_direction = 'INFLOW')
AND ('Y' = 'Y' AND EXISTS
...
...
@@ -189,14 +253,16 @@
AND a2.authorized_user_id = ${/session/@user_id}
AND trunc(SYSDATE) BETWEEN a2.start_date AND
nvl(a2.end_date, trunc(SYSDATE))))
And ( (decode(${/session/@user_id}, 10600, 1, 2) = 1
And exists (select 1 from hls_bp_master hb where hb.bp_id = cc.bp_id_agent_level1
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) ) ) t1
And ((decode(${/session/@user_id}, 10600, 1, 2) = 1
<bm:data-filterenforceOperations="query"expression="t1.internal_period_num = ${@internal_period_num} and exists (Select 1 From con_contract c Where t1.contract_id = c.contract_id And c.data_class = 'NORMAL' And (c.contract_status = 'INCEPT' Or c.contract_status = 'TERMINATE' Or (c.contract_status = 'PENDING' And Exists (Select 1 From con_contract_et_hd e Where e.contract_id = c.contract_id And e.document_type = 'ET' And e.available_flag = 'Y' And e.status = 'NEW')) Or c.contract_status = 'ETING' Or (c.contract_status = 'PENDING' And Exists (Select 1 From con_contract_change_req cc Where cc.contract_id = c.contract_id And cc.document_type = 'PAYCARD' And cc.req_status In ('NEW'))))) and exists (select 1 from con_contract_cashflow c where c.cashflow_id = t1.cashflow_id and c.interest is not null)"/>
<bm:data-filterenforceOperations="query"expression="t1.internal_period_num = ${@internal_period_num} and exists (Select 1 From con_contract cc Where t1.contract_id = cc.contract_id And cc.data_class = 'NORMAL' And t1.cf_item In (1, 8) And ((t1.cf_item = 1 And cc.contract_status In ('TERMINATE', 'INCEPT', 'ETING', 'REPURING')) Or (t1.cf_item = 8 And cc.contract_status In ('TERMINATE', 'INCEPT'))) ) and exists (select 1 from con_contract_cashflow c where c.cashflow_id = t1.cashflow_id and c.interest is not null)"/>
<bm:data-filterenforceOperations="query"expression="t1.cashflow_id in (select cw.cashflow_id from con_contract_cashflow cw where cw.cf_direction not in ('NONCASH'))"/>
<!-- <bm:data-filter enforceOperations="query" expression="t1.contract_id in (select contract_id from con_contract t where nvl(t.fraud_flag,'N') !='Y')"/>-->
expression:"(Exists (Select 1 From con_contract_cashflow c1 Where c1.contract_id = t1.contract_id And c1.times = t1.times And ((nvl(t1.overdue_status, 'N') = 'Y' And t1.cf_item <> 9) Or (t1.cf_item = 9)) And nvl(c1.write_off_flag, 'NOT') <> 'FULL'))"