<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm
    $Date: 2013-12-28 下午1:31:12
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1"
          baseTable="CON_UNEARNED_FINANCE_INCOME" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
        SELECT *
          FROM (SELECT cc.contract_number,
                       ccl.dcs_no no,
                       to_char(ccl.delivery_date, 'yyyy-mm-dd') retaildate,
                       m1.bp_name AS tenant_name,
                       m2.bp_name AS agent_name,
                       ccl.pattern,
                       ccl.machine_number,
                       ccl.equipment_number,
                       ccl.factory_price
                  FROM con_contract               cc,
                       con_contract_lease_item    ccl,
                       hls_bp_master              m1,
                       hls_bp_master              m2
                 WHERE ccl.equipment_number IS NOT NULL
                   AND cc.contract_status IN ('NEW', 'SIGN')
                   AND cc.contract_id = ccl.contract_id
                   AND cc.bp_id_tenant = m1.bp_id(+)
                   AND cc.bp_id_agent_level1 = m2.bp_id(+)
                   AND ccl.equipment_type = 'MAIN') t

               #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="no" queryExpression="t.no=${@no}"/>
        <bm:query-field name="tenant_name" queryExpression="t.tenant_name=${@tenant_name}"/>
        <bm:query-field name="agent_name" queryExpression="t.agent_name=${@agent_name}"/>
    </bm:query-fields>
</bm:model>
