<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2014-7-22 上午10:14:09  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="query_method" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="load_card_ln_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOAD_CARD_LN_ID" prompt="HLS_BP_MASTER_LOAD_CARD_LN.LOAD_CARD_LN_ID"/>
        <bm:field name="load_card_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOAD_CARD_HD_ID" prompt="HLS_BP_MASTER_LOAD_CARD_LN.LOAD_CARD_HD_ID"/>
        <bm:field name="loan_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LOAN_AMOUNT" prompt="HLS_BP_MASTER_LOAD_CARD_LN.LOAN_AMOUNT"/>
        <bm:field name="note" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NOTE" prompt="HLS_BP_MASTER_LOAD_CARD_LN.NOTE"/>
        <bm:field name="point_date" databaseType="DATE" datatype="java.util.Date" physicalName="POINT_DATE" prompt="HLS_BP_MASTER_LOAD_CARD_LN.POINT_DATE"/>
        <bm:field name="bill_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BILL_AMOUNT" prompt="HLS_BP_MASTER_LOAD_CARD_LN.BILL_AMOUNT"/>
        <bm:field name="guarantee_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="GUARANTEE_AMOUNT" prompt="HLS_BP_MASTER_LOAD_CARD_LN.GUARANTEE_AMOUNT"/>
        <bm:field name="gua_letter_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="GUA_LETTER_AMOUNT" prompt="HLS_BP_MASTER_LOAD_CARD_LN.GUA_LETTER_AMOUNT"/>
        <bm:field name="factoring_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FACTORING_AMOUNT" prompt="HLS_BP_MASTER_LOAD_CARD_LN.FACTORING_AMOUNT"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="HLS_BP_MASTER_LOAD_CARD_LN.DESCRIPTION"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
					select t1.*
  from (select h.load_card_hd_id,
               h.bp_id,
               h.query_method,
               m.bp_code,
               m.bp_name,
               ls.load_card_ln_id,
               ls.loan_amount,
               ls.note,
               ls.point_date,
               ls.bill_amount,
               ls.guarantee_amount,
               ls.gua_letter_amount,
               ls.factoring_amount,
               h.description
          from hls_bp_master_load_card_hd h,
               (select l.*
                  from hls_bp_master_load_card_ln l,
                       (select l.load_card_hd_id,
                               max(l.point_date) max_point_date
                          from hls_bp_master_load_card_ln l
                         group by l.load_card_hd_id) ls
                 where l.load_card_hd_id = ls.load_card_hd_id
                   and l.point_date = max_point_date) ls,
               hls_bp_master m
         where h.bp_id = m.bp_id
           and h.load_card_hd_id = ls.load_card_hd_id(+)) t1
	   #WHERE_CLAUSE#
           order by t1.bp_code desc
					
]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="bp_id" queryOperator="="/>
        <bm:query-field field="bp_name" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
