<?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 t.product_plan_id code,
         t.PRODUCT_NAME_WRITE,
         t.if_self_definition,
         t.hd_user_col_v05,
         t.hd_user_col_v05_n,
         t.SPECIAL_NOTE code_name,
         t.DOWN_PAYMENT_RATIO*100 DOWN_PAYMENT_RATIO,
         t.MARGIN_RATIO*100 MARGIN_RATIO,
         t.LEASE_CHARGE_RATIO*100 LEASE_CHARGE_RATIO,
         t.BTB_INT_RATE_IMPLICIT*100 BTB_INT_RATE_IMPLICIT,
         t.TIMES lease_times,
         t.times_n lease_times_n,
         t.REPAYMENTS ANNUAL_PAY_TIMES,
         t.repayments_n ANNUAL_PAY_TIMES_n,
         t.int_rate_display,
         
         t.PRICE_LIST,
        
         (select hl.description  from hls_price_list hl where hl.price_list=t.price_list) 
          price_list_n
          
from HLS_PRODUCT_PLAN_DEFINITION_VL t where t.PRODUCT_NAME_WRITE != 'HAND001' and
 t.product_plan_id in
       (select h.product_plan_id
          from hls_product_plan_district h
         where h.unit_id in
               (Select eou.unit_id
                  From exp_employee_assigns ea,
                       exp_org_position     eop,
                       exp_org_unit         eou,
                       zj_wfl_users_v       a1
                 Where ea.position_id = eop.position_id
                   And eop.unit_id = eou.unit_id
                   And a1.employee_id = ea.employee_id
                   And a1.user_id =${@user_id}
                   And ea.enabled_flag = 'Y'
                   And ea.primary_position_flag = 'Y'))
   and ((t.division = ${@code} and t.status in ('NEW', 'TEST_RUN', 'ONLINE')) or
       (t.division is null and t.status in ('NEW', 'TEST_RUN', 'ONLINE')))

            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CODE" required="true"/>
        <bm:field name="code_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NAME"/>
        <bm:field name="PRODUCT_NAME_WRITE"/>
        <bm:field name="DOWN_PAYMENT_RATIO"/>
        <bm:field name="hd_user_col_v05"/>
        <bm:field name="hd_user_col_v05_n"/>
        <bm:field name="MARGIN_RATIO"/>
        <bm:field name="LEASE_CHARGE_RATIO"/>
        <bm:field name="BTB_INT_RATE_IMPLICIT"/>
        <bm:field name="lease_times"/>
        <bm:field name="lease_times_n"/>
        <bm:field name="ANNUAL_PAY_TIMES"/>
        <bm:field name="ANNUAL_PAY_TIMES_n"/>
        <bm:field name="PRICE_LIST"/>
        <bm:field name="price_list_n"/>
        <bm:field name="int_rate_display"/>
        <bm:field name="if_self_definition"/>
    </bm:fields>
</bm:model>
