<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" baseTable="hls_lease_arch_agreement" alias="t1" needAccessControl="false">
    <bm:fields>
        <bm:field name="agreement_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="bp_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="bp_name" forUpdate="false" forInsert="false" prompt="客户名称"/>
        <bm:field name="firm_cd"/>
        <bm:field name="cust_no"/>
        <bm:field name="seq"/>
        <bm:field name="lmt_amt" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="lmt_jamt" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="strt_ymd" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="expr_ymd" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="obtn_cst_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="assu_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="imp_fee_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="stm_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="uarv_rtn_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="mrepay_fee_ratio" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="sngl_unt_cd"/>
        <bm:field name="sngl_unt_cd_n" forUpdate="false" forInsert="false"/>
        <bm:field name="sngl_prc_cd"/>
        <bm:field name="sngl_prc_cd_n" forUpdate="false" forInsert="false"/>
        <bm:field name="trm_calc_way"/>
        <bm:field name="trm_calc_way_n" forUpdate="false" forInsert="false"/>
        <bm:field name="cnfm_ymd" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="cnfm_empno"/>
        <bm:field name="status"/>
        <bm:field name="history_flag" forUpdate="false" forInsert="false"/>
    </bm:fields>
    <bm:primary-key>
        <bm:pk-field name="agreement_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
     select * from (select
       t.agreement_id,
       t.bp_id,
       (select h.bp_name from hls_bp_master h where h.bp_id = t.bp_id) bp_name,
       t.firm_cd,
       t.cust_no,
       t.seq,
       t.lmt_amt,
       t.lmt_jamt,
       to_date(t.strt_ymd,'yyyy-mm-dd') strt_ymd,
       to_date(t.expr_ymd,'yyyy-mm-dd') expr_ymd,
       t.obtn_cst_ratio,
       t.assu_ratio,
       t.imp_fee_ratio,
       t.stm_ratio,
       t.uarv_rtn_ratio,
       t.mrepay_fee_ratio,
       t.sngl_unt_cd,
       (select v.code_value_name
          from sys_code_values_v v
         where v.code = 'HLS_SNGL_UNT_CD'
           and v.code_value = t.sngl_unt_cd) sngl_unt_cd_n,
       t.sngl_prc_cd,
       (select v.code_value_name
          from sys_code_values_v v
         where v.code = 'HLS_SNGL_PRC_CD'
           and v.code_value = t.sngl_prc_cd) sngl_prc_cd_n,
       t.trm_calc_way,
       (select v.code_value_name
          from sys_code_values_v v
         where v.code = 'HLS_TRM_CALC_WAY'
           and v.code_value = t.trm_calc_way) trm_calc_way_n,
       to_date(t.cnfm_ymd,'yyyy-mm-dd') cnfm_ymd,
       t.cnfm_empno,
       t.status,
       t.history_flag
  from hls_lease_arch_agreement t)t1

                #WHERE_CLAUSE#
                #ORDER_BY_CLAUSE#
                ]]></bm:query-sql>
        </bm:operation>

    <bm:operation name="insert">
        <bm:update-sql><![CDATA[
            begin
                hls_lease_arch_agreement_pkg.arch_agreement_update(p_agreement_id => ${@agreement_id},
                                  p_bp_id           => ${@bp_id},
                                  p_firm_cd         => ${@firm_cd},
                                  p_cust_no         => ${@cust_no},
                                  p_seq             => ${@seq},
                                  p_lmt_amt         => ${@lmt_amt},
                                  p_lmt_jamt        => ${@lmt_jamt},
                                  p_strt_ymd        => ${@strt_ymd},
                                  p_expr_ymd        => ${@expr_ymd},
                                  p_obtn_cst_ratio  => ${@obtn_cst_ratio},
                                  p_assu_ratio      => ${@assu_ratio},
                                  p_imp_fee_ratio   => ${@imp_fee_ratio},
                                  p_stm_ratio       => ${@stm_ratio},
                                  p_uarv_rtn_ratio  => ${@uarv_rtn_ratio},
                                  p_mrepay_fee_ratio => ${@mrepay_fee_ratio},
                                  p_sngl_unt_cd     => ${@sngl_unt_cd},
                                  p_sngl_prc_cd     => ${@sngl_prc_cd},
                                  p_trm_calc_way    => ${@trm_calc_way},
                                  p_cnfm_ymd        => ${@cnfm_ymd},
                                  p_cnfm_empno      => ${@cnfm_empno},
                                  p_status          => ${@status},
                                  p_user_id         => ${/session/@user_id});
            end;]]></bm:update-sql>
    </bm:operation>
    <bm:operation name="update">
        <bm:update-sql><![CDATA[
            begin
                hls_lease_arch_agreement_pkg.arch_agreement_update(p_agreement_id => ${@agreement_id},
                                  p_bp_id           => ${@p_bp_id},
                                  p_firm_cd         => ${@firm_cd},
                                  p_cust_no         => ${@cust_no},
                                  p_seq             => ${@seq},
                                  p_lmt_amt         => ${@lmt_amt},
                                  p_lmt_jamt        => ${@lmt_jamt},
                                  p_strt_ymd        => ${@strt_ymd},
                                  p_expr_ymd        => ${@expr_ymd},
                                  p_obtn_cst_ratio  => ${@obtn_cst_ratio},
                                  p_assu_ratio      => ${@assu_ratio},
                                  p_imp_fee_ratio   => ${@imp_fee_ratio},
                                  p_stm_ratio       => ${@stm_ratio},
                                  p_uarv_rtn_ratio  => ${@uarv_rtn_ratio},
                                  p_mrepay_fee_ratio => ${@mrepay_fee_ratio},
                                  p_sngl_unt_cd     => ${@sngl_unt_cd},
                                  p_sngl_prc_cd     => ${@sngl_prc_cd},
                                  p_trm_calc_way    => ${@trm_calc_way},
                                  p_cnfm_ymd        => ${@cnfm_ymd},
                                  p_cnfm_empno      => ${@cnfm_empno},
                                  p_status          => ${@status},
                                  p_user_id         => ${/session/@user_id});
            end;]]></bm:update-sql>
    </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="bp_name" queryOperator="like"/>
        <bm:query-field field="seq" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
