<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                select t1.* from( SELECT confirmed_by_name,
                   create_je_flag,
                   document_type_desc,
                   vat_interface_status,
                   project_name,
                   company_id,
                   business_type_desc,
                   billing_method,
                   claim_status_n,
                   total_amount,
                   confirmed_date,
                   invoice_bp_code,
                   tax_amount,
                   owner_user_id,
                   receipt_number,
                   contract_number,
                   exchange_rate_quotation,
                   ref_d01,
                   ref_v05,
                   express_company,
                   currency,
                   confirmed_by,
                   contract_name,
                   invoice_code,
                   to_char(accounting_date,'yyyy-mm-dd')accounting_date,
                   ref_d04,
                   invoice_kind,
                   contract_id,
                   project_id,
                   ref_v02,
                   created_by,
                   ref_v08,
                   return_tax_amount,
                   ref_v03,
                   ref_n01,
                   document_number,
                   document_category,
                   reverse_date,
                   express_by,
                   express_note,
                   invoice_bp_id,
                   ref_v07,
                   source_document_number,
                   ref_v04,
                   ref_n10,
                   ref_n04,
                   ref_d02,
                   invoice_number,
                   bp_agent_name,
                   division_desc,
                   vat_invoice_status,
                   invoice_title,
                   posted_by_name,
                   express_status_desc,
                   ref_vat_invoice_code,
                   ref_n09,
                   currency_desc,
                   vat_red_notice_num,
                   last_receipt_print_time,
                   spv_company_id,
                   lease_organization_desc,
                   posted_date,
                   receipt_print_status,
                   ref_n08,
                   posted_by,
                   invoice_status_desc,
                   billing_method_desc,
                   exchange_rate_type_desc,
                   invoice_bp_name,
                   dif_tax_amount,
                   document_type,
                   reversed_flag_desc,
                   lease_channel,
                   bp_address_phone_num,
                   owner_user_name,
                   invoice_kind_desc,
                   ref_v10,
                   ref_v09,
                   express_date,
                   lease_organization,
                   last_updated_by,
                   tax_code,
                   description,
                   express_status,
                   to_char(invoice_date,'yyyy-mm-dd')invoice_date,
                   manual_invoice_flag,
                   exchange_rate_type,
                   document_category_desc,
                   gld_interface_flag,
                   last_update_date,
                   business_type,
                   period_name,
                   source_invoice_header_id,
                   distribution_set_id,
                   ref_invoice_number,
                   internal_period_num,
                   billing_way_desc,
                   net_amount,
                   express_num,
                   tax_msg,
                   ref_n05,
                   ref_n03,
                   billing_way,
                   batch_id,
                   vat_invoice_code,
                   bp_tax_registry_num,
                   created_by_name,
                   ref_v06,
                   ref_n06,
                   invoice_status,
                   ref_d05,
                   project_number,
                   exchange_rate,
                   express_by_name,
                   ref_v01,
                   ref_d03,
                   lease_channel_desc,
                   creation_date,
                   bp_bank_account,
                   division,
                   invoice_hd_id,
                   ref_n07,
                   reversed_flag,
                   claim_status,
                   ref_n02,
                   invoice_apply_num,
                        ACR_INVOICE_WFL_PKG.get_invoice_transaction_flag(t.invoice_hd_id)csh_transaction_flag,
                        decode(ACR_INVOICE_WFL_PKG.get_invoice_transaction_flag(t.invoice_hd_id),'NOT','未收款','PARTIAL','部分收款','FULL','完全收款')csh_transaction_flag_desc

              FROM acr_invoice_hd_v t) t1
                        #WHERE_CLAUSE#
                ORDER BY t1.invoice_date desc , t1.document_number desc
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                 BEGIN
                    acr_invoice_claim_pkg.apply_invoice_confirm(p_invoice_hd_id 	=> ${@invoice_hd_id},
            	    								    p_user_id 			=> ${/session/@user_id});
            	END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="total_amount_f" queryExpression="t1.total_amount &gt;= ${@total_amount_f}"/>
        <bm:query-field name="total_amount_t" queryExpression="t1.total_amount &lt;= ${@total_amount_t}"/>
        <bm:query-field name="invoice_kind_desc" queryExpression="t1.invoice_kind_desc = ${@invoice_kind_desc}"/>
        <bm:query-field name="invoice_status_desc" queryExpression="t1.invoice_status_desc = ${@invoice_status_desc}"/>
        <bm:query-field name="claim_status" queryExpression="t1.claim_status = ${@claim_status}"/>
        <bm:query-field name="claim_status_n" queryExpression="t1.claim_status_n = ${@claim_status_n}"/>
        <bm:query-field name="csh_transaction_flag" queryExpression="t1.csh_transaction_flag = ${@csh_transaction_flag}"/>
        <bm:query-field name="cf_item_desc" queryExpression="t1.cf_item_desc = ${@cf_item_desc}"/>
        <bm:query-field name="document_number" queryExpression="t1.document_number like ${@document_number}"/>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number like ${@contract_number}"/>
        <bm:query-field name="contract_name" queryExpression="t1.contract_name like ${@contract_name}"/>
        <bm:query-field name="invoice_title" queryExpression="t1.invoice_title like ${@invoice_title}"/>
        <bm:query-field name="invoice_apply_num" queryExpression="t1.invoice_apply_num like ${@invoice_apply_num}"/>
        <bm:query-field name="invoice_code" queryExpression="t1.invoice_code like ${@invoice_code}"/>
        <bm:query-field name="vat_invoice_code" queryExpression="t1.vat_invoice_code like ${@vat_invoice_code}"/>
        <bm:query-field name="invoice_number" queryExpression="t1.invoice_number like ${@invoice_number}"/>
        <bm:query-field name="invoice_date_from" queryExpression=" to_date(t1.invoice_date,&apos;yyyy-mm-dd&apos;) &gt;= to_date(${@invoice_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="invoice_date_to" queryExpression="to_date(t1.invoice_date,&apos;yyyy-mm-dd&apos;) &lt;= to_date(${@invoice_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="query_contract_number" queryExpression="exists     (select 1            from hls_document_flow_all_v df, con_contract cc           where df.contract_id = cc.contract_id             and df.ar_invoice_hd_id = t1.invoice_hd_id             and cc.contract_number between nvl(${@contract_number_f}, cc.contract_number) and nvl(${@contract_number_t}, cc.contract_number))"/>
        <bm:query-field name="query_project_number" queryExpression="exists     (select 1           from hls_document_flow_all_v df, prj_project pp          where df.ar_invoice_hd_id = t1.invoice_hd_id            and df.project_id = pp.project_id            and pp.project_number between nvl(${@project_number_f}, pp.project_number) and nvl(${@project_number_t}, pp.project_number))"/>
    </bm:query-fields>
    <bm:data-filters>
<!--        <bm:data-filter enforceOperations="query" expression="t1.contract_id = t2.contract_id"/>-->
<!--        <bm:data-filter enforceOperations="query" expression="t2.write_off_flag = &apos;FULL&apos;"/>-->
        <bm:data-filter enforceOperations="query" expression="t1.vat_interface_status = &apos;BACK&apos;"/>
        <bm:data-filter enforceOperations="query" expression="t1.claim_status not in  (&apos;UNCLAIMED&apos;)"/>
    </bm:data-filters>
</bm:model>
