and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
and al.cashflow_id = l.cashflow_id
AND not EXISTS (SELECT 1
and ah.invoice_kind in ('0', '2')
FROM acr_invoice_hd hi, acr_invoice_ln li
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
WHERE hi.invoice_hd_id = li.invoice_hd_id
and ah.invoice_status = 'CONFIRM'),
AND hi.vat_interface_status = 'BACK'
0)
AND to_char(hi.invoice_date,'yyyymm') <= ${@base_period}
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
AND (li.cashflow_id = l.cashflow_id OR
ccc.due_amount -
li.ref_n04 = l.journal_line_id))
nvl((select sum(al.total_amount)
UNION
from acr_invoice_hd ah, acr_invoice_ln al
select vl.*
where ah.invoice_hd_id = al.invoice_hd_id
from ET_VAT_JOURNAL_LV vl
and ah.reversed_flag = 'N'
where not EXISTS
and al.cashflow_id = l.cashflow_id
(SELECT 1
and ah.invoice_kind in ('0', '2')
FROM acr_invoice_hd hi, acr_invoice_ln li
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
WHERE hi.invoice_hd_id = li.invoice_hd_id
and ah.invoice_status = 'CONFIRM'),
AND hi.vat_interface_status = 'BACK'
0)
AND to_char(hi.invoice_date, 'yyyymm') <= ${@base_period}
else
AND (li.cashflow_id = vl.cashflow_id))
ccc.due_amount -
UNION
nvl((select sum(al.total_amount)
select rl.*
from acr_invoice_hd ah, acr_invoice_ln al
from REPURSE_VAT_JOURNAL_LV rl
where ah.invoice_hd_id = al.invoice_hd_id
where not EXISTS
and ah.reversed_flag = 'N'
(SELECT 1
and al.cashflow_id = l.cashflow_id
FROM acr_invoice_hd hi, acr_invoice_ln li
and ah.invoice_kind in ('0', '2')
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
AND hi.vat_interface_status = 'BACK'
and ah.invoice_status = 'CONFIRM'),
AND to_char(hi.invoice_date, 'yyyymm') <= ${@base_period}
0)
AND (li.cashflow_id = rl.cashflow_id))
end
from con_contract cc, con_contract_cashflow ccc
UNION
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) due_amount,
SELECT h.period_year,
(select case
h.period_num,
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
h.internal_period_num,
0
h.journal_date,
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
h.sbo_num journal_num,
nvl((select sum(al.total_amount)
reference3 contract_number,
from acr_invoice_hd ah, acr_invoice_ln al
reference1 bp_code,
where ah.invoice_hd_id = al.invoice_hd_id
(SELECT BP_NAME
and ah.reversed_flag = 'N'
FROM hls_bp_master
and al.cashflow_id = l.cashflow_id
WHERE bp_code = reference1
and ah.invoice_kind in ('0', '2')
AND ROWNUM = 1) bp_name,
AND to_char(ah.invoice_date, 'yyyymm') <=
l.journal_header_id,
${@base_period}
(SELECT hi.invoice_date
and ah.invoice_status = 'CONFIRM'),
FROM acr_invoice_hd hi, acr_invoice_ln li
0) > nvl(ccc.interest,0) then
WHERE hi.invoice_hd_id = li.invoice_hd_id
ccc.due_amount-nvl((select sum(al.total_amount)
AND hi.reversed_flag = 'N'
from acr_invoice_hd ah, acr_invoice_ln al
AND hi.vat_interface_status = 'BACK'
where ah.invoice_hd_id = al.invoice_hd_id
AND li.cf_item = 2
and ah.reversed_flag = 'N'
and hi.contract_id = l.source_doc_id
and al.cashflow_id = l.cashflow_id
AND ROWNUM = 1) invoice_date,
and ah.invoice_kind in ('0', '2')
round(l.amount_dr,2) amount_tax,
AND to_char(ah.invoice_date, 'yyyymm') <=
'首付款' times,
${@base_period}
and ah.invoice_status = 'CONFIRM'),
(SELECT due_date
0)
FROM con_contract_cashflow
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
WHERE contract_id = l.source_doc_id
nvl((select sum(al.total_amount)
AND cf_item = 2
from acr_invoice_hd ah, acr_invoice_ln al
AND ROWNUM = 1) due_date,
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
(SELECT due_amount
and al.cashflow_id = l.cashflow_id
FROM con_contract_cashflow
and ah.invoice_kind in ('0', '2')
WHERE contract_id = l.source_doc_id
AND to_char(ah.invoice_date, 'yyyymm') <=
AND cf_item = 2
${@base_period}
AND ROWNUM = 1)
and ah.invoice_status = 'CONFIRM'),
due_amount,
0) <=nvl(ccc.interest,0) then
nvl(ccc.principal, 0)
(SELECT due_amount
else
FROM con_contract_cashflow
ccc.principal
WHERE contract_id = l.source_doc_id
end
AND cf_item = 2
from con_contract cc, con_contract_cashflow ccc
AND ROWNUM = 1) principal,
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) principal,
(SELECT interest
(select case
FROM con_contract_cashflow
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
WHERE contract_id = l.source_doc_id
nvl(ccc.interest, 0) -
AND cf_item = 2
nvl((select sum(al.tax_amount)
AND ROWNUM = 1) interest,
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
(SELECT vat_due_amount
and ah.reversed_flag = 'N'
FROM con_contract_cashflow
and al.cashflow_id = l.cashflow_id
WHERE contract_id = l.source_doc_id
and ah.invoice_kind in ('0', '2')
AND cf_item = 2
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
AND ROWNUM = 1) vat_due_amount,
and ah.invoice_status = 'CONFIRM'),
NVL(ROUND(
0)
(SELECT vat_due_amount/net_due_amount
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
FROM con_contract_cashflow
nvl((select sum(al.total_amount)
WHERE contract_id = l.source_doc_id
from acr_invoice_hd ah, acr_invoice_ln al
AND cf_item = 2
where ah.invoice_hd_id = al.invoice_hd_id
AND ROWNUM = 1),
and ah.reversed_flag = 'N'
2) * 100,
and al.cashflow_id = l.cashflow_id
0) || '%' vat_rate,
and ah.invoice_kind in ('0', '2')
h.je_transaction_code,
AND to_char(ah.invoice_date, 'yyyymm') <=
l.cashflow_id
${@base_period}
FROM hls_journal_header h, hls_journal_detail l
and ah.invoice_status = 'CONFIRM'),
WHERE h.journal_header_id = l.journal_header_id
0) >nvl(ccc.interest,0) then
and h.sbo_num is not null
0
and h.reversed_flag='N'
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
AND h.je_transaction_code = 'LEASE_INCEPT'
nvl((select sum(al.total_amount)
AND l.je_template_ln_id = 8797
from acr_invoice_hd ah, acr_invoice_ln al
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
where ah.invoice_hd_id = al.invoice_hd_id
AND not EXISTS
and ah.reversed_flag = 'N'
(SELECT 1
and al.cashflow_id = l.cashflow_id
FROM acr_invoice_hd hi, acr_invoice_ln li
and ah.invoice_kind in ('0', '2')
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND to_char(ah.invoice_date, 'yyyymm') <=
AND hi.vat_interface_status = 'BACK'
${@base_period}
AND to_char(hi.invoice_date,'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),
AND ((hi.contract_id = l.source_doc_id AND li.cf_item IN (2))))
con_contract cc,con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id
and cc.contract_id=ccc.contract_id) vat_rate,
h.je_transaction_code,
l.cashflow_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
WHERE h.journal_header_id = l.journal_header_id
and h.sbo_num is not null
and h.total_amount_dr!=0
and ga.account_id=l.account_id
and ga.account_code in('2221001020','2221001023')
and h.reversed_flag='N'
and h.internal_period_num=to_number(${@base_period})
AND (h.je_transaction_code= 'HL_SALES_TAX_ACT_NEW')
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
union
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.sbo_num journal_num,
reference3 contract_number,
reference1 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference1
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
round(l.amount_cr -
nvl((select sum(al.tax_amount)
from acr_invoice_hd ah, acr_invoice_ln al
where ah.contract_id = h.source_id
and ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and al.ref_n03 = l.journal_header_id
and al.ref_n04 = l.journal_line_id
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') < =${@base_period}
and ah.invoice_status = 'CONFIRM'),
0),2) amount_tax,
'违约金' times,
h.journal_date due_date,
(select d.amount_dr
from hls_journal_detail d
where d.journal_header_id = h.journal_header_id
and exists
(select 1
from gld_accounts g
where g.account_id = d.account_id
and g.account_code in ('1122000001', '1122000002'))
and rownum = 1) due_amount,
null principal,
(select d.amount_dr
from hls_journal_detail d
where d.journal_header_id = h.journal_header_id
and exists
(select 1
from gld_accounts g
where g.account_id = d.account_id
and g.account_code in ('1122000001', '1122000002'))
and rownum = 1) interest,
round(l.amount_cr -
nvl((select sum(al.tax_amount)
from acr_invoice_hd ah, acr_invoice_ln al
where ah.contract_id = h.source_id
and ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and al.ref_n03 = l.journal_header_id
and al.ref_n04 = l.journal_line_id
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') < =${@base_period}
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) interest,
l.amount_cr-nvl((select sum(al.tax_amount) from acr_invoice_hd ah,acr_invoice_ln al where
ah.invoice_hd_id=al.invoice_hd_id
and ah.reversed_flag='N'
and al.cashflow_id=l.cashflow_id
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date,'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select
round(ccc.vat_due_amount/ccc.net_due_amount,2)
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
h.je_transaction_code,
l.cashflow_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
WHERE h.journal_header_id = l.journal_header_id
and h.sbo_num is not null
and h.total_amount_dr!=0
and ga.account_id=l.account_id
and ga.account_code in('2221001020','2221001023')
and h.reversed_flag='N'
and h.internal_period_num=to_number(${@base_period})
And exists (selEct 1
from gld_je_template_hds hd
where hd.je_template_hd_id =
h.je_template_hd_id
and hd.je_template_code in
('HL_CON_TAX_ET',
'HL_CON_TAX_ET_N',
'HL_CON_FIN_ETFEE',
'HL_CON_FIN_ETFEE_N'))
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
union
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.sbo_num journal_num,
reference3 contract_number,
reference1 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference1
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
l.amount_cr amount_tax,
(select decode(ccc.cf_item,
8,
'留购价',
'解约回购利息/'||to_char(ccc.times)) from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) times,
(select ccc.due_date from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_date,
(select decode(ccc.cf_item,
250,
ccc.interest,
ccc.due_amount)
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_amount,
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
h.je_transaction_code,
l.cashflow_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
WHERE h.journal_header_id = l.journal_header_id
and h.sbo_num is not null
and h.total_amount_dr!=0
and ga.account_id=l.account_id
and ga.account_code in('2221001020','2221001023')
and h.reversed_flag='N'
and h.internal_period_num=to_number(${@base_period})
AND not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
and hi.invoice_status='CONFIRM'
AND to_char(hi.invoice_date,'yyyymm') < =${@base_period}
and li.cashflow_id=l.cashflow_id )
And exists (selEct 1
from gld_je_template_hds hd
where hd.je_template_hd_id =
h.je_template_hd_id
and hd.je_template_code in
('HL_FIN_INCOME_REPURCHASE',
'HL_FIN_INCOME_REPURCHASE_N'))
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
union
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
h.sbo_num journal_num,
reference3 contract_number,
reference1 bp_code,
(SELECT BP_NAME
FROM hls_bp_master
WHERE bp_code = reference1
AND ROWNUM = 1) bp_name,
l.journal_header_id,
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
nvl((select sum(ccc.vat_principal) FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3
and cc.data_class='NORMAL'
and ccc.cf_item=250
and ccc.contract_id=cc.contract_id
and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
and ccc.billing_status!='FULL'
),0) amount_tax,
'解约回购本金' times,
h.journal_date due_date,
nvl((select sum(ccc.principal) FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3
and cc.data_class='NORMAL'
and ccc.contract_id=cc.contract_id
and ccc.cf_item=250
and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
),0) due_amount,
nvl((select sum(ccc.principal) FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3
and cc.data_class='NORMAL'
and ccc.contract_id=cc.contract_id
and ccc.cf_item=250
and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
),0) principal,
null interest,
nvl((select sum(ccc.vat_principal) FROM con_contract cc,con_contract_cashflow ccc
<bm:data-filterenforceOperations="query"expression="exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.data_class='NORMAL')"/>
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
'HL_CSH_CONSOLIDATION_DALAY',
AND not EXISTS (SELECT 1
decode(reference6, NULL, l.amount_dr, 0),
FROM acr_invoice_hd hi, acr_invoice_ln li
'HL_SALES_TAX_ACT_NEW',
WHERE hi.invoice_hd_id = li.invoice_hd_id
(SELECT decode(cf_item, 8, due_amount, interest)
AND hi.vat_interface_status = 'BACK'
FROM con_contract_cashflow
and hi.invoice_status='CONFIRM'
WHERE cashflow_id = l.cashflow_id),
AND to_char(hi.invoice_date,'yyyymm') < ${@base_period}
to_char(ccc.times)) from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) times,
instr(h.description, '调平') > 0))
(select ccc.due_date from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_date,
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
AND not EXISTS (SELECT 1
(select case
FROM acr_invoice_hd hi, acr_invoice_ln li
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
WHERE hi.invoice_hd_id = li.invoice_hd_id
nvl(ccc.interest, 0) -
AND hi.vat_interface_status = 'BACK'
nvl((select sum(al.tax_amount)
AND to_char(hi.invoice_date,'yyyymm') < ${@base_period}
from acr_invoice_hd ah, acr_invoice_ln al
AND (li.cashflow_id = l.cashflow_id OR
where ah.invoice_hd_id = al.invoice_hd_id
li.ref_n04 = l.journal_line_id))
and ah.reversed_flag = 'N'
UNION
and al.cashflow_id = l.cashflow_id
select vl.*
and ah.invoice_kind in ('0', '2')
from ET_VAT_JOURNAL_LV vl
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
where not EXISTS
and ah.invoice_status = 'CONFIRM'),
(SELECT 1
0)
FROM acr_invoice_hd hi, acr_invoice_ln li
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
WHERE hi.invoice_hd_id = li.invoice_hd_id
ccc.due_amount -
AND hi.vat_interface_status = 'BACK'
nvl((select sum(al.total_amount)
AND to_char(hi.invoice_date, 'yyyymm') < ${@base_period}
from acr_invoice_hd ah, acr_invoice_ln al
AND (li.cashflow_id = vl.cashflow_id))
where ah.invoice_hd_id = al.invoice_hd_id
UNION
and ah.reversed_flag = 'N'
select rl.*
and al.cashflow_id = l.cashflow_id
from REPURSE_VAT_JOURNAL_LV rl
and ah.invoice_kind in ('0', '2')
where not EXISTS
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
(SELECT 1
and ah.invoice_status = 'CONFIRM'),
FROM acr_invoice_hd hi, acr_invoice_ln li
0)
WHERE hi.invoice_hd_id = li.invoice_hd_id
else
AND hi.vat_interface_status = 'BACK'
ccc.due_amount -
AND to_char(hi.invoice_date, 'yyyymm') < ${@base_period}
nvl((select sum(al.total_amount)
AND (li.cashflow_id = rl.cashflow_id))
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
UNION
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
SELECT h.period_year,
and ah.invoice_kind in ('0', '2')
h.period_num,
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
h.internal_period_num,
and ah.invoice_status = 'CONFIRM'),
h.journal_date,
0)
h.sbo_num journal_num,
end
reference3 contract_number,
from con_contract cc, con_contract_cashflow ccc
reference1 bp_code,
where ccc.cashflow_id = l.cashflow_id
(SELECT BP_NAME
and ccc.contract_id = cc.contract_id) due_amount,
FROM hls_bp_master
(select case
WHERE bp_code = reference1
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
AND ROWNUM = 1) bp_name,
0
l.journal_header_id,
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
(SELECT hi.invoice_date
nvl((select sum(al.total_amount)
FROM acr_invoice_hd hi, acr_invoice_ln li
from acr_invoice_hd ah, acr_invoice_ln al
WHERE hi.invoice_hd_id = li.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
AND hi.reversed_flag = 'N'
and ah.reversed_flag = 'N'
AND hi.vat_interface_status = 'BACK'
and al.cashflow_id = l.cashflow_id
AND li.cf_item = 2
and ah.invoice_kind in ('0', '2')
and hi.contract_id = l.source_doc_id
AND to_char(ah.invoice_date, 'yyyymm') <=
AND ROWNUM = 1) invoice_date,
${@base_period}
round(l.amount_dr,2) amount_tax,
and ah.invoice_status = 'CONFIRM'),
'首付款' times,
0) > nvl(ccc.interest,0) then
ccc.due_amount-nvl((select sum(al.total_amount)
(SELECT due_date
from acr_invoice_hd ah, acr_invoice_ln al
FROM con_contract_cashflow
where ah.invoice_hd_id = al.invoice_hd_id
WHERE contract_id = l.source_doc_id
and ah.reversed_flag = 'N'
AND cf_item = 2
and al.cashflow_id = l.cashflow_id
AND ROWNUM = 1) due_date,
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <=
(SELECT due_amount
${@base_period}
FROM con_contract_cashflow
and ah.invoice_status = 'CONFIRM'),
WHERE contract_id = l.source_doc_id
0)
AND cf_item = 2
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
AND ROWNUM = 1)
nvl((select sum(al.total_amount)
due_amount,
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
(SELECT due_amount
and ah.reversed_flag = 'N'
FROM con_contract_cashflow
and al.cashflow_id = l.cashflow_id
WHERE contract_id = l.source_doc_id
and ah.invoice_kind in ('0', '2')
AND cf_item = 2
AND to_char(ah.invoice_date, 'yyyymm') <=
AND ROWNUM = 1) principal,
${@base_period}
and ah.invoice_status = 'CONFIRM'),
(SELECT interest
0) <=nvl(ccc.interest,0) then
FROM con_contract_cashflow
nvl(ccc.principal, 0)
WHERE contract_id = l.source_doc_id
else
AND cf_item = 2
ccc.principal
AND ROWNUM = 1) interest,
end
from con_contract cc, con_contract_cashflow ccc
(SELECT vat_due_amount
where ccc.cashflow_id = l.cashflow_id
FROM con_contract_cashflow
and ccc.contract_id = cc.contract_id) principal,
WHERE contract_id = l.source_doc_id
(select case
AND cf_item = 2
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
AND ROWNUM = 1) vat_due_amount,
nvl(ccc.interest, 0) -
NVL(ROUND(
nvl((select sum(al.tax_amount)
(SELECT vat_due_amount/net_due_amount
from acr_invoice_hd ah, acr_invoice_ln al
FROM con_contract_cashflow
where ah.invoice_hd_id = al.invoice_hd_id
WHERE contract_id = l.source_doc_id
and ah.reversed_flag = 'N'
AND cf_item = 2
and al.cashflow_id = l.cashflow_id
AND ROWNUM = 1),
and ah.invoice_kind in ('0', '2')
2) * 100,
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
0) || '%' vat_rate,
and ah.invoice_status = 'CONFIRM'),
h.je_transaction_code,
0)
l.cashflow_id
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
FROM hls_journal_header h, hls_journal_detail l
nvl((select sum(al.total_amount)
WHERE h.journal_header_id = l.journal_header_id
from acr_invoice_hd ah, acr_invoice_ln al
and h.sbo_num is not null
where ah.invoice_hd_id = al.invoice_hd_id
and h.reversed_flag='N'
and ah.reversed_flag = 'N'
AND h.je_transaction_code = 'LEASE_INCEPT'
and al.cashflow_id = l.cashflow_id
AND l.je_template_ln_id = 8797
and ah.invoice_kind in ('0', '2')
and( (trunc(h.journal_date)<=trunc(to_date('2020-01-31','yyyy-mm-dd')) and h.description='MANUAL_IMPORT')or(trunc(h.journal_date)>trunc(to_date('2020-01-31','yyyy-mm-dd'))))
AND to_char(ah.invoice_date, 'yyyymm') <=
AND not EXISTS
${@base_period}
(SELECT 1
and ah.invoice_status = 'CONFIRM'),
FROM acr_invoice_hd hi, acr_invoice_ln li
0) >nvl(ccc.interest,0) then
WHERE hi.invoice_hd_id = li.invoice_hd_id
0
AND hi.vat_interface_status = 'BACK'
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
AND to_char(hi.invoice_date,'yyyymm') < ${@base_period}
nvl((select sum(al.total_amount)
AND ((hi.contract_id = l.source_doc_id AND li.cf_item IN (2))))
<bm:data-filterenforceOperations="query"expression="exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.data_class='NORMAL')"/>
<bm:query-fieldname="vat_6_flag"queryExpression="((${@vat_6_flag}='Y' and t1.tax_type_rate=0.06) or(${@vat_6_flag}!='Y' and t1.tax_type_rate!=0.06))"/>
expression:"t1.journal_date <= add_months(last_day(to_date(${@base_period},'yyyymm')),-1) and (t1.invoice_date is null or t1.invoice_date >= TRUNC(to_date(${@base_period},'yyyymm'),'dd'))"