<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: jack  
    $Date: 2014-6-9 下午3:00:38  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
SELECT t1.*
  FROM (SELECT a.project_id,
               hd.finance_amount,
               decode(hd.finance_amount,
                      0,
                      '0.00',
                      to_char(round(hd.finance_amount,
                                    4),
                              'FM999,999,999,999.00')) finance_amount_fm,
               decode(hd.down_payment,
                      0,
                      '0.00',
                      to_char(round(hd.down_payment,
                                    4),
                              'FM999,999,999,999.00')) down_payment_fm,
               decode(hd.lease_charge,
                      0,
                      '0.00',
                      to_char(round(hd.lease_charge,
                                    4),
                              'FM999,999,999,999.00')) lease_charge_fm,
               decode(hd.deposit,
                      0,
                      '0.00',
                      to_char(round(hd.deposit,
                                    4),
                              'FM999,999,999,999.00')) deposit_fm,
               decode(hd.residual_value,
                      0,
                      '0.00',
                      to_char(round(hd.residual_value,
                                    4),
                              'FM999,999,999,999.00')) residual_value_fm,
               hd.lease_term || '年(' || hd.lease_times || '期)' lease_term,
               '人民银行基准利率' || decode(hd.int_rate_fixing_way,
                                    'MUTIPLY',
                                    '上浮' || decode(hd.int_rate_fixing_range,
                                                   '',
                                                   '',
                                                   round(hd.int_rate_fixing_range,
                                                         '4') * 100) || '%',
                                    'PLUS',
                                    '上调' || decode(hd.int_rate_fixing_range,
                                                   '',
                                                   '',
                                                   round(hd.int_rate_fixing_range,
                                                         '4') * 100) || '%') || ',即' ||
               decode(hd.int_rate,
                      '',
                      '',
                      round(hd.int_rate,
                            4) * 100 || '%') int_rate,
               decode(hd.int_rate_display,
                      '',
                      '',
                      round(hd.int_rate_display * 100,
                            4) || '%') int_rate_display,
               hd.int_rate_display orginal_int_rate_display,
               hd.lease_charge,
               decode(hd.lease_charge_ratio,
                      '',
                      '',
                      to_char(round(hd.lease_charge_ratio,
                                    4) * 100,
                              'FM990.00') || '%') lease_charge_ratio_f,
               decode(hd.annual_pay_times,
                      '12',
                      '按月',
                      '4',
                      '按季',
                      '2',
                      '半年',
                      '1',
                      '按年') || p_list.description || decode(hd.pay_type,
                                                            '1',
                                                            '先付',
                                                            '0',
                                                            '后付') pay_type,
               '占本金比例:' || to_char(round(hd.deposit_ratio,
                                         4) * 100,
                                   'FM990.00') || '% , 金额:' ||
               decode(hd.deposit,
                      0,
                      '0.00',
                      to_char(round(hd.deposit,
                                    4),
                              'FM999,999,999,999.00')) || ' , 抵扣方式:' ||
               (SELECT a.code_value_name
                  FROM sys_code_values_v a
                 WHERE a.code = 'HLS500_DEPOSIT_DEDUCTION'
                       AND a.code_value = hd.deposit_deduction) deposit_detial,
               hd.deposit,
               hd.residual_value,
               hd.insurance_fee,
               p_list.description price_list_name,
               decode(hd.irr,
                      '',
                      '',
                      round(hd.irr,
                            4) * 100 || '%') irr,
               hd.irr orginal_irr,
               hd.hd_user_col_n07,
               to_char(round(hd.hd_user_col_n07,4)*100,'fm990.00')||'%' roe_f,
               hd.HD_USER_COL_N04 PROJECT_INCOME,
               hd.HD_USER_COL_N03 PORJECT_COST,
               hd.HD_USER_COL_N02 PROJECT_TAX,
               hd.HD_USER_COL_N05 PROJECT_PROFIT_NET
          FROM prj_project           a,
               prj_quotation         d,
               hls_fin_calculator_hd hd,
               hls_price_list        p_list
         WHERE a.project_id = d.document_id(+)
               AND d.document_category = 'PROJECT'
               AND hd.price_list = p_list.price_list
               AND d.ref_v05 = 'Y'
               AND d.enabled_flag = 'Y'
               AND d.calc_session_id = hd.calc_session_id) t1

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