<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: sf
    $Date: 2019-9-9 下午01:23:36
    $Revision: 1.0
    $Purpose:
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CSH_TRANSACTION" defaultOrderBy="t1.transaction_num" needAccessControl="false">
    <bm:fields>
        <bm:field name="transaction_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TRANSACTION_ID" prompt="CSH511.CSH_TRANSACTION.TRANSACTION_ID"/>
        <bm:field name="transaction_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TRANSACTION_NUM" prompt="CSH511.CSH_TRANSACTION.TRANSACTION_NUM"/>
        <bm:field name="transaction_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TRANSACTION_CATEGORY" prompt="CSH511.CSH_TRANSACTION.TRANSACTION_CATEGORY"/>
        <bm:field name="transaction_type" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="CSH511_TRANSACTION_TYPE" lookupField="transaction_type_desc" physicalName="TRANSACTION_TYPE" prompt="CSH511.CSH_TRANSACTION.TRANSACTION_TYPE"/>
        <bm:field name="transaction_date" databaseType="DATE" datatype="java.util.Date" physicalName="TRANSACTION_DATE" prompt="CSH511.CSH_TRANSACTION.TRANSACTION_DATE"/>
        <bm:field name="penalty_calc_date" databaseType="DATE" datatype="java.util.Date" physicalName="PENALTY_CALC_DATE" prompt="CSH511.CSH_TRANSACTION.PENALTY_CALC_DATE"/>
        <bm:field name="bank_slip_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_SLIP_NUM" prompt="CSH511.CSH_TRANSACTION.BANK_SLIP_NUM"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="CSH511.CSH_TRANSACTION.COMPANY_ID"/>
        <bm:field name="internal_period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INTERNAL_PERIOD_NUM" prompt="CSH511.CSH_TRANSACTION.INTERNAL_PERIOD_NUM"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" prompt="HLS.ACCOUNT_PERIOD_NAME"/>
        <bm:field name="payment_method_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PAYMENT_METHOD_ID" prompt="HLS.PAYMENT_METHOD"/>
        <bm:field name="distribution_set_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DISTRIBUTION_SET_ID" prompt="CSH511.CSH_TRANSACTION.DISTRIBUTION_SET_ID"/>
        <bm:field name="cashflow_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="CASHFLOW_AMOUNT" prompt="CSH511.CSH_TRANSACTION.CASHFLOW_AMOUNT"/>
        <bm:field name="currency_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_CODE" prompt="HLS.CURRENCY"/>
        <bm:field name="transaction_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TRANSACTION_AMOUNT" prompt="CSH511.CSH_TRANSACTION.TRANSACTION_AMOUNT"/>
        <bm:field name="exchange_rate_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_TYPE" prompt="HLS.EXCHANGE_RATE_TYPE_DESC"/>
        <bm:field name="exchange_rate_quotation" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXCHANGE_RATE_QUOTATION" prompt="CSH511.CSH_TRANSACTION.EXCHANGE_RATE_QUOTATION"/>
        <bm:field name="exchange_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="EXCHANGE_RATE" prompt="HLS.EXCHANGE_RATE"/>
        <bm:field name="bank_account_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BANK_ACCOUNT_ID" prompt="CSH511.CSH_TRANSACTION.BANK_ACCOUNT_ID"/>
        <bm:field name="bp_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CATEGORY" prompt="CSH511.CSH_TRANSACTION.BP_CATEGORY"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID" prompt="CSH511.CSH_TRANSACTION.BP_ID"/>
        <bm:field name="bp_bank_account_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_BANK_ACCOUNT_ID" prompt="CSH511.CSH_TRANSACTION.BP_BANK_ACCOUNT_ID"/>
        <bm:field name="bp_bank_account_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_BANK_ACCOUNT_NUM" prompt="CSH511.BANK_ACCOUNT_NUM"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="HLS.NOTE"/>
        <bm:field name="handling_charge" databaseType="NUMBER" datatype="java.lang.Double" physicalName="HANDLING_CHARGE" prompt="CSH511.CSH_TRANSACTION.HANDLING_CHARGE"/>
        <bm:field name="posted_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POSTED_FLAG" prompt="CSH511.CSH_TRANSACTION.POSTED_FLAG"/>
        <bm:field name="reversed_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REVERSED_FLAG" prompt="CSH511.CSH_TRANSACTION.REVERSED_FLAG"/>
        <bm:field name="reversed_date" databaseType="DATE" datatype="java.util.Date" physicalName="REVERSED_DATE" prompt="CSH511.CSH_TRANSACTION.REVERSED_DATE"/>
        <bm:field name="returned_flag" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="CSH510_RETURN_SELECT" lookupField="returned_flag_desc" physicalName="RETURNED_FLAG" prompt="CSH511.CSH_TRANSACTION.RETURNED_FLAG"/>
        <bm:field name="returned_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RETURNED_AMOUNT" prompt="CSH511.CSH_TRANSACTION.RETURNED_AMOUNT"/>
        <bm:field name="write_off_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WRITE_OFF_FLAG" prompt="CSH511.CSH_TRANSACTION.WRITE_OFF_FLAG"/>
        <bm:field name="write_off_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_AMOUNT" prompt="CSH511.CSH_TRANSACTION.WRITE_OFF_AMOUNT"/>
        <bm:field name="full_write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="FULL_WRITE_OFF_DATE" prompt="CSH511.CSH_TRANSACTION.FULL_WRITE_OFF_DATE"/>
        <bm:field name="twin_csh_trx_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TWIN_CSH_TRX_ID" prompt="CSH511.CSH_TRANSACTION.TWIN_CSH_TRX_ID"/>
        <bm:field name="return_from_csh_trx_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RETURN_FROM_CSH_TRX_ID" prompt="CSH511.CSH_TRANSACTION.RETURN_FROM_CSH_TRX_ID"/>
        <bm:field name="reversed_csh_trx_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REVERSED_CSH_TRX_ID" prompt="CSH511.CSH_TRANSACTION.REVERSED_CSH_TRX_ID"/>
        <bm:field name="source_csh_trx_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_CSH_TRX_TYPE" prompt="CSH511.CSH_TRANSACTION.SOURCE_CSH_TRX_TYPE"/>
        <bm:field name="source_csh_trx_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SOURCE_CSH_TRX_ID" prompt="CSH511.CSH_TRANSACTION.SOURCE_CSH_TRX_ID"/>
        <bm:field name="source_doc_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_DOC_CATEGORY"/>
        <bm:field name="source_doc_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_DOC_TYPE" prompt="CSH511.CSH_TRANSACTION.SOURCE_DOC_TYPE"/>
        <bm:field name="source_doc_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SOURCE_DOC_ID" prompt="CSH511.CSH_TRANSACTION.SOURCE_DOC_ID"/>
        <bm:field name="source_doc_line_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SOURCE_DOC_LINE_ID" prompt="CSH511.CSH_TRANSACTION.SOURCE_DOC_LINE_ID"/>
        <bm:field name="create_je_mothed" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREATE_JE_MOTHED"/>
        <bm:field name="create_je_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREATE_JE_FLAG"/>
        <bm:field name="gld_interface_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="GLD_INTERFACE_FLAG" prompt="CSH511.CSH_TRANSACTION.GLD_INTERFACE_FLAG"/>
        <bm:field name="bp_code" expression="(select d.bp_code from hls_bp_master_v d where d.bp_id=t1.bp_id)" forInsert="false" forUpdate="false" prompt="HLS.BP_CODE"/>
        <bm:field name="bp_name" expression="(select d.bp_name
  from hls_bp_master_v d
 where d.bp_id = (case
  when ( SELECT c.division
    FROM con_contract c
   WHERE c.contract_id =  t1.ref_contract_id) = '70' then
    (SELECT cc.bp_id_agent_level1
      FROM con_contract cc
     WHERE cc.contract_id =  t1.ref_contract_id) else  t1.bp_id end))" forInsert="false" forUpdate="false" prompt="HLS.BP_NAME"/>
        <bm:field name="unit_id" expression="(select d.unit_id from hls_bp_master d where d.bp_id=t1.bp_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="payment_method_display" expression="(select cp.description from csh_payment_method cp where cp.payment_method_id=t1.payment_method_id)" forInsert="false" forUpdate="false" prompt="HLS.PAYMENT_METHOD"/>
        <bm:field name="currency_name" expression="(select gc.currency_name from gld_currency_vl gc where gc.currency_code=t1.currency_code)" forInsert="false" forUpdate="false" prompt="HLS.CURRENCY"/>
        <bm:field name="bp_category_display" expression="(select b.description from hls_bp_category b where b.bp_category=t1.bp_category)" forInsert="false" forUpdate="false" prompt="CSH511.CSH_TRANSACTION.BP_CATEGORY"/>
        <bm:field name="exchange_rate_type_display" expression="(select tv.type_name from gld_exchangerate_types_vl tv where tv.type_code=t1.exchange_rate_type)" forInsert="false" forUpdate="false" prompt="HLS.EXCHANGE_RATE_TYPE_DESC"/>
        <bm:field name="transaction_functional_amount" expression="gld_exchange_rate_pkg.get_currency_exchange(t1.transaction_amount,t1.exchange_rate,t1.exchange_rate_quotation)" forInsert="false" forUpdate="false" prompt="HLS.FUNCTIONAL_AMOUNT"/>
        <bm:field name="bank_account_code" expression="(select a.bank_account_code from csh_bank_account a where a.bank_account_id=t1.bank_account_id)" forInsert="false" forUpdate="false" prompt="CSH511.BANK_ACCOUNT_CODE"/>
        <bm:field name="bank_account_name" expression="(select a.bank_account_name from csh_bank_account a where a.bank_account_id=t1.bank_account_id)" forInsert="false" forUpdate="false" prompt="CSH511.BANK_ACCOUNT_NAME"/>
        <bm:field name="bank_account_num" expression="(select a.bank_account_num from csh_bank_account a where a.bank_account_id=t1.bank_account_id)" forInsert="false" forUpdate="false" prompt="CSH511.BANK_ACCOUNT_NUM"/>
        <bm:field name="bp_bank_account_code" expression="(select a.bank_account_code  from hls_bp_master_bank_account a  where a.bank_account_id = t1.bp_bank_account_id)" forInsert="false" forUpdate="false" prompt="CSH511.BP_BANK_ACCOUNT_CODE"/>
        <!--<bm:field name="bp_bank_account_name" expression="(select a.bank_account_name   from hls_bp_master_bank_account a  where a.bank_account_id = t1.bp_bank_account_id)" forInsert="false" forUpdate="false" prompt="CSH511.BANK_ACCOUNT_NAME"/>-->
        <bm:field name="bp_bank_account_name"  prompt="CSH511.BANK_ACCOUNT_NAME"/>
        <bm:field name="functional_currency_code" expression="(select gb.functional_currency_code   from fnd_companies fc, gld_set_of_books gb  where fc.company_id = ${/session/@company_id}    and fc.set_of_books_id = gb.set_of_books_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="rate_method_code" expression="(select t.rate_method_code from gld_exchangerate_types t where t.type_code=t1.exchange_rate_type)" forInsert="false" forUpdate="false"/>
        <bm:field name="zero_amounts_allowed" expression="(select d.zero_amounts_allowed from csh_bank_account_v d where d.bank_account_id=t1.bank_account_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="transaction_type_desc" forInsert="false" forUpdate="false" prompt="HLS.TRANSACTION_TYPE"/>
                <!--        <bm:field name="unwrite_off_amount" expression="(nvl(t1.transaction_amount,0)-nvl(t1.write_off_amount,0)-nvl(t1.returned_amount,0))" forInsert="false" forUpdate="false" prompt="HLS.UNWRITEOFF_AMOUNT"/>-->
        <bm:field name="unwrite_off_amount" expression="(t1.transaction_amount-nvl((select sum(cw.write_off_due_amount) from csh_write_off cw where cw.csh_transaction_id=t1.transaction_id and cw.reversed_flag='N' and cw.write_off_date &lt;=nvl(to_date(${@write_off_date_to},&apos;yyyy-mm-dd&apos;),sysdate) ),0))" forInsert="false" forUpdate="false" prompt="HLS.UNWRITEOFF_AMOUNT"/>
		<bm:field name="precision" expression="(select g.precision from gld_currency g where g.currency_code =t1.currency_code)" forInsert="false" forUpdate="false"/>
        <bm:field name="reverse_amount" expression="(-1*t1.transaction_amount)" forInsert="false" forUpdate="false" prompt="CSH511.REVERSE_AMOUNT"/>
        <bm:field name="user_desc" expression="(select su.description from sys_user su where su.user_id=t1.created_by)" forInsert="false" forUpdate="false"/>
        <bm:field name="auto_filt_penalty" expression="&apos;N&apos;" forInsert="false" forUpdate="false" prompt="CSH513.AUTO_FILT_PENALTY"/>
        <bm:field name="auto_filt_prinicipal_interest" expression="&apos;Y&apos;" forInsert="false" forUpdate="false" prompt="CSH513.AUTO_FILT_PRINICIPAL_INTEREST"/>
        <bm:field name="returned_flag_desc" forInsert="false" forUpdate="false" prompt="CSH511.CSH_TRANSACTION.RETURNED_FLAG"/>
        <bm:field name="receipt_type"/>
        <bm:field name="receipt_type_des" expression="(select v.code_value_name from sys_code_values_v v where v.code=&apos;RECEIPT_TYPE&apos; and v.code_value=t1.receipt_type)"/>
        <bm:field name="ref_contract_id"/>
        <bm:field name="contract_number" expression="(select cc.contract_number from con_contract cc where cc.contract_id = t1.ref_contract_id)"/>
        <bm:field name="collection_classes"/>
        <bm:field name="collection_classes_desc" expression="(select v.code_value_name from sys_code_values_v v where v.code = 'DS_COLLECTION_CLASSES' and v.code_value =t1.collection_classes)" forInsert="false" forUpdate="false"/>
        <bm:field name="confirmed_flag_desc" expression="(select v.code_value_name from sys_code_values_v v where v.code = 'CONFIRMED_FLAG' and v.code_value =t1.confirmed_flag)" forInsert="false" forUpdate="false"/>
        <bm:field name="written_off_flag_desc" expression="(select v.code_value_name from sys_code_values_v v where v.code = 'WRITE_OFF_FLAG' and v.code_value =t1.WRITE_OFF_FLAG)" forInsert="false" forUpdate="false"/>
        <bm:field name="bank_branch_name" expression="(select bank_branch_name from csh_bank_branch where bank_branch_id = (select bank_branch_id from csh_bank_account where bank_account_id = t1.bank_account_id))" forInsert="false" forUpdate="false"/>
        <bm:field name="use_money_amount" expression="(select t1.transaction_amount-t1.returned_amount from dual)" forInsert="false" forUpdate="false"/>
        <bm:field name="opposite_band_na"/>
        <bm:field name="banka"/>
        <bm:field name="purpose"/>
        <bm:field name="gsber"/>
        <bm:field name="sus_belnr"/>
        <bm:field name="bp_virtual_bank_account"/>
        <bm:field name="confirmed_flag" />
        <bm:field name="debt_confirmed_by"/>
        <bm:field name="debt_confirmed_by_desc" expression="(select description from sys_user where user_id=t1.debt_confirmed_by)" forInsert="false" forUpdate="false"/>
        <bm:field name="acc_confirmed_by"/>
        <bm:field name="acc_confirmed_by_desc" expression="(select description from sys_user where user_id=t1.acc_confirmed_by)" forInsert="false" forUpdate="false"/>
        <bm:field name="receipt_type_n" expression="(select v.code_value_name from sys_code_values_v v where v.code = 'RECEIPT_TYPE' and v.code_value =t1.receipt_type)" forInsert="false" forUpdate="false"/>
        <bm:field name="deposit_trans_type" expression="decode(t1.ref_contract_id,
              null,
              decode(t1.collection_classes,
                     'OPERAT_DEPOSIT',
                     'vender_deposit',
                     t1.deposit_trans_type),
              t1.deposit_trans_type)" forInsert="false" forUpdate="false" />
        <bm:field name="deposit_trans_type_desc" expression="decode(t1.ref_contract_id,
              null,
              decode(t1.collection_classes,
                     'OPERAT_DEPOSIT',
                     (select v.code_value_name value_name
                        from sys_code_values_v v
                       where v.code = 'DEPOSIT_TRANS_TYPE'
                         and v.code_value = 'vender_deposit'),
                     (select v.code_value_name
                        from sys_code_values_v v
                       where v.code = 'DEPOSIT_TRANS_TYPE'
                         and v.code_value = t1.deposit_trans_type)),
              (select v.code_value_name
                 from sys_code_values_v v
                where v.code = 'DEPOSIT_TRANS_TYPE'
                  and v.code_value = t1.deposit_trans_type))" forInsert="false" forUpdate="false"/>
		<bm:field name="bp_id_telnet_n" expression="(select hb.bp_name from hls_bp_master hb,con_contract ct where ct.contract_id=t1.ref_contract_id and hb.bp_id=ct.bp_id_tenant)" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_name_n" expression="(select hb.bp_name from hls_bp_master hb,con_contract ct where ct.contract_id=t1.ref_contract_id and hb.bp_id=ct.bp_id_agent_level1)" forInsert="false" forUpdate="false"/>
        <bm:field name="source_type"/>
        <bm:field name="approve_status" expression=" nvl(( hlcm_cux_deposit_pkg.get_transaction_status_new(p_transaction_id=>t1.transaction_id,p_user_id=>1) ),'正常')" forInsert="false" forUpdate="false"/>
        <bm:field name="vender_contract_number" expression="(select cc.search_term_1 vender_contract_number from con_contract cc where cc.contract_id = t1.ref_contract_id)"/>
        <bm:field name="vender_project_number" expression="(select p.project_number vender_project_number from prj_project_lease_item pi, prj_project p, con_contract_lease_item ci where pi.source_project_id = p.project_id and pi.project_lease_item_id = ci.project_lease_item_id and ci.contract_id=t1.ref_contract_id)"/>
        <bm:field name="business_type" expression=" decode(t1.ref_contract_id,
              null,
              decode(t1.collection_classes,
                     'OPERAT_DEPOSIT',
                     'LEASEOPERAT',
                     (select cc.business_type
                        from con_contract cc
                       where cc.contract_id = t1.ref_contract_id)),
              (select cc.business_type
                 from con_contract cc
                where cc.contract_id = t1.ref_contract_id))"/>
        <bm:field name="business_type_desc" expression="decode(t1.ref_contract_id,
              null,
              decode(t1.collection_classes,
                     'OPERAT_DEPOSIT',
                     (select ht.description
                        from hls_business_type ht
                       where ht.business_type = 'LEASEOPERAT'),
                     (select hb.description
                        from con_contract cc, hls_business_type_v hb
                       where cc.business_type = hb.business_type
                         and hb.enabled_flag = 'Y'
                         and cc.contract_id = t1.ref_contract_id)),
              (select hb.description
                 from con_contract cc, hls_business_type_v hb
                where cc.business_type = hb.business_type
                  and hb.enabled_flag = 'Y'
                  and cc.contract_id = t1.ref_contract_id))"/>
		</bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="transaction_id"/>
    </bm:primary-key>
    <bm:data-filters>
        <bm:data-filter name="query" expression="(t1.company_id=${/session/@company_id})"/>
        <bm:data-filter name="query" expression="(t1.transaction_num not in('R23120500038'))"/>
        <bm:data-filter name="query" expression="(SELECT cc.contract_number FROM con_contract cc WHERE cc.contract_id = t1.ref_contract_id) not in('XND24010001')"/>

        <!--<bm:data-filter name="query" expression="((nvl(t1.transaction_amount,0)-nvl(t1.write_off_amount,0)-nvl(t1.returned_amount,0)) >0)"/>-->
