Commit eda1a4ad authored by 王炜's avatar 王炜

增值税台账-追加回购凭证

parent 0e034d89
......@@ -762,7 +762,68 @@ 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')
)
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,
null invoice_date,
(select
round(l.reference7/(1+cc.vat_rate_of_interest)*cc.vat_rate_of_interest,2)
from
con_contract cc where
cc.contract_number=l.reference3
and cc.data_class='NORMAL') amount_tax,
(select
to_char(ccc.times)
from
con_contract_cashflow ccc where
ccc.cashflow_id=l.cashflow_id) times,
h.journal_date due_date,
to_number(l.reference7) due_amount,
null principal,
to_number(l.reference7) interest,
(select
round(l.reference7/(1+cc.vat_rate_of_interest)*cc.vat_rate_of_interest,2)
from
con_contract cc where
cc.contract_number=l.reference3
and cc.data_class='NORMAL') vat_due_amount,
(select
cc.vat_rate_of_interest
from
con_contract cc where
cc.contract_number=l.reference3
and cc.data_class='NORMAL') 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','2221001024')
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='HL_REPURCHASE_INTEREST_REVERSE')
and l.reference6 is not null
AND not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
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 li.cashflow_id=l.cashflow_id )
) t1
#WHERE_CLAUSE#
]]></bm:query-sql>
......
......@@ -841,6 +841,69 @@ 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')
)
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,
null invoice_date,
(select
round(l.reference7/(1+cc.vat_rate_of_interest)*cc.vat_rate_of_interest,2)
from
con_contract cc where
cc.contract_number=l.reference3
and cc.data_class='NORMAL') amount_tax,
(select
to_char(ccc.times)
from
con_contract_cashflow ccc where
ccc.cashflow_id=l.cashflow_id) times,
h.journal_date due_date,
to_number(l.reference7) due_amount,
null principal,
to_number(l.reference7) interest,
(select
round(l.reference7/(1+cc.vat_rate_of_interest)*cc.vat_rate_of_interest,2)
from
con_contract cc where
cc.contract_number=l.reference3
and cc.data_class='NORMAL') vat_due_amount,
(select
cc.vat_rate_of_interest
from
con_contract cc where
cc.contract_number=l.reference3
and cc.data_class='NORMAL') 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','2221001024')
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='HL_REPURCHASE_INTEREST_REVERSE')
and l.reference6 is not null
AND not EXISTS (SELECT 1
FROM acr_invoice_hd hi, acr_invoice_ln li
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 li.cashflow_id=l.cashflow_id )
) t1
#WHERE_CLAUSE#
]]></bm:query-sql>
......
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