<?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
                        ln.bp_credit_line_id,
                        ln.bp_credit_hd_id,
                        ln.bp_id,
                        bp.bp_code,
                        bp.bp_name,
                        bp.bp_category,
                        ln.credit_number,
                        (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,
                        ln.credit_total_amount,
                        ln.open_amount,
                        TO_CHAR(ln.credit_date_from, 'yyyy-mm-dd') credit_date_from,
                        TO_CHAR(ln.credit_date_to, 'yyyy-mm-dd') credit_date_to,
                        ln.enable_flag
                    FROM
                        hls_bp_master_credit_ln ln,
                        hls_bp_master bp
                    WHERE
                        ln.bp_id           = bp.bp_id AND
                        ln.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_ln_save(p_bp_credit_line_id =>${@bp_credit_line_id},
                               p_bp_credit_hd_id   => ${@bp_credit_hd_id},
                               p_bp_id             => ${@bp_id},
                               p_credit_number     => ${@credit_number},
                               p_total_amount      =>${@credit_total_amount},
                               p_open_amount       =>${@open_amount},
                               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="credit_total_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CREDIT_TOTAL_AMOUNT"/>
        <bm:field name="open_amount" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OPEN_AMOUNT"/>
        <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="bp_credit_line_id"/>
        <bm:field name="credit_number"/>
    </bm:fields>
</bm:model>
