<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: WangYu  
    $Date: 2014-12-16 下午12:43:22  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false" defaultOrderBy="enabled_flag desc,order_seq">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[select * from  (SELECT t1.PRICE_LIST, t1.DESCRIPTION, t1.CALC_METHOD, t1.AUTHORITY_GROUP,t1.enabled_flag,t1.order_seq
  FROM HLS_PRICE_LIST t1
 WHERE exists (select 1
          from hls_price_list_assign t
         where t.price_list = t1.price_list
           and t.company_id =  ${/session/@company_id})
   and exists
 (select 1
          from hls_price_list_conds_lease b,
               exp_org_unit_vl            t1,
               exp_emp_assign_e_v         t2
         where b.price_list = t1.price_list
           and t2.user_id =  ${/session/@user_id}
           and t1.UNIT_ID = t2.unit_id
           and (t1.yonda_organization_code = b.lease_organization or
               b.lease_org_unit = t2.unit_id))
   AND t1.enabled_flag = 'Y'
union
select a.price_list, a.description ,a.CALC_METHOD, a.AUTHORITY_GROUP,a.enabled_flag,a.order_seq
  from hls_price_list a
 where a.enabled_flag = 'Y'
   and exists (select 1
          from hls_price_list_assign t
         where t.price_list = a.price_list
           and t.company_id = ${/session/@company_id})
   and not exists (select 1
          from hls_price_list_conds_lease t
         where t.price_list = a.price_list)) aa #WHERE_CLAUSE# #ORDER_BY_CLAUSE#]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="price_list" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forInsert="true" forQuery="true" physicalName="PRICE_LIST"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="300" forDisplay="true" forInsert="true" physicalName="DESCRIPTION"/>
        <bm:field name="calc_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CALC_METHOD"/>
        <bm:field name="authority_group" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AUTHORITY_GROUP"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="price_list" queryOperator="="/>
    </bm:query-fields>
</bm:model>
