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', '2221001024')
and h.reversed_flag = 'N' and h.post_gl_status = 'Y'
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
#WHERE_CLAUSE#
)
select * from (
select '合计' tax_month,
sum(sale_amount) sale_amount,
1 order_seq,
null period_year,
null period_num,
null internal_period_num,
null journal_date,
null journal_num,
null reference2,
null line_description,
null journal_number,
null contract_number,
null bp_code,
null bp_name,
null journal_header_id,
null invoice_date,
sum(amount_tax) amount_tax,
null times,
null due_date,
sum(due_amount) due_amount,
sum(principal) principal,
sum(interest) interest,
sum(vat_due_amount) vat_due_amount,
null vat_rate,
null je_transaction_code,
null cashflow_id,
null fixed_data_flag from temp
union
select * from temp) data order by data.order_seq
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:data-filters>
<!-- <bm:data-filter enforceOperations="query" expression="(t1.amount_tax > 0 or t1.fixed_data_flag='Y')"/>-->
<bm:data-filterenforceOperations="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:query-field name="vat_6_flag" queryExpression="((${@vat_6_flag}='Y' and t1.vat_rate=0.06) or (${@vat_6_flag}!='Y' and nvl(t1.vat_rate,0)!=0.06))"/>-->
<bm:query-fieldname="vat_6_flag"queryExpression="((${@vat_6_flag}='Y' and t1.tax_type_rate=0.06) or(${@vat_6_flag}!='Y' and t1.tax_type_rate!=0.06))"/>