<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Mouse Chow  
    $Date: 2012-12-23 下午03:40:38  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="LCH_LEASE_CHANCE_REQS">
    <bm:fields>
        <bm:field name="lease_chance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_CHANCE_ID" prompt="LCH_LEASE_CHANCE_REQS.LEASE_CHANCE_ID"/>
        <bm:field name="lease_requisition_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LEASE_REQUISITION_ID" prompt="LCH_LEASE_CHANCE_REQS.LEASE_REQUISITION_ID"/>
        <bm:field name="lease_req_number" forInsert="false" forUpdate="false"/>
        <bm:field name="customer_name" forInsert="false" forUpdate="false"/>
        <bm:field name="sum_amount" forInsert="false" forUpdate="false"/>
        <bm:field name="req_status" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="lease_chance_id"/>
        <bm:pk-field name="lease_requisition_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="lease_chance_id" queryOperator="="/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			
    				select 
    				   cr.lease_chance_id,
    				   lq.lease_requisition_id,
				       lq.lease_req_number,
					   pc.customer_name,
				       cv.code_value_name as req_status,
				       (lease_amt_sum + downpay_amount) as sum_amount
				  from hls_prj_lease_requisition lq,
				       hls_prj_customer          pc,
				       sys_codes                 sc,
				       sys_code_values_vl        cv,
				       lch_lease_chance_reqs	 cr
				  where lq.customer_id = pc.customer_id      
					   and sc.code = 'HLS_LEASE_REQUISITION_STAUTS'      
					   and sc.code_id = cv.code_id      
					   and cv.code_value = lq.requisition_status
    				   and lq.lease_requisition_id = cr.lease_requisition_id
    				   and cr.lease_chance_id = ${@lease_chance_id}
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
