<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-12-4 上午11:14:47  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="HLS_JOURNAL_HEADER_V">
    <bm:fields>
        <bm:field name="journal_header_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JOURNAL_HEADER_ID" prompt="HLS_JOURNAL_HEADER_V.JOURNAL_HEADER_ID"/>
        <bm:field name="source_table" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_TABLE" prompt="HLS_JOURNAL_HEADER_V.SOURCE_TABLE"/>
        <bm:field name="source_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SOURCE_ID" prompt="HLS_JOURNAL_HEADER_V.SOURCE_ID"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="HLS_JOURNAL_HEADER_V.COMPANY_ID"/>
        <bm:field name="je_company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JE_COMPANY_ID" prompt="HLS_JOURNAL_HEADER_V.JE_COMPANY_ID"/>
        <bm:field name="js_company_short_name" expression="(select c.company_short_name from fnd_companies_vl c where c.company_id=je_company_id)"/>
        <bm:field name="journal_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JOURNAL_NUM" prompt="HLS_JOURNAL_HEADER_V.JOURNAL_NUM"/>
        <bm:field name="journal_date" databaseType="DATE" datatype="java.util.Date" physicalName="JOURNAL_DATE" prompt="HLS_JOURNAL_HEADER_V.JOURNAL_DATE"/>
        <bm:field name="period_set_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_SET_CODE" prompt="HLS_JOURNAL_HEADER_V.PERIOD_SET_CODE"/>
        <bm:field name="internal_period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INTERNAL_PERIOD_NUM" prompt="HLS_JOURNAL_HEADER_V.INTERNAL_PERIOD_NUM"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" prompt="HLS_JOURNAL_HEADER_V.PERIOD_NAME"/>
        <bm:field name="period_year" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PERIOD_YEAR" prompt="HLS_JOURNAL_HEADER_V.PERIOD_YEAR"/>
        <bm:field name="period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PERIOD_NUM" prompt="HLS_JOURNAL_HEADER_V.PERIOD_NUM"/>
        <bm:field name="je_template_set_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_TEMPLATE_SET_CODE" prompt="HLS_JOURNAL_HEADER_V.JE_TEMPLATE_SET_CODE"/>
        <bm:field name="je_transaction_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_TRANSACTION_CODE" prompt="HLS_JOURNAL_HEADER_V.JE_TRANSACTION_CODE"/>
        <bm:field name="je_transaction_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_TRANSACTION_DESC" prompt="HLS_JOURNAL_HEADER_V.JE_TRANSACTION_DESC"/>
        <bm:field name="currency_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_CODE" prompt="HLS_JOURNAL_HEADER_V.CURRENCY_CODE"/>
        <bm:field name="currency_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_DESC" prompt="HLS_JOURNAL_HEADER_V.CURRENCY_DESC"/>
        <bm:field name="exchange_rate_quotation" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_QUOTATION" prompt="HLS_JOURNAL_HEADER_V.EXCHANGE_RATE_QUOTATION"/>
        <bm:field name="exchange_rate_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_TYPE" prompt="HLS_JOURNAL_HEADER_V.EXCHANGE_RATE_TYPE"/>
        <bm:field name="exchange_rate_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_TYPE_DESC" prompt="HLS_JOURNAL_HEADER_V.EXCHANGE_RATE_TYPE_DESC"/>
        <bm:field name="exchange_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="EXCHANGE_RATE" prompt="HLS_JOURNAL_HEADER_V.EXCHANGE_RATE"/>
        <bm:field name="attachment_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ATTACHMENT_NUM" prompt="HLS_JOURNAL_HEADER_V.ATTACHMENT_NUM"/>
        <bm:field name="total_amount_dr" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_AMOUNT_DR" prompt="HLS_JOURNAL_HEADER_V.TOTAL_AMOUNT_DR"/>
        <bm:field name="total_amount_cr" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_AMOUNT_CR" prompt="HLS_JOURNAL_HEADER_V.TOTAL_AMOUNT_CR"/>
        <bm:field name="total_amount_fuc_dr" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_AMOUNT_FUC_DR" prompt="HLS_JOURNAL_HEADER_V.TOTAL_AMOUNT_FUC_DR"/>
        <bm:field name="total_amount_fuc_cr" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_AMOUNT_FUC_CR" prompt="HLS_JOURNAL_HEADER_V.TOTAL_AMOUNT_FUC_CR"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="HLS_JOURNAL_HEADER_V.DESCRIPTION"/>
        <bm:field name="approved_date" databaseType="DATE" datatype="java.util.Date" physicalName="APPROVED_DATE" prompt="HLS_JOURNAL_HEADER_V.APPROVED_DATE"/>
        <bm:field name="approved_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="APPROVED_BY" prompt="HLS_JOURNAL_HEADER_V.APPROVED_BY"/>
        <bm:field name="post_gl_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_GL_STATUS" prompt="HLS_JOURNAL_HEADER_V.POST_GL_STATUS"/>
        <bm:field name="post_gl_status_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_GL_STATUS_DESC" prompt="HLS_JOURNAL_HEADER_V.POST_GL_STATUS_DESC"/>
        <bm:field name="post_gl_date" databaseType="DATE" datatype="java.util.Date" physicalName="POST_GL_DATE" prompt="HLS_JOURNAL_HEADER_V.POST_GL_DATE"/>
        <bm:field name="post_gl_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="POST_GL_BY" prompt="HLS_JOURNAL_HEADER_V.POST_GL_BY"/>
        <bm:field name="post_gl_log" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POST_GL_LOG" prompt="HLS_JOURNAL_HEADER_V.POST_GL_LOG"/>
        <bm:field name="je_batch_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JE_BATCH_ID" prompt="HLS_JOURNAL_HEADER_V.JE_BATCH_ID"/>
        <bm:field name="reversed_journal_header_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REVERSED_JOURNAL_HEADER_ID" prompt="HLS_JOURNAL_HEADER_V.REVERSED_JOURNAL_HEADER_ID"/>
        <bm:field name="reversed_flag" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="HLS_REVERSED_FLAG" lookupField="reversed_flag_desc" physicalName="REVERSED_FLAG" prompt="HLS_JOURNAL_HEADER_V.REVERSED_FLAG"/>
        <bm:field name="reversed_flag_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REVERSED_FLAG_DESC"/>
        <bm:field name="reversed_date" databaseType="DATE" datatype="java.util.Date" physicalName="REVERSED_DATE" prompt="HLS_JOURNAL_HEADER_V.REVERSED_DATE"/>
        <bm:field name="external_journal_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EXTERNAL_JOURNAL_HD_ID" prompt="HLS_JOURNAL_HEADER_V.EXTERNAL_JOURNAL_HD_ID"/>
        <bm:field name="external_journal_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXTERNAL_JOURNAL_NUM" prompt="HLS_JOURNAL_HEADER_V.EXTERNAL_JOURNAL_NUM"/>
        <bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS" prompt="HLS_JOURNAL_HEADER_V.STATUS"/>
        <bm:field name="status_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS_DESC" prompt="HLS_JOURNAL_HEADER_V.STATUS_DESC"/>
        <bm:field name="result_id"/>
        <bm:field name="merge_parent_flag"/>
        <bm:field name="merge_flag"/>
        <!--<bm:field name="kingdee_head_flag" expression="(select hls_journal_pkg.get_kingdee_head_flag(t1.journal_header_id) from dual)" forInsert="false" forUpdate="false"/>
        <bm:field name="kingdee_line_assist_flag" expression="(select hls_journal_pkg.get_journal_line_assist_flag(t1.journal_header_id) from dual)" forInsert="false" forUpdate="false"/>-->
        <bm:field name="sap_belnr"/>
        <bm:field name="re_meg"/>
        <bm:field name="re_journal_num"/>
        <bm:field name="re_sap_belnr"/>
        <bm:field name="created_by_n" expression="(select su.description from sys_user su where su.user_id = t1.CREATED_BY)"/>
	    <bm:field name="je_detail_count"/>
        <bm:field name="sbo_num"/>
        <bm:field name="sbo_req_number"/>
        <bm:field name="reversed_19_flag"/>
       <bm:field name="immediately_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="IMMEDIATELY_FLAG" prompt="HLS_JOURNAL_HEADER_V.IMMEDIATELY_FLAG"/>
       <bm:field name="immediately_flag_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="IMMEDIATELY_FLAG_DESC" prompt="HLS_JOURNAL_HEADER_V.IMMEDIATELY_FLAG_DESC"/>
        <bm:field name="division" expression="(select hj.division from hls_payment_je_v hj where hj.journal_header_id = t1.journal_header_id)"/>

    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="merge_parent_flag" queryOperator="="/>
        <bm:query-field name="contract_number" queryExpression="exists (select 1 from HLS_JOURNAL_DETAIL_LV hl   where hl.journal_header_id = t1.journal_header_id     and hl.reference3 like ${@contract_number})"/>
        <bm:query-field field="journal_num" queryOperator="like"/>
        <bm:query-field name="journal_date_from" queryExpression="t1.journal_date &gt;= to_date(${@journal_date_from},'yyyy-mm-dd')"/>
        <bm:query-field name="journal_date_to" queryExpression="t1.journal_date &lt;= to_date(${@journal_date_to},'yyyy-mm-dd')"/>
	<bm:query-field name="sbo_num" queryExpression="t1.sbo_num like &apos;%&apos;||${@sbo_num}||&apos;%&apos; "/>
        <bm:query-field name="sbo_req_number" queryExpression="t1.sbo_req_number like &apos;%&apos;||${@sbo_req_number}||&apos;%&apos; "/>
        <bm:query-field name="external_journal_num" queryExpression="t1.external_journal_num like &apos;%&apos;||${@external_journal_num}||&apos;%&apos; "/>
        <bm:query-field field="je_transaction_code" queryOperator="="/>
        <bm:query-field name="total_amount_dr_from" datatype="java.lang.Double" queryExpression="nvl(t1.total_amount_dr,t1.total_amount_cr) &gt;= ${@total_amount_dr_from}"/>
        <bm:query-field name="total_amount_dr_to" datatype="java.lang.Double" queryExpression="nvl(t1.total_amount_dr,t1.total_amount_cr) &lt;= ${@total_amount_dr_to}"/>
        <bm:query-field field="post_gl_status" queryExpression="nvl(t1.post_gl_status,&apos;N&apos;)=${@post_gl_status}"/>
        <bm:query-field field="company_id" queryOperator="="/>
        <bm:query-field field="currency_code" queryOperator="="/>
        <bm:query-field field="je_company_id" queryOperator="="/>
        <bm:query-field field="status" queryOperator="="/>
        <bm:query-field name="created_by" queryExpression="t1.created_by = ${@created_by}"/>
        <bm:query-field name="sap_belnr" queryExpression="t1.sap_belnr like &apos;%&apos;||${@sap_belnr}||&apos;%&apos;"/>
        <bm:query-field name="description" queryExpression="t1.description like &apos;%&apos;||${@description}||&apos;%&apos;"/>
        <bm:query-field name="query_reversed_flag" queryExpression="(${@query_reversed_flag}=&apos;Y&apos; and nvl(t1.reversed_flag,&apos;N&apos;)=&apos;N&apos;)"/>
        <bm:query-field name="status_list_flag" queryExpression="(${@status_list_flag}=&apos;Y&apos; and t1.status in (&apos;U&apos;,&apos;B&apos;))"/>
        <!--<bm:query-field name="gld_flag" queryExpression="exists (select 1 from gld_je_transaction d where d.je_transaction_code = t1.je_transaction_code and d.gld_flag = ${@gld_flag})"/>-->
	<bm:query-field name="bp_id_tenant" queryExpression="exists (select 1 from hls_journal_detail_v dv where dv.reference1=(select a.bp_code from hls_bp_master a where a.bp_id=${@bp_id_tenant} )and dv.journal_header_id=t1.journal_header_id )"/>
        <bm:query-field name="desc" queryExpression="t1.description like &apos;%&apos;||${@desc}||&apos;%&apos; "/>
        <bm:query-field name="post_sap" queryExpression="(decode(t1.sap_belnr,null,'N','Y') = ${@post_sap})"/>
    </bm:query-fields>
    <bm:data-filters>
     <bm:data-filter name="query" expression="(CASE WHEN ${/session/@role_id} in (select role_id from sys_role where role_code in('HAND','0017')) THEN nvl(t1.manual_flag,&apos;N&apos;) else 'N' end =&apos;N&apos;)"/>

    </bm:data-filters>
</bm:model>
