<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2014-1-10 上午10:56:15  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" defaultOrderBy="b.contract_number,a.times" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select b.contract_number,
       b.bp_id_tenant,
       b.bp_id_tenant_n,
       b.bp_id_agent_level1,
       b.bp_id_agent_level1_n,
       a.times,
       a.internal_period_num,
       c.PERIOD_NAME,
       a.calc_start_date,
       a.calc_end_date,
       b.division,
       b.division_n,
       b.lease_organization_n,
       a.unearned_finance_income,
       a.finance_income_recognized
  from con_unearned_finance_income a,
       con_contract_lv             b,
       gld_period_all_v          c
 where a.contract_id = b.contract_id
   and c.COMPANY_ID = ${/session/@company_id}
   and c.INTERNAL_PERIOD_NUM = a.internal_period_num
   and b.bp_id_tenant = nvl(${@bp_id_tenant}, b.bp_id_tenant)
   and (b.bp_id_vender = nvl(${@bp_id_vender}, b.bp_id_vender) or b.bp_id_vender is null)
   and c.PERIOD_NAME between nvl(${@period_name_from}, c.PERIOD_NAME) and
       nvl(${@period_name_to}, c.PERIOD_NAME)
   and b.contract_id = nvl(${@contract_id},b.contract_id)
   and a.finance_income_recognized = nvl(${@finance_income_recognized},a.finance_income_recognized)
   and b.bp_id_agent_level1 = nvl(${@bp_id_agent_level1},b.bp_id_agent_level1) 
   and a.cf_item = 1
 #WHERE_CLAUSE#
 #ORDER_BY_CLAUSE#
 ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" required="true"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT" required="true"/>
        <bm:field name="bp_id_tenant_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_ID_TENANT_N"/>
        <bm:field name="bp_id_agent_level1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_AGENT_LEVEL1"/>
        <bm:field name="bp_id_agent_level1_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_ID_AGENT_LEVEL1_N"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TIMES"/>
        <bm:field name="internal_period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INTERNAL_PERIOD_NUM"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" required="true"/>
        <bm:field name="calc_start_date" databaseType="DATE" datatype="java.util.Date" physicalName="CALC_START_DATE"/>
        <bm:field name="calc_end_date" databaseType="DATE" datatype="java.util.Date" physicalName="CALC_END_DATE"/>
        <bm:field name="unearned_finance_income" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNEARNED_FINANCE_INCOME"/>
        <bm:field name="finance_income_recognized" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FINANCE_INCOME_RECOGNIZED"/>
        <bm:field name="division"/>
        <bm:field name="division_n"/>
        <bm:field name="lease_organization_n"/>
    </bm:fields>
</bm:model>
