<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Administrator  
    $Date: 2016-8-4 下午3:38:54  
    $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
                    BP.bp_name,
                    BP.tax_registry_num,
                    bp.invoice_bp_address_phone_num,
                    bp.invoice_phone_number,
                    bp.invoice_bank,
                    bp.invoice_bp_bank_account,
                    (SELECT fc.company_full_name FROM fnd_companies fc WHERE fc.company_id=${/session/@company_id}
                    ) company_full_name,
                    (SELECT fc.tax_registry_num FROM fnd_companies fc WHERE fc.company_id=${/session/@company_id}
                    ) hn_tax_registry_num,
                    (SELECT
                        fc.invoice_bp_address_phone_num
                    FROM
                        fnd_companies fc
                    WHERE
                        fc.company_id=${/session/@company_id}
                    ) hn_invoice_bp_address,
                    (SELECT
                        fc.invoice_bp_bank_account
                    FROM
                        fnd_companies fc
                    WHERE
                        fc.company_id=${/session/@company_id}
                    ) hn_invoice_bp_bank,
                    to_char(NVL(
                    (SELECT
                        SUM(sai1.due_amount)
                    FROM
                        sdic_acr_invoice sai1
                    WHERE
                        sai1.invoice_id in(${:@invoice_id_str})
                    ),0),'FM999,999,999,999,990.00') sum_due_amout,
                    change_number_to_rmb(NVL(
                    (SELECT
                        SUM(sai1.due_amount)
                    FROM
                        sdic_acr_invoice sai1
                    WHERE
                        sai1.invoice_id in(${:@invoice_id_str})
                    ),0)) sum_due_amout_F,
                    to_char(sysdate,'yyyy')||'  年'||'  '||to_char(sysdate,'mm')||'  月'||'  '||to_char(sysdate,'dd')||'  '||'日' sysdate_f,
                    (select distinct sc.code_value_name from sdic_acr_invoice sai ,sys_code_values_v sc  where sai.INVOICE_ID in(${:@invoice_id_str})
       and sc.code='ACR510_INVOICE_KIND'
       and sc.code_value=sai.invoice_kind)  invoice_kind_desc
                FROM
                    (SELECT DISTINCT
                        sai.bp_id
                    FROM
                        sdic_acr_invoice sai
                    WHERE
                        sai.INVOICE_ID in(${:@invoice_id_str})
                    ) t1,
                    hls_bp_master bp
                WHERE
                    bp.bp_id=t1.bp_id
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
