<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: jack  
    $Date: 2014-5-30 上午10:13:26  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
        SELECT t1.*
  FROM (SELECT b.project_id ,
  decode(c.finance_amount,0,'0',round(c.finance_amount/10000,4)) finance_amount_fm,
  decode(c.down_payment,0,'0',round(c.down_payment/10000,4)) down_payment_fm,
  decode(c.lease_charge,0,'0',round(c.lease_charge/10000,4)) lease_charge_fm,
  decode(c.deposit,0,'0',round(c.deposit/10000,4)) deposit_fm,
  decode(c.residual_value,0,'0.00',to_char(round(c.residual_value,4),'FM999,999,999,990.00')) residual_value_fm,
  decode(c.pay_type,1,'先付',0,'后付')   pay_type_name,
  decode(c.annual_pay_times,12,'按月',4,'按季',2,'半年',1,'按年') annual_pay_times_name,
  decode(c.deposit_ratio, '', '', round(c.deposit_ratio * 100, 4) || '%') deposit_ratio_rate,
  decode(c.lease_charge_ratio, '', '', round(c.lease_charge_ratio * 100, 4) || '%') lease_charge_ratio_rate,
  (select p_list.description from hls_price_list p_list where p_list.price_list=c.price_list) price_list_name,
decode(c.btb_finance_ratio,'','',(round(c.btb_finance_ratio*100,3)||'%')) btb_finance_ratio_c,
decode(c.down_payment_ratio,'','',(round(c.down_payment_ratio*100,3)||'%')) down_payment_ratio_c,
decode(c.lease_charge_ratio,'','',(round(c.lease_charge_ratio*100,3)||'%')) lease_charge_ratio_c,
decode(c.deposit_ratio,'','',(round(c.deposit_ratio*100,3)||'%')) deposit_ratio_c,
decode(c.int_rate,'','',(round(c.int_rate*100,3)||'%')) int_rate_c,
decode(c.irr,'','',(round(c.irr*100,3)||'%')) irr_c,
       c.*
  FROM prj_quotation         a,
       prj_project           b,
       hls_fin_calculator_hd  c
 WHERE a.document_category = 'PROJECT'
       AND a.document_id = b.project_id
       AND a.ref_v05 = 'Y'
       AND a.enabled_flag = 'Y'
       and a.calc_session_id=c.calc_session_id) t1 #WHERE_CLAUSE#

          ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
