<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="a" extend="fnd.fnd_coding_rule_objects" extendMode="reference">
    <bm:fields>
        <bm:field name="coding_rule_object_id"/>
        <bm:field name="document_category" prompt="HLS.DOCUMENT_CATEGORY"/>
        <bm:field name="document_category_desc" prompt="HLS.DOCUMENT_CATEGORY_DESC"/>
        <bm:field name="priority" prompt="HLS.PRIORITY"/>
        <bm:field name="document_type" prompt="HLS.DOCUMENT_TYPE"/>
        <bm:field name="document_type_desc" prompt="HLS.DOCUMENT_TYPE_DESC"/>
        <bm:field name="company_id"/>
        <bm:field name="company_code" prompt="HLS.COMPANY_CODE"/>
        <bm:field name="company_short_name" prompt="HLS.COMPANY_SHORT_NAME"/>
        <bm:field name="enabled_flag" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="operation_unit_id"/>
        <bm:field name="operation_unit_name" prompt="HLS.OPERATION_UNIT"/>
        <bm:field name="coding_rule_desc"/>
        <bm:field name="coding_rule_id"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT t1.coding_rule_object_id,
				       t1.document_category,
				       t1.document_category_desc,
				       t1.priority,
				       t1.document_type,
				       t1.document_type_desc,
				       t1.company_id,
				       t1.company_code,
				       t1.company_short_name,
				       t1.enabled_flag,
				       t1.operation_unit_id,
				       t1.operation_unit_name,
				       (select description_text
			          from fnd_descriptions f
			         where description_id = (select description_id from fnd_coding_rules r where r.coding_rule_id = t1.coding_rule_id)
			           AND f.Language = userenv('LANG')
			           )coding_rule_desc,
           			t1.coding_rule_id
				  FROM fnd_coding_rule_object_v t1
				  #WHERE_CLAUSE#
				 order by t1.document_category, t1.priority
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:primary-key>
        <bm:pk-field name="coding_rule_object_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="coding_rule_object_id" queryOperator="="/>
        <bm:query-field field="company_id" queryOperator="="/>
        <bm:query-field field="document_type_desc" queryOperator="like"/>
        <bm:query-field field="document_category" queryOperator="="/>
        <bm:query-field field="operation_unit_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
