<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Guoxuezhao  
    $Date: 2013-6-21 上午10:56:28  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features">
    <bm:fields>
        <bm:field name="loan_contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOAN_CONTRACT_ID" prompt="TRE_LOAN_CONTRACT_V.LOAN_CONTRACT_ID"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="TRE_LOAN_CONTRACT_V.COMPANY_ID"/>
        <bm:field name="loan_contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOAN_CONTRACT_NUMBER" prompt="TRE_LOAN_CONTRACT_V.LOAN_CONTRACT_NUMBER"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY" prompt="TRE_LOAN_CONTRACT_V.DOCUMENT_CATEGORY"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE" prompt="TRE_LOAN_CONTRACT_V.BUSINESS_TYPE"/>
        <bm:field name="document_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE" prompt="TRE_LOAN_CONTRACT_V.DOCUMENT_TYPE"/>
        <bm:field name="loan_contract_book_date" databaseType="DATE" datatype="java.util.Date" physicalName="LOAN_CONTRACT_BOOK_DATE" prompt="TRE_LOAN_CONTRACT_V.LOAN_CONTRACT_BOOK_DATE"/>
        <bm:field name="bank_credit_contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BANK_CREDIT_CONTRACT_ID" prompt="TRE_LOAN_CONTRACT_V.BANK_CREDIT_CONTRACT_ID"/>
        <bm:field name="bank_credit_contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_CREDIT_CONTRACT_NUMBER" prompt="TRE_LOAN_CONTRACT_V.BANK_CREDIT_CONTRACT_NUMBER"/>
        <bm:field name="bank_account_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BANK_ACCOUNT_ID" prompt="TRE_LOAN_CONTRACT_V.BANK_ACCOUNT_ID"/>
        <bm:field name="withdraw_account_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WITHDRAW_ACCOUNT_ID" prompt="TRE_LOAN_CONTRACT_V.WITHDRAW_ACCOUNT_ID"/>
        <bm:field name="withdraw_account_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WITHDRAW_ACCOUNT_CODE" prompt="TRE_LOAN_CONTRACT_V.WITHDRAW_ACCOUNT_CODE"/>
        <bm:field name="withdraw_account_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WITHDRAW_ACCOUNT_NUM" prompt="TRE_LOAN_CONTRACT_V.WITHDRAW_ACCOUNT_NUM"/>
        <bm:field name="bank_full_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_FULL_NAME" prompt="TRE_LOAN_CONTRACT_V.BANK_FULL_NAME"/>
        <bm:field name="bank_branch_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_BRANCH_NAME" prompt="TRE_LOAN_CONTRACT_V.BANK_BRANCH_NAME"/>
        <bm:field name="bank_branch_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BANK_BRANCH_ID" prompt="TRE_LOAN_CONTRACT_V.BANK_BRANCH_ID"/>
        <bm:field name="bank_branch_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_BRANCH_CODE" prompt="TRE_LOAN_CONTRACT_V.BANK_BRANCH_CODE"/>
        <bm:field name="bank_account_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_ACCOUNT_CODE" prompt="TRE_LOAN_CONTRACT_V.BANK_ACCOUNT_CODE"/>
        <bm:field name="bank_account_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_ACCOUNT_NUM" prompt="TRE_LOAN_CONTRACT_V.BANK_ACCOUNT_NUM"/>
        <bm:field name="loan_certificate_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOAN_CERTIFICATE_FLAG" prompt="TRE_LOAN_CONTRACT_V.LOAN_CERTIFICATE_FLAG"/>
        <bm:field name="related_party_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RELATED_PARTY_FLAG" prompt="TRE_LOAN_CONTRACT_V.RELATED_PARTY_FLAG"/>
        <bm:field name="loan_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="LOAN_AMOUNT" prompt="TRE_LOAN_CONTRACT_V.LOAN_AMOUNT"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY" prompt="TRE_LOAN_CONTRACT_V.CURRENCY"/>
        <bm:field name="precision" databaseType="number" datatype="java.lang.Long" physicalName="PRECISION" prompt="TRE_LOAN_CONTRACT_V.PRECISION"/>
        <bm:field name="currency_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_DESC" prompt="TRE_LOAN_CONTRACT_V.CURRENCY_DESC"/>
        <bm:field name="loan_amount_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOAN_AMOUNT_TYPE" prompt="TRE_LOAN_CONTRACT_V.LOAN_AMOUNT_TYPE"/>
        <bm:field name="loan_contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOAN_CONTRACT_STATUS" prompt="TRE_LOAN_CONTRACT_V.LOAN_CONTRACT_STATUS"/>
        <bm:field name="time_horizon" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TIME_HORIZON" prompt="TRE_LOAN_CONTRACT_V.TIME_HORIZON"/>
        <bm:field name="loan_date_from" databaseType="DATE" datatype="java.util.Date" physicalName="LOAN_DATE_FROM" prompt="TRE_LOAN_CONTRACT_V.LOAN_DATE_FROM"/>
        <bm:field name="loan_date_to" databaseType="DATE" datatype="java.util.Date" physicalName="LOAN_DATE_TO" prompt="TRE_LOAN_CONTRACT_V.LOAN_DATE_TO"/>
        <bm:field name="base_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BASE_RATE" prompt="TRE_LOAN_CONTRACT_V.BASE_RATE"/>
        <bm:field name="int_rate_fixing_way" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INT_RATE_FIXING_WAY" prompt="TRE_LOAN_CONTRACT_V.INT_RATE_FIXING_WAY"/>
        <bm:field name="int_rate_fixing_range" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INT_RATE_FIXING_RANGE" prompt="TRE_LOAN_CONTRACT_V.INT_RATE_FIXING_RANGE"/>
        <bm:field name="interest_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_RATE" prompt="TRE_LOAN_CONTRACT_V.INTEREST_RATE"/>
        <bm:field name="calc_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CALC_METHOD" prompt="TRE_LOAN_CONTRACT_V.CALC_METHOD"/>
        <bm:field name="interest_period" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INTEREST_PERIOD" prompt="TRE_LOAN_CONTRACT_V.INTEREST_PERIOD"/>
        <bm:field name="interest_calc_date" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INTEREST_CALC_DATE" prompt="TRE_LOAN_CONTRACT_V.INTEREST_CALC_DATE"/>
        <bm:field name="interest_payment_date" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INTEREST_PAYMENT_DATE" prompt="TRE_LOAN_CONTRACT_V.INTEREST_PAYMENT_DATE"/>
        <bm:field name="penalty_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PENALTY_RATE" prompt="TRE_LOAN_CONTRACT_V.PENALTY_RATE"/>
        <bm:field name="misappropriate_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="MISAPPROPRIATE_RATE" prompt="TRE_LOAN_CONTRACT_V.MISAPPROPRIATE_RATE"/>
        <bm:field name="et_penalty_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="ET_PENALTY_RATE" prompt="TRE_LOAN_CONTRACT_V.ET_PENALTY_RATE"/>
        <bm:field name="annual_days" databaseType="NUMBER" datatype="java.lang.Double" physicalName="ANNUAL_DAYS" prompt="TRE_LOAN_CONTRACT_V.ANNUAL_DAYS"/>
        <bm:field name="rate_float_cycle" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RATE_FLOAT_CYCLE" prompt="TRE_LOAN_CONTRACT_V.RATE_FLOAT_CYCLE"/>
        <bm:field name="flt_execute_times_day" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FLT_EXECUTE_TIMES_DAY" prompt="TRE_LOAN_CONTRACT_V.FLT_EXECUTE_TIMES_DAY"/>
        <bm:field name="adjust_day" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ADJUST_DAY" prompt="TRE_LOAN_CONTRACT_V.ADJUST_DAY"/>
        <bm:field name="withdrawal_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WITHDRAWAL_METHOD" prompt="TRE_LOAN_CONTRACT_V.WITHDRAWAL_METHOD"/>
        <bm:field name="last_withdrawal_date" databaseType="DATE" datatype="java.util.Date" physicalName="LAST_WITHDRAWAL_DATE" prompt="TRE_LOAN_CONTRACT_V.LAST_WITHDRAWAL_DATE"/>
        <bm:field name="factoring_financing_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FACTORING_FINANCING_METHOD" prompt="TRE_LOAN_CONTRACT_V.FACTORING_FINANCING_METHOD"/>
        <bm:field name="payment_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PAYMENT_METHOD" prompt="TRE_LOAN_CONTRACT_V.PAYMENT_METHOD"/>
        <bm:field name="payment_date" databaseType="DATE" datatype="java.util.Date" physicalName="PAYMENT_DATE" prompt="TRE_LOAN_CONTRACT_V.PAYMENT_DATE"/>
        <bm:field name="discount_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DISCOUNT_RATE" prompt="TRE_LOAN_CONTRACT_V.DISCOUNT_RATE"/>
        <bm:field name="bank_financing_scale" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BANK_FINANCING_SCALE" prompt="TRE_LOAN_CONTRACT_V.BANK_FINANCING_SCALE"/>
        <bm:field name="financing_scale" databaseType="NUMBER" datatype="java.lang.Double" physicalName="FINANCING_SCALE" prompt="TRE_LOAN_CONTRACT_V.FINANCING_SCALE"/>
        <bm:field name="repayment_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REPAYMENT_METHOD" prompt="TRE_LOAN_CONTRACT_V.REPAYMENT_METHOD"/>
        <bm:field name="last_repayment_date" databaseType="DATE" datatype="java.util.Date" physicalName="LAST_REPAYMENT_DATE" prompt="TRE_LOAN_CONTRACT_V.LAST_REPAYMENT_DATE"/>
        <bm:field name="total_repayment" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_REPAYMENT" prompt="TRE_LOAN_CONTRACT_V.TOTAL_REPAYMENT"/>
        <bm:field name="total_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_INTEREST" prompt="TRE_LOAN_CONTRACT_V.TOTAL_INTEREST"/>
        <bm:field name="total_fee" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_FEE" prompt="TRE_LOAN_CONTRACT_V.TOTAL_FEE"/>
        <bm:field name="total_fee_pv" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_FEE_PV" prompt="TRE_LOAN_CONTRACT_V.TOTAL_FEE_PV"/>
        <bm:field name="net_finance_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_FINANCE_AMOUNT" prompt="TRE_LOAN_CONTRACT_V.NET_FINANCE_AMOUNT"/>
        <bm:field name="interest_margin" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_MARGIN" prompt="TRE_LOAN_CONTRACT_V.INTEREST_MARGIN"/>
        <bm:field name="reviewed_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REVIEWED_BY" prompt="TRE_LOAN_CONTRACT_V.REVIEWED_BY"/>
        <bm:field name="reviewed_date" databaseType="DATE" datatype="java.util.Date" physicalName="REVIEWED_DATE" prompt="TRE_LOAN_CONTRACT_V.REVIEWED_DATE"/>
        <bm:field name="closed_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CLOSED_BY" prompt="TRE_LOAN_CONTRACT_V.CLOSED_BY"/>
        <bm:field name="closed_date" databaseType="DATE" datatype="java.util.Date" physicalName="CLOSED_DATE" prompt="TRE_LOAN_CONTRACT_V.CLOSED_DATE"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="TRE_LOAN_CONTRACT_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="TRE_LOAN_CONTRACT_V.CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME" prompt="TRE_LOAN_CONTRACT_V.CONTRACT_NAME"/>
        <bm:field name="vat_rate_of_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_RATE_OF_INTEREST" prompt="TRE_LOAN_CONTRACT_V.VAT_RATE_OF_INTEREST"/>
        <bm:field name="note" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NOTE" prompt="TRE_LOAN_CONTRACT_V.NOTE"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="TRE_LOAN_CONTRACT_V.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="TRE_LOAN_CONTRACT_V.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="TRE_LOAN_CONTRACT_V.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="TRE_LOAN_CONTRACT_V.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="TRE_LOAN_CONTRACT_V.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Double" physicalName="REF_N01" prompt="TRE_LOAN_CONTRACT_V.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Double" physicalName="REF_N02" prompt="TRE_LOAN_CONTRACT_V.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Double" physicalName="REF_N03" prompt="TRE_LOAN_CONTRACT_V.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Double" physicalName="REF_N04" prompt="TRE_LOAN_CONTRACT_V.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Double" physicalName="REF_N05" prompt="TRE_LOAN_CONTRACT_V.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="TRE_LOAN_CONTRACT_V.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="TRE_LOAN_CONTRACT_V.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="TRE_LOAN_CONTRACT_V.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="TRE_LOAN_CONTRACT_V.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="TRE_LOAN_CONTRACT_V.REF_D05"/>
    </bm:fields>
    <bm:features>
        <o:sequence-pk/>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="loan_contract_id"/>
    </bm:primary-key>
    <!-- <bm:relations>
        <bm:relation name="tre_creidt" joinType="left outer" refAlias="t2" refModel="tre.tre501.tre_bank_credit_contract">
            <bm:reference foreignField="credit_contract_id" localField="bank_credit_contract_id"/>
        </bm:relation>
        <bm:relation name="bp_master" joinType="left outer" refAlias="t3" refModel="tre.tre503.hls_bp_master_for_credit_con_lov">
            <bm:reference foreignField="bp_id" localField="bank_id"/>
        </bm:relation>
    </bm:relations>
    <bm:ref-fields>
        <bm:ref-field name="bank_name" relationName="bp_master" sourceField="bp_name"/>
        <bm:ref-field name="bank_credit_contract_number" relationName="tre_creidt" sourceField="credit_contract_number"/>
    </bm:ref-fields> -->
    <bm:operations>
        <bm:operation name="query">
            <bm:update-sql><![CDATA[
                select t1.loan_contract_id,
				       t1.company_id,
				       t1.loan_contract_number,
				       t1.document_category,
				       t1.business_type,
				       t1.document_type,
				       t1.loan_contract_book_date,
				       t1.bank_credit_contract_id,
				       t1.bank_credit_contract_number,
				       t1.bank_account_id,
				       t1.bank_full_name,
				       t1.bank_branch_id,
				       t1.bank_branch_name,
				       t1.bank_branch_code,
				       t1.bank_account_code,
				       t1.bank_account_num,
				       t1.withdraw_account_id,
				       t1.withdraw_account_code,
				       t1.withdraw_account_num,
				       t1.loan_certificate_flag,
				       t1.related_party_flag,
				       t1.loan_amount,
				       t1.currency,
				       t1.precision,
				       t1.currency_desc,
				       t1.loan_amount_type,
				       t1.loan_contract_status,
				       t1.time_horizon,
				       t1.loan_date_from,
				       t1.loan_date_to,
				       t1.base_rate,
				       t1.int_rate_fixing_way,
				       t1.int_rate_fixing_range,
				       t1.interest_rate,
				       t1.calc_method,
				       t1.interest_period,
				       t1.interest_calc_date,
				       t1.interest_payment_date,
				       t1.penalty_rate,
				       t1.misappropriate_rate,
				       t1.et_penalty_rate,
				       t1.annual_days,
				       t1.rate_float_cycle,
				       t1.flt_execute_times_day,
				       t1.adjust_day,
				       t1.withdrawal_method,
				       t1.last_withdrawal_date,
				       t1.factoring_financing_method,
				       t1.payment_method,
				       t1.payment_date,
				       t1.discount_rate,
				       t1.bank_financing_scale,
				       t1.financing_scale,
				       t1.repayment_method,
				       t1.last_repayment_date,
				       t1.total_repayment,
				       t1.total_interest,
				       t1.total_fee,
				       t1.total_fee_pv,
				       t1.net_finance_amount,
				       t1.interest_margin,
				       t1.reviewed_by,
       				   t1.reviewed_date,
       				   t1.closed_by,
       				   t1.closed_date,
       				   t1.note,
       				   t1.contract_id,
       				   t1.contract_number,
       				   t1.contract_name,
       				   t1.vat_rate_of_interest,
				       t1.creation_date,
				       t1.created_by,
				       t1.last_update_date,
				       t1.last_updated_by,
				       t1.ref_v01,
				       (select v.code_value_name 
				       from sys_code_values_v v 
				       where v.code='EQUITY_TTADING_PROJECT_TAPE' and v.code_value=t1.ref_v01)ref_v01_desc,
				       t1.ref_v02,
				       t1.ref_v03,
				       t1.ref_v04,
				       t1.ref_v05,
				       t1.ref_n01,
				       t1.ref_n02,
				       t1.ref_n03,
				       t1.ref_n04,
				       t1.ref_n05,
				       t1.ref_d01,
				       t1.ref_d02,
				       t1.ref_d03,
				       t1.ref_d04,
				       t1.ref_d05
				  from tre_loan_contract_v t1 
				  #WHERE_CLAUSE#
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="loan_contract_id" dataType="java.lang.Long" input="false" output="true" outputPath="@loan_contract_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
                begin
                    tre_loan_contract_pkg.insert_loan_contract(   
                    	  p_loan_contract_id=>${@loan_contract_id},
			              p_company_id=>${/session/@company_id},
			              p_loan_contract_number=>${@loan_contract_number},
			              p_document_category=>${@document_category},
			              p_business_type=>${@business_type},
			              p_document_type=>${@document_type},
			              p_loan_contract_book_date=>to_date(${@loan_contract_book_date},'yyyy-mm-dd'),
			              p_bank_credit_contract_id=>${@bank_credit_contract_id},
			              p_bank_account_id=>${@bank_account_id},
			              p_bank_account_num=>${@bank_account_num},
			              p_withdraw_account_id=>${@withdraw_account_id},
			              p_loan_certificate_flag=>${@loan_certificate_flag},
			              p_related_party_flag=>${@related_party_flag},
			              p_loan_amount=>${@loan_amount},
			              p_currency=>${@currency},
			              p_loan_amount_type=>${@loan_amount_type},
			              p_loan_contract_status=>nvl(${@loan_contract_status},'NEW'),
			              p_time_horizon=>${@time_horizon},
			              p_loan_date_from=>to_date(${@loan_date_from},'yyyy-mm-dd'),
			              p_loan_date_to=>to_date(${@loan_date_to},'yyyy-mm-dd'),
			              p_base_rate=>${@base_rate},
			              p_int_rate_fixing_way=>${@int_rate_fixing_way},
			              p_int_rate_fixing_range=>${@int_rate_fixing_range},
			              p_interest_rate=>${@interest_rate},
			              p_calc_method=>${@calc_method},
			              p_interest_period=>${@interest_period},
			              p_interest_calc_date=>${@interest_calc_date},
			              p_interest_payment_date=>${@interest_payment_date},
			              p_penalty_rate=>${@penalty_rate},
			              p_misappropriate_rate=>${@misappropriate_rate},
			              p_et_penalty_rate=>${@et_penalty_rate},
			              p_annual_days=>${@annual_days},
			              p_rate_float_cycle=>${@rate_float_cycle},
			              p_flt_execute_times_day=>${@flt_execute_times_day},
			              p_adjust_day=>${@adjust_day},
			              p_withdrawal_method=>${@withdrawal_method},
			              p_last_withdrawal_date=>to_date(${@last_withdrawal_date},'yyyy-mm-dd'),
			              p_factoring_financing_method=>${@factoring_financing_method},
			              p_payment_method=>${@payment_method},
			              p_payment_date=>to_date(${@payment_date},'yyyy-mm-dd'),
			              p_discount_rate=>${@discount_rate},
			              p_bank_financing_scale=>${@bank_financing_scale},
			              p_financing_scale=>${@financing_scale},
			              p_repayment_method=>${@repayment_method},
			              p_last_repayment_date=>to_date(${@last_repayment_date},'yyyy-mm-dd'),
			              p_total_repayment=>${@total_repayment},
			              p_total_interest=>${@total_interest},
			              p_total_fee=>${@total_fee},
			              p_total_fee_pv=>${@total_fee_pv},
			              p_net_finance_amount=>${@net_finance_amount},
			              p_interest_margin=>${@interest_margin},
			              p_reviewed_by=>${@reviewed_by},
                          p_reviewed_date=>to_date(${@reviewed_date},'yyyy-mm-dd'),
			              p_closed_by=>${@closed_by},
                          p_closed_date=>to_date(${@closed_date},'yyyy-mm-dd'),
                          p_contract_id=>${@contract_id},
                          p_note=>${@note},
			              p_user_id=>${/session/@user_id},
			              p_ref_v01=>${@ref_v01},
			              p_ref_v02=>${@ref_v02},
			              p_ref_v03=>${@ref_v03},
			              p_ref_v04=>${@ref_v04},
			              p_ref_v05=>${@ref_v05},
			              p_ref_n01=>${@ref_n01},
			              p_ref_n02=>${@ref_n02},
			              p_ref_n03=>${@ref_n03},
			              p_ref_n04=>${@ref_n04},
			              p_ref_n05=>${@ref_n05},
			              p_ref_d01=>to_date(${@ref_d01},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d02=>to_date(${@ref_d02},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d03=>to_date(${@ref_d03},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d04=>to_date(${@ref_d04},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d05=>to_date(${@ref_d05},'yyyy-mm-dd hh24:mi:ss')
			    );
                end;]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                    TRE_LOAN_CONTRACT_PKG.UPDATE_LOAN_CONTRACT
                    (
                    	  p_loan_contract_id=>${@loan_contract_id},
			              p_company_id=>${/session/@company_id},
			              p_loan_contract_number=>${@loan_contract_number},
			              p_document_category=>${@document_category},
			              p_business_type=>${@business_type},
			              p_document_type=>${@document_type},
			              p_loan_contract_book_date=>to_date(${@loan_contract_book_date},'yyyy-mm-dd'),
			              p_bank_credit_contract_id=>${@bank_credit_contract_id},
			              p_bank_account_id=>${@bank_account_id},
			              p_bank_account_num=>${@bank_account_num},
			              p_withdraw_account_id=>${@withdraw_account_id},
			              p_loan_certificate_flag=>${@loan_certificate_flag},
			              p_related_party_flag=>${@related_party_flag},
			              p_loan_amount=>${@loan_amount},
			              p_currency=>${@currency},
			              p_loan_amount_type=>${@loan_amount_type},
			              p_loan_contract_status=>${@loan_contract_status},
			              p_time_horizon=>${@time_horizon},
			              p_loan_date_from=>to_date(${@loan_date_from},'yyyy-mm-dd'),
			              p_loan_date_to=>to_date(${@loan_date_to},'yyyy-mm-dd'),
			              p_base_rate=>${@base_rate},
			              p_int_rate_fixing_way=>${@int_rate_fixing_way},
			              p_int_rate_fixing_range=>${@int_rate_fixing_range},
			              p_interest_rate=>${@interest_rate},
			              p_calc_method=>${@calc_method},
			              p_interest_period=>${@interest_period},
			              p_interest_calc_date=>${@interest_calc_date},
			              p_interest_payment_date=>${@interest_payment_date},
			              p_penalty_rate=>${@penalty_rate},
			              p_misappropriate_rate=>${@misappropriate_rate},
			              p_et_penalty_rate=>${@et_penalty_rate},
			              p_annual_days=>${@annual_days},
			              p_rate_float_cycle=>${@rate_float_cycle},
			              p_flt_execute_times_day=>${@flt_execute_times_day},
			              p_adjust_day=>${@adjust_day},
			              p_withdrawal_method=>${@withdrawal_method},
			              p_last_withdrawal_date=>to_date(${@last_withdrawal_date},'yyyy-mm-dd'),
			              p_factoring_financing_method=>${@factoring_financing_method},
			              p_payment_method=>${@payment_method},
			              p_payment_date=>to_date(${@payment_date},'yyyy-mm-dd'),
			              p_discount_rate=>${@discount_rate},
			              p_bank_financing_scale=>${@bank_financing_scale},
			              p_financing_scale=>${@financing_scale},
			              p_repayment_method=>${@repayment_method},
			              p_last_repayment_date=>to_date(${@last_repayment_date},'yyyy-mm-dd'),
			              p_total_repayment=>${@total_repayment},
			              p_total_interest=>${@total_interest},
			              p_total_fee=>${@total_fee},
			              p_total_fee_pv=>${@total_fee_pv},
			              p_net_finance_amount=>${@net_finance_amount},
			              p_interest_margin=>${@interest_margin},
			              p_reviewed_by=>${@reviewed_by},
                          p_reviewed_date=>to_date(${@reviewed_date},'yyyy-mm-dd'),
			              p_closed_by=>${@closed_by},
                          p_closed_date=>to_date(${@closed_date},'yyyy-mm-dd'),
                          p_contract_id=>${@contract_id},
			              p_note=>${@note},
			              p_user_id=>${/session/@user_id},
			              p_ref_v01=>${@ref_v01},
			              p_ref_v02=>${@ref_v02},
			              p_ref_v03=>${@ref_v03},
			              p_ref_v04=>${@ref_v04},
			              p_ref_v05=>${@ref_v05},
			              p_ref_n01=>${@ref_n01},
			              p_ref_n02=>${@ref_n02},
			              p_ref_n03=>${@ref_n03},
			              p_ref_n04=>${@ref_n04},
			              p_ref_n05=>${@ref_n05},
			              p_ref_d01=>to_date(${@ref_d01},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d02=>to_date(${@ref_d02},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d03=>to_date(${@ref_d03},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d04=>to_date(${@ref_d04},'yyyy-mm-dd hh24:mi:ss'),
			              p_ref_d05=>to_date(${@ref_d05},'yyyy-mm-dd hh24:mi:ss')
                    );
                    if nvl(${@validate_source},'CREATE')='INTEREST_RESET' then
            		   tre_loan_contract_pkg.update_after_interest_rest(
            		   	   p_loan_contract_id =>${@loan_contract_id},
                           p_user_id          =>${/session/@user_id}
                       );
            		end if;
                end;]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="loan_contract_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>