<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-9-5 下午02:31:29  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            
            	select sc.result_id,
				       sc.sc_score_id,
				       sc.template_type,
                       sc.last_updated_by,
                      (select u.user_name from sys_user u where u.user_id=sc.last_updated_by) last_update_name,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'FND_SC_TEMPLATE_TYPE'
				           and v.code_value = sc.template_type) as template_type_desc,
				       sc.object_id,
				       decode(sc.template_type,
				              'LGD',
				              (select prj.project_name
				                 from prj_project prj
				                where prj.project_id = sc.object_id),
				              'PD',
				              (select bp.bp_name
				                 from hls_bp_master bp
				                where bp.bp_id = sc.object_id),
				              '') object_name,
				       sc.score_template_id,
				       (select te.score_template_name
				          from fnd_score_template te
				         where te.score_template_id = sc.score_template_id) template_name,
				       sc.internal_period_num,
				       sc.score_date,
				       sc.description,
				       sc.score_result,
				       sc.status,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'FND_SCORE_CARD_APPROVAL_STATUS'
				           and sc.status = v.code_value) status_desc,
				           sc.ref_v01,
				           sc.ref_v02,
				           sc.ref_v03,
				          sc.net_capital
				  from fnd_sc_score_result sc
				  #WHERE_CLAUSE#
 
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="sc.sc_score_id = ${@sc_score_id}"/>
    </bm:data-filters>
    <bm:fields>
        <bm:field name="sc_score_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SC_SCORE_ID"/>
        <bm:field name="result_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RESULT_ID"/>
        <bm:field name="template_type"/>
        <bm:field name="template_name"/>
        <bm:field name="template_type_desc"/>
        <bm:field name="object_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OBJECT_ID"/>
        <bm:field name="object_name"/>
        <bm:field name="last_updated_by" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="last_update_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="score_template_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SCORE_TEMPLATE_ID"/>
        <bm:field name="internal_period_num" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="score_result" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="score_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS"/>
        <bm:field name="ref_v01"/>
        <bm:field name="ref_v02"/>
        <bm:field name="ref_v03"/>
        <bm:field name="net_capital" databaseType="VARCHAR2" datatype="java.lang.String"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="object_id" queryOperator="="/>
        <bm:query-field field="object_name" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
