<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="fcr" baseTable="fnd_coding_rules">
    <bm:fields>
        <bm:field name="coding_rule_id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="coding_rule_code" databaseType="VARCHAR2" datatype="java.lang.String" prompt="HLS.CODING_RULE_CODE"/>
        <bm:field name="description_id" databaseType="NUMBER" datatype="java.lang.Long" multiLanguage="true" multiLanguageDescField="coding_rule_desc"/>
        <bm:field name="coding_rule_desc" forInsert="false" forUpdate="false" prompt="HLS.CODING_RULE_DESC"/>
        <bm:field name="note" databaseType="VARCHAR2" datatype="java.lang.String" prompt="FND1910.FND_CODING_RULES.NOTE"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="reset_frequence" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="reset_frequence_name" forInsert="false" forUpdate="false" prompt="FND1910.FND_CODING_RULES.RESET_FREQUENCE"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" prompt="单据类别"/>
        <bm:field name="document_category_desc" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT t1.coding_rule_id,
				       t1.document_category,
				       (SELECT d.description
				          FROM fnd_code_rule_doc_category_v d
				         WHERE d.document_category = t1.document_category) AS document_category_desc,
				       t1.coding_rule_code,
				       t1.description_id,
				       (SELECT description_text
				          FROM fnd_descriptions f
				         WHERE description_id = t1.description_id
				           AND f.Language = userenv('LANG')) AS coding_rule_desc,
				       t1.note,
				       t1.reset_frequence,
				       (SELECT v.code_value_name
				          FROM sys_code_values_v v
				         WHERE v.code = 'CODING_RULE_RESET_FREQUENCY'
				           AND v.code_value = t1.reset_frequence) AS reset_frequence_name,
				       t1.enabled_flag
 				 FROM fnd_coding_rules t1
				  #WHERE_CLAUSE#
				  order by t1.coding_rule_code
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:primary-key>
        <bm:pk-field name="coding_rule_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="document_category" queryOperator="="/>
        <bm:query-field field="coding_rule_code" queryExpression="t1.coding_rule_code like  &apos;%&apos;||${@coding_rule_code}||&apos;%&apos;"/>
        <bm:query-field field="reset_frequence" queryOperator="="/>
        <bm:query-field field="enabled_flag" queryExpression="((decode(${@enabled_flag},&apos;ALL&apos;,1,0) = 1) or t1.enabled_flag = ${@enabled_flag})  "/>
    </bm:query-fields>
    <bm:features>
        <o:sequence-pk/>
        <f:standard-who/>
        <f:multi-language-storage/>
    </bm:features>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="FND1910.ERROR.CODING_RULE_CODE_REPEATED"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
