Commit 9499eb25 authored by 王炜's avatar 王炜

增值税台账修复-提前结清凭证

parent 32ab2c84
...@@ -245,7 +245,7 @@ SELECT h.period_year, ...@@ -245,7 +245,7 @@ SELECT h.period_year,
where ccc.cashflow_id = l.cashflow_id where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) interest, and ccc.contract_id = cc.contract_id) interest,
l.amount_cr-nvl((select sum(al.tax_amount) from acr_invoice_hd ah,acr_invoice_ln al where 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 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')
...@@ -417,7 +417,7 @@ SELECT h.period_year, ...@@ -417,7 +417,7 @@ SELECT h.period_year,
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 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 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')
...@@ -431,7 +431,7 @@ SELECT h.period_year, ...@@ -431,7 +431,7 @@ SELECT h.period_year,
(select (select
case when ccc.cf_item=200 then case when ccc.cf_item=200 then
ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where
ah.invoice_hd_id=al.invoice_hd_id 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')
...@@ -443,7 +443,7 @@ SELECT h.period_year, ...@@ -443,7 +443,7 @@ SELECT h.period_year,
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) due_amount,
(select case when ccc.cf_item=200 then (select case when ccc.cf_item=200 then
ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where
ah.invoice_hd_id=al.invoice_hd_id 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')
...@@ -453,17 +453,19 @@ SELECT h.period_year, ...@@ -453,17 +453,19 @@ SELECT h.period_year,
0 0
end end
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) principal, from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) principal,
(select decode(ccc.cf_item,'200',0,ccc.due_amount) (select decode(ccc.cf_item,'200',ccc.interest,ccc.due_amount)
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) interest, 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 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 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) vat_due_amount, and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select (select
case when nvl(ccc.due_amount-ccc.vat_due_amount,0)!=0 then case when nvl(ccc.interest,0)!=0 then
round(ccc.vat_interest/ccc.interest,2)
when nvl(ccc.due_amount-ccc.vat_due_amount,0)!=0 then
round(ccc.vat_due_amount/(ccc.due_amount-ccc.vat_due_amount),2) round(ccc.vat_due_amount/(ccc.due_amount-ccc.vat_due_amount),2)
else else
null null
...@@ -487,7 +489,13 @@ SELECT h.period_year, ...@@ -487,7 +489,13 @@ SELECT h.period_year,
('HL_CON_TAX_ET', ('HL_CON_TAX_ET',
'HL_CON_TAX_ET_N', 'HL_CON_TAX_ET_N',
'HL_CON_FIN_ETFEE', 'HL_CON_FIN_ETFEE',
'HL_CON_FIN_ETFEE_N')) 'HL_CON_FIN_ETFEE_N',
'HL_CON_ETREPUR_TAX',
'HL_CON_ETREPUR_TAX_LB',
'HL_CON_ETFEE',
'HL_CON_ETFEE_LB',
'HL_CON_ET_TAX',
'HL_CON_ET_TAX_LB'))
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
...@@ -560,7 +568,9 @@ SELECT h.period_year, ...@@ -560,7 +568,9 @@ SELECT h.period_year,
'HL_FIN_INCOME_REPURCHASE_N', 'HL_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET', 'HL_FIN_INCOME_REPURCHASE_ET',
'HL_CON_FIN_ETREPUR_INT', 'HL_CON_FIN_ETREPUR_INT',
'HL_CON_FIN_ETREPUR_INT_N')) 'HL_CON_FIN_ETREPUR_INT_N',
'HL_CON_ETREPUR_FEE',
'HL_CON_ETREPUR_FEE_LB'))
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
...@@ -658,7 +668,7 @@ SELECT h.period_year, ...@@ -658,7 +668,7 @@ SELECT h.period_year,
FROM con_contract cc,con_contract_cashflow ccc FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3 where cc.contract_number=l.reference3
and cc.data_class='NORMAL' and cc.data_class='NORMAL'
and cc.contract_id=ccc.contract_id and cc.contract_id=ccc.contract_id
and ccc.cf_item=250 and ccc.cf_item=250
and ccc.cf_status='RELEASE' and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW' and ccc.cf_direction='INFLOW'
......
...@@ -109,7 +109,7 @@ SELECT h.period_year, ...@@ -109,7 +109,7 @@ SELECT h.period_year,
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 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 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')
...@@ -253,7 +253,7 @@ SELECT h.period_year, ...@@ -253,7 +253,7 @@ SELECT h.period_year,
where ccc.cashflow_id = l.cashflow_id where ccc.cashflow_id = l.cashflow_id
and ccc.contract_id = cc.contract_id) interest, and ccc.contract_id = cc.contract_id) interest,
l.amount_cr-nvl((select sum(al.tax_amount) from acr_invoice_hd ah,acr_invoice_ln al where 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 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')
...@@ -451,7 +451,7 @@ SELECT h.period_year, ...@@ -451,7 +451,7 @@ SELECT h.period_year,
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 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 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')
...@@ -465,7 +465,7 @@ SELECT h.period_year, ...@@ -465,7 +465,7 @@ SELECT h.period_year,
(select (select
case when ccc.cf_item=200 then case when ccc.cf_item=200 then
ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where
ah.invoice_hd_id=al.invoice_hd_id 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')
...@@ -477,7 +477,7 @@ SELECT h.period_year, ...@@ -477,7 +477,7 @@ SELECT h.period_year,
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) due_amount,
(select case when ccc.cf_item=200 then (select case when ccc.cf_item=200 then
ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where ccc.due_amount-nvl((select sum(al.total_amount) from acr_invoice_hd ah,acr_invoice_ln al where
ah.invoice_hd_id=al.invoice_hd_id 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')
...@@ -487,17 +487,19 @@ SELECT h.period_year, ...@@ -487,17 +487,19 @@ SELECT h.period_year,
0 0
end end
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) principal, from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) principal,
(select decode(ccc.cf_item,'200',0,ccc.due_amount) (select decode(ccc.cf_item,'200',ccc.interest,ccc.due_amount)
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) interest, 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 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 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) vat_due_amount, and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select (select
case when nvl(ccc.due_amount-ccc.vat_due_amount,0)!=0 then case when nvl(ccc.interest,0)!=0 then
round(ccc.vat_interest/ccc.interest,2)
when nvl(ccc.due_amount-ccc.vat_due_amount,0)!=0 then
round(ccc.vat_due_amount/(ccc.due_amount-ccc.vat_due_amount),2) round(ccc.vat_due_amount/(ccc.due_amount-ccc.vat_due_amount),2)
else else
null null
...@@ -522,7 +524,13 @@ SELECT h.period_year, ...@@ -522,7 +524,13 @@ SELECT h.period_year,
('HL_CON_TAX_ET', ('HL_CON_TAX_ET',
'HL_CON_TAX_ET_N', 'HL_CON_TAX_ET_N',
'HL_CON_FIN_ETFEE', 'HL_CON_FIN_ETFEE',
'HL_CON_FIN_ETFEE_N')) 'HL_CON_FIN_ETFEE_N',
'HL_CON_ETREPUR_TAX',
'HL_CON_ETREPUR_TAX_LB',
'HL_CON_ETFEE',
'HL_CON_ETFEE_LB',
'HL_CON_ET_TAX',
'HL_CON_ET_TAX_LB'))
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
...@@ -607,7 +615,9 @@ SELECT h.period_year, ...@@ -607,7 +615,9 @@ SELECT h.period_year,
'HL_FIN_INCOME_REPURCHASE_N', 'HL_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET', 'HL_FIN_INCOME_REPURCHASE_ET',
'HL_CON_FIN_ETREPUR_INT', 'HL_CON_FIN_ETREPUR_INT',
'HL_CON_FIN_ETREPUR_INT_N')) 'HL_CON_FIN_ETREPUR_INT_N',
'HL_CON_ETREPUR_FEE',
'HL_CON_ETREPUR_FEE_LB'))
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
...@@ -658,8 +668,8 @@ SELECT h.period_year, ...@@ -658,8 +668,8 @@ SELECT h.period_year,
and t.session_id=${/session/@session_id} and t.session_id=${/session/@session_id}
and nvl(t.un_bill_principal,0)>0 and nvl(t.un_bill_principal,0)>0
and h.internal_period_num < to_number(${@base_period}) and h.internal_period_num < to_number(${@base_period})
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,
...@@ -714,7 +724,7 @@ SELECT h.period_year, ...@@ -714,7 +724,7 @@ SELECT h.period_year,
FROM con_contract cc,con_contract_cashflow ccc FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3 where cc.contract_number=l.reference3
and cc.data_class='NORMAL' and cc.data_class='NORMAL'
and cc.contract_id=ccc.contract_id and cc.contract_id=ccc.contract_id
and ccc.cf_item=250 and ccc.cf_item=250
and ccc.cf_status='RELEASE' and ccc.cf_status='RELEASE'
and ccc.cf_direction='INFLOW' and ccc.cf_direction='INFLOW'
......
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