📄 finbalance.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 Smart Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.report;
import java.sql.*;
import java.util.*;
import java.math.*;
import org.apache.log4j.Logger;
import org.compiere.process.*;
import org.compiere.model.*;
import org.compiere.util.DB;
/**
* Financial Balance Maintenance Engine
*
* @author Jorg Janke
* @version $Id: FinBalance.java,v 1.3 2003/04/01 05:54:09 jjanke Exp $
*/
public class FinBalance extends SvrProcess
{
/**
* Financial Report Constructor
*/
public FinBalance()
{
super();
log.info(" ");
} // FinBalance
/** Logger */
protected static Logger s_log = Logger.getLogger (FinBalance.class);
private int m_C_AcctSchema_ID = 0;
private int m_C_Calendar_ID = 0;
private boolean m_IsRecreate = false;
/**
* Prepare - e.g., get Parameters.
*/
protected void prepare()
{
// Parameter
Parameter[] para = getParameter();
for (int i = 0; i < para.length; i++)
{
String name = para[i].ParameterName;
if (para[i].Parameter == null)
;
else if (name.equals("C_AcctSchema_ID"))
m_C_AcctSchema_ID = ((BigDecimal)para[i].Parameter).intValue();
else if (name.equals("IsRecreate"))
m_IsRecreate = "Y".equals(para[i].Parameter);
else
log.error("prepare - Unknown Parameter: " + name);
}
log.debug("prepare - C_AcctSchema_ID=" + m_C_AcctSchema_ID
+ ", C_Calendar_ID=" + m_C_Calendar_ID + ", IsRecreate=" + m_IsRecreate);
} // prepare
/**
* Perform process.
* @return Message to be translated
* @throws Exception
*/
protected String doIt() throws java.lang.Exception
{
if (m_IsRecreate && m_C_AcctSchema_ID != 0)
deleteBalance (m_C_AcctSchema_ID);
if (m_IsRecreate && m_C_AcctSchema_ID == 0)
updateBalance(m_C_AcctSchema_ID, true); // Delete & Insert
else
updateBalance(m_C_AcctSchema_ID, false); // Update & Insert
return "";
} // doIt
/**
* Delete Balances
* @param C_AcctSchema_ID accounting schema
* @return Message to be translated
*/
public static String deleteBalance (int C_AcctSchema_ID)
{
StringBuffer sql = new StringBuffer ("DELETE FROM Fact_Acct_Balance WHERE ");
if (C_AcctSchema_ID != 0)
sql.append ("C_AcctSchema_ID=").append (C_AcctSchema_ID);
//
int no = DB.executeUpdate(sql.toString());
String msg = "@Deleted@=" + no;
s_log.debug("deleteBalance - C_AcctSchema_ID=" + C_AcctSchema_ID + " #=" + no);
//
return msg;
} // deleteBalance
/**
* Update / Create Balances
* @param C_AcctSchema_ID accounting schema (ignored)
* @param deleteFirst delete (all) balances first
* @return Message to be translated
*/
public static String updateBalance (int C_AcctSchema_ID, boolean deleteFirst)
{
s_log.info("updateBalance - C_AcctSchema_ID=" + C_AcctSchema_ID + " - DeleteFirst=" + deleteFirst);
long start = System.currentTimeMillis();
try
{
String sql = "{CALL Fact_Acct_Balance_Update(?)}";
CallableStatement cstmt = DB.prepareCall(sql);
cstmt.setString(1, deleteFirst ? "Y" : "N");
cstmt.executeUpdate();
cstmt.close();
}
catch(SQLException e)
{
s_log.error("FinBalance.updateBalance", e);
return e.getLocalizedMessage();
}
//
start = System.currentTimeMillis() - start;
s_log.info("updateBalance - " + (start/1000) + " sec");
return "";
} // updateBalance
/*************************************************************************/
/**
* Test
* @param args ignored
*/
public static void main(String[] args)
{
FinBalance finBalance1 = new FinBalance();
} // main
} // FinBalance
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -