<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Leaf Generator
    $Date: Tue Sep 04 12:50:25 CST 2018  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:o="leaf.database.local.oracle"
          xmlns:f="leaf.database.features" alias="t1" baseTable="ds_tax_class_num" needAccessControl="false">
    <bm:fields>
        <bm:field name="class_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CLASS_ID" prompt="DS_TAX_CLASS_NUM.CLASS_ID"/>
        <bm:field name="contract_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_TYPE" prompt="DS_TAX_CLASS_NUM.CONTRACT_TYPE"/>
        <bm:field name="division" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DIVISION" prompt="DS_TAX_CLASS_NUM.DIVISION"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM" prompt="DS_TAX_CLASS_NUM.CF_ITEM"/>
        <bm:field name="cf_type" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_TYPE" prompt="DS_TAX_CLASS_NUM.CF_TYPE"/>
        <bm:field name="tax_class_num" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAX_CLASS_NUM" prompt="DS_TAX_CLASS_NUM.TAX_CLASS_NUM"/>
        <bm:field name="goods_version" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="GOODS_VERSION" prompt="DS_TAX_CLASS_NUM.GOODS_VERSION"/>
    </bm:fields>
    <bm:features>
        <f:standard-who xmlns:f="leaf.database.features"/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="class_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            SELECT * FROM (
               SELECT dt.class_id,
       dt.contract_type,
       (select hbt.description
          from hls_business_type hbt
         where dt.contract_type = hbt.business_type) as contract_type_n,
       dt.division,
       (select hd.description
          from hls_division hd
         where dt.division = hd.division) as division_n,
       dt.cf_item,
       (select hci.description
          from hls_cashflow_item hci
         where dt.cf_item = hci.cf_item) as cf_item_n,
       dt.cf_type,
       (select hct.description
          from hls_cashflow_type hct
         where dt.cf_type = hct.cf_type) as cf_type_n,
       tax_class_num,
       goods_version
  FROM DS_TAX_CLASS_NUM dt
                  ) t
                #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
            ds_tax_class_num_pkg.insert_tax_information(
                               p_class_id		    =>    ${@class_id},
                               p_contract_type      =>    ${@contract_type},
                               p_division           =>    ${@division},
				               p_cf_item		    =>    ${@cf_item},
				               p_cf_type	        =>    ${@cf_type},
				               p_tax_class_num      =>    ${@tax_class_num},
				               p_goods_version      =>    ${@goods_version},
				               p_created_by	        =>    ${/session/@user_id});
            end;]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin


                ds_tax_class_num_pkg.update_tax_info(p_class_id       => ${@class_id},
                                                    p_division        => ${@division},
                                                    p_contract_type   => ${@contract_type},
                                                    p_cf_item         => ${@cf_item},
                                                    p_tax_class_num   => ${@tax_class_num},
                                                    p_goods_version   => ${@goods_version},
                                                    p_user_id         => ${/session/@user_id});
            end;]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="contract_type" queryExpression="t.contract_type = ${@contract_type}"/>
        <bm:query-field name="division" queryExpression="t.division = ${@division}"/>
        <bm:query-field name="cf_item" queryExpression="t.cf_item = ${@cf_item}"/>
        <bm:query-field name="cf_type" queryExpression="t.cf_type = ${@cf_type_f}"/>
        <bm:query-field name="tax_class_num" queryExpression="t.tax_class_num = ${@tax_class_num}"/>
    </bm:query-fields>
</bm:model>