<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-7-18 下午2:24:20  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t.project_id,
                    t.product_plan_id,
                    t.product_plan_id_n,
                    t.lease_times,
                    t.lease_times times,
                    t.down_payment_ratio,
                    t.deposit_ratio,
                    t.balloon_ratio,
                    (SELECT
                        h.pmt
                    FROM
                        prj_quotation pq,
                        hls_fin_calculator_hd h
                    WHERE
                        pq.document_category = 'PROJECT' AND
                        pq.document_id       = t.project_id AND
                        pq.calc_session_id   = h.calc_session_id
                    ) pmt,
                    t.down_payment,
                    t.deposit,
                    t.lease_charge,
                    t.balloon,
                    t.down_payment + NVL(t.deposit, 0) + NVL(t.lease_charge, 0) first_payment,
                    (SELECT
                        h.finance_amount
                    FROM
                        prj_quotation pq,
                        hls_fin_calculator_hd h
                    WHERE
                        pq.document_category = 'PROJECT' AND
                        pq.document_id       = t.project_id AND
                        pq.calc_session_id   = h.calc_session_id
                    ) finance_amount
                FROM
                    prj_project_lease_item_lv t
                WHERE
                    t.project_id =${@project_id}
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID"/>
        <bm:field name="product_plan_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRODUCT_PLAN_ID"/>
        <bm:field name="product_plan_id_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRODUCT_PLAN_ID_N"/>
        <bm:field name="lease_times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_TIMES"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TIMES"/>
        <bm:field name="down_payment_ratio" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DOWN_PAYMENT_RATIO"/>
        <bm:field name="deposit_ratio" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DEPOSIT_RATIO_N"/>
        <bm:field name="balloon_ratio" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BALLOON_RATIO"/>
        <bm:field name="pmt" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PMT"/>
        <bm:field name="down_payment" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DOWN_PAYMENT"/>
        <bm:field name="deposit" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DEPOSIT"/>
        <bm:field name="lease_charge" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LEASE_CHARGE"/>
        <bm:field name="balloon" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BALLOON"/>
        <bm:field name="first_payment" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FIRST_PAYMENT"/>
        <bm:field name="finance_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FINANCE_AMOUNT"/>
    </bm:fields>
</bm:model>
