<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-27 下午3:17:24  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="GLD_JE_TEMPLATE_HDS">
    <bm:fields>
        <bm:field name="je_template_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JE_TEMPLATE_HD_ID"/>
        <bm:field name="je_transaction_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_TRANSACTION_CODE" prompt="GLD104.GLD_JE_TRANSACTION.JE_TRANSACTION_CODE"/>
        <bm:field name="je_transaction_desc" forInsert="false" forUpdate="false" prompt="GLD104.GLD_JE_TRANSACTION.JE_TRANSACTION_DESC"/>
        <bm:field name="je_template_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_TEMPLATE_CODE" prompt="GLD107.GLD_JE_TEMPLATE_HDS.JE_TEMPLATE_CODE"/>
        <bm:field name="je_template_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_TEMPLATE_DESC" prompt="GLD107.GLD_JE_TEMPLATE_HDS.JE_TEMPLATE_DESC"/>
        <bm:field name="je_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_DESC" prompt="GLD107.GLD_JE_TEMPLATE_HDS.JE_DESC"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="je_company_id_config_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JE_COMPANY_ID_CONFIG_ID"/>
        <bm:field name="je_company_id_config" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JE_COMPANY_ID_CONFIG" prompt="GLD107.GLD_JE_TEMPLATE_HDS.JE_COMPANY_ID_CONFIG"/>
        <bm:field name="journal_date_config_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JOURNAL_DATE_CONFIG_ID"/>
        <bm:field name="journal_date_config" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="JOURNAL_DATE_CONFIG" prompt="GLD107.GLD_JE_TEMPLATE_HDS.JOURNAL_DATE_CONFIG"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="company_short_name" forInsert="false" forUpdate="false" prompt="HLS.COMPANY_SHORT_NAME"/>
        <bm:field name="document_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_TYPE" prompt="GLD107.GLD_JE_TEMPLATE_HDS.DOCUMENT_TYPE"/>
        <bm:field name="document_type_desc" forInsert="false" forUpdate="false" prompt="GLD107.GLD_JE_TEMPLATE_HDS.DOCUMENT_TYPE_DESC"/>
        <bm:field name="immediately_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="IMMEDIATELY_FLAG"/>
        <bm:field name="immediately_flag_n" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT t1.JE_TEMPLATE_HD_ID,
				       t1.JE_TRANSACTION_CODE,
				       t1.JE_TEMPLATE_CODE,
				       t1.JE_TEMPLATE_DESC,
				       t1.JE_DESC,
				       t1.JE_COMPANY_ID_CONFIG_ID,
				       t1.JE_COMPANY_ID_CONFIG,
				       t1.JOURNAL_DATE_CONFIG_ID,
				       t1.JOURNAL_DATE_CONFIG,
				       t1.JE_TRANSACTION_DESC,
				       t1.COMPANY_ID,
				       t1.COMPANY_SHORT_NAME,
				       t1.ENABLED_FLAG,
				       t1.DOCUMENT_TYPE,
				       t1.DOCUMENT_TYPE_DESC,
				       t1.immediately_flag,
				       t1.immediately_flag_n
				  from GLD_JE_TEMPLATE_HDS_V t1
				  #WHERE_CLAUSE#
				 order by t1.JE_TRANSACTION_CODE,t1.JE_TEMPLATE_CODE
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="je_template_hd_id" dataType="java.lang.Long" input="false" output="true" outputPath="@je_template_hd_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
            	begin
			  			  GLD104_SAVE_PKG.head_manage(p_sql_type				=> 'INSERT',
				  									  p_je_template_hd_id       => ${@je_template_hd_id},
										              p_je_transaction_code     => ${@je_transaction_code},
										              p_je_template_code		=> ${@je_template_code},
										              p_je_template_desc        => ${@je_template_desc},
										              p_je_desc                 => ${@je_desc},
										              p_enabled_flag            => ${@enabled_flag},
										              p_user_id                 => ${/session/@user_id},
										              p_company_id				=> ${/session/@company_id},
										              p_document_type			=> ${@document_type},
										              p_immediately_flag		=> ${@immediately_flag});
				
				end;
    		]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            	begin
			  			  GLD104_SAVE_PKG.head_manage(p_sql_type				=> 'UPDATE',
				  									  p_je_template_hd_id       => ${@je_template_hd_id},
										              p_je_transaction_code     => ${@je_transaction_code},
										              p_je_template_code		=> ${@je_template_code},
										              p_je_template_desc        => ${@je_template_desc},
										              p_je_desc                 => ${@je_desc},
										              p_enabled_flag            => ${@enabled_flag},
										              p_user_id                 => ${/session/@user_id},
										              p_company_id				=> ${/session/@company_id},
										              p_document_type			=> ${@document_type},
										              p_immediately_flag		=> ${@immediately_flag});
				
				end;
    		]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            	begin
			  			  GLD104_SAVE_PKG.head_manage(p_sql_type				=> 'DELETE',
				  									  p_je_template_hd_id       => ${@je_template_hd_id},
										              p_je_transaction_code     => ${@je_transaction_code},
										              p_je_template_code		=> ${@je_template_code},
										              p_je_template_desc        => ${@je_template_desc},
										              p_je_desc                 => ${@je_desc},
										              p_enabled_flag            => ${@enabled_flag},
										              p_user_id                 => ${/session/@user_id},
										              p_company_id				=> ${/session/@company_id},
										              p_document_type			=> ${@document_type},
										              p_immediately_flag		=> ${@immediately_flag});
				
				end;
    		]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            	begin
            		gld104_save_pkg.je_template_copy(p_je_template_hd_id   => ${@je_template_hd_id},
						                             p_to_je_template_code => ${@to_je_template_code},
						                             p_to_je_template_desc => ${@to_je_template_desc},
						                             p_company_id          => ${/session/@company_id},
						                             p_user_id             => ${/session/@user_id});
				
				end;
    		]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="je_transaction_code" queryExpression="t1.je_transaction_code=${@je_transaction_code}"/>
        <bm:query-field field="je_template_hd_id" queryExpression="t1.je_template_hd_id=${@je_template_hd_id}"/>
        <bm:query-field field="je_template_code" queryExpression="t1.je_template_code like ${@je_template_code}"/>
        <bm:query-field field="je_template_desc" queryExpression="t1.je_template_desc like ${@je_template_desc}"/>
        <bm:query-field field="enabled_flag" queryExpression="t1.enabled_flag = ${@enabled_flag}"/>
    </bm:query-fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="je_template_hd_id"/>
    </bm:primary-key>
</bm:model>
