<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-7-16 上午09:06:33  
    $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 t1.invoice_hd_id,
				       t1.document_number,
				       to_char(t1.invoice_date, 'yyyy-mm-dd') as invoice_date,
				       t1.document_category,
				       t1.contract_id,
				       t1.contract_number,
				       t1.contract_name,
				       t1.project_id,
				       t1.project_number,
				       t1.project_name,
				       t1.invoice_bp_id,
				       t1.invoice_bp_code,
				       t1.invoice_bp_name,
				       t1.invoice_title,
				       t1.invoice_number,
				       t1.invoice_status,
				       t1.invoice_status_desc,
				       t1.currency,
				       t1.business_type,
				       t1.business_type_desc,
				       t1.invoice_kind,
				       t1.invoice_kind_desc,
				       t1.document_type,
				       t1.created_by_name,
				       t1.created_by,
				       to_char(t1.accounting_date, 'yyyy-mm-dd') as accounting_date,
				       t1.total_amount,
				       t1.tax_amount,
				       t1.billing_method,
				       t1.lease_organization,
				       t1.lease_channel,
				       t1.division,
				       t1.company_id,
				       t1.invoice_code
				  FROM acp_invoice_hd_v t1
                #WHERE_CLAUSE#
                ORDER BY t1.invoice_date desc , t1.document_number desc
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
				begin
					 ACP_INVOICE_PKG.delete_invoice(p_invoice_hd_id 	=> ${@invoice_hd_id},
					 								p_user_id 			=> ${/session/@user_id});
				end;
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="nvl(t1.reversed_flag,&apos;N&apos;) = &apos;N&apos;"/>
        <bm:data-filter enforceOperations="query" expression="t1.company_id = ${/session/@company_id}"/>
        <bm:data-filter enforceOperations="query" expression="exists (select 1 from acp_invoice_ln where cashflow_id = ${@cashflow_id} and invoice_header_id = t1.invoice_hd_id)"/>
    </bm:data-filters>
</bm:model>
