Commit 03e9d3b5 authored by 王炜's avatar 王炜

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

parent 2b853576
......@@ -245,7 +245,7 @@ SELECT h.period_year,
where ccc.cashflow_id = l.cashflow_id
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
ah.invoice_hd_id=al.invoice_hd_id
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')
......@@ -428,7 +428,7 @@ SELECT h.period_year,
li.ref_n03 = l.journal_header_id)
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
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')
......@@ -442,7 +442,7 @@ SELECT h.period_year,
(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
ah.invoice_hd_id=al.invoice_hd_id
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')
......@@ -454,7 +454,7 @@ SELECT h.period_year,
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_amount,
(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
ah.invoice_hd_id=al.invoice_hd_id
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')
......@@ -464,17 +464,19 @@ SELECT h.period_year,
0
end
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,
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 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
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)
else
null
......@@ -498,7 +500,13 @@ SELECT h.period_year,
('HL_CON_TAX_ET',
'HL_CON_TAX_ET_N',
'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'))))
union
......@@ -571,7 +579,9 @@ SELECT h.period_year,
'HL_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET',
'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'))))
union
......@@ -669,7 +679,7 @@ SELECT h.period_year,
FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3
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_status='RELEASE'
and ccc.cf_direction='INFLOW'
......
......@@ -109,7 +109,7 @@ SELECT h.period_year,
li.ref_n03 = l.journal_header_id)
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
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')
......@@ -253,7 +253,7 @@ SELECT h.period_year,
where ccc.cashflow_id = l.cashflow_id
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
ah.invoice_hd_id=al.invoice_hd_id
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')
......@@ -467,7 +467,7 @@ SELECT h.period_year,
li.ref_n03 = l.journal_header_id)
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
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')
......@@ -481,7 +481,7 @@ SELECT h.period_year,
(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
ah.invoice_hd_id=al.invoice_hd_id
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')
......@@ -493,7 +493,7 @@ SELECT h.period_year,
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) due_amount,
(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
ah.invoice_hd_id=al.invoice_hd_id
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')
......@@ -503,17 +503,19 @@ SELECT h.period_year,
0
end
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,
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 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
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)
else
null
......@@ -538,7 +540,13 @@ SELECT h.period_year,
('HL_CON_TAX_ET',
'HL_CON_TAX_ET_N',
'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 ( not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
......@@ -623,7 +631,9 @@ SELECT h.period_year,
'HL_FIN_INCOME_REPURCHASE_N',
'HL_FIN_INCOME_REPURCHASE_ET',
'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 not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
......@@ -674,8 +684,8 @@ SELECT h.period_year,
and t.session_id=${/session/@session_id}
and nvl(t.un_bill_principal,0)>0
and h.internal_period_num < to_number(${@base_period})
union
SELECT h.period_year,
union
SELECT h.period_year,
h.period_num,
h.internal_period_num,
h.journal_date,
......@@ -730,7 +740,7 @@ SELECT h.period_year,
FROM con_contract cc,con_contract_cashflow ccc
where cc.contract_number=l.reference3
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_status='RELEASE'
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