<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-5-22 下午03:50:12  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="CON_CONTRACT_CASHFLOW_V" defaultOrderBy="t1.due_date,t1.write_off_order,t1.times">
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="CON_CONTRACT_CASHFLOW_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="CON_CONTRACT_CASHFLOW_V.CONTRACT_NUMBER"/>
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS" prompt="CON_CONTRACT_CASHFLOW_V.CONTRACT_STATUS"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY" prompt="HLS.CURRENCY"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY" prompt="CON_CONTRACT_CASHFLOW_V.DOCUMENT_CATEGORY"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" prompt="CON_CONTRACT_CASHFLOW_V.PROJECT_ID"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT" prompt="CON_CONTRACT_CASHFLOW_V.BP_ID_TENANT"/>
        <bm:field name="bp_id_agent_level1" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_AGENT_LEVEL1" prompt="CON_CONTRACT_CASHFLOW_V.BP_ID_AGENT_LEVEL1"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER" prompt="CON_CONTRACT_CASHFLOW_V.PROJECT_NUMBER"/>
        <bm:field name="project_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NAME" prompt="CON_CONTRACT_CASHFLOW_V.PROJECT_NAME"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CODE" prompt="CON_CONTRACT_CASHFLOW_V.BP_CODE"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME" prompt="CON_CONTRACT_CASHFLOW_V.BP_NAME"/>
        <bm:field name="cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CASHFLOW_ID" prompt="CON_CONTRACT_CASHFLOW_V.CASHFLOW_ID"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM" prompt="CON_CONTRACT_CASHFLOW_V.CF_ITEM"/>
        <bm:field name="cf_item_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_ITEM_NAME" prompt="CON_CONTRACT_CASHFLOW_V.CF_ITEM_NAME"/>
        <bm:field name="cf_type" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_TYPE" prompt="CON_CONTRACT_CASHFLOW_V.CF_TYPE"/>
        <bm:field name="cf_type_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_TYPE_NAME" prompt="CON_CONTRACT_CASHFLOW_V.CF_TYPE_NAME"/>
        <bm:field name="cf_direction" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_DIRECTION" prompt="CON_CONTRACT_CASHFLOW_V.CF_DIRECTION"/>
        <bm:field name="cf_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_STATUS" prompt="CON_CONTRACT_CASHFLOW_V.CF_STATUS"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TIMES" prompt="CON_CONTRACT_CASHFLOW_V.TIMES"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date" physicalName="DUE_DATE" prompt="CON_CONTRACT_CASHFLOW_V.DUE_DATE"/>
        <bm:field name="due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DUE_AMOUNT" prompt="CON_CONTRACT_CASHFLOW_V.DUE_AMOUNT"/>
        <bm:field name="principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.PRINCIPAL"/>
        <bm:field name="interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.INTEREST"/>
        <bm:field name="due_amount_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DUE_AMOUNT_CNY" prompt="CON_CONTRACT_CASHFLOW_V.DUE_AMOUNT_CNY"/>
        <bm:field name="principal_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL_CNY" prompt="CON_CONTRACT_CASHFLOW_V.PRINCIPAL_CNY"/>
        <bm:field name="interest_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_CNY" prompt="CON_CONTRACT_CASHFLOW_V.INTEREST_CNY"/>
        <bm:field name="penalty" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PENALTY" prompt="CON_CONTRACT_CASHFLOW_V.PENALTY"/>
        <bm:field name="penalty_cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PENALTY_CASHFLOW_ID" prompt="CON_CONTRACT_CASHFLOW_V.PENALTY_CASHFLOW_ID"/>
        <bm:field name="outstanding_rental" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OUTSTANDING_RENTAL" prompt="CON_CONTRACT_CASHFLOW_V.OUTSTANDING_RENTAL"/>
        <bm:field name="outstanding_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OUTSTANDING_PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.OUTSTANDING_PRINCIPAL"/>
        <bm:field name="outstanding_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OUTSTANDING_INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.OUTSTANDING_INTEREST"/>
        <bm:field name="interest_accrual_balance" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_ACCRUAL_BALANCE" prompt="CON_CONTRACT_CASHFLOW_V.INTEREST_ACCRUAL_BALANCE"/>
        <bm:field name="principal_implicit_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL_IMPLICIT_RATE" prompt="CON_CONTRACT_CASHFLOW_V.PRINCIPAL_IMPLICIT_RATE"/>
        <bm:field name="interest_implicit_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_IMPLICIT_RATE" prompt="CON_CONTRACT_CASHFLOW_V.INTEREST_IMPLICIT_RATE"/>
        <bm:field name="vat_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_DUE_AMOUNT" prompt="CON_CONTRACT_CASHFLOW_V.VAT_DUE_AMOUNT"/>
        <bm:field name="vat_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.VAT_PRINCIPAL"/>
        <bm:field name="vat_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.VAT_INTEREST"/>
        <bm:field name="net_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_DUE_AMOUNT" prompt="CON_CONTRACT_CASHFLOW_V.NET_DUE_AMOUNT"/>
        <bm:field name="net_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.NET_PRINCIPAL"/>
        <bm:field name="net_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.NET_INTEREST"/>
        <bm:field name="equal_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EQUAL_FLAG" prompt="CON_CONTRACT_CASHFLOW_V.EQUAL_FLAG"/>
        <bm:field name="manual_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MANUAL_FLAG" prompt="CON_CONTRACT_CASHFLOW_V.MANUAL_FLAG"/>
        <bm:field name="fix_principal_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIX_PRINCIPAL_FLAG" prompt="CON_CONTRACT_CASHFLOW_V.FIX_PRINCIPAL_FLAG"/>
        <bm:field name="fix_rental_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIX_RENTAL_FLAG" prompt="CON_CONTRACT_CASHFLOW_V.FIX_RENTAL_FLAG"/>
        <bm:field name="salestax" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SALESTAX" prompt="CON_CONTRACT_CASHFLOW_V.SALESTAX"/>
        <bm:field name="calc_line_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALC_LINE_ID" prompt="CON_CONTRACT_CASHFLOW_V.CALC_LINE_ID"/>
        <bm:field name="overdue_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OVERDUE_STATUS" prompt="CON_CONTRACT_CASHFLOW_V.OVERDUE_STATUS"/>
        <bm:field name="overdue_book_date" databaseType="DATE" datatype="java.util.Date" physicalName="OVERDUE_BOOK_DATE" prompt="CON_CONTRACT_CASHFLOW_V.OVERDUE_BOOK_DATE"/>
        <bm:field name="overdue_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OVERDUE_AMOUNT" prompt="CON_CONTRACT_CASHFLOW_V.OVERDUE_AMOUNT"/>
        <bm:field name="overdue_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OVERDUE_PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.OVERDUE_PRINCIPAL"/>
        <bm:field name="overdue_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OVERDUE_INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.OVERDUE_INTEREST"/>
        <bm:field name="overdue_remark" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OVERDUE_REMARK" prompt="CON_CONTRACT_CASHFLOW_V.OVERDUE_REMARK"/>
        <bm:field name="received_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_AMOUNT" prompt="CON_CONTRACT_CASHFLOW_V.RECEIVED_AMOUNT"/>
        <bm:field name="received_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.RECEIVED_PRINCIPAL"/>
        <bm:field name="received_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.RECEIVED_INTEREST"/>
        <bm:field name="received_amount_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_AMOUNT_CNY" prompt="CON_CONTRACT_CASHFLOW_V.RECEIVED_AMOUNT_CNY"/>
        <bm:field name="received_principal_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_PRINCIPAL_CNY" prompt="CON_CONTRACT_CASHFLOW_V.RECEIVED_PRINCIPAL_CNY"/>
        <bm:field name="received_interest_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_INTEREST_CNY" prompt="CON_CONTRACT_CASHFLOW_V.RECEIVED_INTEREST_CNY"/>
        <bm:field name="write_off_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WRITE_OFF_FLAG" prompt="CON_CONTRACT_CASHFLOW_V.WRITE_OFF_FLAG"/>
        <bm:field name="payment_precondition_status" expression="decode(t1.write_off_flag,&apos;FULL&apos;,&apos;已支付&apos;,&apos;PARTIAL&apos;,&apos;部分&apos;,&apos;NOT&apos;,&apos;未付&apos;)" forInsert="false" forUpdate="false"/>
        <bm:field name="full_write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="FULL_WRITE_OFF_DATE" prompt="CON_CONTRACT_CASHFLOW_V.FULL_WRITE_OFF_DATE"/>
        <bm:field name="penalty_process_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PENALTY_PROCESS_STATUS" prompt="CON_CONTRACT_CASHFLOW_V.PENALTY_PROCESS_STATUS"/>
        <bm:field name="unreceived_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_AMOUNT" prompt="CON_CONTRACT_CASHFLOW_V.UNRECEIVED_AMOUNT"/>
        <bm:field name="unreceived_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_PRINCIPAL" prompt="CON_CONTRACT_CASHFLOW_V.UNRECEIVED_PRINCIPAL"/>
        <bm:field name="unreceived_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_INTEREST" prompt="CON_CONTRACT_CASHFLOW_V.UNRECEIVED_INTEREST"/>
        <bm:field name="unreceived_amount_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_AMOUNT_CNY" prompt="CON_CONTRACT_CASHFLOW_V.UNRECEIVED_AMOUNT_CNY"/>
        <bm:field name="unreceived_principal_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_PRINCIPAL_CNY" prompt="CON_CONTRACT_CASHFLOW_V.UNRECEIVED_PRINCIPAL_CNY"/>
        <bm:field name="unreceived_interest_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_INTEREST_CNY" prompt="CON_CONTRACT_CASHFLOW_V.UNRECEIVED_INTEREST_CNY"/>
        <bm:field name="write_off_order" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WRITE_OFF_ORDER" prompt="CON_CONTRACT_CASHFLOW_V.WRITE_OFF_ORDER"/>
        <bm:field name="write_off_order100" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WRITE_OFF_ORDER100" prompt="CON_CONTRACT_CASHFLOW_V.WRITE_OFF_ORDER100"/>
        <bm:field name="write_off_order101" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WRITE_OFF_ORDER101" prompt="CON_CONTRACT_CASHFLOW_V.WRITE_OFF_ORDER101"/>
        <bm:field name="rent_bank_account" databaseType="NUMBER" datatype="java.lang.Long" expression="(select r.rent_bank_account from tre_funds_reservation r where r.project_id=t1.project_id)"/>
        <bm:field name="deposit_bank_account" databaseType="NUMBER" datatype="java.lang.Long" expression="(select r.deposit_bank_account from tre_funds_reservation r where r.project_id=t1.project_id)"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <!--  <s:bm-script><![CDATA[
            if ($ctx.parameter.auto_write_off_flag == 'Y') {
                var order_by_bm = $bm('basic.sys_code_default_value');
                $ctx.parameter.code = 'CSH_AUTO_WRITE_OFF_RULE'
                var sub_tn_map = order_by_bm.queryAsMap();
                var sub_base_children = sub_tn_map.getChildren();
                if (sub_base_children.length != 0) {
                    $this.setDefaultOrderby(sub_base_children[0].CODE_VALUE);
                }
            }
        ]]></s:bm-script> -->
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="contract_id" queryOperator="="/>
        <bm:query-field name="contract_status" queryExpression="t1.contract_status != ${@contract_status}"/>
        <bm:query-field field="bp_id_tenant" queryOperator="="/>
        <!-- <bm:query-field field="bp_id_tenant" queryExpression="t1.bp_id_tenant =  decode(nvl(${@bp_limit_flag},&apos;N&apos;),&apos;N&apos;,${@bp_id_tenant},&apos;Y&apos;,t1.bp_id_tenant)"/> -->
        <bm:query-field field="cf_direction" queryOperator="="/>
        <bm:query-field field="cf_status" queryOperator="="/>
        <bm:query-field field="cf_type" queryOperator="="/>
        <bm:query-field field="cf_item" queryOperator="="/>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <!--缺少   故添加  hongquan.dai 2018/03/13-->
        <!-- 库融（）的经销商即是承租人 -->
        <bm:query-field name="bp_id1" queryExpression="decode(t1.division,&apos;02&apos;,t1.bp_id_tenant,&apos;09&apos;,t1.bp_id_tenant,t1.bp_id_agent_level1) = decode(nvl(${@limit_flag},&apos;N&apos;),&apos;Y&apos;,${@bp_id1},&apos;N&apos;,decode(t1.division,&apos;02&apos;,t1.bp_id_tenant,&apos;09&apos;,t1.bp_id_tenant,t1.bp_id_agent_level1))"/>
        <!-- <bm:query-field name="bp_id" queryExpression="exists(select 1 from con_contract_bp b where b.bp_category = &apos;TENANT&apos; and b.bp_id=${@bp_id} and b.contract_id=t1.contract_id)"/> -->
        <bm:query-field name="due_date_from" queryExpression="due_date &gt;= to_date(${@due_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="due_date_to" queryExpression="due_date &lt;= to_date(${@due_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="due_amount_from" queryExpression="due_amount &gt;= ${@due_amount_from}"/>
        <bm:query-field name="due_amount_to" queryExpression="due_amount &lt;= ${@due_amount_to}"/>
        <bm:query-field name="not_write_off_flag_f" queryExpression="(t1.write_off_flag != ${@not_write_off_flag_f})"/>
        <bm:query-field name="no_cf_type" queryExpression="t1.cf_type!=${@no_cf_type}"/>
        <bm:query-field name="contract_writeoff_status" queryExpression="(${@contract_writeoff_status}=&apos;Y&apos; and t1.contract_status not in (&apos;PENDING&apos;))"/>
        <bm:query-field field="currency" queryOperator="="/>
        <bm:query-field name="not_currency" queryExpression="t1.currency!=${@not_currency}"/>
        <bm:query-field name="contract_number" queryExpression="t1.contract_number =${@contract_number}"/>
    </bm:query-fields>
    <bm:data-filters>
        <!-- <bm:data-filter name="rec_bp_filter" enforceOperations="query" expression="(${@transaction_type} != &apos;RECEIPT&apos; or (${@transaction_type} = &apos;RECEIPT&apos; and t1.bp_id_tenant = nvl(decode((select count(*) from hls_bp_master hm where hm.bp_id=${@bp_id} and hm.bp_category=&apos;TENANT&apos;),0,t1.bp_id_tenant,${@bp_id}),t1.bp_id_tenant)))"/>
                     FORM已默认查询条件  且当删除FORM查询条件时 需要查询所有 hongquan.dai 2018/03/13-->
        <bm:data-filter name="contract_number" enforceOperations="query" expression="data_class = &apos;NORMAL&apos; and contract_status not in (&apos;PENDING&apos;,&apos;REJECT&apos;) and nvl(t1.spv_company_id,t1.company_id)=${/session/@company_id} and t1.cf_status=&apos;RELEASE&apos;"/>
    </bm:data-filters>
</bm:model>