<!--        <bm:data-filter name="query" expression="(t1.ref_contract_id is not null)"/>-->
        <bm:data-filter name="query" expression="(t1.transaction_type ='DEPOSIT')"/>
<!--        <bm:data-filter name="query" expression="(t1.source_type is not null)"/>-->
        <bm:data-filter name="query" expression="((t1.ref_contract_id is not null and t1.source_type is not null) or
          exists (select hm.bp_id
          from hls_bp_master hm
         where hm.bp_code in('D00010020','D00010023')
           and hm.bp_id = t1.bp_id
           and t1.collection_classes = 'DEPOSIT'
           and t1.paid_byother_flag = 'F') or
           (t1.ref_contract_id is null and nvl(t1.reversed_flag, 'N') = 'N' and
           t1.confirmed_flag not in ('ACCAUDITING', 'NEW', 'CT_REJECTED','ACCAUDITED_RECOI')))"/>
		<bm:data-filter name="query" expression="(t1.returned_flag &lt;&gt; 'RETURN')"/>
        <bm:data-filter name="query" expression="(exists (
                (select 1
                from exp_emp_assign_e_v ee
               where ee.user_id = ${/session/@user_id}
                  and ee.unit_id not in (1565,1552,1564,1551,1559,1547,1560,1545,1546,1568,1566,1570,1550,1569,1555,1571,1558)
                  and ee.unit_id=(SELECT h.unit_id FROM hls_bp_master h WHERE h.bp_id=t1.bp_id)
                  and ${/session/@role_id} in (select v.role_id from sys_role_vl v where v.role_code in ('0018','0019')) ) )
                  or (${/session/@role_id} not in (select v.role_id from sys_role_vl v where v.role_code in ('0018','0019')) ))"/>
        <bm:data-filter name="query" expression="( (decode(${/session/@user_id}, 10600, 1, 2) = 1
                                                   and exists (select 1 from hls_bp_master hb where hb.bp_id = t1.bp_id
                                                   and hb.bp_code in  ('D00000028','D00000035','D00000016','D00000021','D00000039','D00000025','D00000034','D00000017','D00000018','D00000024','D00000032','D00000009','D00000012','D00000014','D00000015','D00000023')) )
                                                   or (decode(${/session/@user_id}, 10600, 1, 2) = 2) )"/>
    </bm:data-filters>
    <bm:query-fields>
	    <bm:query-field name="query_amount_flag" queryExpression="((${@query_amount_flag}='1' and ((t1.transaction_amount-nvl((select sum(cw.write_off_due_amount) from csh_write_off cw where cw.csh_transaction_id=t1.transaction_id and cw.reversed_flag='N' and cw.write_off_date &lt;=nvl(to_date(${@write_off_date_to},&apos;yyyy-mm-dd&apos;),sysdate) ),0))>0) )or(${@query_amount_flag}='2' and ( (t1.transaction_amount-nvl((select sum(cw.write_off_due_amount) from csh_write_off cw where cw.csh_transaction_id=t1.transaction_id and cw.reversed_flag='N' and cw.write_off_date &lt;=nvl(to_date(${@write_off_date_to},&apos;yyyy-mm-dd&apos;),sysdate) ),0))=0) )or (${@query_amount_flag}='3' and ( (t1.transaction_amount-nvl((select sum(cw.write_off_due_amount) from csh_write_off cw where cw.csh_transaction_id=t1.transaction_id and cw.reversed_flag='N' and cw.write_off_date &lt;=nvl(to_date(${@write_off_date_to},&apos;yyyy-mm-dd&apos;),sysdate) ),0))>=0)))"/>
        <bm:query-field field="confirmed_flag" queryExpression="t1.confirmed_flag =${@confirmed_flag}"/>
        <bm:query-field field="write_off_flag" queryExpression="t1.write_off_flag =${@write_off_flag}"/>
        <bm:query-field field="bp_bank_account_name" queryOperator="like"/>
        <bm:query-field field="receipt_type" queryOperator="="/>
        <bm:query-field field="opposite_band_na" queryOperator="like"/>
        <bm:query-field name="transaction_num_from" queryExpression="t1.transaction_num &gt;= ${@transaction_num_from}"/>
        <bm:query-field name="transaction_num_to" queryExpression="t1.transaction_num &lt;= ${@transaction_num_to}"/>
        <bm:query-field name="bank_slip_num" queryExpression="t1.bank_slip_num like &apos;%&apos;||${@bank_slip_num}||&apos;%&apos;"/>
      <!--  <bm:query-field name="bank_slip_num_to" queryExpression="t1.bank_slip_num &lt;= ${@bank_slip_num_to}"/>-->
        <bm:query-field name="transaction_amount_from" queryExpression="t1.transaction_amount &gt;= ${@transaction_amount_from}"/>
        <bm:query-field name="transaction_amount_to" queryExpression="t1.transaction_amount &lt;= ${@transaction_amount_to}"/>
        <bm:query-field name="currency_code_from" queryExpression="t1.currency_code &gt;= ${@currency_code_from}"/>
        <bm:query-field name="currency_code_to" queryExpression="t1.currency_code &lt;= ${@currency_code_to}"/>
        <bm:query-field name="bank_account_code" queryExpression="exists (select a.bank_account_code from csh_bank_account a where a.bank_account_id=t1.bank_account_id and a.bank_account_code = ${@bank_account_code})"/>
        <bm:query-field name="bank_account_code_from" queryExpression="(select a.bank_account_code from csh_bank_account a where a.bank_account_id=t1.bank_account_id) &gt;= ${@bank_account_code_from}"/>
        <bm:query-field name="bank_account_code_to" queryExpression="(select a.bank_account_code from csh_bank_account a where a.bank_account_id=t1.bank_account_id) &lt;= ${@bank_account_code_to}"/>
        <bm:query-field name="transaction_date_from" queryExpression="transaction_date &gt;= to_date(${@transaction_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="transaction_date_to" queryExpression="transaction_date &lt;= to_date(${@transaction_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="user_id" queryExpression="t1.created_by=${@user_id}"/>
        <bm:query-field name="receipt" queryExpression="(t1.transaction_type=${@receipt} or t1.transaction_type=${@advance_receipt})"/>
        <bm:query-field name="full_write_off_flag" queryExpression="t1.write_off_flag!=${@full_write_off_flag}"/>
        <bm:query-field name="full_returned_flag" queryExpression="t1.returned_flag!=${@full_returned_flag}"/>
        <bm:query-field name="not_write_off_flag" queryExpression="t1.write_off_flag!=${@not_write_off_flag}"/>
        <bm:query-field name="not_reversed_flag_r" queryExpression="t1.reversed_flag!=${@not_reversed_flag_r}"/>
        <bm:query-field name="bp_id_from" queryExpression="t1.bp_id&gt;=${@bp_id_from}"/>
        <bm:query-field name="bp_id_to" queryExpression="t1.bp_id&lt;=${@bp_id_to}"/>
        <bm:query-field field="write_off_flag" queryOperator="="/>
        <bm:query-field field="posted_flag" queryOperator="="/>
        <bm:query-field field="returned_flag" queryOperator="="/>
        <bm:query-field field="reversed_flag" queryOperator="="/>
        <bm:query-field field="period_name" queryOperator="="/>
        <bm:query-field field="payment_method_id" queryOperator="="/>
        <bm:query-field field="transaction_category" queryOperator="="/>
        <bm:query-field field="transaction_type" queryOperator="="/>
        <bm:query-field field="transaction_id" queryOperator="="/>
        <bm:query-field field="collection_classes" queryOperator="="/>
        <bm:query-field field="bp_bank_account_num" queryOperator="like"/>
        <bm:query-field name="bp_id_from" queryExpression="t1.bp_id &gt;= ${@bp_id_from}"/>
        <bm:query-field name="bp_id_to" queryExpression="t1.bp_id &lt;= ${@bp_id_to}"/>
        <bm:query-field name="reverse_write_off_amount_flag" queryExpression="t1.write_off_amount &gt; 0 and ${@reverse_write_off_amount_flag}=&apos;Y&apos;"/>
        <bm:query-field field="bp_id" queryOperator="="/>
        <bm:query-field name="description" queryExpression="t1.description like &apos;%&apos;||${@description}||&apos;%&apos;"/>
        <bm:query-field name="bank_account_num" queryExpression="(select a.bank_account_num from csh_bank_account a where a.bank_account_id=t1.bank_account_id) like  &apos;%&apos;||upper(${@bank_account_num})||&apos;%&apos;"/>
        <!--<bm:query-field name="contract_number" queryExpression="(SELECT cc.contract_number FROM con_contract cc WHERE cc.contract_id = t1.ref_contract_id) like  &apos;%&apos;||upper(${@contract_number})||&apos;%&apos;"/>-->
        <bm:query-field name="bp_id_telnet_n" queryExpression="(select hb.bp_name from hls_bp_master hb,con_contract ct where ct.contract_id=t1.ref_contract_id and hb.bp_id=ct.bp_id_tenant) like &apos;%&apos;||${@bp_id_telnet_n}||&apos;%&apos; "/>
        <bm:query-field name="contract_number" queryExpression="(SELECT cc.contract_number FROM con_contract cc WHERE cc.contract_id = t1.ref_contract_id) like  &apos;%&apos;||${@contract_number}||&apos;%&apos;"/>
        <bm:query-field name="bp_name_n" queryExpression="(select d.bp_name from hls_bp_master_v d where d.bp_id=t1.bp_id) like &apos;%&apos;||${@bp_name_n}||&apos;%&apos; "/>
        <bm:query-field name="deposit_trans_type" queryExpression="t1.deposit_trans_type=${@deposit_trans_type}"/>
		<bm:query-field name="vender_contract_number" queryExpression="(SELECT cc.search_term_1 FROM con_contract cc WHERE cc.contract_id = t1.ref_contract_id) like  &apos;%&apos;||${@vender_contract_number}||&apos;%&apos;"/>
        <bm:query-field name="vender_project_number" queryExpression="(select p.project_number  from prj_project_lease_item pi, prj_project p, con_contract_lease_item ci where pi.source_project_id = p.project_id and pi.project_lease_item_id = ci.project_lease_item_id and ci.contract_id=t1.ref_contract_id) like  &apos;%&apos;||${@vender_project_number}||&apos;%&apos;"/>
        <bm:query-field name="business_type" queryExpression="(SELECT cc.business_type FROM con_contract cc WHERE cc.contract_id = t1.ref_contract_id) like  &apos;%&apos;||${@business_type}||&apos;%&apos;"/>
   </bm:query-fields>
</bm:model>
