<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Peter Soong  
    $Date: 2014-06-11 10:25:24
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:fields>
        <bm:field name="result_id"/>
        <bm:field name="journal_num"/>
        <bm:field name="js_company_short_name"/>
        <bm:field name="period_name"/>
        <bm:field name="total_amount_dr"/>
        <bm:field name="currency_desc"/>
        <bm:field name="total_amount_fuc_dr"/>
        <bm:field name="je_transaction_desc"/>
        <bm:field name="description"/>
        <bm:field name="result_state"/>
        <bm:field name="result_state_n"/>
        <bm:field name="time"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        t1.journal_num,
                        t1.je_company_id,
                        (SELECT
                            c.company_short_name
                        FROM
                            fnd_companies_vl c
                        WHERE
                            c.company_id = t1.je_company_id
                        ) js_company_short_name,
                        t1.period_name,
                        t1.total_amount_dr,
                        t1.currency_desc,
                        t1.total_amount_fuc_dr,
                        t1.je_transaction_desc,
                        t1.description,
                        t2.result_state,
                        TO_CHAR(t2.creation_date,'yyyy-mm-dd hh24:mi:ss') TIME,
                        DECODE(t2.result_state, '1', '成功', '2', '失败', '3','程序异常','未知错误') result_state_n,
                        t2.result_id
                    FROM
                        HLS_JOURNAL_HEADER_V t1,
                        gh_nc_inter_return t2
                    WHERE
                        t1.journal_header_id = t2.document_id AND
                        t2.document_table    = 'HLS_JOURNAL'
                    ) t1 #WHERE_CLAUSE#
                ORDER BY
                    t1.time DESC
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="journal_num" queryOperator="like"/>
        <bm:query-field field="js_company_short_name" queryOperator="like"/>
        <bm:query-field field="period_name" queryOperator="like"/>
        <bm:query-field field="total_amount_dr" queryOperator="like"/>
        <bm:query-field field="currency_desc" queryOperator="like"/>
        <bm:query-field field="total_amount_fuc_dr" queryOperator="like"/>
        <bm:query-field field="je_transaction_desc" queryOperator="like"/>
        <bm:query-field field="description" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
