📄 docline_cash.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.acct;
import java.math.*;
import java.sql.*;
import org.compiere.util.*;
import org.compiere.model.*;
/**
* Cash Journal Line
*
* @author Jorg Janke
* @version $Id: DocLine_Cash.java,v 1.6 2003/04/30 06:26:09 jjanke Exp $
*/
public class DocLine_Cash extends DocLine
{
/**
* Cosntructor
* @param DocumentType document type
* @param TrxHeader_ID trx header
* @param TrxLine_ID trx line
*/
public DocLine_Cash (String DocumentType, int TrxHeader_ID, int TrxLine_ID)
{
super (DocumentType, TrxHeader_ID, TrxLine_ID);
} // DocLine_Cash
/** Cash Type */
private String m_CashType = "";
// AD_Reference_ID=217
public static final String CASHTYPE_CHARGE = "C";
public static final String CASHTYPE_DIFFERENCE = "D";
public static final String CASHTYPE_EXPENSE = "E";
public static final String CASHTYPE_INVOICE = "I";
public static final String CASHTYPE_RECEIPT = "R";
public static final String CASHTYPE_TRANSFER = "T";
// References
private int m_C_BankAccount_ID = 0;
private int m_C_Invoice_ID = 0;
private int m_C_BPartner_ID = 0;
//
private int m_C_Currency_ID = -1;
private int m_AD_Org_ID = -1;
// Amounts
private BigDecimal m_Amount = Env.ZERO;
private BigDecimal m_DiscountAmt = Env.ZERO;
private BigDecimal m_WriteOffAmt = Env.ZERO;
/**
* Set Cash Type
* @param CashType see CASHTYPE_*
*/
public void setCashType(String CashType)
{
if (CashType != null)
m_CashType = CashType;
} // setCashType
/**
* Get Cash Type
* @return cash type
*/
public String getCashType()
{
return m_CashType;
} // getCashType
/**
* Set References
* @param C_BankAccount_ID bank account
* @param C_Invoice_ID invoice
*/
public void setReference (int C_BankAccount_ID, int C_Invoice_ID)
{
m_C_BankAccount_ID = C_BankAccount_ID;
m_C_Invoice_ID = C_Invoice_ID;
setReferenceInfo();
} // setReference
/**
* Get Bank Account
* @return Bank Account
*/
public int getC_BankAccount_ID()
{
return m_C_BankAccount_ID;
} // getC_BankAccount_ID
/**
* Get Invoice
* @return C_Invoice_ID
*/
public int getC_Invoice_ID()
{
return m_C_Invoice_ID;
} // getC_Invoice_ID
/**
* Set Amounts
* @param Amount payment amount
* @param DiscountAmt discount
* @param WriteOffAmt wrire-off
*/
public void setAmount(BigDecimal Amount, BigDecimal DiscountAmt, BigDecimal WriteOffAmt)
{
if (Amount != null)
m_Amount = Amount;
if (DiscountAmt != null)
m_DiscountAmt = DiscountAmt;
if (WriteOffAmt != null)
m_WriteOffAmt = WriteOffAmt;
//
setAmount(Amount);
} // setAmount
/**
* Get Amount
* @return Payment Amount
*/
public BigDecimal getAmount()
{
return m_Amount;
}
/**
* Get Discount
* @return Discount Amount
*/
public BigDecimal getDiscountAmt()
{
return m_DiscountAmt;
}
/**
* Get WriteOff
* @return Write-Off Amount
*/
public BigDecimal getWriteOffAmt()
{
return m_WriteOffAmt;
}
/**
* Get Currency of invoice or bank
* @return C_Currency_ID
*/
public int getC_Currency_ID()
{
if (m_C_BankAccount_ID == 0 && m_C_Invoice_ID == 0)
return super.getC_Currency_ID();
if (m_C_Currency_ID == -1)
setReferenceInfo();
return m_C_Currency_ID;
} // getC_Currency_ID
/**
* Get Organization of invoice or bank
* @return AD_Org_ID
*/
public int getAD_Org_ID()
{
if (m_C_BankAccount_ID == 0 && m_C_Invoice_ID == 0)
return super.getAD_Org_ID();
if (m_AD_Org_ID == -1)
setReferenceInfo();
return m_AD_Org_ID;
} // getAD_Org_ID
/**
* Get BPartner of Invoice
* @return C_BPartner_ID
*/
public int getC_BPartner_ID()
{
if (m_C_Invoice_ID == 0)
return super.getC_BPartner_ID();
if (m_C_BPartner_ID == -1)
setReferenceInfo();
return m_C_BPartner_ID;
} // getC_BPartner_ID
/**
* Get Reference Info
* - Organization
* - Currency
* - BPartner
*/
private void setReferenceInfo()
{
m_C_Currency_ID = 0;
m_AD_Org_ID = 0;
m_C_BPartner_ID = 0;
String sql = null;
int parameter = 0;
// Bank Account Info
if (m_C_BankAccount_ID != 0)
{
sql = "SELECT AD_Org_ID, C_Currency_ID, 0 FROM C_BankAccount WHERE C_BankAccount_ID=?";
parameter = m_C_BankAccount_ID;
}
else if (m_C_Invoice_ID != 0)
{
sql = "SELECT AD_Org_ID, C_Currency_ID, C_BPartner_ID FROM C_Invoice WHERE C_Invoice_ID=?";
parameter = m_C_Invoice_ID;
}
else
return;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, parameter);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
m_AD_Org_ID = rs.getInt(1);
m_C_Currency_ID = rs.getInt(2);
m_C_BPartner_ID = rs.getInt(3);
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.error("setReferenceInfo", e);
}
} // setReferenceInfo
} // DocLine_Cash
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -