<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: syj  
    $Date: 2015年7月20日17:25:30
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" 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.bp_name, --承租人
       				a.extra_nam, --简称
			       (SELECT t.description
			          FROM hls_business_type t
			         WHERE t.business_type = p.business_type) business_type_desc, --租赁方式
			       p.lease_organization_desc, --报审部门
			       p.employee_name, --项目经办人
			       p.employee_id_of_manager_desc, --部门负责人
			       q.lease_item_amount/10000 lease_item_amount, --租赁本金
			       q.down_payment, --零期租金
			       h.lease_charge_ratio, --手续费
			       h.int_rate, --年租息率
			       h.deposit_ratio, --保证金
			       h.other_fee, --其他
			       h.lease_term, --合同期限
			       h.lease_times, --还款周期
			       h.residual_value, --名义货价
			       --'', --名义货价优惠措施
			       (SELECT l.description
			          FROM hls_price_list l
			         WHERE l.price_list = h.price_list) price_list_desc, --租金计算方式
			       hls_common_pkg.get_lease_item_name(p.project_id) lease_item_name, --租赁物名称
			       --'', --租赁物保险方式
			       --  hls_common_pkg.get_mortgage_name(p.project_id) mortgage_name,--抵质押物名称
			       --  (SELECT m.mortgage_type_n FROM prj_project_mortgage_lv m WHERE m.project_id = p.project_id) mortgage_type_n, --抵质押方式
			       b.bp_name guarantor_name, --个人担保姓名
			       (SELECT m.bp_name_sp FROM hls_bp_master m WHERE m.bp_id = b.bp_id) bp_name_sp, --配偶姓名
			       (SELECT m.id_card_no FROM hls_bp_master m WHERE m.bp_id = a.bp_id) id_card_no, --身份证号码
			       (SELECT m.id_card_no FROM hls_bp_master m WHERE m.bp_id = b.bp_id) id_card_no_sp, --身份证号码
			       --'', --投放付款方式
			       --'', --投放方式
			       --'', --分次投放或分合同投放描述
			       c.bp_name vender_name, --资金支付对象
			       --'', --风险控制方案
			       hls_common_pkg.get_approval_status(p.project_id) approval_result,
			       p.project_id
			  FROM prj_project_v         p,
			       prj_quotation         q,
			       hls_fin_calculator_hd h,
			       prj_project_bp        a,
			       prj_project_bp        b,
			       prj_project_bp        c
			 WHERE q.document_category = 'PROJECT'
			   AND q.document_id = p.project_id
			   AND q.calc_session_id = h.calc_session_id
			   AND a.project_id(+) = p.project_id
   			   AND a.bp_category(+) = 'TENANT'
			   AND b.project_id(+) = p.project_id
			   AND b.bp_category(+) = 'GUARANTOR'
			   AND c.project_id(+) = p.project_id
			   AND c.bp_category(+) = 'VENDER'
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="extra_nam" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="business_type_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="lease_organization_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="employee_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="employee_id_of_manager_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="lease_item_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="down_payment" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="lease_charge_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="int_rate" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="deposit_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="other_fee" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="lease_term" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="lease_times" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="residual_value" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="price_list_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="lease_item_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <!-- <bm:field name="mortgage_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="mortgage_type_n" databaseType="VARCHAR2" datatype="java.lang.String"/> -->
        <bm:field name="guarantor_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="bp_name_sp" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="id_card_no" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="id_card_no_sp" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="vender_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="approval_result" databaseType="VARCHAR2" datatype="java.lang.String"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="project_id" queryExpression="t1.project_id = ${@project_id}"/>
    </bm:query-fields>
</bm:model>
