<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-5 下午05:04:37  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                select
                	cc.contract_id contract_id,
                    cc.flt_int_rate_adj_date, --e1
                    cc.contract_number,       --e2
                    (select
                        pp.virtual_con_number
                    from
                        prj_project pp
                    where
                        pp.project_id = cc.project_id
                    ) virtual_con_number, --e4
                    (select
                        hbm.bp_name
                    from
                        hls_bp_master hbm
                    where
                        cc.bp_id_tenant = hbm.bp_id
                        and hbm.enabled_flag='Y'
                    ) bp_name, --e5
                    --cc.lease_term,--e7
                    content_fun_pkg.lease_term_convert_date(cc.lease_term) as lease_term,
                    (select
                        sc.code_value_name
                    from
                        sys_code_values_v sc
                    where
                        sc.code_value =
                        (select
                            hfh.int_rate_fixing_way
                        from
                            hls_fin_calculator_hd hfh
                        where
                            cc.calc_session_id = hfh.calc_session_id
                        )
                    ) int_rate_fixing_way, --e8
                    /*
                    (select hh.int_rate_fixing_range
                    from hls_fin_calculator_hd hh
                    where hh.calc_session_id = cc.calc_session_id) int_rate_fixing_range,--e9
                    */
                    to_number(
                    (select
                        hh.int_rate_fixing_range
                    from
                        hls_fin_calculator_hd hh
                    where
                        hh.calc_session_id = cc.calc_session_id
                    )) as temp,
                    content_fun_pkg.rete_convert_percent(
                    (select
                        hh.int_rate_fixing_range
                    from
                        hls_fin_calculator_hd hh
                    where
                        hh.calc_session_id = cc.calc_session_id
                    )) int_rate_fixing_range,
                    --select ccc.due_amount from con-contract-cashflow  where ccc.contract_id = cc.contract_id --e6
                    /*content_fun_pkg.due_amount_convert_money ( select ccc.due_amount
                    from con_contract_cashflow ccc
                    where ccc.contract_id =
                    cc.contract_id) as due_amount, --e6*/
                    --cc.lease_term, --e10
                    content_fun_pkg.lease_term_convert_num_year(cc.lease_term) as lease_term_num,
                    (select
                        sc.code_value_name
                    from
                        sys_code_values_v sc
                    where
                        sc.code_value = to_char(cc.annual_pay_times) and
                        sc.code_id    = 323
                    ) annual_pay_times, --e11
                    --cc.vat_flag, --e12
                    cc.vat_flag vat_flag,
                    content_fun_pkg.content_flag_y_n_return_data(cc.vat_flag) as vat_flag_n,
                    --cc.hd_user_col_n05, --e13
                    content_fun_pkg.convert_hd_user_col_n05(cc.contract_id) as hd_user_col_n05,
                    cc.residual_value,     --e14
                    to_char(cc.inception_of_lease,'yyyy-mm-dd') inception_of_lease, --e15
                    (select
                        pp.virtual_con_number
                    from
                        prj_project pp
                    where
                        pp.project_id = cc.project_id
                    ) virtual_con_number, --e16
                    --content_fun_pkg.due_amount_convert_money('') as due_amount, --e17
                    content_fun_pkg.DUE_AMOUNT_CONVERT_MONEY((SELECT CCC.DUE_AMOUNT
          FROM CON_CONTRACT_CASHFLOW CCC
         WHERE CCC.CONTRACT_ID = CC.CONTRACT_ID
           AND CCC.CF_TYPE = 0) ) AS DUE_AMOUNT, --e17
                    --cc.inception_of_lease, --e18
                    to_char(cc.inception_of_lease, 'yyyy"年"mm"月"dd"日"') as inception_of_lease_year, --e18
                    -- cc.inception_of_lease, --e19
                    --to_char(cc.inception_of_lease, 'yyyy"年"mm"月"dd"日"') as inception_of_lease --e19
                    decode(cc.tax_type_id,1,'营业税','增值税') vat_type
                from
                    con_contract cc #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="flt_int_rate_adj_date"/>
        <bm:field name="contract_number"/>
        <bm:field name="virtual_con_number"/>
        <bm:field name="bp_name"/>
        <bm:field name="lease_term"/>
        <bm:field name="int_rate_fixing_way"/>
        <bm:field name="int_rate_fixing_range"/>
        <bm:field name="lease_term_num"/>
        <bm:field name="annual_pay_times"/>
        <bm:field name="vat_flag"/>
        <bm:field name="vat_type"/>
        <bm:field name="vat_flag_n"/>
        <bm:field name="hd_user_col_n05"/>
        <bm:field name="residual_value"/>
        <bm:field name="inception_of_lease"/>
        <bm:field name="due_amount"/>
        <bm:field name="inception_of_lease_year"/>
        <bm:field name="contract_id"/>
    </bm:fields>
    <bm:query-fields>
        <!-- <bm:query-field  name="contract_id" queryExpression="cc.contract_id=${@contract_id}"  /> -->
        <!-- <bm:query-field  name="contract_id" queryExpression="cc.contract_id=776"  /> --><![CDATA[
        
        
        
        
        
        
    	
    	
    ]]></bm:query-fields>
    <bm:data-filters>
        <!-- <bm:data-filter enforceOperations="query" expression="cc.contract_id=${@contract_id}"  /> --><![CDATA[
        
        
        
    	
    ]]></bm:data-filters>
    <bm:features>
        <s:bm-script><![CDATA[
        ]]></s:bm-script>
    </bm:features>
</bm:model>
