Commit e4dc4755 authored by 王炜's avatar 王炜

增值税台账

parent 7bd894a1
......@@ -9,7 +9,7 @@
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
SELECT * FROM (
SELECT * FROM (
SELECT h.period_year,
h.period_num,
h.internal_period_num,
......@@ -54,7 +54,13 @@ SELECT h.period_year,
and ah.invoice_kind in ('0', '2')
AND ah.vat_interface_status = 'BACK'
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select round(ccc.vat_due_amount/ccc.net_due_amount,2) from con_contract_cashflow ccc where ccc.contract_id=h.source_id
(select
case 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
end
from con_contract_cashflow ccc where ccc.contract_id=h.source_id
and ccc.cf_item=2) vat_rate,
h.je_transaction_code,
l.cashflow_id
......@@ -246,10 +252,14 @@ SELECT h.period_year,
AND to_char(ah.invoice_date,'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select
DECODE( ccc.cf_item,1,
decode(cc.business_type,'LEASEBACK',
round(ccc.vat_interest/ccc.net_interest,2),
round(ccc.vat_due_amount/ccc.net_due_amount,2)), round(ccc.vat_due_amount/ccc.net_due_amount,2))
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,
......@@ -429,7 +439,11 @@ SELECT h.period_year,
AND to_char(ah.invoice_date,'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select
round(ccc.vat_due_amount/ccc.net_due_amount,2)
case 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
end
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
h.je_transaction_code,
l.cashflow_id
......@@ -488,8 +502,13 @@ SELECT h.period_year,
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) interest,
l.amount_cr vat_due_amount,
(select
decode(ccc.cf_item,250,round(ccc.vat_interest/ccc.net_interest,2),
round(ccc.vat_due_amount/ccc.net_due_amount,2))
case when ccc.cf_item=250 and nvl(ccc.interest-ccc.vat_interest,0)!=0 then
round(ccc.vat_interest/(ccc.interest-ccc.vat_interest),2)
when ccc.cf_item!=250 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_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
h.je_transaction_code,
l.cashflow_id
......@@ -574,7 +593,11 @@ SELECT h.period_year,
and ccc.cf_direction='INFLOW'
and ccc.billing_status!='FULL'
),0) vat_due_amount,
(select round(ccc.vat_principal/ccc.net_principal,2)
(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'
......@@ -639,7 +662,12 @@ union
null principal,
to_number(l.reference7) interest,
l.amount_cr vat_due_amount,
round( l.amount_cr/(l.reference7-l.amount_cr),2) vat_rate,
case when nvl(l.reference7-abs(l.amount_cr),0)!=0 then
round(abs(l.amount_cr/(l.reference7-abs(l.amount_cr))),2)
else
null
end
vat_rate,
h.je_transaction_code,
l.cashflow_id
FROM hls_journal_header h, hls_journal_detail l,gld_accounts ga
......@@ -675,7 +703,7 @@ union
</bm:operations>
<bm:data-filters>
<bm:data-filter enforceOperations="query" expression="t1.amount_tax &lt;&gt;0"/>
<bm:data-filter enforceOperations="query" expression="exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.data_class='NORMAL')"/>
<bm:data-filter enforceOperations="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-filters>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="t1.contract_number = ${@contract_number}"/>
......
......@@ -54,7 +54,13 @@ SELECT h.period_year,
and ah.invoice_kind in ('0', '2')
AND ah.vat_interface_status = 'BACK'
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select round(ccc.vat_due_amount/ccc.net_due_amount,2) from con_contract_cashflow ccc where ccc.contract_id=h.source_id
(select
case 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
end
from con_contract_cashflow ccc where ccc.contract_id=h.source_id
and ccc.cf_item=2) vat_rate,
h.je_transaction_code,
l.cashflow_id,
......@@ -255,10 +261,14 @@ SELECT h.period_year,
AND to_char(ah.invoice_date,'yyyymm') < =${@base_period}
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select
DECODE( ccc.cf_item,1,
decode(cc.business_type,'LEASEBACK',
round(ccc.vat_interest/ccc.net_interest,2),
round(ccc.vat_due_amount/ccc.net_due_amount,2)), round(ccc.vat_due_amount/ccc.net_due_amount,2))
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,
......@@ -394,7 +404,7 @@ SELECT h.period_year,
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
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_n04 = l.journal_line_id)
union
......@@ -464,7 +474,11 @@ SELECT h.period_year,
AND to_char(ah.invoice_date,'yyyymm') <= ${@base_period}
and ah.invoice_status = 'CONFIRM'),0) vat_due_amount,
(select
round(ccc.vat_due_amount/ccc.net_due_amount,2)
case 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
end
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
h.je_transaction_code,
l.cashflow_id,
......@@ -492,7 +506,7 @@ SELECT h.period_year,
WHERE hi.invoice_hd_id = li.invoice_hd_id
AND hi.vat_interface_status = 'BACK'
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.cashflow_id=l.cashflow_id )
or
--日立返还金额外判断
......@@ -542,8 +556,13 @@ SELECT h.period_year,
from con_contract_cashflow ccc where ccc.cashflow_id=l.cashflow_id) interest,
l.amount_cr vat_due_amount,
(select
decode(ccc.cf_item,250,round(ccc.vat_interest/ccc.net_interest,2),
round(ccc.vat_due_amount/ccc.net_due_amount,2))
case when ccc.cf_item=250 and nvl(ccc.interest-ccc.vat_interest,0)!=0 then
round(ccc.vat_interest/(ccc.interest-ccc.vat_interest),2)
when ccc.cf_item!=250 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_cashflow ccc where ccc.cashflow_id=l.cashflow_id) vat_rate,
h.je_transaction_code,
l.cashflow_id,
......@@ -629,7 +648,11 @@ SELECT h.period_year,
and ccc.cf_direction='INFLOW'
and ccc.billing_status!='FULL'
),0) vat_due_amount,
(select round(ccc.vat_principal/ccc.net_principal,2)
(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'
......@@ -695,7 +718,12 @@ SELECT h.period_year,
null principal,
to_number(l.reference7) interest,
l.amount_cr vat_due_amount,
round( l.amount_cr/(l.reference7-l.amount_cr),2) vat_rate,
case when nvl(l.reference7-abs(l.amount_cr),0)!=0 then
round(abs(l.amount_cr/(l.reference7-abs(l.amount_cr))),2)
else
null
end
vat_rate,
h.je_transaction_code,
l.cashflow_id,
'N' fixed_data_flag
......@@ -754,7 +782,7 @@ SELECT h.period_year,
</bm:operations>
<bm:data-filters>
<bm:data-filter enforceOperations="query" expression="(t1.amount_tax > 0 or t1.fixed_data_flag='Y')"/>
<bm:data-filter enforceOperations="query" expression="(exists(select 1 from con_contract cc where cc.contract_number=t1.contract_number and cc.data_class='NORMAL') or t1.fixed_data_flag='Y')"/>
<bm:data-filter enforceOperations="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-filters>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="t1.contract_number = ${@contract_number}"/>
......
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