<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-5-27 下午3:52:40  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_CASHFLOW_ITEM_COMPANY">
    <bm:fields>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" forUpdate="false" insertExpression="${/session/@company_id}" physicalName="COMPANY_ID"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM" prompt="HLS005.HLS_CASHFLOW_ITEM.CF_ITEM"/>
        <bm:field name="cf_item_desc" forInsert="false" forUpdate="false" prompt="HLS006.HLS_CASHFLOW_ITEM_COMPANY.CF_ITEM_DESC"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="company_code" forInsert="false" forUpdate="false" prompt="HLS.COMPANY_CODE"/>
        <bm:field name="company_short_name" forInsert="false" forUpdate="false" prompt="HLS.COMPANY_SHORT_NAME"/>
        <bm:field name="cf_direction" forInsert="false" forUpdate="false"/>
        <bm:field name="cf_direction_desc" forInsert="false" forUpdate="false" prompt="HLS005.HLS_CASHFLOW_TYPE.CF_DIRECTION"/>
        <bm:field name="default_cf_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEFAULT_CF_STATUS"/>
        <bm:field name="default_cf_status_desc" forInsert="false" forUpdate="false" prompt="HLS006.HLS_CASHFLOW_ITEM_COMPANY.DEFAULT_CF_STATUS"/>
        <bm:field name="cf_type" forInsert="false" forUpdate="false" prompt="HLS005.HLS_CASHFLOW_TYPE.CF_TYPE"/>
        <bm:field name="cf_type_desc" forInsert="false" forUpdate="false" prompt="HLS006.HLS_CASHFLOW_ITEM_COMPANY.CF_TYPE_DESC"/>
        <bm:field name="write_off_order" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WRITE_OFF_ORDER" prompt="HLS005.HLS_CASHFLOW_ITEM.WRITE_OFF_ORDER"/>
        <bm:field name="calc_penalty" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CALC_PENALTY" prompt="HLS005.HLS_CASHFLOW_ITEM.CALC_PENALTY"/>
        <bm:field name="billing_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BILLING_DESC" prompt="HLS005.HLS_CASHFLOW_ITEM.BILLING_DESC"/>
        <bm:field name="ref_v01"/>
        <bm:field name="ref_v01_n" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.cf_item,
                    t1.cf_item_desc,
                    t1.enabled_flag,
                    t1.company_id,
                    t1.company_code,
                    t1.company_short_name,
                    t1.cf_direction,
                    t1.cf_direction_desc,
                    t1.default_cf_status,
                    t1.default_cf_status_desc,
                    t1.cf_type,
                    t1.cf_type_desc,
                    t1.write_off_order,
                    t1.calc_penalty,
                    t1.billing_desc,
                    t1.ref_v01,
                    (SELECT
                        v.code_value_name
                    FROM
                        sys_code_values_v v
                    WHERE
                        v.code       = 'NC_CF_ITEM' AND
                        v.code_value = t1.ref_v01
                    ) ref_v01_n
                FROM
                    hls_cashflow_item_company_v t1 #WHERE_CLAUSE#
                ORDER BY
                    t1.cf_type,
                    t1.cf_item
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
        		begin
        			HLS006_SAVE_PKG.export(p_company_id => ${/session/@company_id}, p_user_id => ${/session/@user_id});
        		end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="cf_item"/>
        <bm:pk-field name="company_id"/>
    </bm:primary-key>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.company_id = ${/session/@company_id}"/>
    </bm:data-filters>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="HLS006.HLS_CASHFLOW_ITEM_COMPANY.UNIQUE_INDEX_REPEATED"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
