<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Clocc  
    $Date: 2015-6-10 下午3:57:56  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CSH_WRITE_OFF" defaultOrderBy="contract_id,times,cf_item">
    <bm:fields>
        <bm:field name="write_off_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WRITE_OFF_ID" prompt="CSH_WRITE_OFF.WRITE_OFF_ID"/>
        <bm:field name="write_off_type" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="CSH513_WRITE_OFF_TYPE" lookupField="write_off_type_name" physicalName="WRITE_OFF_TYPE" prompt="CSH_WRITE_OFF.WRITE_OFF_TYPE"/>
        <bm:field name="write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="WRITE_OFF_DATE" prompt="HLS.WRITE_OFF_DATE"/>
        <bm:field name="internal_period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INTERNAL_PERIOD_NUM" prompt="CSH_WRITE_OFF.INTERNAL_PERIOD_NUM"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" prompt="CSH_WRITE_OFF.PERIOD_NAME"/>
        <bm:field name="csh_transaction_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CSH_TRANSACTION_ID" prompt="CSH_WRITE_OFF.CSH_TRANSACTION_ID"/>
        <bm:field name="csh_write_off_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="CSH_WRITE_OFF_AMOUNT" prompt="HLS.CSH_WRITE_OFF_AMOUNT"/>
        <bm:field name="subsequent_csh_trx_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SUBSEQUENT_CSH_TRX_ID" prompt="CSH_WRITE_OFF.SUBSEQUENT_CSH_TRX_ID"/>
        <bm:field name="subseq_csh_write_off_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SUBSEQ_CSH_WRITE_OFF_AMOUNT" prompt="CSH_WRITE_OFF.SUBSEQ_CSH_WRITE_OFF_AMOUNT"/>
        <bm:field name="reversed_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REVERSED_FLAG" prompt="CSH_WRITE_OFF.REVERSED_FLAG"/>
        <bm:field name="reversed_write_off_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REVERSED_WRITE_OFF_ID" prompt="CSH_WRITE_OFF.REVERSED_WRITE_OFF_ID"/>
        <bm:field name="reversed_date" databaseType="DATE" datatype="java.util.Date" physicalName="REVERSED_DATE" prompt="CSH_WRITE_OFF.REVERSED_DATE"/>
        <bm:field name="cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CASHFLOW_ID" prompt="CSH_WRITE_OFF.CASHFLOW_ID"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CSH_WRITE_OFF.CONTRACT_ID"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TIMES" prompt="CSH_WRITE_OFF.TIMES"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM" prompt="CSH_WRITE_OFF.CF_ITEM"/>
        <bm:field name="cf_type" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_TYPE" prompt="CSH_WRITE_OFF.CF_TYPE"/>
        <bm:field name="penalty_calc_date" databaseType="DATE" datatype="java.util.Date" physicalName="PENALTY_CALC_DATE" prompt="CSH_WRITE_OFF.PENALTY_CALC_DATE"/>
        <bm:field name="write_off_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_DUE_AMOUNT" prompt="HLS.WRITEOFF_DUE_AMOUNT"/>
        <bm:field name="write_off_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_PRINCIPAL" prompt="CSH513.WRITE_OFF_PRINCIPAL"/>
        <bm:field name="write_off_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_INTEREST" prompt="CSH513.WRITE_OFF_INTEREST"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="CSH_WRITE_OFF.DESCRIPTION"/>
        <bm:field name="opposite_doc_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OPPOSITE_DOC_CATEGORY" prompt="CSH_WRITE_OFF.OPPOSITE_DOC_CATEGORY"/>
        <bm:field name="opposite_doc_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OPPOSITE_DOC_TYPE" prompt="CSH_WRITE_OFF.OPPOSITE_DOC_TYPE"/>
        <bm:field name="opposite_doc_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OPPOSITE_DOC_ID" prompt="CSH_WRITE_OFF.OPPOSITE_DOC_ID"/>
        <bm:field name="opposite_doc_line_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OPPOSITE_DOC_LINE_ID" prompt="CSH_WRITE_OFF.OPPOSITE_DOC_LINE_ID"/>
        <bm:field name="opposite_doc_detail_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OPPOSITE_DOC_DETAIL_ID" prompt="CSH_WRITE_OFF.OPPOSITE_DOC_DETAIL_ID"/>
        <bm:field name="opposite_write_off_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OPPOSITE_WRITE_OFF_AMOUNT" prompt="CSH_WRITE_OFF.OPPOSITE_WRITE_OFF_AMOUNT"/>
        <bm:field name="create_je_mothed" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREATE_JE_MOTHED" prompt="CSH_WRITE_OFF.CREATE_JE_MOTHED"/>
        <bm:field name="create_je_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREATE_JE_FLAG" prompt="CSH_WRITE_OFF.CREATE_JE_FLAG"/>
        <bm:field name="gld_interface_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="GLD_INTERFACE_FLAG" prompt="CSH_WRITE_OFF.GLD_INTERFACE_FLAG"/>
        <bm:field name="write_off_type_name" forInsert="false" forUpdate="false" prompt="HLS.WRITE_OFF_TYPE"/>
        <bm:field name="reversed_flag_desc" expression="(select a.code_value_name from sys_code_values_v a where code=&apos;HLS_REVERSED_FLAG&apos; and a.code_value=t1.reversed_flag )" forInsert="false" forUpdate="false"/>
        <bm:field name="transaction_date" databaseType="DATE" datatype="java.util.Date" expression="(select ct.transaction_date from csh_transaction ct where ct.transaction_id = t1.csh_transaction_id)" forInsert="false" forQuery="true" forUpdate="false"/>
        <bm:field name="bank_slip_num" expression="(select bank_slip_num from CSH_TRANSACTION a where a.TRANSACTION_ID=t1.CSH_TRANSACTION_ID)" forInsert="false" forUpdate="false"/>
        <!-- <bm:field name="transaction_date" databaseType="DATE" datatype="java.util.Date" expression="(select transaction_date from CSH_TRANSACTION a where a.TRANSACTION_ID=t1.CSH_TRANSACTION_ID)"  forInsert="false" forUpdate="false" /> -->
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="write_off_id"/>
    </bm:primary-key>
    <bm:relations>
        <bm:relation name="con_cashflow" joinType="left outer" refAlias="t2" refModel="cont.CON500.con_contract_cashflow_v">
            <bm:reference foreignField="cashflow_id" localField="cashflow_id"/>
        </bm:relation>
        <bm:relation name="hls_cf_type" joinType="left outer" refAlias="t3" refModel="hls.HLS005.hls_cashflow_type_v">
            <bm:reference foreignField="cf_type" localField="cf_type"/>
        </bm:relation>
        <bm:relation name="hls_cf_item" joinType="left outer" refAlias="t4" refModel="hls.HLS005.hls_cashflow_item_v">
            <bm:reference foreignField="cf_item" localField="cf_item"/>
        </bm:relation>
    </bm:relations>
    <bm:ref-fields>
        <bm:ref-field name="due_date" relationName="con_cashflow" sourceField="due_date"/>
        <bm:ref-field name="contract_number" relationName="con_cashflow" sourceField="contract_number"/>
        <bm:ref-field name="project_name" relationName="con_cashflow" sourceField="project_name"/>
        <bm:ref-field name="bp_name" relationName="con_cashflow" sourceField="bp_name"/>
        <bm:ref-field name="cf_type_name" relationName="hls_cf_type" sourceField="description"/>
        <bm:ref-field name="cf_item_name" relationName="hls_cf_item" sourceField="cf_item_desc"/>
    </bm:ref-fields>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="t1.contract_id=${@contract_id}"/>
        <bm:query-field field="write_off_id" queryOperator="="/>
        <bm:query-field field="write_off_date" queryOperator="="/>
        <bm:query-field field="csh_transaction_id" queryOperator="="/>
        <bm:query-field field="reversed_flag" queryOperator="="/>
        <bm:query-field name="reverse_detail_flag" queryExpression="${@reverse_detail_flag}=&apos;Y&apos; and t1.write_off_type in (&apos;RECEIPT_CREDIT&apos;,&apos;RECEIPT_ADVANCE_RECEIPT&apos;,&apos;ADVANCE_RECEIPT_CREDIT&apos;)"/>
        <!-- <bm:query-field name="bank_slip_num" queryExpression="bank_slip_num like ${@bank_slip_num}"/> -->
        <bm:query-field field="transaction_date" queryOperator="="/>
        <bm:query-field name="bank_slip_num_from" queryExpression="t1.bank_slip_num &gt;= ${@bank_slip_num_from}"/>
        <bm:query-field name="bank_slip_num_to" queryExpression="t1.bank_slip_num &lt;= ${@bank_slip_num_to}"/>
        <bm:query-field name="transaction_date_from" queryExpression="transaction_date &gt;= to_date(${@transaction_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="transaction_date_to" queryExpression="transaction_date &lt;= to_date(${@transaction_date_to},&apos;yyyy-mm-dd&apos;)"/>
    </bm:query-fields>
    <!--     <bm:data-filters >
    
    <bm:data-filter name="query" expression="reversed_flag = 'Y'"   />
    </bm:data-filters> -->
</bm:model>
