<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="SDIC_FIN_PLAN_RPT_QUARTER_HD">
    <bm:fields>
        <bm:field name="hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HD_ID" prompt="SDIC_FIN_PLAN_RPT_QUARTER_HD.HD_ID"/>
        <bm:field name="data_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DATA_ID" prompt="SDIC_FIN_PLAN_RPT_QUARTER_HD.DATA_ID"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="SDIC_FIN_PLAN_RPT_QUARTER_HD.DESCRIPTION"/>
        <bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS" prompt="SDIC_FIN_PLAN_RPT_QUARTER_HD.STATUS"/>
        <bm:field name="status_n" forInsert="false" forUpdate="false"/>
        <bm:field name="wfl_instance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WFL_INSTANCE_ID" prompt="SDIC_FIN_PLAN_RPT_QUARTER_HD.WFL_INSTANCE_ID"/>
        <bm:field name="plan_year" forInsert="false" forUpdate="false"/>
        <bm:field name="plan_year_n" forInsert="false" forUpdate="false"/>
        <bm:field name="plan_month" forInsert="false" forUpdate="false"/>
        <bm:field name="plan_month_n" forInsert="false" forUpdate="false"/>
        <bm:field name="plan_frequency" forInsert="false" forUpdate="false"/>
        <bm:field name="plan_frequency_n" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="hd_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (
                SELECT
                    h.hd_id,
                    h.data_id,
                    t.plan_year,
                    (t.plan_year
                    || '年') plan_year_n,
                    t.plan_month,
                    (t.plan_month
                    || '月') plan_month_n,
                    t.plan_frequency,
                    (SELECT
                        v.code_value_name
                    FROM
                        sys_code_values_v v
                    WHERE
                        v.code       = 'PLAN_FREQUENCY' AND
                        v.code_value = t.plan_frequency
                    ) plan_frequency_n,
                    h.description,
                    h.wfl_instance_id,
                    h.status,
                    (SELECT
                        v.code_value_name
                    FROM
                        sys_code_values_v v
                    WHERE
                        v.code       = 'VIRTUAL_CON_CONTENT_STATUS' AND
                        v.code_value = h.status
                    ) status_n
                FROM
                    sdic_fin_plan_rpt_quarter_hd h,
                    sdic_fin_plan_base_data t
                WHERE
                    h.data_id = t.data_id
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:query-sql><![CDATA[
            begin
               sdic_fin_plan_rpt_pkg.del_sdic_fin_plan_rpt_quart_hd(p_hd_id =>${@hd_id});
            end;
        ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:query-sql><![CDATA[
            begin
               sdic_fin_plan_rpt_pkg.sdic_fin_plan_quarter_hd_sub(p_hd_id =>${@hd_id},
                                                                p_company_id=>${/session/@company_id},
                                                                p_user_id=>${/session/@user_id});
            end;
        ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="hd_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
