from acr_invoice_contract_v t1, ACR_INVOICE_CONTRACT_CF_V t2
from cus_acr_invoice_contract_v t1,
where
con_contract_cashflow t2
t1.contract_id=t2.contract_id
where t1.contract_id = t2.contract_id
and t1.bp_wfl_status = 'APPROVED'
and t1.invoice_wfl_status = 'APPROVED'
and (t1.invoice_method = 'BILLING' or
(t1.invoice_method = 'NO_BILLING' and
((t1.bill_object_bp_class = 'NP' and
t1.inv_billing_object_code <> 'D00000009' AND
((to_number(to_char(sysdate, 'MM')) in
(3, 6, 9, 12) and trunc(t2.due_date) <= sysdate
and ((to_number(to_char(t2.due_date, 'MM')) in
(3, 6, 9, 12)) or
(to_number(to_char(t2.due_date, 'MM')) in
(1, 4, 7, 10) and
nextduedate(t2.due_date, 2, 1) <= sysdate) or
(to_number(to_char(t2.due_date, 'MM')) in
(2, 5, 8, 11) and
nextduedate(t2.due_date, 1, 1) <= sysdate))
) or (
to_number(to_char(sysdate, 'MM')) in (1, 2) and
trunc(t2.due_date) <=
(trunc(sysdate, 'yyyy') - 1)) or
(
to_number(to_char(sysdate, 'MM')) in (4, 5) and
t2.due_date <=
last_day(to_date(to_char(sysdate, 'yyyy') ||
'-03',
'yyyy-mm'))) or
(to_number(to_char(sysdate, 'MM')) in (7, 8) and
t2.due_date <=
last_day(to_date(to_char(sysdate, 'yyyy') ||
'-06',
'yyyy-mm'))) or
(to_number(to_char(sysdate, 'MM')) in (10, 11) and
t2.due_date <=
last_day(to_date(to_char(sysdate, 'yyyy') ||
'-09',
'yyyy-mm'))))) or
((t1.bill_object_bp_class = 'ORG' or
(t1.inv_billing_object_code = 'D00000009' and
t1.bill_object_bp_class = 'NP')) AND
t1.contract_status in ('TERMINATE', 'ET', 'REPUR')))))
and ((decode(t2.cf_item,
and ((decode(t2.cf_item,
'250',
'250',
t1.inv_object_taxpayer_type,
t1.inv_object_taxpayer_type,
t1.object_taxpayer_type) = 'SMALL_SCALE_TAXPAYER' and
t1.object_taxpayer_type) =
to_char(t2.due_date,'yyyy-mm') <= to_char(SYSDATE,'yyyy-mm')) or (t2.write_off_flag = 'FULL' and t1.contract_status not in('REPURING','REPUR')) or(nvl(t2.write_off_flag,'NOT')='FULL' and t1.contract_status in('REPURING','REPUR') and t2.cf_item<>1) or (nvl(t2.write_off_flag,'NOT') <> 'NOT' and t1.contract_status in('REPURING','REPUR') and t2.cf_item=1 ) )
'SMALL_SCALE_TAXPAYER' and
AND cf_item<> 9
to_char(t2.due_date, 'yyyy-mm') <=
AND ((t2.cf_status='RELEASE' and t1.contract_status not in('REPURING','REPUR') and t2.cf_direction='INFLOW') or(t1.contract_status in ('REPURING','REPUR') and t2.cf_item in(1,2,250) and t2.cf_status='RELEASE' )or ( t2.cf_status in('BLOCK') and nvl(t2.write_off_flag,'NOT')='PARTIAL' and nvl(t2.billing_status,'NOT') != 'FULL' and t1.contract_status in ('REPURING','REPUR') and t2.cf_item =1 and t2.cf_direction='NONCASH' and nvl(t2.billing_amount,0) <> t2.received_amount))
to_char(SYSDATE, 'yyyy-mm')) or
and t2.cashflow_id not in (20265,34267,24445)
(t2.write_off_flag = 'FULL' and
and nvl(t2.billing_status,'NOT') != 'FULL'
t1.contract_status not in ('REPURING', 'REPUR')) or
(nvl(t2.write_off_flag, 'NOT') = 'FULL' and
t1.contract_status in ('REPURING', 'REPUR') and
t2.cf_item <> 1) or
(nvl(t2.write_off_flag, 'NOT') <> 'NOT' and
t1.contract_status in ('REPURING', 'REPUR') and
t2.cf_item = 1))
AND cf_item <> 9
AND ((t2.cf_status = 'RELEASE' and
t1.contract_status not in ('REPURING', 'REPUR') and
t2.cf_direction = 'INFLOW') or
(t1.contract_status in ('REPURING', 'REPUR') and
t2.cf_item in (1, 2, 250) and
t2.cf_status = 'RELEASE') or
(t2.cf_status in ('BLOCK') and
nvl(t2.write_off_flag, 'NOT') = 'PARTIAL' and
nvl(t2.billing_status, 'NOT') != 'FULL' and
t1.contract_status in ('REPURING', 'REPUR') and
t2.cf_item = 1 and t2.cf_direction = 'NONCASH' and
nvl(t2.billing_amount, 0) <> t2.received_amount))
and t2.cashflow_id not in (20265, 34267, 24445)
and nvl(t2.billing_status, 'NOT') != 'FULL'
--and t2.cf_direction='INFLOW'
--and t2.cf_direction='INFLOW'
and ((decode(t2.cf_item,
and ((decode(t2.cf_item,
'250',
'250',
t1.inv_object_taxpayer_type,
t1.inv_object_taxpayer_type,
t1.object_taxpayer_type) <> 'SMALL_SCALE_TAXPAYER' and
t1.object_taxpayer_type) <>
received_amount>0) OR (decode(t2.cf_item,
'SMALL_SCALE_TAXPAYER' and received_amount > 0) OR
<bm:query-fieldname="received_flag"queryExpression="(nvl(t1.express_status,'UNDELIVERED') !='RECEIVED' or ${@received_flag}='Y')"/>
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from con_contract cc where t1.contract_id = cc.contract_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:data-filterenforceOperations="query"expression="t1.invoice_status IN ('CONFIRM', 'POST')"/>
from acr_invoice_hd ah, acr_invoice_hd_wfl ahw
<bm:data-filterenforceOperations="query"expression="not exists (select 1 from acr_invoice_hd_wfl ah where ah.invoice_hd_id = t1.invoice_hd_id and ah.reversed_flag = 'I')"/>
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, con_contract cc where df.contract_id = cc.contract_id and df.ar_invoice_hd_id = t1.invoice_hd_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, con_contract cc where df.contract_id = cc.contract_id and df.ar_invoice_hd_id = t1.invoice_hd_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, con_contract cc where df.contract_id = cc.contract_id and df.ar_invoice_hd_id = t1.invoice_hd_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, con_contract cc where df.contract_id = cc.contract_id and df.ar_invoice_hd_id = t1.invoice_hd_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:fieldname="invoice_apply_num"expression="(select ap.invoice_apply_num from acr_invoice_apply ap, acr_invoice_hd_wfl aw where ap.wfl_apply_status='APPROVED' and ap.apply_mode='APPLY' and ap.invoice_apply_id=aw.invoice_apply_id
and aw.invoice_hd_id=t1.invoice_hd_id)"/>
<bm:fieldname="invoice_apply_id"expression="(select ap.invoice_apply_id from acr_invoice_apply ap, acr_invoice_hd_wfl aw where ap.wfl_apply_status='APPROVED' and ap.apply_mode='APPLY' and ap.invoice_apply_id=aw.invoice_apply_id
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, con_contract cc where df.contract_id = cc.contract_id and df.ar_invoice_hd_id = t1.invoice_hd_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_contract_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, con_contract cc where df.contract_id = cc.contract_id and df.ar_invoice_hd_id = t1.invoice_hd_id and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:query-fieldname="query_project_number"queryExpression="exists (select 1 from hls_document_flow_all_v df, prj_project pp where df.ar_invoice_hd_id = t1.invoice_hd_id and df.project_id = pp.project_id and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
<bm:query-fieldname="invoice_apply_num"queryExpression="${@invoice_apply_num}=(select ap.invoice_apply_num from acr_invoice_apply ap, acr_invoice_hd_wfl aw where ap.wfl_apply_status='APPROVED' and ap.apply_mode='APPLY' and ap.invoice_apply_id=aw.invoice_apply_id