<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2014-2-24 下午3:38:29  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="ACR_INVOICE_BILL_V">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="ACR_INVOICE_BILL_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="HLS.CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME" prompt="HLS.CONTRACT_NAME"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER" prompt="HLS.PROJECT_NUMBER"/>
        <bm:field name="project_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NAME" prompt="HLS.PROJECT_NAME"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CODE" prompt="HLS.BP_CODE"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME" prompt="HLS.BP_NAME"/>
        <bm:field name="taxpayer_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAXPAYER_TYPE"/>
        <bm:field name="taxpayer_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAXPAYER_TYPE_DESC" prompt="纳税人类型"/>
        <bm:field name="vat_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VAT_FLAG" prompt="ACR_INVOICE_BILL_V.VAT_FLAG"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE" prompt="ACR_INVOICE_BILL_V.BUSINESS_TYPE"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TIMES" prompt="HLS.TIMES"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date" physicalName="DUE_DATE" prompt="应收日期"/>
        <bm:field name="full_write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="FULL_WRITE_OFF_DATE" prompt="核销日期"/>
        <bm:field name="cf_type" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_TYPE" prompt="ACR_INVOICE_BILL_V.CF_TYPE"/>
        <bm:field name="cf_type_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_TYPE_DESC" prompt="ACR_INVOICE_BILL_V.CF_TYPE_DESC"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM" prompt="HLS.CF_ITEM"/>
        <bm:field name="cf_item_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_ITEM_DESC" prompt="HLS.CF_ITEM_DESC"/>
        <bm:field name="invoice_kind" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_KIND" prompt="ACR.INVOICE_KIND"/>
        <bm:field name="invoice_kind_desc" prompt="ACR.INVOICE_KIND_DESC"/>
        <bm:field name="due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DUE_AMOUNT" prompt="应开票金额"/>
        <bm:field name="billing_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="BILLING_AMOUNT" prompt="已开票金额"/>
        <bm:field name="not_billing_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NOT_BILLING_AMOUNT" prompt="未开票金额"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT t1.contract_id,
				       t1.contract_number,
				       t1.contract_name,
				       t1.project_number,
				       t1.project_name,
				       t1.bp_code,
				       t1.bp_name,
				       t1.taxpayer_type,
				       t1.taxpayer_type_desc,
				       t1.vat_flag,
				       t1.business_type,
				       t1.times,
				       t1.due_date,
				       t1.full_write_off_date,
				       t1.cf_type,
				       t1.cf_type_desc,
				       t1.cf_item,
				       t1.cf_item_desc,
				       t1.invoice_kind,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'ACR510_INVOICE_KIND'
				           and v.code_value = t1.invoice_kind) as invoice_kind_desc,
				       t1.due_amount,
				       t1.billing_amount,
				       t1.not_billing_amount,
				       t1.cf_direction
				  FROM ACR_INVOICE_BILL_V t1
				  #WHERE_CLAUSE#
				 order by t1.contract_id, t1.times, t1.due_date
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.contract_status != &apos;NEW&apos; and t1.cf_direction=&apos;INFLOW&apos;"/>
        <bm:data-filter enforceOperations="query" expression="t1.cf_status = &apos;RELEASE&apos;"/>
        <bm:data-filter enforceOperations="query" expression="t1.billing_status != &apos;FULL&apos;"/>
        <bm:data-filter enforceOperations="query" expression="((t1.cf_type = 109) OR (t1.cf_type = 9 AND t1.write_off_flag != &apos;NOT&apos;) OR (t1.write_off_flag = &apos;FULL&apos; AND t1.cf_direction = &apos;INFLOW&apos;))"/>
        <bm:data-filter enforceOperations="query" expression="t1.due_amount&gt;0"/>
        <bm:data-filter enforceOperations="query" expression="t1.not_billing_amount&gt;0 and t1.invoice_kind!=&apos;RECEIPT&apos;"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field field="contract_number" queryOperator="like"/>
        <bm:query-field field="invoice_kind" queryOperator="="/>
        <bm:query-field field="cf_type" queryOperator="="/>
        <bm:query-field name="due_date_from" queryExpression="t1.due_date &gt;= trunc(to_date(${@due_date_from},&apos;yyyy-mm-dd&apos;)) "/>
        <bm:query-field name="due_date_to" queryExpression="t1.due_date &lt;= trunc(to_date(${@due_date_to},&apos;yyyy-mm-dd&apos;))+1 "/>
        <bm:query-field field="project_number" queryOperator="like"/>
        <bm:query-field name="contract_name" queryExpression="t1.contract_name like &apos;%&apos; || ${@contract_name} || &apos;%&apos; "/>
        <bm:query-field name="bp_name" queryExpression="t1.bp_name like &apos;%&apos; || ${@bp_name} || &apos;%&apos; "/>
    </bm:query-fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
</bm:model>
