<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2016-3-3 上午11:21:49  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="SDIC_CONTRACT_CALC_INTEREST">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="record_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="tenant_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="calc_interest" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="interest_balance" databaseType="NUMBER" datatype="java.lang.Double"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="record_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
           SELECT t1.*
  from (SELECT CC.CONTRACT_ID,
               ci.record_id,
               CC.CONTRACT_NUMBER,
               CC.CONTRACT_NAME,
               (SELECT BP.BP_NAME
                  FROM HLS_BP_MASTER BP
                 WHERE BP.BP_ID = CC.BP_ID_TENANT) TENANT_NAME,
               CI.DUE_DATE,
               CI.TIMES,
               nvl(CI.CALC_INTEREST,0) CALC_INTEREST,
               CI.INTEREST_BALANCE
          FROM SDIC_CONTRACT_CALC_INTEREST CI, CON_CONTRACT CC
         WHERE CI.CONTRACT_ID = CC.CONTRACT_ID
           AND CC.DATA_CLASS = 'NORMAL') t1
          #WHERE_CLAUSE#
 ORDER BY t1.CONTRACT_NUMBER DESC, t1.TIMES
           
       ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like ${@contract_number}"/>
        <bm:query-field name="contract_name" queryExpression="t1.contract_name like ${@contract_name}"/>
        <bm:query-field name="tenant_name" queryExpression="t1.tenant_name like ${@tenant_name}"/>
    </bm:query-fields>
</bm:model>
