<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: qwm  
    $Date: 2013-6-3 下午05:18:31  
    $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 r.return_id,
       r.this_return_amount,
       to_char(r.return_date,'yyyy-mm-dd') transaction_date,
       r.bp_bank_account_num bank_account_num,
       r.bp_bank_account_name bank_branch_name,
       t.bank_slip_num,
        (select u.employee_name
                  from sys_user_v u
                 where u.user_id = r.created_by) user_desc,
       t.transaction_num,
        (SELECT listagg(h.sbo_num,',') within group (order by h.source_id)
          from hls_journal_header h
         WHERE r.return_transaction_id = h.source_id
           and h.source_table = 'CSH_TRANSACTION') sbo_num,
       (SELECT h.sbo_num
          from csh_transaction ct, csh_write_off cw, hls_journal_header h
         WHERE r.transaction_id = ct.transaction_id
           and ct.source_doc_type = cw.write_off_type
           and ct.source_doc_id = cw.write_off_id
           and h.source_table = 'CSH_TRANSACTION'
           and h.source_id = cw.csh_transaction_id
           and exists (select 1
                  from hls_journal_detail d
                 where h.journal_header_id = d.journal_header_id
                   and cw.write_off_id = d.cashflow_id))  receipt_sbo_num
    FROM csh_transaction_return r,
         csh_transaction t
         --hls_bp_master_bank_account v
     WHERE r.transaction_id= ${@return_from_csh_trx_id}
          AND r.status='APPROVED'
          AND t.transaction_id=r.return_transaction_id



                ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
