from con_contract_cashflow ccc where ccc.contract_id=h.source_id
from con_contract_cashflow ccc where ccc.contract_id=h.source_id
and ccc.cf_item=2) vat_rate,
and ccc.cf_item=2) vat_rate,
h.je_transaction_code,
h.je_transaction_code,
l.cashflow_id
l.cashflow_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
WHERE h.journal_header_id = l.journal_header_id
WHERE h.journal_header_id = l.journal_header_id
and h.sbo_num is not null
and h.sbo_num is not null
and h.total_amount_dr!=0
and h.total_amount_dr!=0
and ga.account_id=l.account_id
and ga.account_id=l.account_id
and ga.account_code in('2221001020','2221001023')
and ga.account_code in('2221001020','2221001023','2221001024')
and h.reversed_flag='N'
and h.reversed_flag='N'
and h.internal_period_num=to_number(${@base_period})
and h.internal_period_num=to_number(${@base_period})
AND (h.je_transaction_code= 'LEASE_INCEPT')
AND (h.je_transaction_code= 'LEASE_INCEPT')
and exists (select 1
and exists (select 1
from gld_je_template_hds hd
from gld_je_template_hds hd
where hd.je_template_hd_id =
where hd.je_template_hd_id =
h.je_template_hd_id
h.je_template_hd_id
and hd.je_template_code =
and hd.je_template_code =
'HL_INCEPT_DOWN_PAYMENT_CF')
'HL_INCEPT_DOWN_PAYMENT_CF')
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'))))
union
union
SELECT h.period_year,
SELECT h.period_year,
h.period_num,
h.period_num,
h.internal_period_num,
h.internal_period_num,
h.journal_date,
h.journal_date,
h.sbo_num journal_num,
h.sbo_num journal_num,
reference3 contract_number,
reference3 contract_number,
reference1 bp_code,
reference1 bp_code,
(SELECT BP_NAME
(SELECT BP_NAME
FROM hls_bp_master
FROM hls_bp_master
WHERE bp_code = reference1
WHERE bp_code = reference1
AND ROWNUM = 1) bp_name,
AND ROWNUM = 1) bp_name,
l.journal_header_id,
l.journal_header_id,
(SELECT hi.invoice_date
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
AND ROWNUM = 1) invoice_date,
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
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 ah.reversed_flag='N'
and al.cashflow_id=l.cashflow_id
and al.cashflow_id=l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date,'yyyymm') < =${@base_period}
AND to_char(ah.invoice_date,'yyyymm') < =${@base_period}
and ah.invoice_status = 'CONFIRM'),0) amount_tax,
and ah.invoice_status = 'CONFIRM'),0) amount_tax,
(select decode(ccc.cf_item,
(select decode(ccc.cf_item,
8,
8,
'留购价',
'留购价',
to_char(ccc.times)) from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) times,
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 ccc.due_date from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_date,
(select case
(select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
nvl(ccc.interest, 0) -
nvl(ccc.interest, 0) -
nvl((select sum(al.tax_amount)
nvl((select sum(al.tax_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0)
0)
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
ccc.due_amount -
ccc.due_amount -
nvl((select sum(al.total_amount)
nvl((select sum(al.total_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0)
0)
else
else
ccc.due_amount -
ccc.due_amount -
nvl((select sum(al.total_amount)
nvl((select sum(al.total_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0)
0)
end
end
from con_contract cc, con_contract_cashflow ccc
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) due_amount,
and ccc.contract_id = cc.contract_id) due_amount,
(select case
(select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
0
0
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
nvl((select sum(al.total_amount)
nvl((select sum(al.total_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <=
AND to_char(ah.invoice_date, 'yyyymm') <=
${@base_period}
${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0) > nvl(ccc.interest,0) then
0) > nvl(ccc.interest,0) then
ccc.due_amount-nvl((select sum(al.total_amount)
ccc.due_amount-nvl((select sum(al.total_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <=
AND to_char(ah.invoice_date, 'yyyymm') <=
${@base_period}
${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0)
0)
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
nvl((select sum(al.total_amount)
nvl((select sum(al.total_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <=
AND to_char(ah.invoice_date, 'yyyymm') <=
${@base_period}
${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0) <=nvl(ccc.interest,0) then
0) <=nvl(ccc.interest,0) then
nvl(ccc.principal, 0)
nvl(ccc.principal, 0)
else
else
ccc.principal
ccc.principal
end
end
from con_contract cc, con_contract_cashflow ccc
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) principal,
and ccc.contract_id = cc.contract_id) principal,
(select case
(select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
nvl(ccc.interest, 0) -
nvl(ccc.interest, 0) -
nvl((select sum(al.tax_amount)
nvl((select sum(al.tax_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
AND to_char(ah.invoice_date, 'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0)
0)
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
nvl((select sum(al.total_amount)
nvl((select sum(al.total_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.invoice_hd_id = al.invoice_hd_id
where ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.cashflow_id = l.cashflow_id
and al.cashflow_id = l.cashflow_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') <=
AND to_char(ah.invoice_date, 'yyyymm') <=
${@base_period}
${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0) >nvl(ccc.interest,0) then
0) >nvl(ccc.interest,0) then
0
0
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' and
con_contract cc,con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id
con_contract cc,con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id
and cc.contract_id=ccc.contract_id) vat_rate,
and cc.contract_id=ccc.contract_id) vat_rate,
h.je_transaction_code,
h.je_transaction_code,
l.cashflow_id
l.cashflow_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
WHERE h.journal_header_id = l.journal_header_id
WHERE h.journal_header_id = l.journal_header_id
and h.sbo_num is not null
and h.sbo_num is not null
and h.total_amount_dr!=0
and h.total_amount_dr!=0
and ga.account_id=l.account_id
and ga.account_id=l.account_id
and ga.account_code in('2221001020','2221001023')
and ga.account_code in('2221001020','2221001023','2221001024')
and h.reversed_flag='N'
and h.reversed_flag='N'
and h.internal_period_num=to_number(${@base_period})
and h.internal_period_num=to_number(${@base_period})
And (h.je_transaction_code ='HL_SALES_TAX_ACT_NEW' )
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'))))
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
union
SELECT h.period_year,
SELECT h.period_year,
h.period_num,
h.period_num,
h.internal_period_num,
h.internal_period_num,
h.journal_date,
h.journal_date,
h.sbo_num journal_num,
h.sbo_num journal_num,
reference3 contract_number,
reference3 contract_number,
reference1 bp_code,
reference1 bp_code,
(SELECT BP_NAME
(SELECT BP_NAME
FROM hls_bp_master
FROM hls_bp_master
WHERE bp_code = reference1
WHERE bp_code = reference1
AND ROWNUM = 1) bp_name,
AND ROWNUM = 1) bp_name,
l.journal_header_id,
l.journal_header_id,
(SELECT hi.invoice_date
(SELECT hi.invoice_date
FROM acr_invoice_hd hi, acr_invoice_ln li
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE hi.invoice_hd_id = li.invoice_hd_id
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.reversed_flag = 'N'
AND hi.reversed_flag = 'N'
AND (li.cashflow_id = l.cashflow_id OR
AND (li.cashflow_id = l.cashflow_id OR
li.ref_n03 = l.journal_header_id)
li.ref_n03 = l.journal_header_id)
AND ROWNUM = 1) invoice_date,
AND ROWNUM = 1) invoice_date,
round(l.amount_cr -
round(l.amount_cr -
nvl((select sum(al.tax_amount)
nvl((select sum(al.tax_amount)
from acr_invoice_hd ah, acr_invoice_ln al
from acr_invoice_hd ah, acr_invoice_ln al
where ah.contract_id = h.source_id
where ah.contract_id = h.source_id
and ah.invoice_hd_id = al.invoice_hd_id
and ah.invoice_hd_id = al.invoice_hd_id
and ah.reversed_flag = 'N'
and ah.reversed_flag = 'N'
and al.ref_n03 = l.journal_header_id
and al.ref_n03 = l.journal_header_id
and al.ref_n04 = l.journal_line_id
and al.ref_n04 = l.journal_line_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_kind in ('0', '2')
AND to_char(ah.invoice_date, 'yyyymm') < =${@base_period}
AND to_char(ah.invoice_date, 'yyyymm') < =${@base_period}
and ah.invoice_status = 'CONFIRM'),
and ah.invoice_status = 'CONFIRM'),
0),2) amount_tax,
0),2) amount_tax,
'违约金' times,
'违约金' times,
h.journal_date due_date,
h.journal_date due_date,
case when ghd.je_template_code in('HL_RECEIVABLES_AGENT_REPUR_LB','HL_RECEIVABLES_AGENT_REPUR','HL_GLD_BALANCE_PENALTY') then
case when ghd.je_template_code in('HL_RECEIVABLES_AGENT_REPUR_LB','HL_RECEIVABLES_AGENT_REPUR','HL_GLD_BALANCE_PENALTY') then
(select d.amount_cr
(select d.amount_cr
from hls_journal_detail d
from hls_journal_detail d
where d.journal_header_id = h.journal_header_id
where d.journal_header_id = h.journal_header_id
and exists
and d.reference3=l.reference3
(select 1
and exists
from gld_accounts g
(select 1
where g.account_id = d.account_id
from gld_accounts g
and g.account_code in ('6041001000'))
where g.account_id = d.account_id
and rownum = 1)
and g.account_code in ('6041001000'))
else
and rownum = 1)
(select d.amount_dr
else
from hls_journal_detail d
(select nvl(d.amount_dr,d.amount_cr)
where d.journal_header_id = h.journal_header_id
from hls_journal_detail d
and exists
where d.journal_header_id = h.journal_header_id
(select 1
and d.reference3=l.reference3
from gld_accounts g
and exists
where g.account_id = d.account_id
(select 1
and g.account_code in ('1122000001', '1122000002'))
from gld_accounts g
and rownum = 1)
where g.account_id = d.account_id
end due_amount,
and g.account_code in ('1122000001', '1122000002'))
null principal,
and rownum = 1)
case when ghd.je_template_code in('HL_RECEIVABLES_AGENT_REPUR_LB','HL_RECEIVABLES_AGENT_REPUR','HL_GLD_BALANCE_PENALTY') then
end due_amount,
(select d.amount_cr
null principal,
from hls_journal_detail d
case when ghd.je_template_code in('HL_RECEIVABLES_AGENT_REPUR_LB','HL_RECEIVABLES_AGENT_REPUR','HL_GLD_BALANCE_PENALTY') then
where d.journal_header_id = h.journal_header_id
(select d.amount_cr
and exists
from hls_journal_detail d
(select 1
where d.journal_header_id = h.journal_header_id
from gld_accounts g
and d.reference3=l.reference3
where g.account_id = d.account_id
and exists
and g.account_code in ('6041001000'))
(select 1
and rownum = 1)
from gld_accounts g
else
where g.account_id = d.account_id
(select d.amount_dr
and g.account_code in ('6041001000'))
from hls_journal_detail d
and rownum = 1)
where d.journal_header_id = h.journal_header_id
else
and exists
(select nvl(d.amount_dr,d.amount_cr)
(select 1
from hls_journal_detail d
from gld_accounts g
where d.journal_header_id = h.journal_header_id
where g.account_id = d.account_id
and d.reference3=l.reference3
and g.account_code in ('1122000001', '1122000002'))
and exists
and rownum = 1)
(select 1
end interest,
from gld_accounts g
round(l.amount_cr -
where g.account_id = d.account_id
nvl((select sum(al.tax_amount)
and g.account_code in ('1122000001', '1122000002'))
from acr_invoice_hd ah, acr_invoice_ln al
and rownum = 1)
where ah.contract_id = h.source_id
end interest,
and ah.invoice_hd_id = al.invoice_hd_id
round(l.amount_cr -
and ah.reversed_flag = 'N'
nvl((select sum(al.tax_amount)
and al.ref_n03 = l.journal_header_id
from acr_invoice_hd ah, acr_invoice_ln al
and al.ref_n04 = l.journal_line_id
where ah.contract_id = h.source_id
and ah.invoice_kind in ('0', '2')
and ah.invoice_hd_id = al.invoice_hd_id
AND to_char(ah.invoice_date, 'yyyymm') < =${@base_period}
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
end
WHERE h.journal_header_id = l.journal_header_id
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
and h.sbo_num is not null
h.je_transaction_code,
and h.total_amount_dr!=0
l.cashflow_id
and ga.account_id=l.account_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
and ga.account_code in('2221001020','2221001023')
WHERE h.journal_header_id = l.journal_header_id
and h.reversed_flag='N'
and h.sbo_num is not null
and h.internal_period_num=to_number(${@base_period})
and h.total_amount_dr!=0
And exists (selEct 1
and ga.account_id=l.account_id
from gld_je_template_hds hd
and ga.account_code in('2221001020','2221001023','2221001024')
where hd.je_template_hd_id =
and h.reversed_flag='N'
h.je_template_hd_id
and h.internal_period_num=to_number(${@base_period})
and hd.je_template_code in
And exists (selEct 1
('HL_CON_TAX_ET',
from gld_je_template_hds hd
'HL_CON_TAX_ET_N',
where hd.je_template_hd_id =
'HL_CON_FIN_ETFEE',
h.je_template_hd_id
'HL_CON_FIN_ETFEE_N'))
and hd.je_template_code in
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_CON_TAX_ET',
'HL_CON_TAX_ET_N',
union
'HL_CON_FIN_ETFEE',
SELECT h.period_year,
'HL_CON_FIN_ETFEE_N'))
h.period_num,
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'))))
h.internal_period_num,
h.journal_date,
union
h.sbo_num journal_num,
SELECT h.period_year,
reference3 contract_number,
h.period_num,
reference1 bp_code,
h.internal_period_num,
(SELECT BP_NAME
h.journal_date,
FROM hls_bp_master
h.sbo_num journal_num,
WHERE bp_code = reference1
reference3 contract_number,
AND ROWNUM = 1) bp_name,
reference1 bp_code,
l.journal_header_id,
(SELECT BP_NAME
(SELECT hi.invoice_date
FROM hls_bp_master
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE bp_code = reference1
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND ROWNUM = 1) bp_name,
AND hi.reversed_flag = 'N'
l.journal_header_id,
AND (li.cashflow_id = l.cashflow_id OR
(SELECT hi.invoice_date
li.ref_n03 = l.journal_header_id)
FROM acr_invoice_hd hi, acr_invoice_ln li
AND ROWNUM = 1) invoice_date,
WHERE hi.invoice_hd_id = li.invoice_hd_id
l.amount_cr amount_tax,
AND hi.reversed_flag = 'N'
(select decode(ccc.cf_item,
AND (li.cashflow_id = l.cashflow_id OR
8,
li.ref_n03 = l.journal_header_id)
'留购价',
AND ROWNUM = 1) invoice_date,
'解约回购利息/'||to_char(ccc.times)) from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) times,
l.amount_cr amount_tax,
(select ccc.due_date from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_date,
(select decode(ccc.cf_item,
(select decode(ccc.cf_item,
8,
250,
'留购价',
ccc.interest,
'解约回购利息/'||to_char(ccc.times)) from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) times,
ccc.due_amount)
(select ccc.due_date from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_date,
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_amount,
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
end
WHERE h.journal_header_id = l.journal_header_id
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
and h.sbo_num is not null
h.je_transaction_code,
and h.total_amount_dr!=0
l.cashflow_id
and ga.account_id=l.account_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
and ga.account_code in('2221001020','2221001023')
WHERE h.journal_header_id = l.journal_header_id
and h.reversed_flag='N'
and h.sbo_num is not null
and h.internal_period_num=to_number(${@base_period})
and h.total_amount_dr!=0
AND not EXISTS (SELECT 1
and ga.account_id=l.account_id
FROM acr_invoice_hd hi, acr_invoice_ln li
and ga.account_code in('2221001020','2221001023','2221001024')
WHERE hi.invoice_hd_id = li.invoice_hd_id
and h.reversed_flag='N'
AND hi.vat_interface_status = 'BACK'
and h.internal_period_num=to_number(${@base_period})
and hi.invoice_status='CONFIRM'
AND not EXISTS (SELECT 1
AND to_char(hi.invoice_date,'yyyymm') < =${@base_period}
FROM acr_invoice_hd hi, acr_invoice_ln li
and li.cashflow_id=l.cashflow_id )
WHERE hi.invoice_hd_id = li.invoice_hd_id
And exists (selEct 1
AND hi.vat_interface_status = 'BACK'
from gld_je_template_hds hd
and hi.invoice_status='CONFIRM'
where hd.je_template_hd_id =
AND to_char(hi.invoice_date,'yyyymm') < =${@base_period}
h.je_template_hd_id
and li.cashflow_id=l.cashflow_id )
and hd.je_template_code in
And exists (selEct 1
('HL_FIN_INCOME_REPURCHASE',
from gld_je_template_hds hd
'HL_FIN_INCOME_REPURCHASE_N',
where hd.je_template_hd_id =
'HL_FIN_INCOME_REPURCHASE_ET',
h.je_template_hd_id
'HL_CON_FIN_ETREPUR_INT',
and hd.je_template_code in
'HL_CON_FIN_ETREPUR_INT_N'))
('HL_FIN_INCOME_REPURCHASE',
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_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET',
union
'HL_CON_FIN_ETREPUR_INT',
SELECT h.period_year,
'HL_CON_FIN_ETREPUR_INT_N'))
h.period_num,
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'))))
h.internal_period_num,
h.journal_date,
union
h.sbo_num journal_num,
SELECT h.period_year,
t.contract_number contract_number,
h.period_num,
(SELECT bp.bp_code
h.internal_period_num,
FROM hls_bp_master bp,hls_journal_detail d
h.journal_date,
WHERE bp.bp_code = d.reference1
h.sbo_num journal_num,
and d.journal_header_id=h.journal_header_id
t.contract_number contract_number,
AND ROWNUM = 1) bp_code,
(SELECT bp.bp_code
(SELECT bp.bp_name
FROM hls_bp_master bp,hls_journal_detail d
FROM hls_bp_master bp,hls_journal_detail d
WHERE bp.bp_code = d.reference1
WHERE bp.bp_code = d.reference1
and d.journal_header_id=h.journal_header_id
and d.journal_header_id=h.journal_header_id
AND ROWNUM = 1) bp_code,
AND ROWNUM = 1) bp_name,
(SELECT bp.bp_name
h.journal_header_id,
FROM hls_bp_master bp,hls_journal_detail d
(SELECT hi.invoice_date
WHERE bp.bp_code = d.reference1
FROM acr_invoice_hd hi, acr_invoice_ln li
and d.journal_header_id=h.journal_header_id
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND ROWNUM = 1) bp_name,
AND hi.reversed_flag = 'N'
h.journal_header_id,
AND (li.cashflow_id = t.cashflow_id OR
(SELECT hi.invoice_date
li.ref_n03 = h.journal_header_id)
FROM acr_invoice_hd hi, acr_invoice_ln li
AND ROWNUM = 1) invoice_date,
WHERE hi.invoice_hd_id = li.invoice_hd_id
t.un_bill_vat_principal amount_tax,
AND hi.reversed_flag = 'N'
'解约回购本金'||t.times times,
AND (li.cashflow_id = t.cashflow_id OR
h.journal_date due_date,
li.ref_n03 = h.journal_header_id)
t.un_bill_principal due_amount,
AND ROWNUM = 1) invoice_date,
t.un_bill_principal principal,
t.un_bill_vat_principal amount_tax,
null interest,
'解约回购本金'||t.times times,
t.un_bill_vat_principal vat_due_amount,
h.journal_date due_date,
t.tax_type_rate vat_rate,
t.un_bill_principal due_amount,
h.je_transaction_code,
t.un_bill_principal principal,
t.cashflow_id
null interest,
FROM hls_journal_header h,VAT_ACCOUNT_250_PRIN_TMP t
t.un_bill_vat_principal vat_due_amount,
WHERE h.journal_header_id = t.journal_header_id
t.tax_type_rate vat_rate,
and t.session_id=${/session/@session_id}
h.je_transaction_code,
and nvl(t.un_bill_principal,0)>0
t.cashflow_id
and h.internal_period_num=to_number(${@base_period})
FROM hls_journal_header h,VAT_ACCOUNT_250_PRIN_TMP t
union
WHERE h.journal_header_id = t.journal_header_id
SELECT h.period_year,
and t.session_id=${/session/@session_id}
h.period_num,
and nvl(t.un_bill_principal,0)>0
h.internal_period_num,
and h.internal_period_num=to_number(${@base_period})
h.journal_date,
union
h.sbo_num journal_num,
SELECT h.period_year,
reference3 contract_number,
h.period_num,
reference1 bp_code,
h.internal_period_num,
(SELECT BP_NAME
h.journal_date,
FROM hls_bp_master
h.sbo_num journal_num,
WHERE bp_code = reference1
reference3 contract_number,
AND ROWNUM = 1) bp_name,
reference1 bp_code,
l.journal_header_id,
(SELECT BP_NAME
(SELECT hi.invoice_date
FROM hls_bp_master
FROM acr_invoice_hd hi, acr_invoice_ln li
WHERE bp_code = reference1
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND ROWNUM = 1) bp_name,
AND hi.reversed_flag = 'N'
l.journal_header_id,
AND (li.cashflow_id = l.cashflow_id OR
(SELECT hi.invoice_date
li.ref_n03 = l.journal_header_id)
FROM acr_invoice_hd hi, acr_invoice_ln li
AND ROWNUM = 1) invoice_date,
WHERE hi.invoice_hd_id = li.invoice_hd_id
l.amount_cr amount_tax,
AND hi.reversed_flag = 'N'
'留购金' times,
AND (li.cashflow_id = l.cashflow_id OR
h.journal_date due_date,
li.ref_n03 = l.journal_header_id)
to_number(l.reference7) due_amount,
AND ROWNUM = 1) invoice_date,
null principal,
l.amount_cr amount_tax,
to_number(l.reference7) interest,
'留购金' times,
l.amount_cr vat_due_amount,
h.journal_date due_date,
case when nvl(l.reference7-abs(l.amount_cr),0)!=0 then
<bm:data-filterenforceOperations="query"expression="exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.contract_status!='CANCEL' and cc.data_class='NORMAL')"/>
<bm:data-filterenforceOperations="query"expression="exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.contract_status!='CANCEL' and cc.data_class='NORMAL')"/>
<bm:data-filterenforceOperations="query"expression="(t1.amount_tax > 0 or t1.fixed_data_flag='Y')"/>
]]></bm:query-sql>
<bm:data-filterenforceOperations="query"expression="(exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.contract_status!='CANCEL' and cc.data_class='NORMAL') or t1.fixed_data_flag='Y')"/>
<bm:data-filterenforceOperations="query"expression="(exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.contract_status!='CANCEL' and cc.data_class='NORMAL') or t1.fixed_data_flag='Y')"/>