<?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 * FROM CON_CONTRACT_CASHFLOW_V t #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="CONTRACT_NUMBER" prompt="HLS.CONTRACT_NUMBER"/>
        <bm:field name="contract_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_STATUS"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="spv_company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SPV_COMPANY_ID"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY"/>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID"/>
        <bm:field name="bp_id_tenant" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID_TENANT"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER"/>
        <bm:field name="project_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NAME"/>
        <bm:field name="prj_short_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRJ_SHORT_NAME"/>
        <bm:field name="bp_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_CODE"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME"/>
        <bm:field name="cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CASHFLOW_ID"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM"/>
        <bm:field name="cf_item_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="100" forDisplay="true" forQuery="true" physicalName="CF_ITEM_NAME" prompt="HLS.CF_ITEM_DESC"/>
        <bm:field name="cf_type" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_TYPE"/>
        <bm:field name="cf_type_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_TYPE_NAME"/>
        <bm:field name="cf_direction" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_DIRECTION"/>
        <bm:field name="cf_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_STATUS"/>
        <bm:field name="times" databaseType="NUMBER" datatype="java.lang.Long" displayWidth="50" forDisplay="true" forQuery="true" physicalName="TIMES" prompt="HLS.TIMES"/>
        <bm:field name="due_date" databaseType="DATE" datatype="java.util.Date" displayWidth="80" forDisplay="true" physicalName="DUE_DATE" prompt="CSH710.DUE_DATE"/>
        <bm:field name="due_amount" databaseType="NUMBER" datatype="java.lang.Double" forDisplay="true" physicalName="DUE_AMOUNT" prompt="CON500.CON_CONTRACT_CASHFLOW.DUE_AMOUNT"/>
        <bm:field name="principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL"/>
        <bm:field name="interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST"/>
        <bm:field name="due_amount_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="DUE_AMOUNT_CNY"/>
        <bm:field name="principal_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL_CNY"/>
        <bm:field name="interest_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_CNY"/>
        <bm:field name="penalty" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PENALTY"/>
        <bm:field name="penalty_cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PENALTY_CASHFLOW_ID"/>
        <bm:field name="outstanding_rental" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OUTSTANDING_RENTAL"/>
        <bm:field name="outstanding_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OUTSTANDING_PRINCIPAL"/>
        <bm:field name="outstanding_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OUTSTANDING_INTEREST"/>
        <bm:field name="interest_accrual_balance" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_ACCRUAL_BALANCE"/>
        <bm:field name="principal_implicit_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="PRINCIPAL_IMPLICIT_RATE"/>
        <bm:field name="interest_implicit_rate" databaseType="NUMBER" datatype="java.lang.Double" physicalName="INTEREST_IMPLICIT_RATE"/>
        <bm:field name="vat_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_DUE_AMOUNT"/>
        <bm:field name="vat_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_PRINCIPAL"/>
        <bm:field name="vat_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="VAT_INTEREST"/>
        <bm:field name="net_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_DUE_AMOUNT"/>
        <bm:field name="net_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_PRINCIPAL"/>
        <bm:field name="net_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="NET_INTEREST"/>
        <bm:field name="equal_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EQUAL_FLAG"/>
        <bm:field name="manual_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MANUAL_FLAG"/>
        <bm:field name="fix_principal_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIX_PRINCIPAL_FLAG"/>
        <bm:field name="fix_rental_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIX_RENTAL_FLAG"/>
        <bm:field name="salestax" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SALESTAX"/>
        <bm:field name="calc_line_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CALC_LINE_ID"/>
        <bm:field name="overdue_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OVERDUE_STATUS"/>
        <bm:field name="overdue_book_date" databaseType="DATE" datatype="java.util.Date" physicalName="OVERDUE_BOOK_DATE"/>
        <bm:field name="overdue_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OVERDUE_AMOUNT"/>
        <bm:field name="overdue_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OVERDUE_PRINCIPAL"/>
        <bm:field name="overdue_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="OVERDUE_INTEREST"/>
        <bm:field name="overdue_remark" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OVERDUE_REMARK"/>
        <bm:field name="received_amount" databaseType="NUMBER" datatype="java.lang.Double" forDisplay="true" physicalName="RECEIVED_AMOUNT" prompt="已收金额"/>
        <bm:field name="received_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_PRINCIPAL"/>
        <bm:field name="received_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_INTEREST"/>
        <bm:field name="received_amount_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_AMOUNT_CNY"/>
        <bm:field name="received_principal_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_PRINCIPAL_CNY"/>
        <bm:field name="received_interest_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="RECEIVED_INTEREST_CNY"/>
        <bm:field name="write_off_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WRITE_OFF_FLAG"/>
        <bm:field name="full_write_off_date" databaseType="DATE" datatype="java.util.Date" physicalName="FULL_WRITE_OFF_DATE"/>
        <bm:field name="penalty_process_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PENALTY_PROCESS_STATUS"/>
        <bm:field name="unreceived_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_AMOUNT" prompt="CSH513.UNRECEIVED_AMOUNT"/>
        <bm:field name="unreceived_principal" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_PRINCIPAL"/>
        <bm:field name="unreceived_interest" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_INTEREST"/>
        <bm:field name="unreceived_amount_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_AMOUNT_CNY"/>
        <bm:field name="unreceived_principal_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_PRINCIPAL_CNY"/>
        <bm:field name="unreceived_interest_cny" databaseType="NUMBER" datatype="java.lang.Double" physicalName="UNRECEIVED_INTEREST_CNY"/>
        <bm:field name="write_off_order" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_ORDER"/>
        <bm:field name="write_off_order100" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_ORDER100"/>
        <bm:field name="write_off_order101" databaseType="NUMBER" datatype="java.lang.Double" physicalName="WRITE_OFF_ORDER101"/>
        <bm:field name="transaction_date" datatype="java.lang.String" forInsert="false" forQuery="true" forUpdate="false"/>
    </bm:fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t.cf_status = &apos;RELEASE&apos;    and t.write_off_flag !=&apos;FULL&apos;    and t.due_amount !=0"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field name="contract_id" queryExpression="(t.contract_id = ${@contract_id})"/>
        <bm:query-field field="contract_number" queryOperator="like"/>
        <bm:query-field field="cf_direction" queryOperator="="/>
        <bm:query-field field="times" queryOperator="="/>
        <bm:query-field field="cf_item_name" queryOperator="like"/>
        <bm:query-field field="cashflow_id" queryOperator="="/>
        <bm:query-field name="bp_id" queryExpression="(${@cashflow_id} is not null or exists (select 1 from con_contract_bp cb where cb.contract_id = t.contract_id and  cb.bp_id = ${@bp_id} and cb.bp_category in  (&apos;TENANT&apos;,&apos;GUARANTOR&apos;)))"/>
        <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="t.write_off_flag!=${@not_write_off_flag_f}"/> -->
        <bm:query-field name="no_cf_type" queryExpression="t.cf_type!=${@no_cf_type}"/>
        <bm:query-field name="contract_writeoff_status" queryExpression="(${@contract_writeoff_status}=&apos;Y&apos; and t.contract_status not in (&apos;NEW&apos;,&apos;PENDING&apos;))"/>
        <bm:query-field field="currency" queryOperator="="/>
        <bm:query-field name="not_currency" queryExpression="t.currency!=${@not_currency}"/>
        <!-- <bm:query-field name="cf_type_fin" queryExpression="(t.cf_type=${@cf_type_fin} or (${@cf_type_fin}=&apos;9&apos; and t.penalty_wf_flag !=${@not_write_off_flag_f}))"/> -->
        <bm:query-field name="cf_type_fin" queryExpression="(t.cf_type=${@cf_type_fin} or (${@cf_type_fin}=&apos;9&apos; ))"/>
    </bm:query-fields>
</bm:model>
