<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2015-5-15 下午4:49:10  
    $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 * from (select 
       (SELECT pp.project_name FROM prj_project pp WHERE pp.project_id = ll.project_id) project_name, 
       hh.je_company_id,
       hh.je_transaction_code,
       hh.currency_code,
       ll.bp_id_tenant,
       hh.post_gl_status,
       hh.journal_header_id,  --凭证ID
       hh.period_year,--会计年
       hh.period_num, --会计期间
       to_char(hh.journal_date,'yyyy-mm-dd') journal_date, --制单日期
       '记' journal_type, --凭证类别
       hh.journal_num,-- 凭证号
       hh.created_by_n, --制单人
       null document, --所附单据数
       null note1, --备注1
       null note2, --备注2
       ll.account_id_n, --科目编码
       ll.line_description , --摘要
       null settle_method, --结算方式编码
       null bill_num, --票据号
       null bill_date, --票据日期
       hh.currency_code_n, --币种名称
       null rate, --汇率
       null price, --单价
       null dr_num, --借方数量
       null cr_num, --贷方数量
       null amount_dr, --原币借方
       null amount_cr, --原币贷方
       ll.amount_fuc_dr,--借方金额
       ll.amount_fuc_cr,--贷方金额
       ll.responsibility_center_code,--部门编码
       null em_code,--职员编码
       (select bm.ref_v05 from hls_bp_master bm where bm.bp_id = ll.bp_id_tenant) ref_v05,--客户编码
       (select bm.ref_v10 from hls_bp_master bm where bm.bp_id = ll.bp_id_vender) ref_v10,--供应商编码
       null project_item_code,--项目大类编码
       (select pp.project_number
          from prj_project pp
         where pp.project_id = ll.project_id) project_number, --项目编码
       null salesman,--业务员
       null define_1,--自定义项1
       null define_2,--自定义项2
       null define_3,--自定义项3
       null define_4,--自定义项4
       null define_5,--自定义项5
       null define_6,--自定义项6
       null define_7,--自定义项7
       null define_8,--自定义项8
       null define_9,--自定义项9
       null define_10,--自定义项10
       null define_11,--自定义项11
       null define_12,--自定义项12
       null define_13,--自定义项13
       null define_14,--自定义项14
       null define_15,--自定义项15
       null define_16,--自定义项16
       null cash_flow_item,--现金流量项目
       null cash_flow_dr,--现金流量借方金额
       null cash_flow_cr, --现金流量贷方金额
       nvl(hh.export_flag,'N') export_flag
  from hls_journal_header_lv hh, hls_journal_detail_lv ll
 where hh.journal_header_id = ll.journal_header_id) t
 #WHERE_CLAUSE#															]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
        			hls_journal_pkg.update_journal_export_flag(p_journal_header_id => ${@journal_header_id},
                                             				   p_user_id => ${/session/@user_id});
        		end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="period_year" queryExpression="t.period_year=${@period_year}"/>
        <bm:query-field name="period_num" queryExpression="t.period_num=${@period_num}"/>
        <bm:query-field name="journal_date_from" queryExpression="to_date(t.journal_date,&apos;yyyy-mm-dd&apos;) &gt;= to_date(${@journal_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="journal_date_to" queryExpression="to_date(t.journal_date,&apos;yyyy-mm-dd&apos;) &lt;= to_date(${@journal_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="journal_num" queryExpression="t.journal_num=${@journal_num}"/>
        <bm:query-field name="export_flag" queryExpression="t.export_flag=${@export_flag}"/>
        <bm:query-field name="total_amount_dr_from" queryExpression="nvl(t.amount_fuc_dr, t.amount_fuc_cr)&gt;=${@total_amount_dr_from}"/>
        <bm:query-field name="total_amount_dr_to" queryExpression="nvl(t.amount_fuc_dr, t.amount_fuc_cr)&lt;=${@total_amount_dr_to}"/>
        <bm:query-field name="responsibility_center_code_from" queryExpression="nvl(t.responsibility_center_code,&apos; &apos;)&gt;=${@responsibility_center_code_from}"/>
        <bm:query-field name="responsibility_center_code_to" queryExpression="nvl(t.responsibility_center_code,&apos; &apos;)&lt;=${@responsibility_center_code_to}"/>
        <bm:query-field name="account_code_from" queryExpression="nvl(t.account_id_n,&apos; &apos;)&gt;=${@account_code_from}"/>
        <bm:query-field name="account_code_to" queryExpression="nvl(t.account_id_n,&apos; &apos;)&lt;=${@account_code_to}"/>
        <bm:query-field name="je_company_id" queryExpression="t.je_company_id=${@je_company_id}"/>
        <bm:query-field name="project_name" queryExpression="t.project_name like ${@project_name}"/>
        <bm:query-field name="je_transaction_code" queryExpression="t.je_transaction_code=${@je_transaction_code}"/>
        <bm:query-field name="currency_code" queryExpression="t.currency_code=${@currency_code}"/>
        <bm:query-field name="bp_id_tenant" queryExpression="t.bp_id_tenant=${@bp_id_tenant}"/>
        <bm:query-field name="post_gl_status" queryExpression="t.post_gl_status=${@post_gl_status}"/>
    </bm:query-fields>
</bm:model>
