<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2014-9-1 上午10:45:47  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        a.virtual_con_number,
                        a.lease_aomunt_recevied_date,
                        a.project_id,
                        a.contract_id,
                        a.contract_number,
                        a.contract_name,
                        a.finance_amount,
                        a.bp_id_tenant_n,
                        a.employee_id_n,
                        a.unit_id_n,
                        a.division_n,
                        a.lease_start_date,
                        b.loan_amount,
                        a.lease_organization,
                        a.hn_industry_classification,
                        b.loan_date,
                        a.pre_incept_date,
                        c.employee_suggest_dec,
                        c.suggest_incept_date,
                        c.lease_condition,
                        c.wfl_instance_id
                    FROM
                        con_contract_lv a,
                        con_contract_incept_wfl c,
                        (SELECT
                            t2.contract_id,
                            SUM(t2.write_off_due_amount) loan_amount,
                            MAX(t2.write_off_date) loan_date
                        FROM
                            csh_write_off t2,
                            con_contract_cashflow t3
                        WHERE
                            t2.reversed_flag = 'N' AND
                            t2.contract_id   = t3.contract_id AND
                            t2.cashflow_id   = t3.cashflow_id AND
                            t2.cf_item       = t3.cf_item
                        GROUP BY
                            t2.contract_id
                        ) b
                    WHERE
                        a.contract_id = c.contract_id AND
                        c.contract_id = b.contract_id(+)
                    ) t #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:parameters>
                <bm:parameter name="flag" output="true" outputPath="@flag"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
             begin
                bus_business_pkg.con_contract_lease_date(p_contract_id =>${@contract_id},
                                                         p_user_id => ${/session/@user_id},
                                                         p_flag =>${@flag});
              end;
          ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="virtual_con_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <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="lease_aomunt_recevied_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="finance_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="loan_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="loan_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="pre_incept_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="lease_start_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="employee_suggest_dec" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="suggest_incept_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="wfl_instance_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="lease_condition"/>
        <bm:field name="bp_id_tenant_n"/>
        <bm:field name="employee_id_n"/>
        <bm:field name="unit_id_n"/>
        <bm:field name="division_n"/>
        <bm:field name="project_id"/>
        <bm:field name="lease_organization"/>
        <bm:field name="hn_industry_classification"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="wfl_instance_id" queryOperator="="/>
        <bm:query-field field="contract_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
