📄 naturalaccount.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.model;
import java.sql.*;
import java.io.*;
import java.beans.*;
import org.compiere.util.*;
/**
* Natural Account
*
* @author Jorg Janke
* @version $Id: NaturalAccount.java,v 1.4 2003/01/16 04:33:38 jjanke Exp $
*/
public final class NaturalAccount implements Serializable
{
/**
* Natural Account minumum Constructor
*/
public NaturalAccount()
{
} // NaturalAccount
/**
* Natural Account default Constructor
*
* @param value key value
* @param name name
* @param description description
* @param accountType account type (asset, ..)
* @param accountSign account sign (natural, dr, cr)
* @param docControlled document controlled
* @param summary summary account
*/
public NaturalAccount(String value, String name, String description,
String accountType, String accountSign, boolean docControlled, boolean summary)
{
setValue(value);
setName(name);
setDescription(description);
setAccountType(accountType);
setAccountSign(accountSign);
setDocControlled(docControlled);
setSummary(summary);
//
// Log.trace(Log.l3_Util, "NaturalAccount - " + Value
// + ", AcctType=" + AccountType + ", Sign=" + AccountSign
// + ", Doc=" + DocControlled + ", Summary=" + Summary
// + " - " + Name + " - " + Description);
} // NaturalAccount
/**
* String represntation
* @return name
*/
public String toString()
{
return Name;
} // toString
/**
* Save (new) Element Value
* @param AD_Client_ID client
* @param AD_Org_ID org
* @return 0 if not added
*/
public int save (int AD_Client_ID, int AD_Org_ID)
{
C_ElementValue_ID = DB.getKeyNextNo(AD_Client_ID, "N", "C_ElementValue");
StringBuffer sql = new StringBuffer ("INSERT INTO C_ElementValue "
+ "(C_ELEMENTVALUE_ID,C_ELEMENT_ID,"
+ "AD_CLIENT_ID,AD_ORG_ID,ISACTIVE,CREATED,CREATEDBY,UPDATED,UPDATEDBY,"
+ "VALUE,NAME,DESCRIPTION,"
+ "ACCOUNTTYPE,ACCOUNTSIGN,ISDOCCONTROLLED,ISSUMMARY,VALIDFROM,VALIDTO,"
+ "POSTACTUAL,POSTBUDGET,POSTENCUMBRANCE,POSTSTATISTICAL,"
+ "ISBANKACCOUNT,C_BANKACCOUNT_ID,"
+ "ISFOREIGNCURRENCY,C_CURRENCY_ID) VALUES (");
sql.append(C_ElementValue_ID).append(",").append(C_Element_ID).append(",");
sql.append(AD_Client_ID).append(",").append(AD_Org_ID).append(",");
sql.append("'Y',SysDate,0,SysDate,0,");
sql.append("'").append(Value).append("','").append(Name).append("','").append(Description).append("',");
sql.append("'").append(AccountType).append("','").append(AccountSign).append("',");
sql.append(DocControlled ? "'Y'," : "'N',");
sql.append(Summary ? "'Y'," : "'N',");
sql.append("NULL,NULL,'Y','Y','Y','Y', 'N',NULL, 'N',NULL)");
//
int n = DB.executeUpdate(sql.toString());
if (n != 1)
{
Log.error("NaturalAccount.save - Natural Account not added");
C_ElementValue_ID = 0;
}
return C_ElementValue_ID;
} // save
/*************************************************************************/
private String Name = "";
private String Description = "";
private String Value = "";
private String AccountType = "E";
private int C_Element_ID = 0;
private String AccountSign = "N";
private boolean DocControlled = true;
private boolean Summary = false;
private int C_ElementValue_ID = 0;
/**
* Set Name
* @param newName name
*/
public void setName(String newName)
{
if (newName == null || newName.length() == 0)
throw new IllegalArgumentException("NaturalAccount.Name invalid:");
Name = newName;
}
public String getName()
{
return Name;
}
/**
* Set Description
* @param newDescription description
*/
public void setDescription(String newDescription)
{
if (newDescription != null)
Description = newDescription;
}
public String getDescription()
{
return Description;
}
/**
* Set Value
* @param newValue value/key
*/
public void setValue(String newValue)
{
if (newValue == null || newValue.length() == 0)
throw new IllegalArgumentException("NaturalAccount.Value invalid");
Value = newValue;
}
public String getValue()
{
return Value;
}
/**
* Set AccountType
* @param newAccountType account type A L O E R M
*/
public void setAccountType(String newAccountType)
{
String s = newAccountType.toUpperCase().substring(0,1);
if (s.equals("A") || s.equals("L") || s.equals("O")
|| s.equals("E") || s.equals("R") || s.equals("M"))
AccountType = s;
else
AccountType = "E";
}
public String getAccountType()
{
return AccountType;
}
/**
* Element ID
* @param newC_Element_ID parent ID
*/
public void setC_Element_ID (int newC_Element_ID)
{
C_Element_ID = newC_Element_ID;
}
public int getC_Element_ID()
{
return C_Element_ID;
}
public int getC_ElementValue_ID()
{
return C_ElementValue_ID;
}
/**
* Account Sign
* @param newAccountSign account sign D C N
*/
public void setAccountSign(String newAccountSign)
{
String s = newAccountSign.toUpperCase().substring(0,1);
if (s.equals("D") || s.equals("C"))
AccountSign = s;
else
AccountSign = "N";
}
public String getAccountSign()
{
return AccountSign;
}
/**
* Doc Controlled
* @param newDocControlled document controlled
*/
public void setDocControlled(boolean newDocControlled)
{
DocControlled = newDocControlled;
}
public boolean isDocControlled()
{
return DocControlled;
}
/**
* Summary
* @param newSummary summary account
*/
public void setSummary(boolean newSummary)
{
Summary = newSummary;
}
public boolean isSummary()
{
return Summary;
}
} // NaturalAccount
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -