<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Feng  
    $Date: 2014-5-27 下午3:27:23  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="ACP_INVOICE_HD_V">
    <bm:fields>
        <bm:field name="invoice_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INVOICE_HD_ID" prompt="ACP_INVOICE_HD_V.INVOICE_HD_ID"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID" prompt="ACP_INVOICE_HD_V.COMPANY_ID"/>
        <bm:field name="document_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_NUMBER" prompt="ACP_INVOICE_HD_V.DOCUMENT_NUMBER"/>
        <bm:field name="document_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY" prompt="ACP_INVOICE_HD_V.DOCUMENT_CATEGORY"/>
        <bm:field name="document_category_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DOCUMENT_CATEGORY_DESC" prompt="ACP_INVOICE_HD_V.DOCUMENT_CATEGORY_DESC"/>
        <bm:field name="invoice_title" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_TITLE" prompt="ACP_INVOICE_HD_V.INVOICE_TITLE"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="ACP_INVOICE_HD_V.DESCRIPTION"/>
        <bm:field name="total_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TOTAL_AMOUNT" prompt="ACP_INVOICE_HD_V.TOTAL_AMOUNT"/>
        <bm:field name="tax_amount" databaseType="NUMBER" datatype="java.lang.Double" physicalName="TAX_AMOUNT" prompt="ACP_INVOICE_HD_V.TAX_AMOUNT"/>
        <bm:field name="internal_period_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INTERNAL_PERIOD_NUM" prompt="ACP_INVOICE_HD_V.INTERNAL_PERIOD_NUM"/>
        <bm:field name="period_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERIOD_NAME" prompt="ACP_INVOICE_HD_V.PERIOD_NAME"/>
        <bm:field name="accounting_date" databaseType="DATE" datatype="java.util.Date" physicalName="ACCOUNTING_DATE" prompt="ACP_INVOICE_HD_V.ACCOUNTING_DATE"/>
        <bm:field name="invoice_date" databaseType="DATE" datatype="java.util.Date" physicalName="INVOICE_DATE" prompt="ACP_INVOICE_HD_V.INVOICE_DATE"/>
        <bm:field name="invoice_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_NUMBER" prompt="ACP_INVOICE_HD_V.INVOICE_NUMBER"/>
        <bm:field name="invoice_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_STATUS" prompt="ACP_INVOICE_HD_V.INVOICE_STATUS"/>
        <bm:field name="invoice_status_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INVOICE_STATUS_DESC" prompt="ACP_INVOICE_HD_V.INVOICE_STATUS_DESC"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="ACP_INVOICE_HD_V.CONTRACT_ID"/>
        <bm:field name="contract_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NUMBER" prompt="ACP_INVOICE_HD_V.CONTRACT_NUMBER"/>
        <bm:field name="contract_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTRACT_NAME" prompt="ACP_INVOICE_HD_V.CONTRACT_NAME"/>
        <bm:field name="reversed_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REVERSED_FLAG" prompt="ACP_INVOICE_HD_V.REVERSED_FLAG"/>
        <bm:field name="reversed_flag_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REVERSED_FLAG_DESC" prompt="ACP_INVOICE_HD_V.REVERSED_FLAG_DESC"/>
        <bm:field name="reversed_date" databaseType="DATE" datatype="java.util.Date" physicalName="REVERSED_DATE" prompt="ACP_INVOICE_HD_V.REVERSED_DATE"/>
        <bm:field name="confirmed_date" databaseType="DATE" datatype="java.util.Date" physicalName="CONFIRMED_DATE" prompt="ACP_INVOICE_HD_V.CONFIRMED_DATE"/>
        <bm:field name="confirmed_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONFIRMED_BY" prompt="ACP_INVOICE_HD_V.CONFIRMED_BY"/>
        <bm:field name="confirmed_by_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONFIRMED_BY_NAME" prompt="ACP_INVOICE_HD_V.CONFIRMED_BY_NAME"/>
        <bm:field name="posted_date" databaseType="DATE" datatype="java.util.Date" physicalName="POSTED_DATE" prompt="ACP_INVOICE_HD_V.POSTED_DATE"/>
        <bm:field name="posted_by" databaseType="NUMBER" datatype="java.lang.Long" physicalName="POSTED_BY" prompt="ACP_INVOICE_HD_V.POSTED_BY"/>
        <bm:field name="posted_by_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="POSTED_BY_NAME" prompt="ACP_INVOICE_HD_V.POSTED_BY_NAME"/>
        <bm:field name="created_by_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CREATED_BY_NAME" prompt="ACP_INVOICE_HD_V.CREATED_BY_NAME"/>
        <bm:field name="owner_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OWNER_USER_ID" prompt="ACP_INVOICE_HD_V.OWNER_USER_ID"/>
        <bm:field name="owner_user_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OWNER_USER_NAME" prompt="ACP_INVOICE_HD_V.OWNER_USER_NAME"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field field="invoice_hd_id" queryOperator="="/>
    </bm:query-fields>
    <bm:operations>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
                BEGIN
                    ACP_INVOICE_PKG.save_invoice(p_invoice_hd_id => ${@invoice_hd_id}, 
                    p_invoice_number => ${@invoice_number}, 
                    p_invoice_date         => to_date(${@invoice_date},'yyyy-mm-dd'),
						                           p_accounting_date      => to_date(${@accounting_date},'yyyy-mm-dd'), 
						                           p_company_id           => ${@company_id},
						                           p_user_id => ${/session/@user_id});
                END;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
