<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-6-19 下午12:44:44  
    $Revision: 1.0  
    $Purpose: 
-->

<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="contract_id"/>
        <bm:field name="bp_id"/>
        <bm:field name="bp_code" displayWidth="200" forDisplay="true" forQuery="true" prompt="商业伙伴编号"/>
        <bm:field name="bp_name" displayWidth="200" forDisplay="true" forQuery="true" prompt="商业伙伴名称"/>
        <bm:field name="bp_category"/>
        <bm:field name="bp_category_desc" forDisplay="true" prompt="商业伙伴类别"/>
        <bm:field name="taxpayer_type"/>
        <bm:field name="taxpayer_type_desc"/>
        <bm:field name="invoice_title"/>
        <bm:field name="invoice_bp_address_phone_num"/>
        <bm:field name="invoice_bp_bank_account"/>
        <bm:field name="tax_registry_num"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select v.contract_id,
               v.bp_id,
               v.bp_class,
               v.bp_code,
               v.bp_name,
               v.bp_category,
               v.bp_category_desc,
               DECODE(bp_class,
               'NP',
               v.bp_name,
               v.invoice_title) invoice_title,
               v.invoice_bp_address_phone_num,
               v.invoice_bp_bank_account,
       DECODE(v.bp_class,'NP','SMALL_SCALE_TAXPAYER',v.taxpayer_type) As taxpayer_type,
      -- m.taxpayer_type As taxpayer_type,
       (SELECT v.code_value_name
          FROM sys_code_values_v v
         WHERE v.code = 'HLS211_TAXPAYER_TYPE'
           AND v.code_value = DECODE(v.bp_class,'NP','SMALL_SCALE_TAXPAYER',v.taxpayer_type)
           ) AS taxpayer_type_desc,
            v.tax_registry_num
          from acr_invoice_billing_object_v v
				 #WHERE_CLAUSE# 
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="bp_code" queryOperator="like"/>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <bm:query-field field="bp_category_desc" queryOperator="like"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="v.contract_id=${@contract_id}"/>
    </bm:data-filters>
</bm:model>
