<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="hls_fin_calculator_hd" needAccessControl="false">
    <bm:fields>
        <bm:field name="contract_amount_desc"/>
        <bm:field name="lease_desc"/>
        <bm:field name="finance_income_desc"/>
        <bm:field name="down_payment_desc"/>
        <bm:field name="deposit_desc"/>
        <bm:field name="lease_charge_desc"/>
        <bm:field name="other_fee2_desc"/>
        <bm:field name="hd_user_col_n03_desc"/>
        <bm:field name="rent"/>
        <bm:field name="irr"/>
        <bm:field name="int_rate_display"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT 
                '￥' || to_char(sum(to_number(t1.lease_item_amount)),'FM999,999,999,990.00')　as contract_amount_desc,
                (max(to_number(t1.lease_term)) || '年     ' || max(to_number(t1.lease_times)) || '期') AS lease_desc,
                '￥' || to_char(sum(to_number(t1.finance_income)),'FM999,999,999,990.00') as finance_income_desc,
                '￥' || to_char(sum(to_number(t1.down_payment)),'FM999,999,999,990.00') as down_payment_desc,
                '￥' || to_char(sum(to_number(t1.deposit)),'FM999,999,999,990.00') as deposit_desc,          
                '￥' || to_char(sum(to_number(t1.lease_charge)),'FM999,999,999,990.00') as lease_charge_desc, 
                '￥' || to_char(sum(to_number(t1.other_fee2)),'FM999,999,999,990.00') as other_fee2_desc, 
                '￥' || to_char(sum(to_number(t1.hd_user_col_n03)),'FM999,999,999,990.00') as hd_user_col_n03_desc,            
                '￥' || prj_project_report_pkg.get_rent_mobile(${/parameter/@instance_id}) as rent,
                prj_project_report_pkg.get_irr_mobile(${/parameter/@instance_id}) as irr,
                prj_project_report_pkg.get_rate_mobile(${/parameter/@instance_id}) as int_rate_display
                FROM hls_fin_calculator_hd t1
                WHERE t1.calc_session_id in (
                      SELECT t2.calc_session_id
                      FROM prj_quotation t2
                      WHERE t2.document_category = 'PROJECT'
                        AND t2.quotation_type = 'MAJOR'
                        AND t2.enabled_flag = 'Y'
                        AND t2.document_id = (select p.project_id from prj_project p where p.wfl_instance_id = ${/parameter/@instance_id})
                    )
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="project_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
