Moving back some non-libero processes
This commit is contained in:
parent
73b5119694
commit
298e915cb7
|
@ -0,0 +1,189 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Copyright (C) 2003-2008 e-Evolution,SC. All Rights Reserved. *
|
||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||
*****************************************************************************/
|
||||
package org.eevolution.process;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MBankAccount;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.AdempiereUserError;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Bank Transfer. Generate two Payments entry
|
||||
*
|
||||
* For Bank Transfer From Bank Account "A"
|
||||
*
|
||||
* @author victor.perez@e-evoltuion.com
|
||||
*
|
||||
**/
|
||||
public class BankTransfer extends SvrProcess
|
||||
{
|
||||
private String p_DocumentNo= ""; // Document No
|
||||
private String p_Description= ""; // Description
|
||||
private int p_C_BPartner_ID = 0; // Business Partner to be used as bridge
|
||||
private int p_C_Currency_ID = 0; // Payment Currency
|
||||
private int p_C_ConversionType_ID = 0; // Payment Conversion Type
|
||||
private int p_C_Charge_ID = 0; // Charge to be used as bridge
|
||||
|
||||
private BigDecimal p_Amount = new BigDecimal(0); // Amount to be transfered between the accounts
|
||||
private int p_From_C_BankAccount_ID = 0; // Bank Account From
|
||||
private int p_To_C_BankAccount_ID= 0; // Bank Account To
|
||||
private Timestamp p_StatementDate = null; // Date Statement
|
||||
private Timestamp p_DateAcct = null; // Date Account
|
||||
|
||||
/**
|
||||
* Prepare - e.g., get Parameters.
|
||||
*/
|
||||
protected void prepare()
|
||||
{
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
if (name.equals("From_C_BankAccount_ID"))
|
||||
p_From_C_BankAccount_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("To_C_BankAccount_ID"))
|
||||
p_To_C_BankAccount_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("C_BPartner_ID"))
|
||||
p_C_BPartner_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("C_Currency_ID"))
|
||||
p_C_Currency_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("C_ConversionType_ID"))
|
||||
p_C_ConversionType_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("C_Charge_ID"))
|
||||
p_C_Charge_ID = para[i].getParameterAsInt();
|
||||
else if (name.equals("DocumentNo"))
|
||||
p_DocumentNo = (String)para[i].getParameter();
|
||||
else if (name.equals("Amount"))
|
||||
p_Amount = ((BigDecimal)para[i].getParameter());
|
||||
else if (name.equals("Description"))
|
||||
p_Description = (String)para[i].getParameter();
|
||||
else if (name.equals("StatementDate"))
|
||||
p_StatementDate = (Timestamp)para[i].getParameter();
|
||||
else if (name.equals("DateAcct"))
|
||||
p_DateAcct = (Timestamp)para[i].getParameter();
|
||||
else
|
||||
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
} // prepare
|
||||
|
||||
/**
|
||||
* Perform process.
|
||||
* @return Message (translated text)
|
||||
* @throws Exception if not successful
|
||||
*/
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
log.info("From Bank="+p_From_C_BankAccount_ID+" - To Bank="+p_To_C_BankAccount_ID
|
||||
+ " - C_BPartner_ID="+p_C_BPartner_ID+"- C_Charge_ID= "+p_C_Charge_ID+" - Amount="+p_Amount+" - DocumentNo="+p_DocumentNo
|
||||
+ " - Description="+p_Description+ " - Statement Date="+p_StatementDate+
|
||||
" - Date Account="+p_DateAcct);
|
||||
|
||||
if (p_To_C_BankAccount_ID == 0 || p_From_C_BankAccount_ID == 0)
|
||||
throw new IllegalArgumentException("Banks required");
|
||||
|
||||
if (p_DocumentNo == null || p_DocumentNo.length() == 0)
|
||||
throw new IllegalArgumentException("Document No required");
|
||||
|
||||
if (p_To_C_BankAccount_ID == p_From_C_BankAccount_ID)
|
||||
throw new AdempiereUserError ("Banks From and To must be different");
|
||||
|
||||
if (p_C_BPartner_ID == 0)
|
||||
throw new AdempiereUserError ("Business Partner required");
|
||||
|
||||
if (p_C_Currency_ID == 0)
|
||||
throw new AdempiereUserError ("Currency required");
|
||||
|
||||
if (p_C_Charge_ID == 0)
|
||||
throw new AdempiereUserError ("Business Partner required");
|
||||
|
||||
if (p_Amount.compareTo(new BigDecimal(0)) == 0)
|
||||
throw new AdempiereUserError ("Amount required");
|
||||
|
||||
// Login Date
|
||||
if (p_StatementDate == null)
|
||||
p_StatementDate = Env.getContextAsDate(getCtx(), "#Date");
|
||||
if (p_StatementDate == null)
|
||||
p_StatementDate = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
if (p_DateAcct == null)
|
||||
p_DateAcct = p_StatementDate;
|
||||
|
||||
generateBankTransfer();
|
||||
|
||||
return "@OK@ ";
|
||||
} // doIt
|
||||
|
||||
|
||||
/**
|
||||
* Generate BankTransfer()
|
||||
*
|
||||
*/
|
||||
private void generateBankTransfer()
|
||||
{
|
||||
|
||||
MBankAccount mBankFrom = new MBankAccount(getCtx(),p_From_C_BankAccount_ID, get_TrxName());
|
||||
MBankAccount mBankTo = new MBankAccount(getCtx(),p_To_C_BankAccount_ID, get_TrxName());
|
||||
|
||||
MPayment paymentBankFrom = new MPayment(getCtx(), 0 , get_TrxName());
|
||||
paymentBankFrom.setC_BankAccount_ID(mBankFrom.getC_BankAccount_ID());
|
||||
paymentBankFrom.setDocumentNo(p_DocumentNo);
|
||||
paymentBankFrom.setDateAcct(p_DateAcct);
|
||||
paymentBankFrom.setDateTrx(p_StatementDate);
|
||||
paymentBankFrom.setTenderType(MPayment.TENDERTYPE_DirectDeposit);
|
||||
paymentBankFrom.setDescription(p_Description);
|
||||
paymentBankFrom.setC_BPartner_ID (p_C_BPartner_ID);
|
||||
paymentBankFrom.setC_Currency_ID(p_C_Currency_ID);
|
||||
if (p_C_ConversionType_ID > 0)
|
||||
paymentBankFrom.setC_ConversionType_ID(p_C_ConversionType_ID);
|
||||
paymentBankFrom.setPayAmt(p_Amount);
|
||||
paymentBankFrom.setOverUnderAmt(Env.ZERO);
|
||||
paymentBankFrom.setC_DocType_ID(false);
|
||||
paymentBankFrom.setC_Charge_ID(p_C_Charge_ID);
|
||||
paymentBankFrom.save();
|
||||
paymentBankFrom.processIt(MPayment.DOCACTION_Complete);
|
||||
paymentBankFrom.saveEx();
|
||||
|
||||
MPayment paymentBankTo = new MPayment(getCtx(), 0 , get_TrxName());
|
||||
paymentBankTo.setC_BankAccount_ID(mBankTo.getC_BankAccount_ID());
|
||||
paymentBankTo.setDocumentNo(p_DocumentNo);
|
||||
paymentBankTo.setDateAcct(p_DateAcct);
|
||||
paymentBankTo.setDateTrx(p_StatementDate);
|
||||
paymentBankTo.setTenderType(MPayment.TENDERTYPE_DirectDeposit);
|
||||
paymentBankTo.setDescription(p_Description);
|
||||
paymentBankTo.setC_BPartner_ID (p_C_BPartner_ID);
|
||||
paymentBankTo.setC_Currency_ID(p_C_Currency_ID);
|
||||
if (p_C_ConversionType_ID > 0)
|
||||
paymentBankFrom.setC_ConversionType_ID(p_C_ConversionType_ID);
|
||||
paymentBankTo.setPayAmt(p_Amount);
|
||||
paymentBankTo.setOverUnderAmt(Env.ZERO);
|
||||
paymentBankTo.setC_DocType_ID(true);
|
||||
paymentBankTo.setC_Charge_ID(p_C_Charge_ID);
|
||||
paymentBankTo.save();
|
||||
paymentBankTo.processIt(MPayment.DOCACTION_Complete);
|
||||
paymentBankTo.saveEx();
|
||||
|
||||
return;
|
||||
|
||||
} // createCashLines
|
||||
|
||||
} // ImmediateBankTransfer
|
|
@ -0,0 +1,103 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||
*****************************************************************************/
|
||||
|
||||
package org.eevolution.process;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.Adempiere;
|
||||
import org.compiere.model.MSequence;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.model.MTable;
|
||||
import org.compiere.model.Query;
|
||||
import org.compiere.model.X_AD_Table;
|
||||
import org.compiere.process.SvrProcess;
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Enable Native Sequence
|
||||
*
|
||||
* @author Victor Perez, e-Evolution, S.C.
|
||||
*/
|
||||
public class EnableNativeSequence extends SvrProcess
|
||||
{
|
||||
|
||||
/**
|
||||
* Prepare - e.g., get Parameters.
|
||||
*/
|
||||
protected void prepare()
|
||||
{
|
||||
} // prepare
|
||||
|
||||
protected String doIt()
|
||||
{
|
||||
boolean SYSTEM_NATIVE_SEQUENCE = MSysConfig.getBooleanValue("SYSTEM_NATIVE_SEQUENCE",false);
|
||||
|
||||
if(SYSTEM_NATIVE_SEQUENCE)
|
||||
throw new AdempiereException("Native Sequence is Actived");
|
||||
else
|
||||
{
|
||||
DB.executeUpdateEx("UPDATE AD_SysConfig SET Value='Y' WHERE Name='SYSTEM_NATIVE_SEQUENCE'",null);
|
||||
MSysConfig.resetCache();
|
||||
}
|
||||
|
||||
List<MTable> tables = new Query(getCtx(),X_AD_Table.Table_Name,"", get_TrxName()).list();
|
||||
for(MTable table : tables)
|
||||
{
|
||||
if(!table.isView())
|
||||
{
|
||||
if(!MSequence.createTableSequence(getCtx(), table.getTableName(), get_TrxName()))
|
||||
{
|
||||
DB.executeUpdateEx("UPDATE AD_SysConfig SET Value='N' WHERE Name='SYSTEM_NATIVE_SEQUENCE'",null);
|
||||
MSysConfig.resetCache();
|
||||
new AdempiereException("Can not create Native Sequence");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.addLog("Create Native Sequence for : "+table.getTableName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return "@OK@";
|
||||
}
|
||||
|
||||
/**
|
||||
* Main test
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
try {
|
||||
Adempiere.startupEnvironment(true);
|
||||
CLogMgt.setLevel(Level.ALL);
|
||||
EnableNativeSequence seqs = new EnableNativeSequence();
|
||||
seqs.doIt();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||
*****************************************************************************/
|
||||
package org.eevolution.process;
|
||||
|
||||
|
||||
|
||||
import org.adempiere.exceptions.FillMandatoryException;
|
||||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.model.MFactAcct;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MPeriod;
|
||||
import org.compiere.process.ProcessInfoParameter;
|
||||
import org.compiere.process.SvrProcess;
|
||||
|
||||
|
||||
/**
|
||||
* Re-calculate Invoice Tax (and unpost the document)
|
||||
* @author victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
|
||||
* <li>FR [ 2520591 ] Support multiples calendar for Org
|
||||
* @see http://sourceforge.net/tracker2/?func=detail&atid=879335&aid=2520591&group_id=176962
|
||||
* @author Teo Sarca, www.arhipac.ro
|
||||
*/
|
||||
public class InvoiceCalculateTax extends SvrProcess
|
||||
{
|
||||
public static final String PARAM_C_Invoice_ID = "C_Invoice_ID";
|
||||
|
||||
private int p_C_Invoice_ID = 0;
|
||||
|
||||
@Override
|
||||
protected void prepare()
|
||||
{
|
||||
for (ProcessInfoParameter para : getParameter())
|
||||
{
|
||||
String name = para.getParameterName();
|
||||
if (para.getParameter() == null)
|
||||
{
|
||||
;
|
||||
}
|
||||
else if (name.equals(PARAM_C_Invoice_ID))
|
||||
{
|
||||
p_C_Invoice_ID = para.getParameterAsInt();
|
||||
}
|
||||
}
|
||||
|
||||
if (p_C_Invoice_ID <= 0)
|
||||
{
|
||||
throw new FillMandatoryException(PARAM_C_Invoice_ID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
MInvoice invoice = new MInvoice(getCtx(), p_C_Invoice_ID, get_TrxName());
|
||||
recalculateTax(invoice);
|
||||
//
|
||||
return "@ProcessOK@";
|
||||
}
|
||||
|
||||
public static void recalculateTax(MInvoice invoice)
|
||||
{
|
||||
//
|
||||
// Delete accounting /UnPost
|
||||
MPeriod.testPeriodOpen(invoice.getCtx(), invoice.getDateAcct(), invoice.getC_DocType_ID(), invoice.getAD_Org_ID());
|
||||
MFactAcct.deleteEx(MInvoice.Table_ID, invoice.get_ID(), invoice.get_TrxName());
|
||||
//
|
||||
// Update Invoice
|
||||
invoice.calculateTaxTotal();
|
||||
invoice.setPosted(false);
|
||||
invoice.saveEx();
|
||||
//
|
||||
// Update balance
|
||||
MBPartner bp = new MBPartner (invoice.getCtx(), invoice.getC_BPartner_ID(), invoice.get_TrxName());
|
||||
bp.setTotalOpenBalance();
|
||||
bp.setSOCreditStatus();
|
||||
bp.saveEx();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue