<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="ACR_INVOICE_LN_LV">
    <bm:fields>
        <bm:field name="invoice_ln_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INVOICE_LN_ID"
                  prompt="ACR_INVOICE_LN_LV.INVOICE_LN_ID"/>
        <bm:field name="invoice_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INVOICE_HD_ID"
                  prompt="ACR_INVOICE_LN_LV.INVOICE_HD_ID"/>
        <bm:field name="line_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LINE_TYPE"
                  prompt="ACR_INVOICE_LN_LV.LINE_TYPE"/>
        <bm:field name="line_type_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LINE_TYPE_N"
                  prompt="ACR_INVOICE_LN_LV.LINE_TYPE_N"/>
        <bm:field name="line_number" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LINE_NUMBER"
                  prompt="ACR_INVOICE_LN_LV.LINE_NUMBER"/>
        <bm:field name="cashflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CASHFLOW_ID"
                  prompt="ACR_INVOICE_LN_LV.CASHFLOW_ID"/>
        <bm:field name="cf_item" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_ITEM"
                  prompt="ACR_INVOICE_LN_LV.CF_ITEM"/>
        <bm:field name="cf_item_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_ITEM_N"
                  prompt="ACR_INVOICE_LN_LV.CF_ITEM_N"/>
        <bm:field name="cf_type" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CF_TYPE"
                  prompt="ACR_INVOICE_LN_LV.CF_TYPE"/>
        <bm:field name="cf_type_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CF_TYPE_N"
                  prompt="ACR_INVOICE_LN_LV.CF_TYPE_N"/>
        <bm:field name="product_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRODUCT_ID"
                  prompt="ACR_INVOICE_LN_LV.PRODUCT_ID"/>
        <bm:field name="product_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRODUCT_NAME"
                  prompt="ACR_INVOICE_LN_LV.PRODUCT_NAME"/>
        <bm:field name="specification" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SPECIFICATION"
                  prompt="ACR_INVOICE_LN_LV.SPECIFICATION"/>
        <bm:field name="quantity" databaseType="NUMBER" datatype="java.lang.Long" physicalName="QUANTITY"
                  prompt="ACR_INVOICE_LN_LV.QUANTITY"/>
        <bm:field name="uom" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UOM"
                  prompt="ACR_INVOICE_LN_LV.UOM"/>
        <bm:field name="uom_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UOM_N"
                  prompt="ACR_INVOICE_LN_LV.UOM_N"/>
        <bm:field name="price" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRICE"
                  prompt="ACR_INVOICE_LN_LV.PRICE"/>
        <bm:field name="price_quantity" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRICE_QUANTITY"
                  prompt="ACR_INVOICE_LN_LV.PRICE_QUANTITY"/>
        <bm:field name="price_quantity_uom" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="PRICE_QUANTITY_UOM" prompt="ACR_INVOICE_LN_LV.PRICE_QUANTITY_UOM"/>
        <bm:field name="price_quantity_uom_n" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="PRICE_QUANTITY_UOM_N" prompt="ACR_INVOICE_LN_LV.PRICE_QUANTITY_UOM_N"/>
        <bm:field name="net_price" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NET_PRICE"
                  prompt="ACR_INVOICE_LN_LV.NET_PRICE"/>
        <bm:field name="tax_type_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TAX_TYPE_ID"
                  prompt="ACR_INVOICE_LN_LV.TAX_TYPE_ID"/>
        <bm:field name="tax_type_id_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAX_TYPE_ID_N"
                  prompt="ACR_INVOICE_LN_LV.TAX_TYPE_ID_N"/>
        <bm:field name="tax_type_rate" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TAX_TYPE_RATE"
                  prompt="ACR_INVOICE_LN_LV.TAX_TYPE_RATE"/>
        <bm:field name="tax_included_flag" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="TAX_INCLUDED_FLAG" prompt="ACR_INVOICE_LN_LV.TAX_INCLUDED_FLAG"/>
        <bm:field name="tax_amount" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAX_AMOUNT"
                  prompt="ACR_INVOICE_LN_LV.TAX_AMOUNT"/>
        <bm:field name="net_amount" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NET_AMOUNT"
                  prompt="ACR_INVOICE_LN_LV.NET_AMOUNT"/>
        <bm:field name="total_amount" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TOTAL_AMOUNT"
                  prompt="ACR_INVOICE_LN_LV.TOTAL_AMOUNT"/>
        <bm:field name="responsibility_center_id" databaseType="NUMBER" datatype="java.lang.Long"
                  physicalName="RESPONSIBILITY_CENTER_ID" prompt="ACR_INVOICE_LN_LV.RESPONSIBILITY_CENTER_ID"/>
        <bm:field name="responsibility_center_id_n" databaseType="VARCHAR2" datatype="java.lang.String"
                  physicalName="RESPONSIBILITY_CENTER_ID_N" prompt="ACR_INVOICE_LN_LV.RESPONSIBILITY_CENTER_ID_N"/>
        <bm:field name="account_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ACCOUNT_ID"
                  prompt="ACR_INVOICE_LN_LV.ACCOUNT_ID"/>
        <bm:field name="account_id_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ACCOUNT_ID_N"
                  prompt="ACR_INVOICE_LN_LV.ACCOUNT_ID_N"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION"
                  prompt="ACR_INVOICE_LN_LV.DESCRIPTION"/>
        <bm:field name="goodstaxno"/>
        <bm:field name="goodsnover"/>
    </bm:fields>
    <bm:features>
        <f:standard-who xmlns:f="leaf.database.features"/>
    </bm:features>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                Select e.invoice_ln_id,
                e.invoice_hd_id,
                e.line_type,
                e.line_type_n,
                e.line_number,
                e.cashflow_id,
                e.cf_item,
                e.cf_item_n,
                e.cf_type,
                e.cf_type_n,
                e.product_id,
                e.product_name,
                e.specification,
                e.quantity,
                e.uom,
                e.uom_n,
                to_char(e.price)price,
                e.price_quantity,
                e.price_quantity_uom,
                e.price_quantity_uom_n,
                e.net_price,
                e.tax_type_id,
                e.tax_type_id_n,
                (e.tax_type_rate*100) tax_type_rate,
                e.tax_included_flag,
                to_char(e.tax_amount)tax_amount,
                to_char(e.net_amount)net_amount,
                to_char(e.total_amount)total_amount,
                e.responsibility_center_id,
                e.responsibility_center_id_n,
                e.account_id,
                e.account_id_n,
                e.description,
                (Select tax_class_num
                From ds_tax_class_num a
                Where a.contract_type = e.business_type
                And a.division = e.division
                And a.cf_item = e.cf_item) goodstaxno,
                (Select goods_version
                From ds_tax_class_num a
                Where a.contract_type = e.business_type
                And a.division = e.division
                And a.cf_item = e.cf_item) goodsnover
                From acr_invoice_ln_lv e
                WHERE e.invoice_hd_id = ${@invoice_hd_id}
                ]]>
            </bm:query-sql>

        </bm:operation>

        <bm:operation name="batch_update">
            <bm:parameters>
                <bm:parameter name="p_check_flag" dataType="java.lang.String" input="false" output="true"
                              outputPath="@p_check_flag"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[ begin
                acr_invoice_pkg.check_inv_goodstaxno(p_invoice_hd_id => ${@invoice_hd_id},
                p_check_flag => null);
                end;
                ]]>
            </bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
