Commit c9863250 authored by 王炜's avatar 王炜

增值税台账上线定版

parent db03706c
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<bm:operations> <bm:operations>
<bm:operation name="query"> <bm:operation name="query">
<bm:query-sql><![CDATA[ <bm:query-sql><![CDATA[
SELECT * FROM ( SELECT * FROM (
SELECT h.period_year, SELECT h.period_year,
h.period_num, h.period_num,
h.internal_period_num, h.internal_period_num,
...@@ -273,7 +273,7 @@ SELECT h.period_year, ...@@ -273,7 +273,7 @@ SELECT h.period_year,
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 (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 (h.je_transaction_code = And (h.je_transaction_code =
'HL_CSH_CONSOLIDATION_DALAY' or 'HL_CSH_CONSOLIDATION_DALAY' or
(h.je_transaction_code = ghd.je_template_code in
'CON_REPURCHASE' and exists ('HL_GLD_BALANCE_REPURCHASE','HL_GLD_BALANCE_REPURCHASE_LB','HL_RECEIVABLES_AGENT_REPUR_LB','HL_RECEIVABLES_AGENT_REPUR','HL_GLD_BALANCE_PENALTY','HL_PENALTY_R_ET','HL_PENALTY_R_ET_LB')
(select 1 )
from gld_je_template_hds ga
where ga.je_template_hd_id =
h.je_template_hd_id
and ga.je_template_code =
'HL_GLD_BALANCE_REPURCHASE')))
and not exists (SELECT 1 and not exists (SELECT 1
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
...@@ -533,109 +553,53 @@ SELECT h.period_year, ...@@ -533,109 +553,53 @@ SELECT h.period_year,
h.je_template_hd_id h.je_template_hd_id
and hd.je_template_code in and hd.je_template_code in
('HL_FIN_INCOME_REPURCHASE', ('HL_FIN_INCOME_REPURCHASE',
'HL_FIN_INCOME_REPURCHASE_N')) 'HL_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET',
'HL_CON_FIN_ETREPUR_INT',
'HL_CON_FIN_ETREPUR_INT_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')))) 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 union
round(ccc.vat_principal/(ccc.principal-ccc.vat_principal),2)
else
null
end
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.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
and ccc.billing_status='FULL'
and ccc.principal>0
and rownum=1
) 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 l.line_description like '%本金%'
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_CHANGE_REPURCHASE_VAT'))
AND EXISTS (SELECT 1
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 cc.contract_id=ccc.contract_id
and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
and ccc.billing_status!='FULL' )
union
SELECT h.period_year, SELECT h.period_year,
h.period_num, h.period_num,
h.internal_period_num, h.internal_period_num,
...@@ -695,6 +659,95 @@ union ...@@ -695,6 +659,95 @@ union
and ccc.cf_status='RELEASE' and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW' and ccc.cf_direction='INFLOW'
and ccc.billing_status!='FULL' ) and ccc.billing_status!='FULL' )
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,
abs(l.amount_cr)*-1
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,
-1* (select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
nvl(ccc.interest, 0)
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
ccc.due_amount
else
ccc.due_amount
end
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) due_amount,
-1* (select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
0
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
nvl(ccc.principal,0)
else
ccc.principal
end
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) principal,
-1*(select case
when ccc.cf_item = 1 then
nvl(ccc.interest, 0)
else
ccc.due_amount
end
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) interest,
-1*abs(l.amount_cr) vat_due_amount,
(select
case when ccc.cf_item=1 and cc.business_type='LEASEBACK' and nvl(ccc.interest-ccc.vat_interest,0) !=0 then
round(ccc.vat_interest/(ccc.interest-ccc.vat_interest),2)
when ((ccc.cf_item=1 and cc.business_type!='LEASEBACK') or ccc.cf_item!=1 ) and nvl(ccc.due_amount-ccc.vat_due_amount,0) !=0 then
round(ccc.vat_due_amount/(ccc.due_amount-ccc.vat_due_amount),2)
else
null
end
from
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 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_VAT_REVERSE_REPURCHASE','HL_VAT_REVERSE_REPURCHASE_LB','HL_CON_VAT_REVERSE_ET','HL_CON_VAT_REVERSE_ET_LB','HL_REPURCHASE_VAT_REVERSE')
)
) t1 ) t1
#WHERE_CLAUSE# #WHERE_CLAUSE#
......
...@@ -80,7 +80,6 @@ SELECT h.period_year, ...@@ -80,7 +80,6 @@ SELECT h.period_year,
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 not EXISTS (SELECT 1 AND not EXISTS (SELECT 1
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
...@@ -305,7 +304,7 @@ SELECT h.period_year, ...@@ -305,7 +304,7 @@ SELECT h.period_year,
ccc.times) > 0 ccc.times) > 0
)) ))
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,
...@@ -338,6 +337,17 @@ SELECT h.period_year, ...@@ -338,6 +337,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
...@@ -346,8 +356,20 @@ SELECT h.period_year, ...@@ -346,8 +356,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
...@@ -356,7 +378,8 @@ SELECT h.period_year, ...@@ -356,7 +378,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
...@@ -376,24 +399,20 @@ SELECT h.period_year, ...@@ -376,24 +399,20 @@ SELECT h.period_year,
h.je_transaction_code, h.je_transaction_code,
l.cashflow_id, l.cashflow_id,
'N' fixed_data_flag 'N' fixed_data_flag
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 (h.je_transaction_code = And (h.je_transaction_code =
'HL_CSH_CONSOLIDATION_DALAY' or 'HL_CSH_CONSOLIDATION_DALAY' or
(h.je_transaction_code = ghd.je_template_code in
'CON_REPURCHASE' and exists ('HL_GLD_BALANCE_REPURCHASE','HL_GLD_BALANCE_REPURCHASE_LB','HL_RECEIVABLES_AGENT_REPUR_LB','HL_RECEIVABLES_AGENT_REPUR','HL_GLD_BALANCE_PENALTY','HL_PENALTY_R_ET','HL_PENALTY_R_ET_LB')
(select 1 )
from gld_je_template_hds ga
where ga.je_template_hd_id =
h.je_template_hd_id
and ga.je_template_code =
'HL_GLD_BALANCE_REPURCHASE')))
and ((trunc(h.journal_date) <= and ((trunc(h.journal_date) <=
trunc(to_date('2020-01-31', 'yyyy-mm-dd')) and trunc(to_date('2020-01-31', 'yyyy-mm-dd')) and
h.description = 'MANUAL_IMPORT') or h.description = 'MANUAL_IMPORT') or
...@@ -404,7 +423,7 @@ SELECT h.period_year, ...@@ -404,7 +423,7 @@ SELECT h.period_year,
WHERE hi.invoice_hd_id = li.invoice_hd_id WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK' AND hi.vat_interface_status = 'BACK'
and hi.invoice_status = 'CONFIRM' and hi.invoice_status = 'CONFIRM'
AND to_char(hi.invoice_date, 'yyyymm') <= ${@base_period} AND to_char(hi.invoice_date, 'yyyymm') < =${@base_period}
and li.ref_n03 = l.journal_header_id and li.ref_n03 = l.journal_header_id
and li.ref_n04 = l.journal_line_id) and li.ref_n04 = l.journal_line_id)
union union
...@@ -581,7 +600,10 @@ SELECT h.period_year, ...@@ -581,7 +600,10 @@ SELECT h.period_year,
h.je_template_hd_id h.je_template_hd_id
and hd.je_template_code in and hd.je_template_code in
('HL_FIN_INCOME_REPURCHASE', ('HL_FIN_INCOME_REPURCHASE',
'HL_FIN_INCOME_REPURCHASE_N')) 'HL_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET',
'HL_CON_FIN_ETREPUR_INT',
'HL_CON_FIN_ETREPUR_INT_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')))) 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 AND not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li FROM acr_invoice_hd hi, acr_invoice_ln li
...@@ -592,105 +614,46 @@ SELECT h.period_year, ...@@ -592,105 +614,46 @@ SELECT h.period_year,
and li.cashflow_id=l.cashflow_id ) and li.cashflow_id=l.cashflow_id )
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,
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_name, AND ROWNUM = 1) bp_code,
l.journal_header_id, (SELECT bp.bp_name
(SELECT hi.invoice_date FROM hls_bp_master bp, hls_journal_detail d
FROM acr_invoice_hd hi, acr_invoice_ln li WHERE bp.bp_code = d.reference1
WHERE hi.invoice_hd_id = li.invoice_hd_id and d.journal_header_id = h.journal_header_id
AND hi.reversed_flag = 'N' AND ROWNUM = 1) bp_name,
AND (li.cashflow_id = l.cashflow_id OR h.journal_header_id,
li.ref_n03 = l.journal_header_id) (SELECT hi.invoice_date
AND ROWNUM = 1) invoice_date, FROM acr_invoice_hd hi, acr_invoice_ln li
nvl((select sum(ccc.vat_principal) FROM con_contract cc,con_contract_cashflow ccc WHERE hi.invoice_hd_id = li.invoice_hd_id
where cc.contract_number=l.reference3 AND hi.reversed_flag = 'N'
and cc.data_class='NORMAL' AND (li.cashflow_id = t.cashflow_id OR
and ccc.cf_item=250 li.ref_n03 = h.journal_header_id)
and ccc.contract_id=cc.contract_id AND ROWNUM = 1) invoice_date,
and ccc.cf_status='RELEASE' t.un_bill_vat_principal amount_tax,
and ccc.cf_direction='INFLOW' '解约回购本金' || t.times times,
and ccc.billing_status!='FULL' h.journal_date due_date,
),0) amount_tax, t.un_bill_principal due_amount,
'解约回购本金' times, t.un_bill_principal principal,
h.journal_date due_date, null interest,
nvl((select sum(ccc.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.contract_id=cc.contract_id t.cashflow_id,
and ccc.cf_item=250 'N' fixed_data_flag
and ccc.cf_status='RELEASE' FROM hls_journal_header h, VAT_ACCOUNT_250_PRIN_TMP t
and ccc.cf_direction='INFLOW' WHERE h.journal_header_id = t.journal_header_id
),0) due_amount, and t.session_id=${/session/@session_id}
nvl((select sum(ccc.principal) FROM con_contract cc,con_contract_cashflow ccc and nvl(t.un_bill_principal,0)>0
where cc.contract_number=l.reference3 and h.internal_period_num < to_number(${@base_period})
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
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) vat_due_amount,
(select case when nvl(ccc.principal-ccc.vat_principal,0)!=0 then
round(ccc.vat_principal/(ccc.principal-ccc.vat_principal),2)
else
null
end
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.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
and ccc.billing_status='FULL'
and ccc.principal>0
and rownum=1
) vat_rate,
h.je_transaction_code,
l.cashflow_id,
'N' fixed_data_flag
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 l.line_description like '%本金%'
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_CHANGE_REPURCHASE_VAT'))
AND EXISTS (SELECT 1
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 cc.contract_id=ccc.contract_id
and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW'
and ccc.billing_status!='FULL' )
union union
SELECT h.period_year, SELECT h.period_year,
h.period_num, h.period_num,
...@@ -775,6 +738,95 @@ SELECT h.period_year, ...@@ -775,6 +738,95 @@ SELECT h.period_year,
null cashflow_id, null cashflow_id,
'Y' fixed_data_flag 'Y' fixed_data_flag
from hl_cm_rpt555_fixed_data h from hl_cm_rpt555_fixed_data h
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,
-1*abs(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,
-1* (select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
nvl(ccc.interest, 0)
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
ccc.due_amount
else
ccc.due_amount
end
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) due_amount,
-1* (select case
when ccc.cf_item = 1 and cc.business_type = 'LEASEBACK' then
0
when ccc.cf_item = 1 and cc.business_type != 'LEASEBACK' then
nvl(ccc.principal,0)
else
ccc.principal
end
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) principal,
-1*(select case
when ccc.cf_item = 1 then
nvl(ccc.interest, 0)
else
ccc.due_amount
end
from con_contract cc, con_contract_cashflow ccc
where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) interest,
-1*abs(l.amount_cr) vat_due_amount,
(select
case when ccc.cf_item=1 and cc.business_type='LEASEBACK' and nvl(ccc.interest-ccc.vat_interest,0) !=0 then
round(ccc.vat_interest/(ccc.interest-ccc.vat_interest),2)
when ((ccc.cf_item=1 and cc.business_type!='LEASEBACK') or ccc.cf_item!=1 ) and nvl(ccc.due_amount-ccc.vat_due_amount,0) !=0 then
round(ccc.vat_due_amount/(ccc.due_amount-ccc.vat_due_amount),2)
else
null
end
from
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,
'Y' fixed_data_flag
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_VAT_REVERSE_REPURCHASE','HL_VAT_REVERSE_REPURCHASE_LB','HL_CON_VAT_REVERSE_ET','HL_CON_VAT_REVERSE_ET_LB','HL_REPURCHASE_VAT_REVERSE')
)
) t1 ) t1
#WHERE_CLAUSE# #WHERE_CLAUSE#
]]></bm:query-sql> ]]></bm:query-sql>
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
$(grid_ds_id_total).setQueryParameter('vat_6_flag','N'); $(grid_ds_id_total).setQueryParameter('vat_6_flag','N');
$(grid_vat_6_ds_id_total).setQueryDataSet($(form_ds_id)); $(grid_vat_6_ds_id_total).setQueryDataSet($(form_ds_id));
$(grid_vat_6_ds_id_total).setQueryParameter('vat_6_flag','Y'); $(grid_vat_6_ds_id_total).setQueryParameter('vat_6_flag','Y');
$(grid_ds_id_before).query(); /*$(grid_ds_id_before).query();
$(grid_ds_id_before_6).query(); $(grid_ds_id_before_6).query();
$(grid_ds_id_current).query(); $(grid_ds_id_current).query();
$(grid_ds_id_current_6).query(); $(grid_ds_id_current_6).query();*/
Leaf.Masker.mask(detail_mask, '正在保存中。。。'); Leaf.Masker.mask(detail_mask, '正在保存中。。。');
Leaf.request({ Leaf.request({
url: $('process_vat_account_data_link').getUrl(), url: $('process_vat_account_data_link').getUrl(),
...@@ -52,6 +52,10 @@ ...@@ -52,6 +52,10 @@
success: function () { success: function () {
$(grid_ds_id_total).query(); $(grid_ds_id_total).query();
$(grid_vat_6_ds_id_total).query(); $(grid_vat_6_ds_id_total).query();
$(grid_ds_id_before).query();
$(grid_ds_id_before_6).query();
$(grid_ds_id_current).query();
$(grid_ds_id_current_6).query();
Leaf.Masker.unmask(detail_mask); Leaf.Masker.unmask(detail_mask);
}, },
failure: function () { failure: function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment