<?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
                    t1.*
                FROM
                    (SELECT
                        ha.assign_id,
                        ha.bp_credit_hd_id,
                        ha.bp_id,
                        bp.bp_code,
                        bp.bp_name,
                        bp.bp_category,
                        (SELECT
                            v.code_value_name
                        FROM
                            sys_code_values_v v
                        WHERE
                            v.code              = 'BP_CATEGORY' AND
                            v.code_enabled_flag = 'Y' AND
                            v.code_value        = bp.bp_category
                        ) bp_category_n,
                        TO_CHAR(ha.credit_date_from, 'yyyy-mm-dd') credit_date_from,
                        TO_CHAR(ha.credit_date_to, 'yyyy-mm-dd') credit_date_to,
                        ha.enable_flag
                    FROM
                        hls_bp_master_credit_assign ha,
                        hls_bp_master bp
                    WHERE
                        ha.bp_id           = bp.bp_id AND
                        ha.bp_credit_hd_id = ${@bp_credit_hd_id}
                    ) t1
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
               begin
               
               
               hls_bp_master_credit_pkg.hls_credit_assign_save(p_assign_id        => ${@assign_id},
                                   						       p_bp_credit_hd_id  => ${@bp_credit_hd_id},
                                   							   p_bp_id            => ${@bp_id},
                                  							   p_credit_date_from => to_date(${@credit_date_from},'yyyy-mm-dd'),
                               								   p_credit_date_to   => to_date(${@credit_date_to},'yyyy-mm-dd'),
                                 							   p_enable_flag      => ${@enable_flag},
                               								   p_user_id          => ${/session/@user_id});
              
               end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="bp_credit_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_CREDIT_HD_ID"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BP_ID"/>
        <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="bp_category"/>
        <bm:field name="bp_category_n"/>
        <bm:field name="credit_date_from"/>
        <bm:field name="credit_date_to"/>
        <bm:field name="enable_flag"/>
        <bm:field name="assign_id"/>
    </bm:fields>
</bm:model>
