<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-9-30 上午10:35:25  
    $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
                    rownum AS line_num,
                    t.*
                FROM
                    (SELECT
                        h.business_type,
                        (SELECT
                            bt.description
                        FROM
                            hls_business_type bt
                        WHERE
                            bt.business_type = h.business_type
                        ) AS business_type_n,
                        h.division,
                        (SELECT d.description FROM hls_division d WHERE d.division = h.division
                        ) AS division_n,
                        (SELECT
                            ch.description
                        FROM
                            hls_lease_channel ch
                        WHERE
                            ch.lease_channel = h.lease_channel
                        ) AS lease_channel_n,
                        (SELECT
                            t.period_name
                        FROM
                            gld_periods t
                        WHERE
                            TRUNC(h.inception_of_lease)  >= TRUNC(t.start_date) AND
                            TRUNC(h.inception_of_lease) <= TRUNC(t.end_date)
                            and t.adjustment_flag='N'
                        ) AS period_name,
                        (SELECT
                            dbms_lob.substr(wmsys.wm_concat(li.serial_number))
                        FROM
                            con_contract_lease_item li
                        WHERE
                            li.contract_id = h.contract_id
                        ) AS serial_number,
                        h.inception_of_lease,
                        (SELECT
                            dbms_lob.substr(wmsys.wm_concat(m.bp_name))
                        FROM
                            con_contract_bp a,
                            hls_bp_master m
                        WHERE
                            a.contract_id = h.contract_id AND
                            a.bp_category = 'TENANT' AND
                            a.bp_id       = m.bp_id
                        ) AS bp_tenant_name,
                        h.search_term_1,
                        (SELECT
                            NVL(COUNT(*), 0)
                        FROM
                            con_contract_cashflow t
                        WHERE
                            t.contract_id    = h.contract_id AND
                            t.write_off_flag = 'FULL' AND
                            t.cf_item        = 1
                        ) AS paid,
                        h.lease_times,
                        h.finance_amount,
                        (SELECT
                            SUM(cf.due_amount - NVL(
                            (SELECT
                                SUM(cw.write_off_due_amount)
                            FROM
                                csh_write_off cw
                            WHERE
                                cw.cashflow_id     = cf.cashflow_id AND
                                cw.write_off_date <= to_date(${@analyze_date}, 'YYYY-MM-DD')
                            ),0))
                        FROM
                            con_contract_cashflow cf
                        WHERE
                            cf.contract_id  = h.contract_id AND
                            cf.cf_item      = 1 AND
                            cf.cf_direction = 'INFLOW'
                        ) AS gross, --现金流租金合计-收款日期在分析日之前的核销金额
                        NVL((SELECT SUM(c.due_amount -
                      NVL((SELECT SUM(w.write_off_due_amount)
                            FROM csh_write_off w, csh_transaction t
                           WHERE w.cashflow_id = c.cashflow_id
                             AND w.csh_transaction_id = t.transaction_id
                             AND t.transaction_date <=
                                 to_date(${@analyze_date}, 'YYYY-MM-DD')),
                          0))
             FROM con_contract_cashflow c
            WHERE c.contract_id = h.contract_id
              AND c.cf_item = 1 
              AND c.cf_direction = 'INFLOW'
              AND c.due_date <= to_date(${@analyze_date}, 'YYYY-MM-DD')),
           0)-
            NVL((SELECT SUM(c.interest -
                      NVL((SELECT SUM(w.write_off_interest)
                            FROM csh_write_off w, csh_transaction t
                           WHERE w.cashflow_id = c.cashflow_id
                             AND w.csh_transaction_id = t.transaction_id
                             AND t.transaction_date <=
                                 to_date(${@analyze_date}, 'YYYY-MM-DD')),
                          0))
             FROM con_contract_cashflow c
            WHERE c.contract_id = h.contract_id
              AND c.cf_item = 1
              and nvl(h.contract_status,'#') = 'PENDING'
              AND c.cf_direction = 'INFLOW'
              AND c.due_date <= to_date(${@analyze_date}, 'YYYY-MM-DD')),
           0)+ NVL(
                        (SELECT
                            SUM(c.principal - NVL(
                            (SELECT
                                SUM(w.write_off_principal)
                            FROM
                                csh_write_off w,
                                csh_transaction t
                            WHERE
                                w.cashflow_id        = c.cashflow_id AND
                                w.csh_transaction_id = t.transaction_id AND
                                t.transaction_date  <= to_date(${@analyze_date},'YYYY-MM-DD')
                            ),0) )
                        FROM
                            con_contract_cashflow c
                        WHERE
                            c.contract_id  = h.contract_id AND
                            c.cf_item      = 1 AND
                            c.cf_direction = 'INFLOW' AND
                            c.due_date     > to_date(${@analyze_date},'YYYY-MM-DD')
                        ) ,0) - NVL(
                        (SELECT
                            SUM(NVL(
                            (SELECT
                                SUM(w.write_off_interest)
                            FROM
                                csh_write_off w,
                                csh_transaction t
                            WHERE
                                w.cashflow_id        = c.cashflow_id AND
                                w.csh_transaction_id = t.transaction_id AND
                                t.transaction_date  <= to_date(${@analyze_date},'YYYY-MM-DD')
                            ),0))
                        FROM
                            con_contract_cashflow c
                        WHERE
                            c.contract_id  = h.contract_id AND
                            c.cf_item      = 1 AND
                            c.cf_direction = 'INFLOW' AND
                            c.due_date     > to_date(${@analyze_date},'YYYY-MM-DD')
                        ) ,0) AS net,
                        NVL(
                        (SELECT
                            NVL(SUM(t.interest), 0)
                        FROM
                            con_contract_cashflow t
                        WHERE
                            t.contract_id = h.contract_id AND
                            t.cf_item     = 1 AND
                            t.due_date    > to_date(${@analyze_date}, 'YYYY-MM-DD')
                        ),0) AS unearned_income, --未到期应收利息
                        NVL(
                        (SELECT
                            SUM(nvl(cf.due_amount,0) - NVL(
                            (SELECT
                                SUM(cw.write_off_due_amount)
                            FROM
                                csh_write_off cw
                            WHERE
                                cw.cashflow_id     = cf.cashflow_id AND
                                cw.write_off_date <= to_date(${@analyze_date}, 'YYYY-MM-DD')
                            ),0))
                        FROM
                            con_contract_cashflow cf
                        WHERE
                            cf.contract_id  = h.contract_id AND
                            cf.cf_item      = 1 AND
                            cf.cf_direction = 'INFLOW'
                        ) - nvl((SELECT SUM(nvl(cf.interest,0) -
                       NVL((SELECT SUM(cw.write_off_interest)
                             FROM csh_write_off cw
                            WHERE cw.cashflow_id = cf.cashflow_id
                              AND cw.write_off_date <=
                                  to_date(${@analyze_date}, 'YYYY-MM-DD')),
                           0))
              FROM con_contract_cashflow cf
             WHERE cf.contract_id = h.contract_id
               AND cf.cf_item = 1
               and h.contract_status = 'PENDING'
               AND cf.cf_direction = 'INFLOW'),0) - DECODE(h.vat_flag,'N',NVL(
                        (SELECT
                            SUM(i.unearned_finance_income)
                        FROM
                            con_unearned_finance_income i
                        WHERE
                            i.contract_id     = h.contract_id AND
                            i.calc_start_date > to_date(${@analyze_date}, 'YYYY-MM-DD')
                        ),0),'Y',NVL(
                        (SELECT
                            SUM(i.unearned_finance_income)
                        FROM
                            con_unearned_finance_income i
                        WHERE
                            i.contract_id     = h.contract_id AND
                            i.calc_start_date > to_date(${@analyze_date}, 'YYYY-MM-DD')
                        ),0)*1.17),0) AS net_finance, --net(finance)新
                        DECODE(h.vat_flag,'N',NVL(
                        (SELECT
                            SUM(i.unearned_finance_income)
                        FROM
                            con_unearned_finance_income i
                        WHERE
                            i.contract_id     = h.contract_id AND
                            i.calc_start_date > to_date(${@analyze_date}, 'YYYY-MM-DD')
                        ),0),'Y',NVL(
                        (SELECT
                            SUM(i.unearned_finance_income)
                        FROM
                            con_unearned_finance_income i
                        WHERE
                            i.contract_id     = h.contract_id AND
                            i.calc_start_date > to_date(${@analyze_date}, 'YYYY-MM-DD')
                        ),0)*1.17) AS unearned_income_interest, --财务未确认收入
                        (SELECT
                            NVL(SUM(t.write_off_due_amount), 0)
                        FROM
                            csh_write_off t
                        WHERE
                            t.contract_id                        = h.contract_id AND
                            t.cf_item = 1 AND
                            TO_CHAR(t.write_off_date, 'YYYY-MM') = SUBSTR(${@analyze_date}, 1, 7)
                        ) AS amt_paid,
                        (SELECT
                            NVL(SUM(nvl(t.received_amount,0)), 0)
                        FROM
                            con_contract_cashflow t
                        WHERE
                            t.contract_id = h.contract_id AND
                            t.cf_direction = 'INFLOW' AND
                            t.cf_item      = 1 AND
                            t.due_date    > to_date(${@analyze_date},'YYYY-MM-DD')
                        ) AS advence,
                        h.contract_id,
                        h.contract_number,
                        h.contract_name,
                        (SELECT
                            NVL(SUM(l.due_amount), 0)
                        FROM
                            con_contract_cashflow l
                        WHERE
                            l.contract_id  = h.contract_id AND
                            l.cf_direction = 'INFLOW' AND
                            l.cf_item      = 1 AND
                            l.due_date    <= to_date(${@analyze_date}, 'yyyy-mm-dd')
                        ) sum_due_amount,
                        (SELECT
                            NVL(SUM(d.write_off_due_amount), 0)
                        FROM
                            csh_write_off d,
                            con_contract_cashflow c
                        WHERE
                            d.cashflow_id   = c.cashflow_id AND
                            c.contract_id   = h.contract_id AND
                            d.reversed_flag = 'N' AND
                            c.cf_direction  = 'INFLOW' AND
                            c.cf_item       = 1 AND
                            (
                                d.write_off_date < to_date(${@analyze_date}, 'yyyy-mm-dd') OR
                                (
                                    d.write_off_date      = to_date(${@analyze_date}, 'yyyy-mm-dd') AND
                                    ${@analyze_date_flag} = 'N'
                                )
                            )
                        ) sum_received_amount,
                        (
                        (SELECT
                            NVL(SUM(l.due_amount), 0)
                        FROM
                            con_contract_cashflow l
                        WHERE
                            l.contract_id  = h.contract_id AND
                            l.cf_direction = 'INFLOW' AND
                            l.cf_item      = 1 AND
                            l.due_date    <= to_date(${@analyze_date}, 'yyyy-mm-dd')
                        ) -
                        (SELECT
                            NVL(SUM(d.write_off_due_amount), 0)
                        FROM
                            csh_write_off d,
                            con_contract_cashflow c
                        WHERE
                            d.cashflow_id   = c.cashflow_id AND
                            c.contract_id   = h.contract_id AND
                            c.cf_direction  = 'INFLOW' AND
                            d.reversed_flag = 'N' AND
                            c.cf_item       = 1 AND
                            (
                                d.write_off_date < to_date(${@analyze_date}, 'yyyy-mm-dd') OR
                                (
                                    d.write_off_date      = to_date(${@analyze_date}, 'yyyy-mm-dd') AND
                                    ${@analyze_date_flag} = 'N'
                                )
                            )
                        )) sum_overdue_amount,
                        (SELECT
                            NVL(SUM(l.due_amount), 0)
                        FROM
                            con_contract_cashflow l
                        WHERE
                            l.contract_id  = h.contract_id AND
                            l.cf_direction = 'INFLOW' AND
                            l.cf_item      = 1 AND
                            (
                                l.due_date > to_date(${@analyze_date}, 'yyyy-mm-dd') OR
                                (
                                    l.due_date            = to_date(${@analyze_date}, 'yyyy-mm-dd') AND
                                    ${@analyze_date_flag} = 'Y'
                                )
                            )
                        ) sum_forecast_amount,
                        h.company_id,
                        (SELECT
                            fc.company_short_name
                        FROM
                            fnd_companies fc
                        WHERE
                            fc.company_id = h.company_id
                        ) AS company_id_n,
                        h.lease_channel,
                        h.lease_organization,
                        (NVL(t1.aging_bucket_1, 0)+NVL(t1.aging_bucket_2, 0)+NVL(t1.aging_bucket_3, 0)+NVL(t1.aging_bucket_4, 0)+NVL(t1.aging_bucket_5, 0) +NVL(t1.aging_bucket_6, 0)+NVL(t1.aging_bucket_7, 0)+NVL(t1.aging_bucket_8, 0)+NVL(t1.aging_bucket_9, 0)+NVL(t1.aging_bucket_10, 0) +NVL(t1.aging_bucket_11, 0)+NVL(t1.aging_bucket_12, 0)+NVL(t1.aging_bucket_13, 0)+NVL(t1.aging_bucket_14, 0)+NVL(t1.aging_bucket_15, 0) +NVL(t1.aging_bucket_16, 0)+NVL(t1.aging_bucket_17, 0)+NVL(t1.aging_bucket_18, 0)+NVL(t1.aging_bucket_19, 0)+NVL(t1.aging_bucket_20, 0) +NVL(t1.aging_bucket_21, 0)+NVL(t1.aging_bucket_22, 0)+NVL(t1.aging_bucket_23, 0)+NVL(t1.aging_bucket_24, 0)+NVL(t1.aging_bucket_25, 0) +NVL(t1.aging_bucket_26, 0)+NVL(t1.aging_bucket_27, 0)+NVL(t1.aging_bucket_28, 0)+NVL(t1.aging_bucket_29, 0)+NVL(t1.aging_bucket_30, 0) +NVL(t1.aging_bucket_31, 0)+NVL(t1.aging_bucket_32, 0)+NVL(t1.aging_bucket_33, 0)+NVL(t1.aging_bucket_34, 0)+NVL(t1.aging_bucket_35, 0)+NVL(t1.aging_bucket_36, 0)) AS total_aging_bucket,
                        NVL(t1.aging_bucket_1, 0) aging_bucket_1,
                        NVL(t1.aging_bucket_2, 0) aging_bucket_2,
                        NVL(t1.aging_bucket_3, 0) aging_bucket_3,
                        NVL(t1.aging_bucket_4, 0) aging_bucket_4,
                        NVL(t1.aging_bucket_5, 0) aging_bucket_5,
                        NVL(t1.aging_bucket_6, 0) aging_bucket_6,
                        NVL(t1.aging_bucket_7, 0) aging_bucket_7,
                        NVL(t1.aging_bucket_8, 0) aging_bucket_8,
                        NVL(t1.aging_bucket_9, 0) aging_bucket_9,
                        NVL(t1.aging_bucket_10, 0) aging_bucket_10,
                        NVL(t1.aging_bucket_11, 0) aging_bucket_11,
                        NVL(t1.aging_bucket_12, 0) aging_bucket_12,
                        NVL(t1.aging_bucket_13, 0) aging_bucket_13,
                        NVL(t1.aging_bucket_14, 0) aging_bucket_14,
                        NVL(t1.aging_bucket_15, 0) aging_bucket_15,
                        NVL(t1.aging_bucket_16, 0) aging_bucket_16,
                        NVL(t1.aging_bucket_17, 0) aging_bucket_17,
                        NVL(t1.aging_bucket_18, 0) aging_bucket_18,
                        NVL(t1.aging_bucket_19, 0) aging_bucket_19,
                        NVL(t1.aging_bucket_20, 0) aging_bucket_20,
                        NVL(t1.aging_bucket_21, 0) aging_bucket_21,
                        NVL(t1.aging_bucket_22, 0) aging_bucket_22,
                        NVL(t1.aging_bucket_23, 0) aging_bucket_23,
                        NVL(t1.aging_bucket_24, 0) aging_bucket_24,
                        NVL(t1.aging_bucket_25, 0) aging_bucket_25,
                        NVL(t1.aging_bucket_26, 0) aging_bucket_26,
                        NVL(t1.aging_bucket_27, 0) aging_bucket_27,
                        NVL(t1.aging_bucket_28, 0) aging_bucket_28,
                        NVL(t1.aging_bucket_29, 0) aging_bucket_29,
                        NVL(t1.aging_bucket_30, 0) aging_bucket_30,
                        NVL(t1.aging_bucket_31, 0) aging_bucket_31,
                        NVL(t1.aging_bucket_32, 0) aging_bucket_32,
                        NVL(t1.aging_bucket_33, 0) aging_bucket_33,
                        NVL(t1.aging_bucket_34, 0) aging_bucket_34,
                        NVL(t1.aging_bucket_35, 0) aging_bucket_35,
                        NVL(t1.aging_bucket_36, 0) aging_bucket_36,
                        h.currency,
                        h.contract_status,
                         (select v.code_value_name
          from sys_code_values_v v
         where v.code = 'CON500_CONTRACT_STATUS'
               and v.code_value = h.contract_status) as contract_status_n
                        
                    FROM
                        con_contract h,
                        fnd_aging_result_hd_tmp t1 #WHERE_CLAUSE#
                    ORDER BY
                        h.inception_of_lease
                    ) t
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="contract_status_n"/>
        <bm:field name="line_num" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="search_term_1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SEARCH_TERM_1"/>
        <bm:field name="bp_tenant_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_TENANT_NAME"/>
        <bm:field name="business_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BUSINESS_TYPE"/>
        <bm:field name="division_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DIVISION_N"/>
        <bm:field name="lease_channel_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL_N"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME"/>
        <bm:field name="serial_number" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="inception_of_lease" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="paid" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="lease_times" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="finance_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="gross" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="net" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="unearned_income" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="net_finance" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="unearned_income_interest" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="amt_paid" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="advence" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="company_id_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COMPANY_ID_N"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME"/>
        <bm:field name="lease_channel" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_CHANNEL"/>
        <bm:field name="lease_organization" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEASE_ORGANIZATION"/>
        <bm:field name="sum_due_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SUM_DUE_AMOUNT"/>
        <bm:field name="sum_received_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SUM_RECEIVED_AMOUNT"/>
        <bm:field name="sum_overdue_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SUM_OVERDUE_AMOUNT"/>
        <bm:field name="sum_forecast_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="SUM_FORECAST_AMOUNT"/>
        <bm:field name="total_aging_bucket" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_AGING_BUCKET"/>
        <bm:field name="aging_bucket_1" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_1"/>
        <bm:field name="aging_bucket_2" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_2"/>
        <bm:field name="aging_bucket_3" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_3"/>
        <bm:field name="aging_bucket_4" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_4"/>
        <bm:field name="aging_bucket_5" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_5"/>
        <bm:field name="aging_bucket_6" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_6"/>
        <bm:field name="aging_bucket_7" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_7"/>
        <bm:field name="aging_bucket_8" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_8"/>
        <bm:field name="aging_bucket_9" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_9"/>
        <bm:field name="aging_bucket_10" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_10"/>
        <bm:field name="aging_bucket_11" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_11"/>
        <bm:field name="aging_bucket_12" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_12"/>
        <bm:field name="aging_bucket_13" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_13"/>
        <bm:field name="aging_bucket_14" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_14"/>
        <bm:field name="aging_bucket_15" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_15"/>
        <bm:field name="aging_bucket_16" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_16"/>
        <bm:field name="aging_bucket_17" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_17"/>
        <bm:field name="aging_bucket_18" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_18"/>
        <bm:field name="aging_bucket_19" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_19"/>
        <bm:field name="aging_bucket_20" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_20"/>
        <bm:field name="aging_bucket_21" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_21"/>
        <bm:field name="aging_bucket_22" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_22"/>
        <bm:field name="aging_bucket_23" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_23"/>
        <bm:field name="aging_bucket_24" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_24"/>
        <bm:field name="aging_bucket_25" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_25"/>
        <bm:field name="aging_bucket_26" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_26"/>
        <bm:field name="aging_bucket_27" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_27"/>
        <bm:field name="aging_bucket_28" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_28"/>
        <bm:field name="aging_bucket_29" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_29"/>
        <bm:field name="aging_bucket_30" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_30"/>
        <bm:field name="aging_bucket_31" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_31"/>
        <bm:field name="aging_bucket_32" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_32"/>
        <bm:field name="aging_bucket_33" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_33"/>
        <bm:field name="aging_bucket_34" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_34"/>
        <bm:field name="aging_bucket_35" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_35"/>
        <bm:field name="aging_bucket_36" databaseType="NUMBER" datatype="java.lang.Double" physicalName="AGING_BUCKET_36"/>
        <bm:field name="currency" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENCY_NAME"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field name="contract_number_from" queryExpression="h.contract_number &gt;= ${@contract_number_from}"/>
        <bm:query-field name="contract_number_to" queryExpression="h.contract_number &lt;= ${@contract_number_to}"/>
        <bm:query-field name="search_term_1_from" queryExpression="h.search_term_1 &gt;= ${@search_term_1_from}"/>
        <bm:query-field name="search_term_1_to" queryExpression="h.search_term_1 &lt;= ${@search_term_1_to}"/>
        <bm:query-field field="company_id" queryOperator="="/>
        <bm:query-field field="lease_channel" queryOperator="="/>
        <bm:query-field field="lease_organization" queryOperator="="/>
        <bm:query-field name="currency_code" queryExpression="h.currency = ${@currency_code}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="nvl(h.legal_status,&apos;NULL&apos;)  in (&apos;NULL&apos;,&apos;RENEW_CONTRACT&apos;,&apos;MEDIATION&apos;)"/>
        <bm:data-filter enforceOperations="query" expression="h.inception_of_lease &lt;= to_date(${@analyze_date}, &apos;yyyy-mm-dd&apos;)"/>
        <bm:data-filter enforceOperations="query" expression="h.contract_id = t1.contract_id and t1.session_id=${/session/@session_id} and h.data_class=&apos;NORMAL&apos; and h.contract_status not in (&apos;NEW&apos;,&apos;SIGN&apos;,&apos;CANCEL&apos;,&apos;ET&apos;,&apos;TERMINATE&apos;)"/>
    </bm:data-filters>
</bm:model>
