<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: WangQiaosen3207  
    $Date: 2011-6-2 上午10:20:12  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                select distinct t.expense_item_id,
                       t.set_of_books_id,
                       t.expense_item_code,
                       t.expense_item_desc,
                       t.currency_code,
                       t.standard_price,
                       decode(ec.enabled_flag, 'Y', t.enabled_flag, ec.enabled_flag) enabled_flag,
                       t.req_item_id,                      
                       t.budget_item_id                                          
                  from exp_expense_items      t,                                                               
                       fnd_companies             fc,
                       exp_company_expense_items ec                                           
                  #WHERE_CLAUSE#
                 order by t.expense_item_code
        ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                begin
                    exp_expense_items_pkg.update_company_expense_items(p_expense_item_id =>${@expense_item_id},
                                                                       p_company_id      =>${/session/@company_id},
                                                                       p_enabled_flag    =>${@enabled_flag},
                                                                       p_last_updated_by =>${/session/@user_id},
                                                                       p_csh_usage_id	 =>${@csh_usage_id},
                                                                       p_quality_id		 =>${@quality_id},
                                                                       p_no_cheat_control=>${@no_cheat_control});
                end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="expense_item_code" queryOperator="like"/>
        <bm:query-field field="expense_item_desc" queryExpression="t.expense_item_desc like ${@description}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="expense_item_id" enforceOperations="query" expression="ec.expense_item_id = t.expense_item_id(+)"/>
        <bm:data-filter name="set_of_books_id" enforceOperations="query" expression="t.set_of_books_id = fc.set_of_books_id"/>
        <bm:data-filter name="filter" enforceOperations="query" expression="fc.company_id =${/session/@company_id} and ec.company_id =${/session/@company_id}"/>
    </bm:data-filters>
    <bm:fields>
        <bm:field name="expense_item_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EXPENSE_ITEM_ID"/>
        <bm:field name="set_of_books_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SET_OF_BOOKS_ID"/>
        <bm:field name="expense_item_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPENSE_ITEM_CODE" prompt="EXP_COMPANY_EXPENSE_ITEMS.EXPENSE_ITEM_ID"/>
        <bm:field name="expense_item_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPENSE_ITEM_DESC" prompt="EXP_COMP_EXP_ITEM.DESCRIPTION"/>
        <bm:field name="currency_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_CODE"/>
        <bm:field name="standard_price" databaseType="NUMBER" datatype="java.lang.Long" physicalName="STANDARD_PRICE"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="EXP_COMPANY_REQ_ITEM.ENABLED_FLAG"/>
        <bm:field name="req_item_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REQ_ITEM_ID"/>
        <bm:field name="budget_item_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BUDGET_ITEM_ID"/>
    </bm:fields>
</bm:model>
