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,
...
@@ -309,6 +309,17 @@ SELECT h.period_year,
...
@@ -309,6 +309,17 @@ SELECT h.period_year,
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
(select d.amount_cr
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 ('6041001000'))
and rownum = 1)
else
(select d.amount_dr
(select d.amount_dr
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
...
@@ -317,8 +328,20 @@ SELECT h.period_year,
...
@@ -317,8 +328,20 @@ SELECT h.period_year,
from gld_accounts g
from gld_accounts g
where g.account_id = d.account_id
where g.account_id = d.account_id
and g.account_code in ('1122000001', '1122000002'))
and g.account_code in ('1122000001', '1122000002'))
and rownum = 1) due_amount,
and rownum = 1)
end due_amount,
null principal,
null principal,
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
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 ('6041001000'))
and rownum = 1)
else
(select d.amount_dr
(select d.amount_dr
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
...
@@ -327,7 +350,8 @@ SELECT h.period_year,
...
@@ -327,7 +350,8 @@ SELECT h.period_year,
from gld_accounts g
from gld_accounts g
where g.account_id = d.account_id
where g.account_id = d.account_id
and g.account_code in ('1122000001', '1122000002'))
and g.account_code in ('1122000001', '1122000002'))
and rownum = 1) interest,
and rownum = 1)
end interest,
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
...
@@ -346,24 +370,20 @@ SELECT h.period_year,
...
@@ -346,24 +370,20 @@ SELECT h.period_year,
and cc.data_class = 'NORMAL') vat_rate,
and cc.data_class = 'NORMAL') 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,gld_je_template_hds ghd
WHERE h.journal_header_id = l.journal_header_id
WHERE h.journal_header_id = l.journal_header_id
and h.je_template_hd_id=ghd.je_template_hd_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')
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( (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,
t.contract_number contract_number,
reference1 bp_code,
(SELECT bp.bp_code
(SELECT BP_NAME
FROM hls_bp_master bp,hls_journal_detail d
FROM hls_bp_master
WHERE bp.bp_code = d.reference1
WHERE bp_code = reference1
and d.journal_header_id=h.journal_header_id
AND ROWNUM = 1) bp_code,
(SELECT bp.bp_name
FROM hls_bp_master bp,hls_journal_detail d
WHERE bp.bp_code = d.reference1
and d.journal_header_id=h.journal_header_id
AND ROWNUM = 1) bp_name,
AND ROWNUM = 1) bp_name,
l.journal_header_id,
h.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 = t.cashflow_id OR
li.ref_n03 = l.journal_header_id)
li.ref_n03 = h.journal_header_id)
AND ROWNUM = 1) invoice_date,
AND ROWNUM = 1) invoice_date,
nvl((select sum(ccc.vat_principal) FROM con_contract cc,con_contract_cashflow ccc
t.un_bill_vat_principal amount_tax,
where cc.contract_number=l.reference3
'解约回购本金'||t.times times,
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,
h.journal_date due_date,
nvl((select sum(ccc.principal) FROM con_contract cc,con_contract_cashflow ccc
t.un_bill_principal due_amount,
where cc.contract_number=l.reference3
t.un_bill_principal principal,
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,
null interest,
nvl((select sum(ccc.vat_principal) FROM con_contract cc,con_contract_cashflow ccc
t.un_bill_vat_principal vat_due_amount,
where cc.contract_number=l.reference3
t.tax_type_rate vat_rate,
and cc.data_class='NORMAL'
h.je_transaction_code,
and ccc.cf_item=250
t.cashflow_id
and ccc.contract_id=cc.contract_id
FROM hls_journal_header h,VAT_ACCOUNT_250_PRIN_TMP t
and ccc.cf_status='RELEASE'
WHERE h.journal_header_id = t.journal_header_id
and ccc.cf_direction='INFLOW'
and t.session_id=${/session/@session_id}
and ccc.billing_status!='FULL'
and nvl(t.un_bill_principal,0)>0
),0) vat_due_amount,
and h.internal_period_num=to_number(${@base_period})
(select case when nvl(ccc.principal-ccc.vat_principal,0)!=0 then