IDEMPIERE-462 Ticket #1001503: Credit Cards Online - support online sales, authorization, delay capture and void payment
This commit is contained in:
parent
3b347d70cd
commit
442fd422a1
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,45 @@
|
|||
package org.compiere.process;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MPaymentTransaction;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
public class VoidOnlineAuthorizationPaymentTransaction extends SvrProcess {
|
||||
|
||||
protected void prepare()
|
||||
{
|
||||
ProcessInfoParameter[] para = getParameter();
|
||||
for (int i = 0; i < para.length; i++)
|
||||
{
|
||||
String name = para[i].getParameterName();
|
||||
if (para[i].getParameter() == null)
|
||||
;
|
||||
else
|
||||
log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
protected String doIt() throws Exception
|
||||
{
|
||||
log.info("Record_ID=" + getRecord_ID());
|
||||
// get Payment
|
||||
MPaymentTransaction pt = new MPaymentTransaction (getCtx(), getRecord_ID(), get_TrxName());
|
||||
|
||||
if (!pt.getTenderType().equals(MPaymentTransaction.TENDERTYPE_CreditCard) || !pt.isOnline() || !pt.getTrxType().equals(MPaymentTransaction.TRXTYPE_Authorization))
|
||||
throw new AdempiereException(Msg.getMsg(Env.getCtx(), "ActionNotSupported"));
|
||||
if (pt.isVoided())
|
||||
throw new AdempiereException(Msg.getMsg(Env.getCtx(), "PaymentTransactionAlreadyVoided"));
|
||||
if (pt.isDelayedCapture())
|
||||
throw new AdempiereException(Msg.getMsg(Env.getCtx(), "PaymentTransactionAlreadyDelayCaptured"));
|
||||
|
||||
// Process it
|
||||
boolean ok = pt.voidOnlineAuthorizationPaymentTransaction();
|
||||
pt.saveEx();
|
||||
if (!ok)
|
||||
throw new Exception(pt.getErrorMessage());
|
||||
return "OK";
|
||||
}
|
||||
}
|
|
@ -24,9 +24,9 @@ import java.net.URL;
|
|||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.MPaymentProcessor;
|
||||
import org.compiere.model.ModelValidator;
|
||||
import org.compiere.model.PaymentInterface;
|
||||
import org.compiere.model.PaymentProcessor;
|
||||
import org.compiere.process.ProcessCall;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -102,7 +102,7 @@ public class Core {
|
|||
* @param mp payment model
|
||||
* @return initialized PaymentProcessor or null
|
||||
*/
|
||||
public static PaymentProcessor getPaymentProcessor(MPaymentProcessor mpp, MPayment mp) {
|
||||
public static PaymentProcessor getPaymentProcessor(MPaymentProcessor mpp, PaymentInterface mp) {
|
||||
s_log.info("create for " + mpp);
|
||||
String className = mpp.getPayProcessorClass();
|
||||
if (className == null || className.length() == 0) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.NumberFormat;
|
||||
|
@ -24,6 +25,7 @@ import org.compiere.model.MBPBankAccount;
|
|||
import org.compiere.model.MBPartner;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -105,4 +107,33 @@ public class PaymentUtil {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getPayAmtInCents(BigDecimal payAmt)
|
||||
{
|
||||
if (payAmt == null)
|
||||
return 0;
|
||||
|
||||
BigDecimal bd = payAmt.multiply(Env.ONEHUNDRED);
|
||||
return bd.intValue();
|
||||
}
|
||||
|
||||
public static String getCreditCardExp(int creditCardExpMM, int creditCardExpYY, String delimiter)
|
||||
{
|
||||
String mm = String.valueOf(creditCardExpMM);
|
||||
String yy = String.valueOf(creditCardExpYY);
|
||||
|
||||
StringBuffer retValue = new StringBuffer();
|
||||
if (mm.length() == 1)
|
||||
retValue.append("0");
|
||||
retValue.append(mm);
|
||||
//
|
||||
if (delimiter != null)
|
||||
retValue.append(delimiter);
|
||||
//
|
||||
if (yy.length() == 1)
|
||||
retValue.append("0");
|
||||
retValue.append(yy);
|
||||
//
|
||||
return (retValue.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,19 +262,6 @@ public interface I_C_Invoice
|
|||
|
||||
public org.compiere.model.I_C_DunningLevel getC_DunningLevel() throws RuntimeException;
|
||||
|
||||
/** Column name ChargeAmt */
|
||||
public static final String COLUMNNAME_ChargeAmt = "ChargeAmt";
|
||||
|
||||
/** Set Charge amount.
|
||||
* Charge Amount
|
||||
*/
|
||||
public void setChargeAmt (BigDecimal ChargeAmt);
|
||||
|
||||
/** Get Charge amount.
|
||||
* Charge Amount
|
||||
*/
|
||||
public BigDecimal getChargeAmt();
|
||||
|
||||
/** Column name C_Invoice_ID */
|
||||
public static final String COLUMNNAME_C_Invoice_ID = "C_Invoice_ID";
|
||||
|
||||
|
@ -297,19 +284,6 @@ public interface I_C_Invoice
|
|||
/** Get C_Invoice_UU */
|
||||
public String getC_Invoice_UU();
|
||||
|
||||
/** Column name CopyFrom */
|
||||
public static final String COLUMNNAME_CopyFrom = "CopyFrom";
|
||||
|
||||
/** Set Copy From.
|
||||
* Copy From Record
|
||||
*/
|
||||
public void setCopyFrom (String CopyFrom);
|
||||
|
||||
/** Get Copy From.
|
||||
* Copy From Record
|
||||
*/
|
||||
public String getCopyFrom();
|
||||
|
||||
/** Column name C_Order_ID */
|
||||
public static final String COLUMNNAME_C_Order_ID = "C_Order_ID";
|
||||
|
||||
|
@ -370,6 +344,32 @@ public interface I_C_Invoice
|
|||
|
||||
public org.compiere.model.I_C_Project getC_Project() throws RuntimeException;
|
||||
|
||||
/** Column name ChargeAmt */
|
||||
public static final String COLUMNNAME_ChargeAmt = "ChargeAmt";
|
||||
|
||||
/** Set Charge amount.
|
||||
* Charge Amount
|
||||
*/
|
||||
public void setChargeAmt (BigDecimal ChargeAmt);
|
||||
|
||||
/** Get Charge amount.
|
||||
* Charge Amount
|
||||
*/
|
||||
public BigDecimal getChargeAmt();
|
||||
|
||||
/** Column name CopyFrom */
|
||||
public static final String COLUMNNAME_CopyFrom = "CopyFrom";
|
||||
|
||||
/** Set Copy From.
|
||||
* Copy From Record
|
||||
*/
|
||||
public void setCopyFrom (String CopyFrom);
|
||||
|
||||
/** Get Copy From.
|
||||
* Copy From Record
|
||||
*/
|
||||
public String getCopyFrom();
|
||||
|
||||
/** Column name Created */
|
||||
public static final String COLUMNNAME_Created = "Created";
|
||||
|
||||
|
|
|
@ -483,6 +483,19 @@ public interface I_C_PaymentProcessor
|
|||
*/
|
||||
public boolean isRequireVV();
|
||||
|
||||
/** Column name TrxType */
|
||||
public static final String COLUMNNAME_TrxType = "TrxType";
|
||||
|
||||
/** Set Transaction Type.
|
||||
* Type of credit card transaction
|
||||
*/
|
||||
public void setTrxType (String TrxType);
|
||||
|
||||
/** Get Transaction Type.
|
||||
* Type of credit card transaction
|
||||
*/
|
||||
public String getTrxType();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,194 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
||||
* 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 *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/** Generated Interface for X_OnlineTrxHistory
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.6.0LTS
|
||||
*/
|
||||
public interface I_X_OnlineTrxHistory
|
||||
{
|
||||
|
||||
/** TableName=X_OnlineTrxHistory */
|
||||
public static final String Table_Name = "X_OnlineTrxHistory";
|
||||
|
||||
/** AD_Table_ID=200032 */
|
||||
public static final int Table_ID = 200032;
|
||||
|
||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||
|
||||
/** AccessLevel = 3 - Client - Org
|
||||
*/
|
||||
BigDecimal accessLevel = BigDecimal.valueOf(3);
|
||||
|
||||
/** Load Meta Data */
|
||||
|
||||
/** Column name AD_Client_ID */
|
||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||
|
||||
/** Get Client.
|
||||
* Client/Tenant for this installation.
|
||||
*/
|
||||
public int getAD_Client_ID();
|
||||
|
||||
/** Column name AD_Org_ID */
|
||||
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
|
||||
|
||||
/** Set Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public void setAD_Org_ID (int AD_Org_ID);
|
||||
|
||||
/** Get Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public int getAD_Org_ID();
|
||||
|
||||
/** Column name AD_Table_ID */
|
||||
public static final String COLUMNNAME_AD_Table_ID = "AD_Table_ID";
|
||||
|
||||
/** Set Table.
|
||||
* Database Table information
|
||||
*/
|
||||
public void setAD_Table_ID (int AD_Table_ID);
|
||||
|
||||
/** Get Table.
|
||||
* Database Table information
|
||||
*/
|
||||
public int getAD_Table_ID();
|
||||
|
||||
public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException;
|
||||
|
||||
/** Column name Created */
|
||||
public static final String COLUMNNAME_Created = "Created";
|
||||
|
||||
/** Get Created.
|
||||
* Date this record was created
|
||||
*/
|
||||
public Timestamp getCreated();
|
||||
|
||||
/** Column name CreatedBy */
|
||||
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
|
||||
|
||||
/** Get Created By.
|
||||
* User who created this records
|
||||
*/
|
||||
public int getCreatedBy();
|
||||
|
||||
/** Column name IsActive */
|
||||
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||
|
||||
/** Set Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public void setIsActive (boolean IsActive);
|
||||
|
||||
/** Get Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/** Column name IsError */
|
||||
public static final String COLUMNNAME_IsError = "IsError";
|
||||
|
||||
/** Set Error.
|
||||
* An Error occurred in the execution
|
||||
*/
|
||||
public void setIsError (boolean IsError);
|
||||
|
||||
/** Get Error.
|
||||
* An Error occurred in the execution
|
||||
*/
|
||||
public boolean isError();
|
||||
|
||||
/** Column name Processed */
|
||||
public static final String COLUMNNAME_Processed = "Processed";
|
||||
|
||||
/** Set Processed.
|
||||
* The document has been processed
|
||||
*/
|
||||
public void setProcessed (boolean Processed);
|
||||
|
||||
/** Get Processed.
|
||||
* The document has been processed
|
||||
*/
|
||||
public boolean isProcessed();
|
||||
|
||||
/** Column name Record_ID */
|
||||
public static final String COLUMNNAME_Record_ID = "Record_ID";
|
||||
|
||||
/** Set Record ID.
|
||||
* Direct internal record ID
|
||||
*/
|
||||
public void setRecord_ID (int Record_ID);
|
||||
|
||||
/** Get Record ID.
|
||||
* Direct internal record ID
|
||||
*/
|
||||
public int getRecord_ID();
|
||||
|
||||
/** Column name TextMsg */
|
||||
public static final String COLUMNNAME_TextMsg = "TextMsg";
|
||||
|
||||
/** Set Text Message.
|
||||
* Text Message
|
||||
*/
|
||||
public void setTextMsg (String TextMsg);
|
||||
|
||||
/** Get Text Message.
|
||||
* Text Message
|
||||
*/
|
||||
public String getTextMsg();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
/** Get Updated.
|
||||
* Date this record was updated
|
||||
*/
|
||||
public Timestamp getUpdated();
|
||||
|
||||
/** Column name UpdatedBy */
|
||||
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
|
||||
|
||||
/** Get Updated By.
|
||||
* User who updated this records
|
||||
*/
|
||||
public int getUpdatedBy();
|
||||
|
||||
/** Column name X_OnlineTrxHistory_ID */
|
||||
public static final String COLUMNNAME_X_OnlineTrxHistory_ID = "X_OnlineTrxHistory_ID";
|
||||
|
||||
/** Set Online Transaction History */
|
||||
public void setX_OnlineTrxHistory_ID (int X_OnlineTrxHistory_ID);
|
||||
|
||||
/** Get Online Transaction History */
|
||||
public int getX_OnlineTrxHistory_ID();
|
||||
|
||||
/** Column name X_OnlineTrxHistory_UU */
|
||||
public static final String COLUMNNAME_X_OnlineTrxHistory_UU = "X_OnlineTrxHistory_UU";
|
||||
|
||||
/** Set X_OnlineTrxHistory_UU */
|
||||
public void setX_OnlineTrxHistory_UU (String X_OnlineTrxHistory_UU);
|
||||
|
||||
/** Get X_OnlineTrxHistory_UU */
|
||||
public String getX_OnlineTrxHistory_UU();
|
||||
}
|
|
@ -1958,6 +1958,78 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
|||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
} // project
|
||||
|
||||
// auto allocate sales payment
|
||||
if (isSOTrx() && !isReversal())
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// auto delay capture authorization payment
|
||||
if (isSOTrx() && !isReversal())
|
||||
{
|
||||
int[] ids = MPaymentTransaction.getAuthorizationPaymentTransactionIDs(getC_Order_ID(), getC_Invoice_ID(), get_TrxName());
|
||||
|
||||
if (ids.length > 0)
|
||||
{
|
||||
ArrayList<MPaymentTransaction> ptList = new ArrayList<MPaymentTransaction>();
|
||||
BigDecimal totalPayAmt = BigDecimal.ZERO;
|
||||
for (int id : ids)
|
||||
{
|
||||
MPaymentTransaction pt = new MPaymentTransaction(Env.getCtx(), id, get_TrxName());
|
||||
totalPayAmt = totalPayAmt.add(pt.getPayAmt());
|
||||
ptList.add(pt);
|
||||
}
|
||||
|
||||
// automatically void authorization payment and create a new sales payment when invoiced amount is NOT equals to the authorized amount
|
||||
if(getGrandTotal().compareTo(totalPayAmt) != 0)
|
||||
{
|
||||
// create a new sales payment
|
||||
MPaymentTransaction newSalesPT = MPaymentTransaction.copyFrom(ptList.get(0), new Timestamp(System.currentTimeMillis()), MPayment.TRXTYPE_Sales, "", get_TrxName());
|
||||
newSalesPT.setIsApproved(false);
|
||||
newSalesPT.setIsVoided(false);
|
||||
newSalesPT.setIsDelayedCapture(false);
|
||||
newSalesPT.setDescription("InvoicedAmt: " + getGrandTotal() + " > TotalAuthorizedAmt: " + totalPayAmt);
|
||||
|
||||
// void authorization payment
|
||||
for (MPaymentTransaction pt : ptList)
|
||||
{
|
||||
pt.setDescription("InvoicedAmt: " + getGrandTotal() + " > AuthorizedAmt: " + pt.getPayAmt());
|
||||
boolean ok = pt.voidOnlineAuthorizationPaymentTransaction();
|
||||
pt.saveEx();
|
||||
if (!ok)
|
||||
{
|
||||
m_processMsg = "Failed to void authorization payment: " + pt.getErrorMessage();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
// process the new sales payment
|
||||
boolean ok = newSalesPT.processOnline();
|
||||
newSalesPT.saveEx();
|
||||
if (!ok)
|
||||
{
|
||||
m_processMsg = "Failed to create a new sales payment: " + newSalesPT.getErrorMessage();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// delay capture authorization payment
|
||||
for (MPaymentTransaction pt : ptList)
|
||||
{
|
||||
boolean ok = pt.delayCaptureOnlineAuthorizationPaymentTransaction(getC_Invoice_ID());
|
||||
pt.saveEx();
|
||||
if (!ok)
|
||||
{
|
||||
m_processMsg = "Failed to delay capture authorization payment: " + pt.getErrorMessage();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// User Validation
|
||||
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MOnlineTrxHistory extends X_X_OnlineTrxHistory {
|
||||
|
||||
public MOnlineTrxHistory(Properties ctx, int X_OnlineTrxHistory_ID, String trxName)
|
||||
{
|
||||
super(ctx, X_OnlineTrxHistory_ID, trxName);
|
||||
}
|
||||
|
||||
public MOnlineTrxHistory(Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
}
|
|
@ -76,7 +76,7 @@ import org.compiere.util.ValueNamePair;
|
|||
* @version $Id: MPayment.java,v 1.4 2006/10/02 05:18:39 jjanke Exp $
|
||||
*/
|
||||
public final class MPayment extends X_C_Payment
|
||||
implements DocAction, ProcessCall
|
||||
implements DocAction, ProcessCall, PaymentInterface
|
||||
{
|
||||
|
||||
|
||||
|
@ -459,11 +459,32 @@ public final class MPayment extends X_C_Payment
|
|||
setIsOnline(true);
|
||||
setErrorMessage(null);
|
||||
// prevent charging twice
|
||||
if (isApproved())
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
{
|
||||
log.info("Already processed - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already Processed");
|
||||
return true;
|
||||
if (isVoided())
|
||||
{
|
||||
log.info("Already voided - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already voided");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(getTrxType().equals(TRXTYPE_DelayedCapture))
|
||||
{
|
||||
if (isDelayedCapture())
|
||||
{
|
||||
log.info("Already delay captured - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already delay captured");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isApproved())
|
||||
{
|
||||
log.info("Already processed - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already processed");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mBankAccountProcessor == null)
|
||||
|
@ -492,10 +513,16 @@ public final class MPayment extends X_C_Payment
|
|||
} else {
|
||||
// Process if validation succeeds
|
||||
approved = pp.processCC ();
|
||||
|
||||
if (approved)
|
||||
setErrorMessage(null);
|
||||
else
|
||||
setErrorMessage("From " + getCreditCardName() + ": " + getR_RespMsg());
|
||||
{
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
setErrorMessage("From " + getCreditCardName() + ": " + getR_VoidMsg());
|
||||
else
|
||||
setErrorMessage("From " + getCreditCardName() + ": " + getR_RespMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -504,7 +531,48 @@ public final class MPayment extends X_C_Payment
|
|||
log.log(Level.SEVERE, "processOnline", e);
|
||||
setErrorMessage("Payment Processor Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
if (approved)
|
||||
{
|
||||
setDateTrx(new Timestamp(System.currentTimeMillis()));
|
||||
setDateAcct(new Timestamp(System.currentTimeMillis()));
|
||||
setProcessed(true); // prevent editing of payment details once approved
|
||||
}
|
||||
|
||||
setIsApproved(approved);
|
||||
|
||||
MPaymentTransaction m_mPaymentTransaction = createPaymentTransaction();
|
||||
m_mPaymentTransaction.setIsApproved(approved);
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
m_mPaymentTransaction.setIsVoided(approved);
|
||||
m_mPaymentTransaction.setProcessed(approved);
|
||||
m_mPaymentTransaction.setC_Payment_ID(getC_Payment_ID());
|
||||
m_mPaymentTransaction.saveEx();
|
||||
|
||||
MOnlineTrxHistory history = new MOnlineTrxHistory(getCtx(), 0, get_TrxName());
|
||||
history.setAD_Table_ID(MPaymentTransaction.Table_ID);
|
||||
history.setRecord_ID(m_mPaymentTransaction.getC_PaymentTransaction_ID());
|
||||
history.setIsError(!approved);
|
||||
history.setProcessed(approved);
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
if (approved)
|
||||
{
|
||||
msg.append("Result: " + getR_Result() + "\n");
|
||||
msg.append("Response Message: " + getR_RespMsg() + "\n");
|
||||
msg.append("Reference: " + getR_PnRef() + "\n");
|
||||
msg.append("Authorization Code: " + getR_AuthCode() + "\n");
|
||||
}
|
||||
else
|
||||
msg.append("ERROR: " + getErrorMessage() + "\n");
|
||||
msg.append("Transaction Type: " + getTrxType());
|
||||
history.setTextMsg(msg.toString());
|
||||
|
||||
history.saveEx();
|
||||
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
setIsVoided(approved);
|
||||
|
||||
return approved;
|
||||
} // processOnline
|
||||
|
||||
|
@ -1884,6 +1952,26 @@ public final class MPayment extends X_C_Payment
|
|||
}
|
||||
// End Trifon - CashPayments
|
||||
|
||||
// update C_Invoice.C_Payment_ID and C_Order.C_Payment_ID reference
|
||||
if (getC_Invoice_ID() != 0)
|
||||
{
|
||||
MInvoice inv = new MInvoice(getCtx(), getC_Invoice_ID(), get_TrxName());
|
||||
if (inv.getC_Payment_ID() != getC_Payment_ID())
|
||||
{
|
||||
inv.setC_Payment_ID(getC_Payment_ID());
|
||||
inv.saveEx();
|
||||
}
|
||||
}
|
||||
if (getC_Order_ID() != 0)
|
||||
{
|
||||
MOrder ord = new MOrder(getCtx(), getC_Order_ID(), get_TrxName());
|
||||
if (ord.getC_Payment_ID() != getC_Payment_ID())
|
||||
{
|
||||
ord.setC_Payment_ID(getC_Payment_ID());
|
||||
ord.saveEx();
|
||||
}
|
||||
}
|
||||
|
||||
// User Validation
|
||||
String valid = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_COMPLETE);
|
||||
if (valid != null)
|
||||
|
@ -2293,6 +2381,9 @@ public final class MPayment extends X_C_Payment
|
|||
|| DOCSTATUS_Approved.equals(getDocStatus())
|
||||
|| DOCSTATUS_NotApproved.equals(getDocStatus()) )
|
||||
{
|
||||
if (!voidOnlinePayment())
|
||||
return false;
|
||||
|
||||
addDescription(Msg.getMsg(getCtx(), "Voided") + " (" + getPayAmt() + ")");
|
||||
setPayAmt(Env.ZERO);
|
||||
setDiscountAmt(Env.ZERO);
|
||||
|
@ -2349,6 +2440,9 @@ public final class MPayment extends X_C_Payment
|
|||
if (m_processMsg != null)
|
||||
return false;
|
||||
|
||||
if (!voidOnlinePayment())
|
||||
return false;
|
||||
|
||||
// Std Period open?
|
||||
Timestamp dateAcct = getDateAcct();
|
||||
if (!MPeriod.isOpen(getCtx(), dateAcct,
|
||||
|
@ -2633,4 +2727,114 @@ public final class MPayment extends X_C_Payment
|
|||
m_processUI = processMonitor;
|
||||
}
|
||||
|
||||
public MPaymentTransaction createPaymentTransaction()
|
||||
{
|
||||
MPaymentTransaction paymentTransaction = new MPaymentTransaction(getCtx(), 0, get_TrxName());
|
||||
paymentTransaction.setA_City(getA_City());
|
||||
paymentTransaction.setA_Country(getA_Country());
|
||||
paymentTransaction.setA_EMail(getA_EMail());
|
||||
paymentTransaction.setA_Ident_DL(getA_Ident_DL());
|
||||
paymentTransaction.setA_Ident_SSN(getA_Ident_SSN());
|
||||
paymentTransaction.setA_Name(getA_Name());
|
||||
paymentTransaction.setA_State(getA_State());
|
||||
paymentTransaction.setA_Street(getA_Street());
|
||||
paymentTransaction.setA_Zip(getA_Zip());
|
||||
paymentTransaction.setAccountNo(getAccountNo());
|
||||
paymentTransaction.setAD_Org_ID(getAD_Org_ID());
|
||||
paymentTransaction.setC_BankAccount_ID(getC_BankAccount_ID());
|
||||
paymentTransaction.setC_BP_BankAccount_ID(getC_BP_BankAccount_ID());
|
||||
paymentTransaction.setC_BPartner_ID(getC_BPartner_ID());
|
||||
paymentTransaction.setC_ConversionType_ID(getC_ConversionType_ID());
|
||||
paymentTransaction.setC_Currency_ID(getC_Currency_ID());
|
||||
paymentTransaction.setC_Invoice_ID(getC_Invoice_ID());
|
||||
paymentTransaction.setC_Order_ID(getC_Order_ID());
|
||||
paymentTransaction.setC_PaymentProcessor_ID(getC_PaymentProcessor_ID());
|
||||
paymentTransaction.setC_POSTenderType_ID(getC_POSTenderType_ID());
|
||||
paymentTransaction.setCheckNo(getCheckNo());
|
||||
paymentTransaction.setCreditCardExpMM(getCreditCardExpMM());
|
||||
paymentTransaction.setCreditCardExpYY(getCreditCardExpYY());
|
||||
paymentTransaction.setCreditCardNumber(getCreditCardNumber());
|
||||
paymentTransaction.setCreditCardType(getCreditCardType());
|
||||
paymentTransaction.setCreditCardVV(getCreditCardVV());
|
||||
paymentTransaction.setCustomerAddressID(getCustomerAddressID());
|
||||
paymentTransaction.setCustomerPaymentProfileID(getCustomerPaymentProfileID());
|
||||
paymentTransaction.setCustomerProfileID(getCustomerProfileID());
|
||||
paymentTransaction.setDateTrx(getDateTrx());
|
||||
paymentTransaction.setDescription(getDescription());
|
||||
paymentTransaction.setIsActive(isActive());
|
||||
paymentTransaction.setIsApproved(isApproved());
|
||||
paymentTransaction.setIsDelayedCapture(isDelayedCapture());
|
||||
paymentTransaction.setIsOnline(isOnline());
|
||||
paymentTransaction.setIsReceipt(isReceipt());
|
||||
paymentTransaction.setIsSelfService(isSelfService());
|
||||
paymentTransaction.setIsVoided(isVoided());
|
||||
paymentTransaction.setMicr(getMicr());
|
||||
paymentTransaction.setOrig_TrxID(getOrig_TrxID());
|
||||
paymentTransaction.setPayAmt(getPayAmt());
|
||||
paymentTransaction.setPONum(getPONum());
|
||||
paymentTransaction.setProcessed(isProcessed());
|
||||
paymentTransaction.setR_AuthCode(getR_AuthCode());
|
||||
paymentTransaction.setR_AvsAddr(getR_AvsAddr());
|
||||
paymentTransaction.setR_AvsZip(getR_AvsZip());
|
||||
paymentTransaction.setR_CVV2Match(isR_CVV2Match());
|
||||
paymentTransaction.setR_Info(getR_Info());
|
||||
paymentTransaction.setR_PnRef(getR_PnRef());
|
||||
paymentTransaction.setR_RespMsg(getR_RespMsg());
|
||||
paymentTransaction.setR_Result(getR_Result());
|
||||
paymentTransaction.setR_VoidMsg(getR_VoidMsg());
|
||||
paymentTransaction.setRoutingNo(getRoutingNo());
|
||||
paymentTransaction.setTaxAmt(getTaxAmt());
|
||||
paymentTransaction.setTenderType(getTenderType());
|
||||
paymentTransaction.setTrxType(getTrxType());
|
||||
paymentTransaction.setVoiceAuthCode(getVoiceAuthCode());
|
||||
|
||||
return paymentTransaction;
|
||||
}
|
||||
|
||||
private boolean voidOnlinePayment()
|
||||
{
|
||||
if (getTenderType().equals(TENDERTYPE_CreditCard) && isOnline())
|
||||
{
|
||||
setOrig_TrxID(getR_PnRef());
|
||||
setTrxType(TRXTYPE_Void);
|
||||
if(!processOnline())
|
||||
{
|
||||
setTrxType(TRXTYPE_CreditPayment);
|
||||
if(!processOnline())
|
||||
{
|
||||
log.log(Level.SEVERE, "Failed to cancel payment online");
|
||||
m_processMsg = "Failed to cancel payment online";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// clear out the cc data when a Void happens since at that point we won't need the card information any longer
|
||||
if (getTenderType().equals(TENDERTYPE_CreditCard))
|
||||
{
|
||||
// setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber()));
|
||||
// setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV()));
|
||||
}
|
||||
|
||||
if (getC_Invoice_ID() != 0)
|
||||
{
|
||||
MInvoice inv = new MInvoice(getCtx(), getC_Invoice_ID(), get_TrxName());
|
||||
inv.setC_Payment_ID(0);
|
||||
inv.save();
|
||||
}
|
||||
if (getC_Order_ID() != 0)
|
||||
{
|
||||
MOrder ord = new MOrder(getCtx(), getC_Order_ID(), get_TrxName());
|
||||
ord.setC_Payment_ID(0);
|
||||
ord.save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PO getPO() {
|
||||
return this;
|
||||
}
|
||||
|
||||
} // MPayment
|
||||
|
|
|
@ -0,0 +1,564 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.IProcessUI;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.ProcessCall;
|
||||
import org.compiere.process.ProcessInfo;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Trx;
|
||||
|
||||
public class MPaymentTransaction extends X_C_PaymentTransaction implements ProcessCall, PaymentInterface {
|
||||
|
||||
public MPaymentTransaction(Properties ctx, int C_PaymentTransaction_ID, String trxName) {
|
||||
super(ctx, C_PaymentTransaction_ID, trxName);
|
||||
|
||||
// New
|
||||
if (C_PaymentTransaction_ID == 0)
|
||||
{
|
||||
setTrxType(TRXTYPE_Sales);
|
||||
//
|
||||
setR_AvsAddr (R_AVSZIP_Unavailable);
|
||||
setR_AvsZip (R_AVSZIP_Unavailable);
|
||||
//
|
||||
setIsReceipt (true);
|
||||
setIsApproved (false);
|
||||
setIsOnline (false);
|
||||
setIsSelfService(false);
|
||||
setIsDelayedCapture (false);
|
||||
setProcessed(false);
|
||||
//
|
||||
setPayAmt(Env.ZERO);
|
||||
setTaxAmt(Env.ZERO);
|
||||
//
|
||||
setDateTrx (new Timestamp(System.currentTimeMillis()));
|
||||
setTenderType(TENDERTYPE_Check);
|
||||
}
|
||||
}
|
||||
|
||||
public MPaymentTransaction(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean beforeSave(boolean newRecord)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAmount (int C_Currency_ID, BigDecimal payAmt)
|
||||
{
|
||||
if (C_Currency_ID == 0)
|
||||
C_Currency_ID = MClient.get(getCtx()).getC_Currency_ID();
|
||||
setC_Currency_ID(C_Currency_ID);
|
||||
setPayAmt(payAmt);
|
||||
}
|
||||
|
||||
public boolean setCreditCard (String TrxType, String creditCardType, String creditCardNumber,
|
||||
String creditCardVV, int creditCardExpMM, int creditCardExpYY)
|
||||
{
|
||||
setTenderType(TENDERTYPE_CreditCard);
|
||||
setTrxType(TrxType);
|
||||
//
|
||||
setCreditCardType (creditCardType);
|
||||
setCreditCardNumber (creditCardNumber);
|
||||
setCreditCardVV (creditCardVV);
|
||||
setCreditCardExpMM (creditCardExpMM);
|
||||
setCreditCardExpYY (creditCardExpYY);
|
||||
//
|
||||
int check = MPaymentValidate.validateCreditCardNumber(creditCardNumber, creditCardType).length()
|
||||
+ MPaymentValidate.validateCreditCardExp(creditCardExpMM, creditCardExpYY).length();
|
||||
if (creditCardVV.length() > 0)
|
||||
check += MPaymentValidate.validateCreditCardVV(creditCardVV, creditCardType).length();
|
||||
return check == 0;
|
||||
}
|
||||
|
||||
public boolean setCreditCard (String TrxType, String creditCardType, String creditCardNumber,
|
||||
String creditCardVV, String creditCardExp)
|
||||
{
|
||||
return setCreditCard(TrxType, creditCardType, creditCardNumber,
|
||||
creditCardVV, MPaymentValidate.getCreditCardExpMM(creditCardExp),
|
||||
MPaymentValidate.getCreditCardExpYY(creditCardExp));
|
||||
}
|
||||
|
||||
public boolean setPaymentProcessor ()
|
||||
{
|
||||
return setPaymentProcessor (getTenderType(), getCreditCardType());
|
||||
}
|
||||
|
||||
/** Temporary Bank Account Processors */
|
||||
private MBankAccountProcessor[] m_mBankAccountProcessors = null;
|
||||
/** Temporary Bank Account Processor */
|
||||
private MBankAccountProcessor m_mBankAccountProcessor = null;
|
||||
|
||||
public boolean setPaymentProcessor (String tender, String CCType)
|
||||
{
|
||||
m_mBankAccountProcessor = null;
|
||||
// Get Processor List
|
||||
if (m_mBankAccountProcessors == null || m_mBankAccountProcessors.length == 0)
|
||||
m_mBankAccountProcessors = MPaymentProcessor.find (getCtx(), tender, CCType, getAD_Client_ID(),
|
||||
getC_Currency_ID(), getPayAmt(), get_TrxName());
|
||||
// Relax Amount
|
||||
if (m_mBankAccountProcessors == null || m_mBankAccountProcessors.length == 0)
|
||||
m_mBankAccountProcessors = MPaymentProcessor.find (getCtx(), tender, CCType, getAD_Client_ID(),
|
||||
getC_Currency_ID(), Env.ZERO, get_TrxName());
|
||||
if (m_mBankAccountProcessors == null || m_mBankAccountProcessors.length == 0)
|
||||
return false;
|
||||
|
||||
// Find the first right one
|
||||
for (int i = 0; i < m_mBankAccountProcessors.length; i++)
|
||||
{
|
||||
MBankAccountProcessor bankAccountProcessor = m_mBankAccountProcessors[i];
|
||||
MPaymentProcessor paymentProcessor = new MPaymentProcessor(bankAccountProcessor.getCtx(), bankAccountProcessor.getC_PaymentProcessor_ID(), bankAccountProcessor.get_TrxName());
|
||||
if (paymentProcessor.accepts (tender, CCType))
|
||||
{
|
||||
m_mBankAccountProcessor = m_mBankAccountProcessors[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_mBankAccountProcessor != null)
|
||||
{
|
||||
setC_BankAccount_ID (m_mBankAccountProcessor.getC_BankAccount_ID());
|
||||
setC_PaymentProcessor_ID (m_mBankAccountProcessor.getC_PaymentProcessor_ID());
|
||||
}
|
||||
//
|
||||
return m_mBankAccountProcessor != null;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Process Payment
|
||||
* @return true if approved
|
||||
*/
|
||||
public boolean processOnline()
|
||||
{
|
||||
log.info ("Amt=" + getPayAmt());
|
||||
//
|
||||
setIsOnline(true);
|
||||
setErrorMessage(null);
|
||||
// prevent charging twice
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
{
|
||||
if (isVoided())
|
||||
{
|
||||
log.info("Already voided - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already voided");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(getTrxType().equals(TRXTYPE_DelayedCapture))
|
||||
{
|
||||
if (isDelayedCapture())
|
||||
{
|
||||
log.info("Already delay captured - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already delay captured");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isApproved())
|
||||
{
|
||||
log.info("Already processed - " + getR_Result() + " - " + getR_RespMsg());
|
||||
setErrorMessage("Payment already processed");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mBankAccountProcessor == null)
|
||||
setPaymentProcessor();
|
||||
if (m_mBankAccountProcessor == null)
|
||||
{
|
||||
log.log(Level.WARNING, "No Payment Processor Model");
|
||||
setErrorMessage("No Payment Processor Model");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean approved = false;
|
||||
boolean processed = false;
|
||||
|
||||
try
|
||||
{
|
||||
MPaymentProcessor paymentProcessor = new MPaymentProcessor(m_mBankAccountProcessor.getCtx(), m_mBankAccountProcessor.getC_PaymentProcessor_ID(), m_mBankAccountProcessor.get_TrxName());
|
||||
PaymentProcessor pp = PaymentProcessor.create(paymentProcessor, this);
|
||||
if (pp == null)
|
||||
setErrorMessage("No Payment Processor");
|
||||
else
|
||||
{
|
||||
// Validate before trying to process
|
||||
String msg = pp.validate();
|
||||
if (msg!=null && msg.trim().length()>0) {
|
||||
setErrorMessage(Msg.getMsg(getCtx(), msg));
|
||||
} else {
|
||||
// Process if validation succeeds
|
||||
approved = pp.processCC ();
|
||||
setIsApproved(approved);
|
||||
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
setIsVoided(approved);
|
||||
else if(getTrxType().equals(TRXTYPE_DelayedCapture))
|
||||
setIsDelayedCapture(approved);
|
||||
|
||||
if (approved)
|
||||
{
|
||||
setErrorMessage(null);
|
||||
|
||||
if (!getTrxType().equals(MPaymentTransaction.TRXTYPE_Authorization)
|
||||
&& !getTrxType().equals(MPaymentTransaction.TRXTYPE_VoiceAuthorization)
|
||||
&& !getTrxType().equals(MPaymentTransaction.TRXTYPE_Void))
|
||||
{
|
||||
MPayment m_mPayment = createPayment();
|
||||
m_mPayment.saveEx();
|
||||
setC_Payment_ID(m_mPayment.getC_Payment_ID());
|
||||
processed = m_mPayment.processIt(DocAction.ACTION_Complete);
|
||||
if (!processed)
|
||||
setErrorMessage(Msg.getMsg(Env.getCtx(), "PaymentNotProcessed"));
|
||||
else
|
||||
m_mPayment.saveEx();
|
||||
}
|
||||
else
|
||||
processed = true;
|
||||
}
|
||||
else
|
||||
setErrorMessage("From " + getCreditCardName() + ": " + getR_RespMsg());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, "processOnline", e);
|
||||
setErrorMessage("Payment Processor Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
setIsApproved(approved);
|
||||
setProcessed(processed);
|
||||
|
||||
if(getTrxType().equals(TRXTYPE_Void) || getTrxType().equals(TRXTYPE_CreditPayment))
|
||||
setIsVoided(approved);
|
||||
else if(getTrxType().equals(TRXTYPE_DelayedCapture))
|
||||
setIsDelayedCapture(approved);
|
||||
|
||||
MOnlineTrxHistory history = new MOnlineTrxHistory(getCtx(), 0, get_TrxName());
|
||||
history.setAD_Table_ID(MPaymentTransaction.Table_ID);
|
||||
history.setRecord_ID(getC_PaymentTransaction_ID());
|
||||
history.setIsError(!(approved && processed));
|
||||
history.setProcessed(approved && processed);
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
if (approved)
|
||||
{
|
||||
msg.append("Result: " + getR_Result() + "\n");
|
||||
msg.append("Response Message: " + getR_RespMsg() + "\n");
|
||||
msg.append("Reference: " + getR_PnRef() + "\n");
|
||||
msg.append("Authorization Code: " + getR_AuthCode() + "\n");
|
||||
}
|
||||
else
|
||||
msg.append("ERROR: " + getErrorMessage() + "\n");
|
||||
msg.append("Transaction Type: " + getTrxType());
|
||||
history.setTextMsg(msg.toString());
|
||||
|
||||
history.saveEx();
|
||||
|
||||
return approved && processed;
|
||||
}
|
||||
|
||||
public boolean voidOnlineAuthorizationPaymentTransaction()
|
||||
{
|
||||
if (getTenderType().equals(TENDERTYPE_CreditCard) && isOnline() && getTrxType().equals(TRXTYPE_Authorization) && !isVoided() && !isDelayedCapture())
|
||||
{
|
||||
MPaymentTransaction m_mPaymentTransaction = copyFrom(this, new Timestamp(System.currentTimeMillis()), TRXTYPE_Void, getR_PnRef(), get_TrxName());
|
||||
m_mPaymentTransaction.setIsApproved(false);
|
||||
m_mPaymentTransaction.setIsVoided(false);
|
||||
m_mPaymentTransaction.setIsDelayedCapture(false);
|
||||
boolean ok = m_mPaymentTransaction.processOnline();
|
||||
m_mPaymentTransaction.setRef_PaymentTransaction_ID(getC_PaymentTransaction_ID());
|
||||
// m_mPaymentTransaction.setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber()));
|
||||
// m_mPaymentTransaction.setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV()));
|
||||
m_mPaymentTransaction.saveEx();
|
||||
|
||||
if (ok)
|
||||
{
|
||||
setIsVoided(true);
|
||||
setR_VoidMsg(m_mPaymentTransaction.getR_VoidMsg());
|
||||
setRef_PaymentTransaction_ID(m_mPaymentTransaction.getC_PaymentTransaction_ID());
|
||||
|
||||
// setCreditCardNumber(PaymentUtil.encrpytCreditCard(getCreditCardNumber()));
|
||||
// setCreditCardVV(PaymentUtil.encrpytCvv(getCreditCardVV()));
|
||||
}
|
||||
else
|
||||
setErrorMessage(m_mPaymentTransaction.getErrorMessage());
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean delayCaptureOnlineAuthorizationPaymentTransaction(int C_Invoice_ID)
|
||||
{
|
||||
if (getTenderType().equals(TENDERTYPE_CreditCard) && isOnline() && getTrxType().equals(TRXTYPE_Authorization) && !isVoided() && !isDelayedCapture())
|
||||
{
|
||||
MPaymentTransaction m_mPaymentTransaction = copyFrom(this, new Timestamp(System.currentTimeMillis()), TRXTYPE_DelayedCapture, getR_PnRef(), get_TrxName());
|
||||
m_mPaymentTransaction.setIsApproved(false);
|
||||
m_mPaymentTransaction.setIsVoided(false);
|
||||
m_mPaymentTransaction.setIsDelayedCapture(false);
|
||||
|
||||
if (C_Invoice_ID != 0)
|
||||
m_mPaymentTransaction.setC_Invoice_ID(C_Invoice_ID);
|
||||
|
||||
boolean ok = m_mPaymentTransaction.processOnline();
|
||||
m_mPaymentTransaction.setRef_PaymentTransaction_ID(getC_PaymentTransaction_ID());
|
||||
m_mPaymentTransaction.saveEx();
|
||||
|
||||
if (ok)
|
||||
{
|
||||
if (C_Invoice_ID != 0)
|
||||
setC_Invoice_ID(C_Invoice_ID);
|
||||
setIsDelayedCapture(true);
|
||||
setRef_PaymentTransaction_ID(m_mPaymentTransaction.getC_PaymentTransaction_ID());
|
||||
}
|
||||
else
|
||||
setErrorMessage(m_mPaymentTransaction.getErrorMessage());
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getCreditCardName()
|
||||
{
|
||||
return getCreditCardName(getCreditCardType());
|
||||
}
|
||||
|
||||
public String getCreditCardName(String CreditCardType)
|
||||
{
|
||||
if (CreditCardType == null)
|
||||
return "--";
|
||||
else if (CREDITCARDTYPE_MasterCard.equals(CreditCardType))
|
||||
return "MasterCard";
|
||||
else if (CREDITCARDTYPE_Visa.equals(CreditCardType))
|
||||
return "Visa";
|
||||
else if (CREDITCARDTYPE_Amex.equals(CreditCardType))
|
||||
return "Amex";
|
||||
else if (CREDITCARDTYPE_ATM.equals(CreditCardType))
|
||||
return "ATM";
|
||||
else if (CREDITCARDTYPE_Diners.equals(CreditCardType))
|
||||
return "Diners";
|
||||
else if (CREDITCARDTYPE_Discover.equals(CreditCardType))
|
||||
return "Discover";
|
||||
else if (CREDITCARDTYPE_PurchaseCard.equals(CreditCardType))
|
||||
return "PurchaseCard";
|
||||
return "?" + CreditCardType + "?";
|
||||
}
|
||||
|
||||
/** Error Message */
|
||||
private String m_errorMessage = null;
|
||||
|
||||
public void setErrorMessage(String errorMessage)
|
||||
{
|
||||
m_errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public String getErrorMessage()
|
||||
{
|
||||
return m_errorMessage;
|
||||
}
|
||||
|
||||
public MPayment createPayment()
|
||||
{
|
||||
MPayment payment = new MPayment(getCtx(), 0, get_TrxName());
|
||||
payment.setA_City(getA_City());
|
||||
payment.setA_Country(getA_Country());
|
||||
payment.setA_EMail(getA_EMail());
|
||||
payment.setA_Ident_DL(getA_Ident_DL());
|
||||
payment.setA_Ident_SSN(getA_Ident_SSN());
|
||||
payment.setA_Name(getA_Name());
|
||||
payment.setA_State(getA_State());
|
||||
payment.setA_Street(getA_Street());
|
||||
payment.setA_Zip(getA_Zip());
|
||||
payment.setAccountNo(getAccountNo());
|
||||
payment.setAD_Org_ID(getAD_Org_ID());
|
||||
payment.setC_BankAccount_ID(getC_BankAccount_ID());
|
||||
payment.setC_BP_BankAccount_ID(getC_BP_BankAccount_ID());
|
||||
payment.setC_BPartner_ID(getC_BPartner_ID());
|
||||
payment.setC_ConversionType_ID(getC_ConversionType_ID());
|
||||
payment.setC_Currency_ID(getC_Currency_ID());
|
||||
payment.setC_Invoice_ID(getC_Invoice_ID());
|
||||
payment.setC_Order_ID(getC_Order_ID());
|
||||
payment.setC_PaymentProcessor_ID(getC_PaymentProcessor_ID());
|
||||
payment.setC_POSTenderType_ID(getC_POSTenderType_ID());
|
||||
payment.setCheckNo(getCheckNo());
|
||||
payment.setCreditCardExpMM(getCreditCardExpMM());
|
||||
payment.setCreditCardExpYY(getCreditCardExpYY());
|
||||
payment.setCreditCardNumber(getCreditCardNumber());
|
||||
payment.setCreditCardType(getCreditCardType());
|
||||
payment.setCreditCardVV(getCreditCardVV());
|
||||
payment.setCustomerAddressID(getCustomerAddressID());
|
||||
payment.setCustomerPaymentProfileID(getCustomerPaymentProfileID());
|
||||
payment.setCustomerProfileID(getCustomerProfileID());
|
||||
payment.setDateTrx(getDateTrx());
|
||||
payment.setDescription(getDescription());
|
||||
payment.setIsActive(isActive());
|
||||
payment.setIsApproved(isApproved());
|
||||
payment.setIsDelayedCapture(isDelayedCapture());
|
||||
payment.setIsOnline(isOnline());
|
||||
payment.setIsReceipt(isReceipt());
|
||||
payment.setIsSelfService(isSelfService());
|
||||
payment.setIsVoided(isVoided());
|
||||
payment.setMicr(getMicr());
|
||||
payment.setOrig_TrxID(getOrig_TrxID());
|
||||
payment.setPayAmt(getPayAmt());
|
||||
payment.setPONum(getPONum());
|
||||
payment.setProcessed(isProcessed());
|
||||
payment.setR_AuthCode(getR_AuthCode());
|
||||
payment.setR_AvsAddr(getR_AvsAddr());
|
||||
payment.setR_AvsZip(getR_AvsZip());
|
||||
payment.setR_CVV2Match(isR_CVV2Match());
|
||||
payment.setR_Info(getR_Info());
|
||||
payment.setR_PnRef(getR_PnRef());
|
||||
payment.setR_RespMsg(getR_RespMsg());
|
||||
payment.setR_Result(getR_Result());
|
||||
payment.setR_VoidMsg(getR_VoidMsg());
|
||||
payment.setRoutingNo(getRoutingNo());
|
||||
payment.setTaxAmt(getTaxAmt());
|
||||
payment.setTenderType(getTenderType());
|
||||
payment.setTrxType(getTrxType());
|
||||
payment.setVoiceAuthCode(getVoiceAuthCode());
|
||||
|
||||
payment.setDateAcct(payment.getDateTrx());
|
||||
|
||||
return payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process Online Payment.
|
||||
* implements ProcessCall after standard constructor
|
||||
* Called when pressing the Process_Online button in C_Payment
|
||||
*
|
||||
* @param ctx Context
|
||||
* @param pi Process Info
|
||||
* @param trx transaction
|
||||
* @return true if the next process should be performed
|
||||
*/
|
||||
@Override
|
||||
public boolean startProcess(Properties ctx, ProcessInfo pi, Trx trx) {
|
||||
log.info("startProcess - " + pi.getRecord_ID());
|
||||
boolean retValue = false;
|
||||
//
|
||||
if (pi.getRecord_ID() != get_ID())
|
||||
{
|
||||
log.log(Level.SEVERE, "startProcess - Not same Payment - " + pi.getRecord_ID());
|
||||
return false;
|
||||
}
|
||||
// Process it
|
||||
retValue = processOnline();
|
||||
saveEx();
|
||||
return retValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private IProcessUI m_processUI;
|
||||
|
||||
@Override
|
||||
public void setProcessUI(IProcessUI processUI) {
|
||||
m_processUI = processUI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PO getPO() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static MPaymentTransaction copyFrom(MPaymentTransaction from, Timestamp dateTrx, String trxType, String orig_TrxID, String trxName) {
|
||||
MPaymentTransaction to = new MPaymentTransaction(from.getCtx(), 0, trxName);
|
||||
to.set_TrxName(trxName);
|
||||
PO.copyValues(from, to, from.getAD_Client_ID(), from.getAD_Org_ID());
|
||||
to.set_ValueNoCheck(COLUMNNAME_C_PaymentTransaction_ID, I_ZERO);
|
||||
//
|
||||
to.setA_City(from.getA_City());
|
||||
to.setA_Country(from.getA_Country());
|
||||
to.setA_EMail(from.getA_EMail());
|
||||
to.setA_Ident_DL(from.getA_Ident_DL());
|
||||
to.setA_Ident_SSN(from.getA_Ident_SSN());
|
||||
to.setA_Name(from.getA_Name());
|
||||
to.setA_State(from.getA_State());
|
||||
to.setA_Street(from.getA_Street());
|
||||
to.setA_Zip(from.getA_Zip());
|
||||
to.setAccountNo(from.getAccountNo());
|
||||
to.setAD_Org_ID(from.getAD_Org_ID());
|
||||
to.setC_BankAccount_ID(from.getC_BankAccount_ID());
|
||||
to.setC_BP_BankAccount_ID(from.getC_BP_BankAccount_ID());
|
||||
to.setC_BPartner_ID(from.getC_BPartner_ID());
|
||||
to.setC_ConversionType_ID(from.getC_ConversionType_ID());
|
||||
to.setC_Currency_ID(from.getC_Currency_ID());
|
||||
to.setC_Invoice_ID(from.getC_Invoice_ID());
|
||||
to.setC_Order_ID(from.getC_Order_ID());
|
||||
to.setC_PaymentProcessor_ID(from.getC_PaymentProcessor_ID());
|
||||
to.setC_POSTenderType_ID(from.getC_POSTenderType_ID());
|
||||
to.setCheckNo(from.getCheckNo());
|
||||
to.setCreditCardExpMM(from.getCreditCardExpMM());
|
||||
to.setCreditCardExpYY(from.getCreditCardExpYY());
|
||||
to.setCreditCardNumber(from.getCreditCardNumber());
|
||||
to.setCreditCardType(from.getCreditCardType());
|
||||
to.setCreditCardVV(from.getCreditCardVV());
|
||||
to.setCustomerAddressID(from.getCustomerAddressID());
|
||||
to.setCustomerPaymentProfileID(from.getCustomerPaymentProfileID());
|
||||
to.setCustomerProfileID(from.getCustomerProfileID());
|
||||
to.setDateTrx(dateTrx);
|
||||
to.setDescription(from.getDescription());
|
||||
to.setIsActive(from.isActive());
|
||||
// to.setIsApproved(from.isApproved());
|
||||
// to.setIsDelayedCapture(from.isDelayedCapture());
|
||||
to.setIsOnline(from.isOnline());
|
||||
to.setIsReceipt(from.isReceipt());
|
||||
to.setIsSelfService(from.isSelfService());
|
||||
// to.setIsVoided(from.isVoided());
|
||||
to.setMicr(from.getMicr());
|
||||
to.setOrig_TrxID(orig_TrxID);
|
||||
to.setPayAmt(from.getPayAmt());
|
||||
to.setPONum(from.getPONum());
|
||||
// to.setProcessed(from.isProcessed());
|
||||
// to.setR_AuthCode(from.getR_AuthCode());
|
||||
// to.setR_AvsAddr(from.getR_AvsAddr());
|
||||
// to.setR_AvsZip(from.getR_AvsZip());
|
||||
// to.setR_CVV2Match(from.isR_CVV2Match());
|
||||
// to.setR_Info(from.getR_Info());
|
||||
// to.setR_PnRef(from.getR_PnRef());
|
||||
// to.setR_RespMsg(from.getR_RespMsg());
|
||||
// to.setR_Result(from.getR_Result());
|
||||
// to.setR_VoidMsg(from.getR_VoidMsg());
|
||||
to.setRoutingNo(from.getRoutingNo());
|
||||
to.setTaxAmt(from.getTaxAmt());
|
||||
to.setTenderType(from.getTenderType());
|
||||
to.setTrxType(trxType);
|
||||
to.setVoiceAuthCode(from.getVoiceAuthCode());
|
||||
//
|
||||
if (!to.save(trxName))
|
||||
throw new IllegalStateException("Could not create Payment Transaction");
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
public static int[] getAuthorizationPaymentTransactionIDs(int C_Order_ID, int C_Invoice_ID, String trxName)
|
||||
{
|
||||
StringBuilder whereClause = new StringBuilder();
|
||||
whereClause.append("TenderType='").append(MPaymentTransaction.TENDERTYPE_CreditCard).append("' ");
|
||||
whereClause.append("AND TrxType='").append(MPaymentTransaction.TRXTYPE_Authorization).append("' ");
|
||||
if (C_Order_ID > 0 && C_Invoice_ID > 0)
|
||||
whereClause.append(" AND (C_Order_ID=").append(C_Order_ID).append(" OR C_Invoice_ID=").append(C_Invoice_ID).append(")");
|
||||
else if (C_Order_ID > 0)
|
||||
whereClause.append(" AND C_Order_ID=").append(C_Order_ID);
|
||||
else if (C_Invoice_ID > 0)
|
||||
whereClause.append(" AND C_Invoice_ID=").append(C_Invoice_ID);
|
||||
whereClause.append(" AND IsApproved='Y' AND IsVoided='N' AND IsDelayedCapture='N' ");
|
||||
whereClause.append("ORDER BY DateTrx DESC");
|
||||
|
||||
return MPaymentTransaction.getAllIDs(Table_Name, whereClause.toString(), trxName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,558 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public interface PaymentInterface {
|
||||
|
||||
/** Set Account City.
|
||||
* City or the Credit Card or Account Holder
|
||||
*/
|
||||
public void setA_City (String A_City);
|
||||
|
||||
/** Get Account City.
|
||||
* City or the Credit Card or Account Holder
|
||||
*/
|
||||
public String getA_City();
|
||||
|
||||
/** Set Account Country.
|
||||
* Country
|
||||
*/
|
||||
public void setA_Country (String A_Country);
|
||||
|
||||
/** Get Account Country.
|
||||
* Country
|
||||
*/
|
||||
public String getA_Country();
|
||||
|
||||
/** Set Account EMail.
|
||||
* Email Address
|
||||
*/
|
||||
public void setA_EMail (String A_EMail);
|
||||
|
||||
/** Get Account EMail.
|
||||
* Email Address
|
||||
*/
|
||||
public String getA_EMail();
|
||||
|
||||
/** Set Driver License.
|
||||
* Payment Identification - Driver License
|
||||
*/
|
||||
public void setA_Ident_DL (String A_Ident_DL);
|
||||
|
||||
/** Get Driver License.
|
||||
* Payment Identification - Driver License
|
||||
*/
|
||||
public String getA_Ident_DL();
|
||||
|
||||
/** Set Social Security No.
|
||||
* Payment Identification - Social Security No
|
||||
*/
|
||||
public void setA_Ident_SSN (String A_Ident_SSN);
|
||||
|
||||
/** Get Social Security No.
|
||||
* Payment Identification - Social Security No
|
||||
*/
|
||||
public String getA_Ident_SSN();
|
||||
|
||||
/** Set Account Name.
|
||||
* Name on Credit Card or Account holder
|
||||
*/
|
||||
public void setA_Name (String A_Name);
|
||||
|
||||
/** Get Account Name.
|
||||
* Name on Credit Card or Account holder
|
||||
*/
|
||||
public String getA_Name();
|
||||
|
||||
/** Set Account State.
|
||||
* State of the Credit Card or Account holder
|
||||
*/
|
||||
public void setA_State (String A_State);
|
||||
|
||||
/** Get Account State.
|
||||
* State of the Credit Card or Account holder
|
||||
*/
|
||||
public String getA_State();
|
||||
|
||||
/** Set Account Street.
|
||||
* Street address of the Credit Card or Account holder
|
||||
*/
|
||||
public void setA_Street (String A_Street);
|
||||
|
||||
/** Get Account Street.
|
||||
* Street address of the Credit Card or Account holder
|
||||
*/
|
||||
public String getA_Street();
|
||||
|
||||
/** Set Account Zip/Postal.
|
||||
* Zip Code of the Credit Card or Account Holder
|
||||
*/
|
||||
public void setA_Zip (String A_Zip);
|
||||
|
||||
/** Get Account Zip/Postal.
|
||||
* Zip Code of the Credit Card or Account Holder
|
||||
*/
|
||||
public String getA_Zip();
|
||||
|
||||
/** Set Account No.
|
||||
* Account Number
|
||||
*/
|
||||
public void setAccountNo (String AccountNo);
|
||||
|
||||
/** Get Account No.
|
||||
* Account Number
|
||||
*/
|
||||
public String getAccountNo();
|
||||
|
||||
/** Set Bank Account.
|
||||
* Account at the Bank
|
||||
*/
|
||||
public void setC_BankAccount_ID (int C_BankAccount_ID);
|
||||
|
||||
/** Get Bank Account.
|
||||
* Account at the Bank
|
||||
*/
|
||||
public int getC_BankAccount_ID();
|
||||
|
||||
public org.compiere.model.I_C_BankAccount getC_BankAccount() throws RuntimeException;
|
||||
|
||||
/** Set Partner Bank Account.
|
||||
* Bank Account of the Business Partner
|
||||
*/
|
||||
public void setC_BP_BankAccount_ID (int C_BP_BankAccount_ID);
|
||||
|
||||
/** Get Partner Bank Account.
|
||||
* Bank Account of the Business Partner
|
||||
*/
|
||||
public int getC_BP_BankAccount_ID();
|
||||
|
||||
public org.compiere.model.I_C_BP_BankAccount getC_BP_BankAccount() throws RuntimeException;
|
||||
|
||||
/** Set Business Partner .
|
||||
* Identifies a Business Partner
|
||||
*/
|
||||
public void setC_BPartner_ID (int C_BPartner_ID);
|
||||
|
||||
/** Get Business Partner .
|
||||
* Identifies a Business Partner
|
||||
*/
|
||||
public int getC_BPartner_ID();
|
||||
|
||||
public org.compiere.model.I_C_BPartner getC_BPartner() throws RuntimeException;
|
||||
|
||||
/** Set Currency Type.
|
||||
* Currency Conversion Rate Type
|
||||
*/
|
||||
public void setC_ConversionType_ID (int C_ConversionType_ID);
|
||||
|
||||
/** Get Currency Type.
|
||||
* Currency Conversion Rate Type
|
||||
*/
|
||||
public int getC_ConversionType_ID();
|
||||
|
||||
public org.compiere.model.I_C_ConversionType getC_ConversionType() throws RuntimeException;
|
||||
|
||||
/** Set Currency.
|
||||
* The Currency for this record
|
||||
*/
|
||||
public void setC_Currency_ID (int C_Currency_ID);
|
||||
|
||||
/** Get Currency.
|
||||
* The Currency for this record
|
||||
*/
|
||||
public int getC_Currency_ID();
|
||||
|
||||
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException;
|
||||
|
||||
/** Set Invoice.
|
||||
* Invoice Identifier
|
||||
*/
|
||||
public void setC_Invoice_ID (int C_Invoice_ID);
|
||||
|
||||
/** Get Invoice.
|
||||
* Invoice Identifier
|
||||
*/
|
||||
public int getC_Invoice_ID();
|
||||
|
||||
public org.compiere.model.I_C_Invoice getC_Invoice() throws RuntimeException;
|
||||
|
||||
/** Set Order.
|
||||
* Order
|
||||
*/
|
||||
public void setC_Order_ID (int C_Order_ID);
|
||||
|
||||
/** Get Order.
|
||||
* Order
|
||||
*/
|
||||
public int getC_Order_ID();
|
||||
|
||||
public org.compiere.model.I_C_Order getC_Order() throws RuntimeException;
|
||||
|
||||
|
||||
/** Set Payment Processor.
|
||||
* Payment processor for electronic payments
|
||||
*/
|
||||
public void setC_PaymentProcessor_ID (int C_PaymentProcessor_ID);
|
||||
|
||||
/** Get Payment Processor.
|
||||
* Payment processor for electronic payments
|
||||
*/
|
||||
public int getC_PaymentProcessor_ID();
|
||||
|
||||
public org.compiere.model.I_C_PaymentProcessor getC_PaymentProcessor() throws RuntimeException;
|
||||
|
||||
/** Set POS Tender Type */
|
||||
public void setC_POSTenderType_ID (int C_POSTenderType_ID);
|
||||
|
||||
/** Get POS Tender Type */
|
||||
public int getC_POSTenderType_ID();
|
||||
|
||||
public org.compiere.model.I_C_POSTenderType getC_POSTenderType() throws RuntimeException;
|
||||
|
||||
/** Set Check No.
|
||||
* Check Number
|
||||
*/
|
||||
public void setCheckNo (String CheckNo);
|
||||
|
||||
/** Get Check No.
|
||||
* Check Number
|
||||
*/
|
||||
public String getCheckNo();
|
||||
|
||||
/** Set Exp. Month.
|
||||
* Expiry Month
|
||||
*/
|
||||
public void setCreditCardExpMM (int CreditCardExpMM);
|
||||
|
||||
/** Get Exp. Month.
|
||||
* Expiry Month
|
||||
*/
|
||||
public int getCreditCardExpMM();
|
||||
|
||||
/** Set Exp. Year.
|
||||
* Expiry Year
|
||||
*/
|
||||
public void setCreditCardExpYY (int CreditCardExpYY);
|
||||
|
||||
/** Get Exp. Year.
|
||||
* Expiry Year
|
||||
*/
|
||||
public int getCreditCardExpYY();
|
||||
|
||||
/** Set Number.
|
||||
* Credit Card Number
|
||||
*/
|
||||
public void setCreditCardNumber (String CreditCardNumber);
|
||||
|
||||
/** Get Number.
|
||||
* Credit Card Number
|
||||
*/
|
||||
public String getCreditCardNumber();
|
||||
|
||||
/** Set Credit Card.
|
||||
* Credit Card (Visa, MC, AmEx)
|
||||
*/
|
||||
public void setCreditCardType (String CreditCardType);
|
||||
|
||||
/** Get Credit Card.
|
||||
* Credit Card (Visa, MC, AmEx)
|
||||
*/
|
||||
public String getCreditCardType();
|
||||
|
||||
/** Set Verification Code.
|
||||
* Credit Card Verification code on credit card
|
||||
*/
|
||||
public void setCreditCardVV (String CreditCardVV);
|
||||
|
||||
/** Get Verification Code.
|
||||
* Credit Card Verification code on credit card
|
||||
*/
|
||||
public String getCreditCardVV();
|
||||
|
||||
/** Set Customer Address ID */
|
||||
public void setCustomerAddressID (String CustomerAddressID);
|
||||
|
||||
/** Get Customer Address ID */
|
||||
public String getCustomerAddressID();
|
||||
|
||||
/** Set Customer Payment Profile ID */
|
||||
public void setCustomerPaymentProfileID (String CustomerPaymentProfileID);
|
||||
|
||||
/** Get Customer Payment Profile ID */
|
||||
public String getCustomerPaymentProfileID();
|
||||
|
||||
/** Set Customer Profile ID */
|
||||
public void setCustomerProfileID (String CustomerProfileID);
|
||||
|
||||
/** Get Customer Profile ID */
|
||||
public String getCustomerProfileID();
|
||||
|
||||
/** Set Transaction Date.
|
||||
* Transaction Date
|
||||
*/
|
||||
public void setDateTrx (Timestamp DateTrx);
|
||||
|
||||
/** Get Transaction Date.
|
||||
* Transaction Date
|
||||
*/
|
||||
public Timestamp getDateTrx();
|
||||
|
||||
/** Set Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description);
|
||||
|
||||
/** Get Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/** Set Approved.
|
||||
* Indicates if this document requires approval
|
||||
*/
|
||||
public void setIsApproved (boolean IsApproved);
|
||||
|
||||
/** Get Approved.
|
||||
* Indicates if this document requires approval
|
||||
*/
|
||||
public boolean isApproved();
|
||||
|
||||
/** Set Delayed Capture.
|
||||
* Charge after Shipment
|
||||
*/
|
||||
public void setIsDelayedCapture (boolean IsDelayedCapture);
|
||||
|
||||
/** Get Delayed Capture.
|
||||
* Charge after Shipment
|
||||
*/
|
||||
public boolean isDelayedCapture();
|
||||
|
||||
/** Set Online Access.
|
||||
* Can be accessed online
|
||||
*/
|
||||
public void setIsOnline (boolean IsOnline);
|
||||
|
||||
/** Get Online Access.
|
||||
* Can be accessed online
|
||||
*/
|
||||
public boolean isOnline();
|
||||
|
||||
/** Set Receipt.
|
||||
* This is a sales transaction (receipt)
|
||||
*/
|
||||
public void setIsReceipt (boolean IsReceipt);
|
||||
|
||||
/** Get Receipt.
|
||||
* This is a sales transaction (receipt)
|
||||
*/
|
||||
public boolean isReceipt();
|
||||
|
||||
/** Set Self-Service.
|
||||
* This is a Self-Service entry or this entry can be changed via Self-Service
|
||||
*/
|
||||
public void setIsSelfService (boolean IsSelfService);
|
||||
|
||||
/** Get Self-Service.
|
||||
* This is a Self-Service entry or this entry can be changed via Self-Service
|
||||
*/
|
||||
public boolean isSelfService();
|
||||
|
||||
/** Set Voided */
|
||||
public void setIsVoided (boolean IsVoided);
|
||||
|
||||
/** Get Voided */
|
||||
public boolean isVoided();
|
||||
|
||||
/** Set Micr.
|
||||
* Combination of routing no, account and check no
|
||||
*/
|
||||
public void setMicr (String Micr);
|
||||
|
||||
/** Get Micr.
|
||||
* Combination of routing no, account and check no
|
||||
*/
|
||||
public String getMicr();
|
||||
|
||||
/** Set Original Transaction ID.
|
||||
* Original Transaction ID
|
||||
*/
|
||||
public void setOrig_TrxID (String Orig_TrxID);
|
||||
|
||||
/** Get Original Transaction ID.
|
||||
* Original Transaction ID
|
||||
*/
|
||||
public String getOrig_TrxID();
|
||||
|
||||
/** Set Payment amount.
|
||||
* Amount being paid
|
||||
*/
|
||||
public void setPayAmt (BigDecimal PayAmt);
|
||||
|
||||
/** Get Payment amount.
|
||||
* Amount being paid
|
||||
*/
|
||||
public BigDecimal getPayAmt();
|
||||
|
||||
/** Set PO Number.
|
||||
* Purchase Order Number
|
||||
*/
|
||||
public void setPONum (String PONum);
|
||||
|
||||
/** Get PO Number.
|
||||
* Purchase Order Number
|
||||
*/
|
||||
public String getPONum();
|
||||
|
||||
/** Set Processed.
|
||||
* The document has been processed
|
||||
*/
|
||||
public void setProcessed (boolean Processed);
|
||||
|
||||
/** Get Processed.
|
||||
* The document has been processed
|
||||
*/
|
||||
public boolean isProcessed();
|
||||
|
||||
/** Set Authorization Code.
|
||||
* Authorization Code returned
|
||||
*/
|
||||
public void setR_AuthCode (String R_AuthCode);
|
||||
|
||||
/** Get Authorization Code.
|
||||
* Authorization Code returned
|
||||
*/
|
||||
public String getR_AuthCode();
|
||||
|
||||
/** Set Address verified.
|
||||
* This address has been verified
|
||||
*/
|
||||
public void setR_AvsAddr (String R_AvsAddr);
|
||||
|
||||
/** Get Address verified.
|
||||
* This address has been verified
|
||||
*/
|
||||
public String getR_AvsAddr();
|
||||
|
||||
/** Set Zip verified.
|
||||
* The Zip Code has been verified
|
||||
*/
|
||||
public void setR_AvsZip (String R_AvsZip);
|
||||
|
||||
/** Get Zip verified.
|
||||
* The Zip Code has been verified
|
||||
*/
|
||||
public String getR_AvsZip();
|
||||
|
||||
/** Set CVV Match.
|
||||
* Credit Card Verification Code Match
|
||||
*/
|
||||
public void setR_CVV2Match (boolean R_CVV2Match);
|
||||
|
||||
/** Get CVV Match.
|
||||
* Credit Card Verification Code Match
|
||||
*/
|
||||
public boolean isR_CVV2Match();
|
||||
|
||||
/** Set Info.
|
||||
* Response info
|
||||
*/
|
||||
public void setR_Info (String R_Info);
|
||||
|
||||
/** Get Info.
|
||||
* Response info
|
||||
*/
|
||||
public String getR_Info();
|
||||
|
||||
/** Set Reference.
|
||||
* Payment reference
|
||||
*/
|
||||
public void setR_PnRef (String R_PnRef);
|
||||
|
||||
/** Get Reference.
|
||||
* Payment reference
|
||||
*/
|
||||
public String getR_PnRef();
|
||||
|
||||
/** Set Response Message.
|
||||
* Response message
|
||||
*/
|
||||
public void setR_RespMsg (String R_RespMsg);
|
||||
|
||||
/** Get Response Message.
|
||||
* Response message
|
||||
*/
|
||||
public String getR_RespMsg();
|
||||
|
||||
/** Set Result.
|
||||
* Result of transmission
|
||||
*/
|
||||
public void setR_Result (String R_Result);
|
||||
|
||||
/** Get Result.
|
||||
* Result of transmission
|
||||
*/
|
||||
public String getR_Result();
|
||||
|
||||
/** Set Void Message */
|
||||
public void setR_VoidMsg (String R_VoidMsg);
|
||||
|
||||
/** Get Void Message */
|
||||
public String getR_VoidMsg();
|
||||
|
||||
/** Set Routing No.
|
||||
* Bank Routing Number
|
||||
*/
|
||||
public void setRoutingNo (String RoutingNo);
|
||||
|
||||
/** Get Routing No.
|
||||
* Bank Routing Number
|
||||
*/
|
||||
public String getRoutingNo();
|
||||
|
||||
/** Set Tax Amount.
|
||||
* Tax Amount for a document
|
||||
*/
|
||||
public void setTaxAmt (BigDecimal TaxAmt);
|
||||
|
||||
/** Get Tax Amount.
|
||||
* Tax Amount for a document
|
||||
*/
|
||||
public BigDecimal getTaxAmt();
|
||||
|
||||
/** Set Tender type.
|
||||
* Method of Payment
|
||||
*/
|
||||
public void setTenderType (String TenderType);
|
||||
|
||||
/** Get Tender type.
|
||||
* Method of Payment
|
||||
*/
|
||||
public String getTenderType();
|
||||
|
||||
/** Set Transaction Type.
|
||||
* Type of credit card transaction
|
||||
*/
|
||||
public void setTrxType (String TrxType);
|
||||
|
||||
/** Get Transaction Type.
|
||||
* Type of credit card transaction
|
||||
*/
|
||||
public String getTrxType();
|
||||
|
||||
/** Set Voice authorization code.
|
||||
* Voice Authorization Code from credit card company
|
||||
*/
|
||||
public void setVoiceAuthCode (String VoiceAuthCode);
|
||||
|
||||
/** Get Voice authorization code.
|
||||
* Voice Authorization Code from credit card company
|
||||
*/
|
||||
public String getVoiceAuthCode();
|
||||
|
||||
/**
|
||||
* Get Persistent Object
|
||||
* @return PO
|
||||
*/
|
||||
public PO getPO();
|
||||
}
|
|
@ -68,10 +68,10 @@ public abstract class PaymentProcessor
|
|||
* @param mpp
|
||||
* @param mp
|
||||
*/
|
||||
public void initialize(MPaymentProcessor mpp, MPayment mp)
|
||||
public void initialize(MPaymentProcessor mpp, PaymentInterface mp)
|
||||
{
|
||||
p_mp = mp;
|
||||
p_mpp = mpp;
|
||||
p_mp = mp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,15 +80,15 @@ public abstract class PaymentProcessor
|
|||
* @param mp payment model
|
||||
* @return initialized PaymentProcessor or null
|
||||
*/
|
||||
public static PaymentProcessor create (MPaymentProcessor mpp, MPayment mp)
|
||||
public static PaymentProcessor create (MPaymentProcessor mpp, PaymentInterface mp)
|
||||
{
|
||||
return Core.getPaymentProcessor(mpp, mp);
|
||||
} // create
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
protected MPaymentProcessor p_mpp = null;
|
||||
protected MPayment p_mp = null;
|
||||
protected MPaymentProcessor p_mpp = null;
|
||||
protected PaymentInterface p_mp = null;
|
||||
//
|
||||
private int m_timeout = 30;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
|
|||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20121003L;
|
||||
private static final long serialVersionUID = 20121022L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_C_PaymentProcessor (Properties ctx, int C_PaymentProcessor_ID, String trxName)
|
||||
|
@ -736,6 +736,38 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
|
|||
return false;
|
||||
}
|
||||
|
||||
/** TrxType AD_Reference_ID=215 */
|
||||
public static final int TRXTYPE_AD_Reference_ID=215;
|
||||
/** Sales = S */
|
||||
public static final String TRXTYPE_Sales = "S";
|
||||
/** Delayed Capture = D */
|
||||
public static final String TRXTYPE_DelayedCapture = "D";
|
||||
/** Credit (Payment) = C */
|
||||
public static final String TRXTYPE_CreditPayment = "C";
|
||||
/** Voice Authorization = F */
|
||||
public static final String TRXTYPE_VoiceAuthorization = "F";
|
||||
/** Authorization = A */
|
||||
public static final String TRXTYPE_Authorization = "A";
|
||||
/** Void = V */
|
||||
public static final String TRXTYPE_Void = "V";
|
||||
/** Set Transaction Type.
|
||||
@param TrxType
|
||||
Type of credit card transaction
|
||||
*/
|
||||
public void setTrxType (String TrxType)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_TrxType, TrxType);
|
||||
}
|
||||
|
||||
/** Get Transaction Type.
|
||||
@return Type of credit card transaction
|
||||
*/
|
||||
public String getTrxType ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_TrxType);
|
||||
}
|
||||
|
||||
/** Set User ID.
|
||||
@param UserID
|
||||
User ID or account number
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,227 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. All Rights Reserved. *
|
||||
* 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 *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
/** Generated Model - DO NOT CHANGE */
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
/** Generated Model for X_OnlineTrxHistory
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.6.0LTS - $Id$ */
|
||||
public class X_X_OnlineTrxHistory extends PO implements I_X_OnlineTrxHistory, I_Persistent
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20121031L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_X_OnlineTrxHistory (Properties ctx, int X_OnlineTrxHistory_ID, String trxName)
|
||||
{
|
||||
super (ctx, X_OnlineTrxHistory_ID, trxName);
|
||||
/** if (X_OnlineTrxHistory_ID == 0)
|
||||
{
|
||||
setAD_Table_ID (0);
|
||||
setIsError (false);
|
||||
// N
|
||||
setProcessed (false);
|
||||
// N
|
||||
setRecord_ID (0);
|
||||
setX_OnlineTrxHistory_ID (0);
|
||||
} */
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_X_OnlineTrxHistory (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/** AccessLevel
|
||||
* @return 3 - Client - Org
|
||||
*/
|
||||
protected int get_AccessLevel()
|
||||
{
|
||||
return accessLevel.intValue();
|
||||
}
|
||||
|
||||
/** Load Meta Data */
|
||||
protected POInfo initPO (Properties ctx)
|
||||
{
|
||||
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
|
||||
return poi;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("X_X_OnlineTrxHistory[")
|
||||
.append(get_ID()).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public org.compiere.model.I_AD_Table getAD_Table() throws RuntimeException
|
||||
{
|
||||
return (org.compiere.model.I_AD_Table)MTable.get(getCtx(), org.compiere.model.I_AD_Table.Table_Name)
|
||||
.getPO(getAD_Table_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Table.
|
||||
@param AD_Table_ID
|
||||
Database Table information
|
||||
*/
|
||||
public void setAD_Table_ID (int AD_Table_ID)
|
||||
{
|
||||
if (AD_Table_ID < 1)
|
||||
set_Value (COLUMNNAME_AD_Table_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_AD_Table_ID, Integer.valueOf(AD_Table_ID));
|
||||
}
|
||||
|
||||
/** Get Table.
|
||||
@return Database Table information
|
||||
*/
|
||||
public int getAD_Table_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Table_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Error.
|
||||
@param IsError
|
||||
An Error occurred in the execution
|
||||
*/
|
||||
public void setIsError (boolean IsError)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsError, Boolean.valueOf(IsError));
|
||||
}
|
||||
|
||||
/** Get Error.
|
||||
@return An Error occurred in the execution
|
||||
*/
|
||||
public boolean isError ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsError);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Processed.
|
||||
@param Processed
|
||||
The document has been processed
|
||||
*/
|
||||
public void setProcessed (boolean Processed)
|
||||
{
|
||||
set_Value (COLUMNNAME_Processed, Boolean.valueOf(Processed));
|
||||
}
|
||||
|
||||
/** Get Processed.
|
||||
@return The document has been processed
|
||||
*/
|
||||
public boolean isProcessed ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_Processed);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Record ID.
|
||||
@param Record_ID
|
||||
Direct internal record ID
|
||||
*/
|
||||
public void setRecord_ID (int Record_ID)
|
||||
{
|
||||
if (Record_ID < 0)
|
||||
set_Value (COLUMNNAME_Record_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_Record_ID, Integer.valueOf(Record_ID));
|
||||
}
|
||||
|
||||
/** Get Record ID.
|
||||
@return Direct internal record ID
|
||||
*/
|
||||
public int getRecord_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_Record_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Text Message.
|
||||
@param TextMsg
|
||||
Text Message
|
||||
*/
|
||||
public void setTextMsg (String TextMsg)
|
||||
{
|
||||
set_Value (COLUMNNAME_TextMsg, TextMsg);
|
||||
}
|
||||
|
||||
/** Get Text Message.
|
||||
@return Text Message
|
||||
*/
|
||||
public String getTextMsg ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_TextMsg);
|
||||
}
|
||||
|
||||
/** Set Online Transaction History.
|
||||
@param X_OnlineTrxHistory_ID Online Transaction History */
|
||||
public void setX_OnlineTrxHistory_ID (int X_OnlineTrxHistory_ID)
|
||||
{
|
||||
if (X_OnlineTrxHistory_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_X_OnlineTrxHistory_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_X_OnlineTrxHistory_ID, Integer.valueOf(X_OnlineTrxHistory_ID));
|
||||
}
|
||||
|
||||
/** Get Online Transaction History.
|
||||
@return Online Transaction History */
|
||||
public int getX_OnlineTrxHistory_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_X_OnlineTrxHistory_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set X_OnlineTrxHistory_UU.
|
||||
@param X_OnlineTrxHistory_UU X_OnlineTrxHistory_UU */
|
||||
public void setX_OnlineTrxHistory_UU (String X_OnlineTrxHistory_UU)
|
||||
{
|
||||
set_Value (COLUMNNAME_X_OnlineTrxHistory_UU, X_OnlineTrxHistory_UU);
|
||||
}
|
||||
|
||||
/** Get X_OnlineTrxHistory_UU.
|
||||
@return X_OnlineTrxHistory_UU */
|
||||
public String getX_OnlineTrxHistory_UU ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_X_OnlineTrxHistory_UU);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ import java.io.Serializable;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.util.PaymentUtil;
|
||||
import org.compiere.util.CLogMgt;
|
||||
|
||||
/**
|
||||
|
@ -217,10 +218,10 @@ public class PP_Optimal extends PaymentProcessor
|
|||
|
||||
param.append(AMP).append(createPair(CARD_TYPE, "VI", 6));
|
||||
param.append(AMP).append(createPair(CARD_NUMBER, p_mp.getCreditCardNumber(), 19));
|
||||
param.append(AMP).append(createPair(CARD_EXPIRATION, p_mp.getCreditCardExp("/"), 5));
|
||||
param.append(AMP).append(createPair(AMOUNT, p_mp.getPayAmtInCents(), 10));
|
||||
param.append(AMP).append(createPair(CARD_EXPIRATION, PaymentUtil.getCreditCardExp(p_mp.getCreditCardExpMM(), p_mp.getCreditCardExpYY(), "/"), 5));
|
||||
param.append(AMP).append(createPair(AMOUNT, PaymentUtil.getPayAmtInCents(p_mp.getPayAmt()), 10));
|
||||
param.append(AMP).append(createPair(OPERATION, OPERATION_Purchase, 1));
|
||||
param.append(AMP).append(createPair(MERCHANT_TXN, p_mp.getC_Payment_ID(), 255));
|
||||
param.append(AMP).append(createPair(MERCHANT_TXN, p_mp.getPO().get_ID(), 255));
|
||||
param.append(AMP).append(createPair(CLIENT_VERSION, _CLIENT_VERSION, 4));
|
||||
param.append(AMP).append(createPair(CUST_NAME1, p_mp.getA_Name(), 255));
|
||||
param.append(AMP).append(createPair(STREET, p_mp.getA_Street(), 255));
|
||||
|
|
|
@ -134,7 +134,7 @@ public final class PP_PayFlowPro extends PaymentProcessor
|
|||
param.append(createPair("&INVNUM", p_mp.getC_Invoice_ID(), 9));
|
||||
|
||||
// COMMENT1/2
|
||||
param.append(createPair("&COMMENT1", p_mp.getC_Payment_ID(), 128)); // Comment
|
||||
param.append(createPair("&COMMENT1", p_mp.getPO().get_ID(), 128)); // Comment
|
||||
param.append(createPair("&COMMENT2", p_mp.getC_BPartner_ID(), 128)); // Comment2
|
||||
|
||||
return process(param.toString());
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.Serializable;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.Util;
|
||||
|
||||
|
@ -150,7 +150,7 @@ public final class PP_PayFlowPro4 extends PaymentProcessor
|
|||
param.append(createPair("&INVNUM", p_mp.getC_Invoice_ID(), 9));
|
||||
|
||||
// COMMENT1/2
|
||||
param.append(createPair("&COMMENT1", p_mp.getC_Payment_ID(), 128)); // Comment
|
||||
param.append(createPair("&COMMENT1", p_mp.getPO().get_ID(), 128)); // Comment
|
||||
param.append(createPair("&COMMENT2", p_mp.getC_BPartner_ID(), 128)); // Comment2
|
||||
|
||||
return process(param.toString());
|
||||
|
|
|
@ -115,6 +115,8 @@ public class VPaymentFormCash extends PaymentFormCash implements ActionListener
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
bAmountField.setValue(m_Amount);
|
||||
|
||||
if (m_C_Payment_ID != 0)
|
||||
|
|
|
@ -83,7 +83,6 @@ public class VPaymentFormCheck extends PaymentFormCheck implements ActionListene
|
|||
sCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||
sNumberField.setPreferredSize(new Dimension(100, 21));
|
||||
sRoutingField.setPreferredSize(new Dimension(70, 21));
|
||||
sStatus.setText(" ");
|
||||
sOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
|
||||
sOnline.addActionListener(this);
|
||||
dialog.getPanel().add(sBankAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||
|
@ -119,6 +118,8 @@ public class VPaymentFormCheck extends PaymentFormCheck implements ActionListene
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
sAmountField.setValue(m_Amount);
|
||||
|
||||
if (m_C_Payment_ID != 0)
|
||||
|
@ -264,7 +265,8 @@ public class VPaymentFormCheck extends PaymentFormCheck implements ActionListene
|
|||
if (kp != null)
|
||||
newC_BankAccount_ID = kp.getKey();
|
||||
|
||||
boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(), sCheckField.getText(), (BigDecimal) sAmountField.getValue());
|
||||
boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(),
|
||||
sCheckField.getText(), (BigDecimal) sAmountField.getValue(), trxName);
|
||||
if (!ok)
|
||||
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
|
|
|
@ -82,7 +82,6 @@ public class VPaymentFormCreditCard extends PaymentFormCreditCard implements Act
|
|||
kAmountLabel.setText(Msg.getMsg(Env.getCtx(), "Amount"));
|
||||
kOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
|
||||
kOnline.addActionListener(this);
|
||||
kStatus.setText(" ");
|
||||
dialog.getPanel().add(kTypeLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 0, 2, 0), 0, 0));
|
||||
dialog.getPanel().add(kTypeCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
|
||||
|
@ -117,6 +116,8 @@ public class VPaymentFormCreditCard extends PaymentFormCreditCard implements Act
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
kAmountField.setValue(m_Amount);
|
||||
|
||||
if (m_C_Payment_ID != 0)
|
||||
|
@ -141,6 +142,8 @@ public class VPaymentFormCreditCard extends PaymentFormCreditCard implements Act
|
|||
/**
|
||||
* Load Credit Cards
|
||||
*/
|
||||
kTypeCombo.removeAllItems();
|
||||
|
||||
ValueNamePair[] ccs = getCreditCardList();
|
||||
for (int i = 0; i < ccs.length; i++)
|
||||
kTypeCombo.addItem(ccs[i]);
|
||||
|
@ -222,7 +225,7 @@ public class VPaymentFormCreditCard extends PaymentFormCreditCard implements Act
|
|||
if (vp != null)
|
||||
newCCType = vp.getValue();
|
||||
|
||||
boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue());
|
||||
boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue(), trxName);
|
||||
if(!ok)
|
||||
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
|
@ -243,8 +246,12 @@ public class VPaymentFormCreditCard extends PaymentFormCreditCard implements Act
|
|||
boolean ok = processOnline(CCType, kNumberField.getText(), kExpField.getText());
|
||||
if (!ok)
|
||||
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
ADialog.info(getWindowNo(), dialog, "PaymentProcessed", processMsg);
|
||||
else
|
||||
{
|
||||
loadData();
|
||||
if (processMsg != null)
|
||||
ADialog.info(getWindowNo(), dialog, "PaymentProcessed", processMsg);
|
||||
}
|
||||
} // online
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,7 +66,6 @@ public abstract class VPaymentFormDirect extends PaymentFormDirect implements Ac
|
|||
tNumberText.setText(Msg.translate(Env.getCtx(), "AccountNo"));
|
||||
tOnline.setText(Msg.getMsg(Env.getCtx(), "Online"));
|
||||
tOnline.addActionListener(this);
|
||||
tStatus.setText(" ");
|
||||
dialog.getPanel().add(tAccountLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
|
||||
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
|
||||
dialog.getPanel().add(tAccountCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
|
||||
|
@ -131,7 +130,7 @@ public abstract class VPaymentFormDirect extends PaymentFormDirect implements Ac
|
|||
|
||||
@Override
|
||||
public boolean saveChangesInTrx(String trxName) {
|
||||
boolean ok = save(0, tRoutingField.getText(), tNumberField.getText());
|
||||
boolean ok = save(0, tRoutingField.getText(), tNumberField.getText(), trxName);
|
||||
if (!ok)
|
||||
ADialog.error(getWindowNo(), dialog, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
|
|
|
@ -55,6 +55,8 @@ public class VPaymentFormOnCredit extends PaymentFormOnCredit {
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
ArrayList<KeyNamePair> list = getPaymentTermList();
|
||||
for (KeyNamePair pp : list)
|
||||
pTermCombo.addItem(pp);
|
||||
|
|
|
@ -129,6 +129,8 @@ public class WPaymentFormCash extends PaymentFormCash implements EventListener<E
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
bAmountField.setValue(m_Amount);
|
||||
|
||||
if (m_C_Payment_ID != 0)
|
||||
|
|
|
@ -92,7 +92,6 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
|
|||
sCurrencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID"));
|
||||
sNumberField.setWidth("100pt");
|
||||
sRoutingField.setWidth("70pt");
|
||||
sStatus.setText(" ");
|
||||
sOnline.setLabel(Msg.getMsg(Env.getCtx(), "Online"));
|
||||
LayoutUtils.addSclass("action-text-button", sOnline);
|
||||
sOnline.addActionListener(this);
|
||||
|
@ -149,7 +148,9 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
|
|||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
sAmountField.setValue(m_Amount);
|
||||
|
||||
if (m_C_Payment_ID != 0)
|
||||
|
@ -292,7 +293,8 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
|
|||
if (kp != null)
|
||||
newC_BankAccount_ID = kp.getKey();
|
||||
|
||||
boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(), sCheckField.getText(), (BigDecimal) sAmountField.getValue());
|
||||
boolean ok = save(newC_BankAccount_ID, sRoutingField.getText(), sNumberField.getText(),
|
||||
sCheckField.getText(), (BigDecimal) sAmountField.getValue(), trxName);
|
||||
if (!ok)
|
||||
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
|
|
|
@ -15,6 +15,7 @@ package org.adempiere.webui.apps.form;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.adempiere.util.PaymentUtil;
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Column;
|
||||
|
@ -34,6 +35,7 @@ import org.adempiere.webui.window.FDialog;
|
|||
import org.compiere.grid.PaymentFormCreditCard;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MBankAccountProcessor;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MPaymentProcessor;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -88,7 +90,6 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
kOnline.setLabel(Msg.getMsg(Env.getCtx(), "Online"));
|
||||
LayoutUtils.addSclass("action-text-button", kOnline);
|
||||
kOnline.addActionListener(this);
|
||||
kStatus.setText(" ");
|
||||
window.getPanel().setId("kPanel");
|
||||
|
||||
Columns columns = new Columns();
|
||||
|
@ -140,6 +141,8 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
kAmountField.setValue(m_Amount);
|
||||
|
||||
if (m_C_Payment_ID != 0)
|
||||
|
@ -151,17 +154,35 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
kAmountField.setValue(m_mPayment.getPayAmt());
|
||||
|
||||
// if approved/paid, don't let it change
|
||||
kTypeCombo.setEnabled(!m_mPayment.isApproved());
|
||||
kNumberField.setReadonly(m_mPayment.isApproved());
|
||||
kExpField.setReadonly(m_mPayment.isApproved());
|
||||
kApprovalField.setReadonly(m_mPayment.isApproved());
|
||||
kOnline.setEnabled(!m_mPayment.isApproved());
|
||||
kAmountField.setReadWrite(!m_mPayment.isApproved());
|
||||
kTypeCombo.setEnabled(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed)));
|
||||
kNumberField.setReadonly(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed));
|
||||
kExpField.setReadonly(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed));
|
||||
kApprovalField.setReadonly(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed));
|
||||
kOnline.setEnabled(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed)));
|
||||
kAmountField.setReadWrite(!(m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed)));
|
||||
}
|
||||
else if (m_mPaymentTransaction != null)
|
||||
{
|
||||
kNumberField.setText(m_mPaymentTransaction.getCreditCardNumber());
|
||||
kExpField.setText(PaymentUtil.getCreditCardExp(m_mPaymentTransaction.getCreditCardExpMM(), m_mPaymentTransaction.getCreditCardExpYY(), null));
|
||||
kApprovalField.setText(m_mPaymentTransaction.getVoiceAuthCode());
|
||||
kStatus.setText(m_mPaymentTransaction.getR_PnRef());
|
||||
kAmountField.setValue(m_mPaymentTransaction.getPayAmt());
|
||||
|
||||
// if approved/paid, don't let it change
|
||||
kTypeCombo.setEnabled(!m_mPaymentTransaction.isApproved());
|
||||
kNumberField.setReadonly(m_mPaymentTransaction.isApproved());
|
||||
kExpField.setReadonly(m_mPaymentTransaction.isApproved());
|
||||
kApprovalField.setReadonly(m_mPaymentTransaction.isApproved());
|
||||
kOnline.setEnabled(!m_mPaymentTransaction.isApproved());
|
||||
kAmountField.setReadWrite(!m_mPaymentTransaction.isApproved());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Credit Cards
|
||||
*/
|
||||
kTypeCombo.removeAllItems();
|
||||
|
||||
ValueNamePair[] ccs = getCreditCardList();
|
||||
for (int i = 0; i < ccs.length; i++)
|
||||
kTypeCombo.addItem(ccs[i]);
|
||||
|
@ -170,14 +191,22 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
if (selectedCreditCard != null)
|
||||
kTypeCombo.setSelectedValueNamePair(selectedCreditCard);
|
||||
|
||||
if (m_mPayment.isApproved())
|
||||
if (m_mPayment.isApproved() && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))
|
||||
{
|
||||
kOnline.setVisible(true);
|
||||
kOnline.setVisible(m_mPayment.isOnline());
|
||||
kOnline.setEnabled(false);
|
||||
|
||||
MBankAccountProcessor bankAccountProcessor = new MBankAccountProcessor(m_mPayment.getCtx(), m_mPayment.getC_BankAccount_ID(), m_mPayment.getC_PaymentProcessor_ID(), null);
|
||||
setBankAccountProcessor(bankAccountProcessor);
|
||||
}
|
||||
else if (m_mPaymentTransaction != null)
|
||||
{
|
||||
kOnline.setVisible(m_mPaymentTransaction.isOnline());
|
||||
kOnline.setEnabled(false);
|
||||
|
||||
MBankAccountProcessor bankAccountProcessor = new MBankAccountProcessor(m_mPaymentTransaction.getCtx(), m_mPaymentTransaction.getC_BankAccount_ID(), m_mPaymentTransaction.getC_PaymentProcessor_ID(), null);
|
||||
setBankAccountProcessor(bankAccountProcessor);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean exist = isBankAccountProcessorExist("", (BigDecimal) kAmountField.getValue());
|
||||
|
@ -237,7 +266,7 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
if (vp != null)
|
||||
newCCType = vp.getValue();
|
||||
|
||||
boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue());
|
||||
boolean ok = save(newCCType, kNumberField.getText(), kExpField.getText(), (BigDecimal) kAmountField.getValue(), trxName);
|
||||
if(!ok)
|
||||
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
|
@ -259,8 +288,12 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
|
|||
boolean ok = processOnline(CCType, kNumberField.getText(), kExpField.getText());
|
||||
if (!ok)
|
||||
FDialog.error(getWindowNo(), window, "PaymentNotProcessed", processMsg);
|
||||
else if (processMsg != null)
|
||||
FDialog.info(getWindowNo(), window, "PaymentProcessed", processMsg);
|
||||
else
|
||||
{
|
||||
loadData();
|
||||
if (processMsg != null)
|
||||
FDialog.info(getWindowNo(), window, "PaymentProcessed", processMsg);
|
||||
}
|
||||
} // online
|
||||
|
||||
@Override
|
||||
|
|
|
@ -78,7 +78,6 @@ public abstract class WPaymentFormDirect extends PaymentFormDirect implements Ev
|
|||
tOnline.setLabel(Msg.getMsg(Env.getCtx(), "Online"));
|
||||
LayoutUtils.addSclass("action-text-button", tOnline);
|
||||
tOnline.addActionListener(this);
|
||||
tStatus.setText(" ");
|
||||
window.getPanel().setId("tPanel");
|
||||
|
||||
Columns columns = new Columns();
|
||||
|
@ -112,7 +111,7 @@ public abstract class WPaymentFormDirect extends PaymentFormDirect implements Ev
|
|||
row.appendChild(new Space());
|
||||
row.appendChild(tOnline);
|
||||
|
||||
row = rows.newRow();
|
||||
row = rows.newRow();
|
||||
row.appendCellChild(tStatus, 2);
|
||||
}
|
||||
|
||||
|
@ -165,7 +164,7 @@ public abstract class WPaymentFormDirect extends PaymentFormDirect implements Ev
|
|||
|
||||
@Override
|
||||
public boolean saveChangesInTrx(final String trxName) {
|
||||
boolean ok = save(0, tRoutingField.getText(), tNumberField.getText());
|
||||
boolean ok = save(0, tRoutingField.getText(), tNumberField.getText(), trxName);
|
||||
if (!ok)
|
||||
FDialog.error(getWindowNo(), window, "PaymentError", processMsg);
|
||||
else if (processMsg != null)
|
||||
|
|
|
@ -74,6 +74,8 @@ public class WPaymentFormOnCredit extends PaymentFormOnCredit {
|
|||
|
||||
@Override
|
||||
public void loadData() {
|
||||
super.loadData();
|
||||
|
||||
ArrayList<KeyNamePair> list = getPaymentTermList();
|
||||
for (KeyNamePair pp : list)
|
||||
pTermCombo.addItem(pp);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
|
|||
zkInit();
|
||||
initOK = dynInit(); // Null Pointer if order/invoice not saved yet
|
||||
} catch (Exception ex) {
|
||||
FDialog.error(windowNo, this, ex.getMessage());
|
||||
FDialog.error(windowNo, this, ex.getMessage() == null ? ex.toString() : ex.getMessage());
|
||||
initOK = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,12 +17,30 @@ import org.compiere.model.MBankAccountProcessor;
|
|||
|
||||
public interface IPaymentForm {
|
||||
|
||||
public boolean dynInit() throws Exception;
|
||||
|
||||
public void loadData();
|
||||
|
||||
public boolean checkMandatory();
|
||||
|
||||
/**************************************************************************
|
||||
* Save Changes
|
||||
* @return true, if Window can exit
|
||||
*/
|
||||
public boolean saveChanges();
|
||||
|
||||
public boolean saveChangesInTrx(final String trxName);
|
||||
|
||||
/**
|
||||
* Need Save record (payment with waiting order)
|
||||
* @return true if payment with waiting order
|
||||
*/
|
||||
public boolean needSave();
|
||||
|
||||
public void processOnline();
|
||||
|
||||
public boolean isApproved();
|
||||
|
||||
public void showWindow();
|
||||
|
||||
public void closeWindow();
|
||||
|
|
|
@ -25,8 +25,6 @@ import java.util.logging.Level;
|
|||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MBankAccountProcessor;
|
||||
import org.compiere.model.MCashLine;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.MPaymentProcessor;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.util.CLogger;
|
||||
|
@ -56,23 +54,12 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
public String m_DocStatus = null;
|
||||
/** Start Payment Rule */
|
||||
public String m_PaymentRule = "";
|
||||
/** Start Payment Term */
|
||||
public int m_C_PaymentTerm_ID = 0;
|
||||
/** Start Acct Date */
|
||||
public Timestamp m_DateAcct = null;
|
||||
/** Start Payment */
|
||||
public int m_C_Payment_ID = 0;
|
||||
public MPayment m_mPayment = null;
|
||||
public MPayment m_mPaymentOriginal = null;
|
||||
/** Start CashBook Line */
|
||||
public int m_C_CashLine_ID = 0;
|
||||
public MCashLine m_cashLine = null;
|
||||
/** Start CreditCard */
|
||||
public String m_CCType = "";
|
||||
/** Start Bank Account */
|
||||
public int m_C_BankAccount_ID = 0;
|
||||
/** Start CashBook */
|
||||
public int m_C_CashBook_ID = 0;
|
||||
// public int m_C_Payment_ID = 0;
|
||||
// public MPayment m_mPayment = null;
|
||||
// public MPayment m_mPaymentOriginal = null;
|
||||
|
||||
/** Invoice Currency */
|
||||
public int m_C_Currency_ID = 0;
|
||||
|
@ -96,6 +83,7 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
m_mTab = mTab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dynInit() throws Exception {
|
||||
m_DocStatus = (String) m_mTab.getValue("DocStatus");
|
||||
log.config(m_DocStatus);
|
||||
|
@ -120,8 +108,6 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
if (!m_onlyRule // Only order has Warehouse
|
||||
&& !m_isSOTrx && m_mTab.getValue("M_Warehouse_ID") != null)
|
||||
m_onlyRule = true;
|
||||
|
||||
// centerPanel.setVisible(!m_onlyRule);
|
||||
|
||||
// Amount
|
||||
m_Amount = (BigDecimal)m_mTab.getValue("GrandTotal");
|
||||
|
@ -140,45 +126,9 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
m_PaymentRule = (String)m_mTab.getValue("PaymentRule");
|
||||
m_C_Currency_ID = ((Integer)m_mTab.getValue("C_Currency_ID")).intValue();
|
||||
m_DateAcct = (Timestamp)m_mTab.getValue("DateAcct");
|
||||
if (m_mTab.getValue("C_PaymentTerm_ID") != null)
|
||||
m_C_PaymentTerm_ID = ((Integer)m_mTab.getValue("C_PaymentTerm_ID")).intValue();
|
||||
// Existing Payment
|
||||
if (m_mTab.getValue("C_Payment_ID") != null)
|
||||
{
|
||||
m_C_Payment_ID = ((Integer)m_mTab.getValue("C_Payment_ID")).intValue();
|
||||
if (m_C_Payment_ID != 0)
|
||||
{
|
||||
m_mPayment = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
|
||||
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null); // full copy
|
||||
m_CCType = m_mPayment.getCreditCardType();
|
||||
m_C_BankAccount_ID = m_mPayment.getC_BankAccount_ID();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mPayment == null)
|
||||
{
|
||||
m_mPayment = new MPayment (Env.getCtx (), 0, null);
|
||||
m_mPayment.setAD_Org_ID(m_AD_Org_ID);
|
||||
m_mPayment.setAmount (m_C_Currency_ID, m_Amount);
|
||||
}
|
||||
|
||||
if (s_Currencies == null)
|
||||
loadCurrencies();
|
||||
|
||||
m_cashLine = null;
|
||||
m_C_CashLine_ID = 0;
|
||||
if (m_mTab.getValue("C_CashLine_ID") != null)
|
||||
{
|
||||
m_C_CashLine_ID = ((Integer)m_mTab.getValue("C_CashLine_ID")).intValue();
|
||||
if (m_C_CashLine_ID == 0)
|
||||
m_cashLine = null;
|
||||
else
|
||||
{
|
||||
m_cashLine = new MCashLine (Env.getCtx(), m_C_CashLine_ID, null);
|
||||
m_DateAcct = m_cashLine.getStatementDate();
|
||||
m_C_CashBook_ID = m_cashLine.getCashBook().getC_CashBook_ID();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Payment Combo
|
||||
|
@ -191,26 +141,13 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
return true;
|
||||
}
|
||||
|
||||
public abstract void loadData();
|
||||
|
||||
/**************************************************************************
|
||||
* Save Changes
|
||||
* @return true, if Window can exit
|
||||
*/
|
||||
@Override
|
||||
public boolean saveChanges() {
|
||||
// BF [ 1920179 ] perform the save in a trx's context.
|
||||
final boolean[] success = new boolean[] { false };
|
||||
final TrxRunnable r = new TrxRunnable() {
|
||||
|
||||
public void run(String trxName) {
|
||||
// set trxname for class objects
|
||||
if (m_cashLine != null)
|
||||
m_cashLine.set_TrxName(trxName);
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(trxName);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(trxName);
|
||||
|
||||
// only Payment Rule
|
||||
if (m_onlyRule)
|
||||
success[0] = true;
|
||||
|
@ -227,12 +164,6 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
success[0] = false;
|
||||
throw new AdempiereException("PaymentError", e);
|
||||
}
|
||||
if (m_cashLine != null)
|
||||
m_cashLine.set_TrxName(null);
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(null);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPayment.set_TrxName(null);
|
||||
return success[0];
|
||||
} // saveChanges
|
||||
|
||||
|
@ -264,10 +195,7 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
}
|
||||
} // loadCurrencies
|
||||
|
||||
/**
|
||||
* Need Save record (payment with waiting order)
|
||||
* @return true if payment with waiting order
|
||||
*/
|
||||
@Override
|
||||
public boolean needSave()
|
||||
{
|
||||
return m_needSave;
|
||||
|
@ -300,12 +228,13 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
return retValue;
|
||||
} // getInvoiceID
|
||||
|
||||
@Override
|
||||
public void processOnline()
|
||||
{
|
||||
throw new AdempiereException(Msg.getMsg(Env.getCtx(), "ActionNotSupported"));
|
||||
}
|
||||
|
||||
public boolean isBankAccountProcessorExist(Properties ctx, String tender, String CCType, int AD_Client_ID, int C_Currency_ID, BigDecimal PayAmt, String trxName)
|
||||
protected boolean isBankAccountProcessorExist(Properties ctx, String tender, String CCType, int AD_Client_ID, int C_Currency_ID, BigDecimal PayAmt, String trxName)
|
||||
{
|
||||
MBankAccountProcessor[] m_mBankAccountProcessors = MPaymentProcessor.find(ctx, tender, CCType, AD_Client_ID, C_Currency_ID, PayAmt, trxName);
|
||||
// Relax Amount
|
||||
|
@ -316,7 +245,7 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
return true;
|
||||
}
|
||||
|
||||
public MBankAccountProcessor getBankAccountProcessor(Properties ctx, String tender, String CCType, int AD_Client_ID, int C_Currency_ID, BigDecimal PayAmt, String trxName)
|
||||
protected MBankAccountProcessor getBankAccountProcessor(Properties ctx, String tender, String CCType, int AD_Client_ID, int C_Currency_ID, BigDecimal PayAmt, String trxName)
|
||||
{
|
||||
MBankAccountProcessor[] m_mBankAccountProcessors = MPaymentProcessor.find(ctx, tender, CCType, AD_Client_ID, C_Currency_ID, PayAmt, trxName);
|
||||
// Relax Amount
|
||||
|
@ -329,8 +258,8 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
// Find the first right one
|
||||
for (int i = 0; i < m_mBankAccountProcessors.length; i++)
|
||||
{
|
||||
MBankAccountProcessor bankAccountProcessor = m_mBankAccountProcessors[i];
|
||||
MPaymentProcessor paymentProcessor = new MPaymentProcessor(bankAccountProcessor.getCtx(), bankAccountProcessor.getC_PaymentProcessor_ID(), bankAccountProcessor.get_TrxName());
|
||||
MBankAccountProcessor bap = m_mBankAccountProcessors[i];
|
||||
MPaymentProcessor paymentProcessor = new MPaymentProcessor(bap.getCtx(), bap.getC_PaymentProcessor_ID(), bap.get_TrxName());
|
||||
if (paymentProcessor.accepts (tender, CCType))
|
||||
{
|
||||
m_mBankAccountProcessor = m_mBankAccountProcessors[i];
|
||||
|
@ -351,9 +280,10 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
return m_onlyRule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApproved()
|
||||
{
|
||||
return m_mPayment.isApproved();
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getWindowNo()
|
||||
|
@ -361,16 +291,19 @@ public abstract class PaymentForm implements IPaymentForm {
|
|||
return m_WindowNo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCustomizePanel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomizeValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBankAccountProcessor(MBankAccountProcessor bankAccountProcessor)
|
||||
{
|
||||
|
||||
|
|
|
@ -45,10 +45,61 @@ import org.compiere.util.TimeUtil;
|
|||
public abstract class PaymentFormCash extends PaymentForm {
|
||||
private final String PAYMENTRULE = MInvoice.PAYMENTRULE_Cash;
|
||||
|
||||
/** Start Payment */
|
||||
public int m_C_Payment_ID = 0;
|
||||
public MPayment m_mPayment = null;
|
||||
public MPayment m_mPaymentOriginal = null;
|
||||
/** Start Bank Account */
|
||||
public int m_C_BankAccount_ID = 0;
|
||||
/** Start CashBook Line */
|
||||
public int m_C_CashLine_ID = 0;
|
||||
public MCashLine m_cashLine = null;
|
||||
/** Start CashBook */
|
||||
public int m_C_CashBook_ID = 0;
|
||||
|
||||
public PaymentFormCash(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
// Existing Payment
|
||||
if (getGridTab().getValue("C_Payment_ID") != null)
|
||||
{
|
||||
m_C_Payment_ID = ((Integer)getGridTab().getValue("C_Payment_ID")).intValue();
|
||||
if (m_C_Payment_ID != 0)
|
||||
{
|
||||
m_mPayment = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
|
||||
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null); // full copy
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mPayment == null)
|
||||
{
|
||||
m_mPayment = new MPayment (Env.getCtx (), 0, null);
|
||||
m_mPayment.setAD_Org_ID(m_AD_Org_ID);
|
||||
m_mPayment.setAmount (m_C_Currency_ID, m_Amount);
|
||||
}
|
||||
|
||||
if (m_C_Payment_ID > 0 && m_mPayment != null)
|
||||
m_C_BankAccount_ID = m_mPayment.getC_BankAccount_ID();
|
||||
|
||||
m_cashLine = null;
|
||||
m_C_CashLine_ID = 0;
|
||||
if (getGridTab().getValue("C_CashLine_ID") != null)
|
||||
{
|
||||
m_C_CashLine_ID = ((Integer)getGridTab().getValue("C_CashLine_ID")).intValue();
|
||||
if (m_C_CashLine_ID == 0)
|
||||
m_cashLine = null;
|
||||
else
|
||||
{
|
||||
m_cashLine = new MCashLine (Env.getCtx(), m_C_CashLine_ID, null);
|
||||
m_DateAcct = m_cashLine.getStatementDate();
|
||||
m_C_CashBook_ID = m_cashLine.getCashBook().getC_CashBook_ID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public KeyNamePair selectedBankAccount;
|
||||
public ArrayList<KeyNamePair> getBankAccountList() {
|
||||
selectedBankAccount = null;
|
||||
|
@ -132,9 +183,29 @@ public abstract class PaymentFormCash extends PaymentForm {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChanges() {
|
||||
boolean ok = super.saveChanges();
|
||||
if (m_cashLine != null)
|
||||
m_cashLine.set_TrxName(null);
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(null);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(null);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public String processMsg;
|
||||
public boolean save(int newC_BankAccount_ID, int newC_CashBook_ID, Timestamp newDateAcct, BigDecimal newAmount, String trxName)
|
||||
{
|
||||
// set trxname for class objects
|
||||
if (m_cashLine != null)
|
||||
m_cashLine.set_TrxName(trxName);
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(trxName);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(trxName);
|
||||
|
||||
processMsg = null;
|
||||
int newC_CashLine_ID = m_C_CashLine_ID;
|
||||
|
||||
|
@ -288,7 +359,6 @@ public abstract class PaymentFormCash extends PaymentForm {
|
|||
// Get changes to cash amount
|
||||
m_mPayment.setTenderType(MPayment.TENDERTYPE_Cash);
|
||||
m_mPayment.setBankCash(newC_BankAccount_ID, m_isSOTrx, MPayment.TENDERTYPE_Cash);
|
||||
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
|
||||
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
|
||||
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
|
||||
if (order != null)
|
||||
|
|
|
@ -41,10 +41,41 @@ import org.compiere.util.Msg;
|
|||
public abstract class PaymentFormCheck extends PaymentForm {
|
||||
private final String PAYMENTRULE = MInvoice.PAYMENTRULE_Check;
|
||||
|
||||
/** Start Payment */
|
||||
public int m_C_Payment_ID = 0;
|
||||
public MPayment m_mPayment = null;
|
||||
public MPayment m_mPaymentOriginal = null;
|
||||
/** Start Bank Account */
|
||||
public int m_C_BankAccount_ID = 0;
|
||||
|
||||
public PaymentFormCheck(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
// Existing Payment
|
||||
if (getGridTab().getValue("C_Payment_ID") != null)
|
||||
{
|
||||
m_C_Payment_ID = ((Integer)getGridTab().getValue("C_Payment_ID")).intValue();
|
||||
if (m_C_Payment_ID != 0)
|
||||
{
|
||||
m_mPayment = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
|
||||
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null); // full copy
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mPayment == null)
|
||||
{
|
||||
m_mPayment = new MPayment (Env.getCtx (), 0, null);
|
||||
m_mPayment.setAD_Org_ID(m_AD_Org_ID);
|
||||
m_mPayment.setAmount (m_C_Currency_ID, m_Amount);
|
||||
}
|
||||
|
||||
if (m_C_Payment_ID > 0 && m_mPayment != null)
|
||||
m_C_BankAccount_ID = m_mPayment.getC_BankAccount_ID();
|
||||
}
|
||||
|
||||
public KeyNamePair selectedBankAccount;
|
||||
public ArrayList<KeyNamePair> getBankAccountList() {
|
||||
selectedBankAccount = null;
|
||||
|
@ -85,9 +116,25 @@ public abstract class PaymentFormCheck extends PaymentForm {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChanges() {
|
||||
boolean ok = super.saveChanges();
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(null);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(null);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public String processMsg = null;
|
||||
public boolean save(int newC_BankAccount_ID, String routing, String number, String check, BigDecimal amount)
|
||||
public boolean save(int newC_BankAccount_ID, String routing, String number, String check, BigDecimal amount, String trxName)
|
||||
{
|
||||
// set trxname for class objects
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(trxName);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(trxName);
|
||||
|
||||
processMsg = null;
|
||||
String payTypes = m_Cash_As_Payment ? "KTSDB" : "KTSD";
|
||||
|
||||
|
@ -172,8 +219,6 @@ public abstract class PaymentFormCheck extends PaymentForm {
|
|||
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
|
||||
m_mPayment.setBankCheck(newC_BankAccount_ID, m_isSOTrx, routing,
|
||||
number, check);
|
||||
// Get changes to check amount
|
||||
m_mPayment.setAmount(m_C_Currency_ID, amount);
|
||||
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
|
||||
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
|
||||
if (order != null)
|
||||
|
|
|
@ -18,9 +18,12 @@ import java.math.BigDecimal;
|
|||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MBankAccountProcessor;
|
||||
import org.compiere.model.MDocType;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MOrder;
|
||||
import org.compiere.model.MPayment;
|
||||
import org.compiere.model.MPaymentProcessor;
|
||||
import org.compiere.model.MPaymentTransaction;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -34,10 +37,89 @@ import org.compiere.util.ValueNamePair;
|
|||
public abstract class PaymentFormCreditCard extends PaymentForm {
|
||||
private final String PAYMENTRULE = MInvoice.PAYMENTRULE_CreditCard;
|
||||
|
||||
/** Start Payment */
|
||||
public int m_C_Payment_ID = 0;
|
||||
public MPayment m_mPayment = null;
|
||||
public MPayment m_mPaymentOriginal = null;
|
||||
public MPaymentTransaction m_mPaymentTransaction = null;
|
||||
/** Start CreditCard */
|
||||
public String m_CCType = "";
|
||||
|
||||
public PaymentFormCreditCard(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
// Existing Payment
|
||||
if (getGridTab().getValue("C_Payment_ID") != null)
|
||||
{
|
||||
m_C_Payment_ID = ((Integer)getGridTab().getValue("C_Payment_ID")).intValue();
|
||||
if (m_C_Payment_ID != 0)
|
||||
{
|
||||
m_mPayment = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
|
||||
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null); // full copy
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mPayment == null || m_mPayment.getC_Payment_ID() == 0)
|
||||
{
|
||||
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
|
||||
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
|
||||
if (C_Invoice_ID == 0 && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))
|
||||
C_Invoice_ID = getInvoiceID (C_Order_ID);
|
||||
|
||||
boolean found = false;
|
||||
if (C_Order_ID > 0 || C_Invoice_ID > 0)
|
||||
{
|
||||
int[] ids = MPaymentTransaction.getAuthorizationPaymentTransactionIDs(C_Order_ID, C_Invoice_ID, null);
|
||||
|
||||
if (ids.length > 0)
|
||||
{
|
||||
if (C_Invoice_ID > 0)
|
||||
{
|
||||
for (int id : ids)
|
||||
{
|
||||
MPaymentTransaction pt = new MPaymentTransaction(Env.getCtx(), id, null);
|
||||
if (pt.getC_Invoice_ID() == C_Invoice_ID)
|
||||
{
|
||||
m_mPaymentTransaction = new MPaymentTransaction(Env.getCtx(), id, null);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (int id : ids)
|
||||
{
|
||||
MPaymentTransaction pt = new MPaymentTransaction(Env.getCtx(), id, null);
|
||||
if (pt.getC_Order_ID() == C_Order_ID)
|
||||
{
|
||||
m_mPaymentTransaction = new MPaymentTransaction(Env.getCtx(), id, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mPayment == null)
|
||||
{
|
||||
m_mPayment = new MPayment (Env.getCtx (), 0, null);
|
||||
m_mPayment.setAD_Org_ID(m_AD_Org_ID);
|
||||
m_mPayment.setAmount (m_C_Currency_ID, m_Amount);
|
||||
}
|
||||
|
||||
if (m_C_Payment_ID > 0 && m_mPayment != null)
|
||||
m_CCType = m_mPayment.getCreditCardType();
|
||||
|
||||
if (m_mPaymentTransaction != null)
|
||||
m_CCType = m_mPaymentTransaction.getCreditCardType();
|
||||
}
|
||||
|
||||
public ValueNamePair selectedCreditCard;
|
||||
public ValueNamePair[] getCreditCardList()
|
||||
{
|
||||
|
@ -51,9 +133,32 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
return ccs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChanges() {
|
||||
boolean ok = super.saveChanges();
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(null);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(null);
|
||||
if (m_mPaymentTransaction != null)
|
||||
m_mPaymentTransaction.set_TrxName(null);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public String processMsg = null;
|
||||
public boolean save(String newCCType, String newCCNumber, String newCCExp, BigDecimal newAmount)
|
||||
public boolean save(String newCCType, String newCCNumber, String newCCExp, BigDecimal newAmount, String trxName)
|
||||
{
|
||||
// set trxname for class objects
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(trxName);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(trxName);
|
||||
if (m_mPaymentTransaction != null)
|
||||
m_mPaymentTransaction.set_TrxName(trxName);
|
||||
|
||||
if (m_mPaymentTransaction != null)
|
||||
return true;
|
||||
|
||||
processMsg = null;
|
||||
String payTypes = m_Cash_As_Payment ? "KTSDB" : "KTSD";
|
||||
|
||||
|
@ -107,8 +212,23 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
// Get Order and optionally Invoice
|
||||
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
|
||||
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
|
||||
if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))
|
||||
if (C_Invoice_ID == 0 && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))
|
||||
C_Invoice_ID = getInvoiceID (C_Order_ID);
|
||||
|
||||
boolean isPOSOrder = false;
|
||||
boolean isInvoice = false;
|
||||
boolean isCreditMemo = false;
|
||||
int doctype = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_DocTypeTarget_ID");
|
||||
if(doctype > 0)
|
||||
{
|
||||
MDocType mDocType = MDocType.get(Env.getCtx(), doctype);
|
||||
if (MDocType.DOCSUBTYPESO_POSOrder.equals(mDocType.getDocSubTypeSO()))
|
||||
isPOSOrder = true;
|
||||
else if (MDocType.DOCBASETYPE_ARInvoice.equals(mDocType.getDocBaseType()))
|
||||
isInvoice = true;
|
||||
else if (MDocType.DOCBASETYPE_ARCreditMemo.equals(mDocType.getDocBaseType()))
|
||||
isCreditMemo = true;
|
||||
}
|
||||
|
||||
// Amount sign negative, if ARC (Credit Memo) or API (AP Invoice)
|
||||
boolean negateAmt = false;
|
||||
|
@ -137,9 +257,26 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
// Set Amount
|
||||
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
|
||||
m_mPayment.setCreditCard(MPayment.TRXTYPE_Sales, newCCType, newCCNumber, "", newCCExp);
|
||||
// Get changes to credit card amount
|
||||
m_mPayment.setAmount(m_C_Currency_ID, newAmount);
|
||||
m_mPayment.setPaymentProcessor();
|
||||
|
||||
if (isPOSOrder || isInvoice)
|
||||
m_mPayment.setTrxType(MPayment.TRXTYPE_Sales);
|
||||
else if (isCreditMemo)
|
||||
{
|
||||
m_mPayment.setTrxType(MPayment.TRXTYPE_CreditPayment);
|
||||
// m_mPayment.setOrig_TrxID(kPGOrderIDField.getValue());
|
||||
}
|
||||
else if (C_Invoice_ID != 0)
|
||||
{
|
||||
if (invoice.isComplete())
|
||||
m_mPayment.setTrxType(MPayment.TRXTYPE_Sales);
|
||||
}
|
||||
else
|
||||
{
|
||||
MPaymentProcessor paymentProcessor = new MPaymentProcessor(m_mPayment.getCtx(), m_mPayment.getC_PaymentProcessor_ID(), m_mPayment.get_TrxName());
|
||||
if (paymentProcessor.getTrxType() != null)
|
||||
m_mPayment.setTrxType(paymentProcessor.getTrxType());
|
||||
}
|
||||
|
||||
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
|
||||
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
|
||||
|
@ -152,7 +289,7 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
m_mPayment.setDateAcct(m_DateAcct);
|
||||
setCustomizeValues();
|
||||
|
||||
if (!m_mPayment.isApproved())
|
||||
if (!m_mPayment.isOnline() && !m_mPayment.isApproved())
|
||||
{
|
||||
processMsg = Msg.getMsg(Env.getCtx(), "CardNotProcessed");
|
||||
throw new AdempiereException(processMsg);
|
||||
|
@ -196,52 +333,87 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
{
|
||||
processMsg = null;
|
||||
boolean error = false;
|
||||
|
||||
boolean approved = false;
|
||||
String info = "";
|
||||
|
||||
m_mPayment.setCreditCard(MPayment.TRXTYPE_Sales, CCType,
|
||||
CCNumber, "", CCExp);
|
||||
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
|
||||
m_mPayment.setPaymentProcessor();
|
||||
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
|
||||
//
|
||||
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
|
||||
int C_Invoice_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Invoice_ID");
|
||||
if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))
|
||||
{
|
||||
int C_Order_ID = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_Order_ID");
|
||||
if (C_Invoice_ID == 0 && m_DocStatus.equals(MInvoice.DOCSTATUS_Completed))
|
||||
C_Invoice_ID = getInvoiceID (C_Order_ID);
|
||||
|
||||
boolean isPOSOrder = false;
|
||||
boolean isInvoice = false;
|
||||
boolean isCreditMemo = false;
|
||||
int doctype = Env.getContextAsInt(Env.getCtx(), getWindowNo(), "C_DocTypeTarget_ID");
|
||||
if(doctype > 0)
|
||||
{
|
||||
MDocType mDocType = MDocType.get(Env.getCtx(), doctype);
|
||||
if (MDocType.DOCSUBTYPESO_POSOrder.equals(mDocType.getDocSubTypeSO()))
|
||||
isPOSOrder = true;
|
||||
else if (MDocType.DOCBASETYPE_ARInvoice.equals(mDocType.getDocBaseType()))
|
||||
isInvoice = true;
|
||||
else if (MDocType.DOCBASETYPE_ARCreditMemo.equals(mDocType.getDocBaseType()))
|
||||
isCreditMemo = true;
|
||||
}
|
||||
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
|
||||
m_mPayment.setDateTrx(m_DateAcct);
|
||||
// Set Amount
|
||||
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
|
||||
|
||||
boolean approved = false;
|
||||
|
||||
MPaymentTransaction mpt = new MPaymentTransaction(Env.getCtx(), 0, null);
|
||||
mpt.setAD_Org_ID(m_AD_Org_ID);
|
||||
mpt.setCreditCard(MPayment.TRXTYPE_Sales, CCType, CCNumber, "", CCExp);
|
||||
mpt.setAmount(m_C_Currency_ID, m_Amount);
|
||||
mpt.setPaymentProcessor();
|
||||
|
||||
if (isPOSOrder || isInvoice)
|
||||
mpt.setTrxType(MPayment.TRXTYPE_Sales);
|
||||
else if (isCreditMemo)
|
||||
{
|
||||
mpt.setTrxType(MPayment.TRXTYPE_CreditPayment);
|
||||
// mpt.setOrig_TrxID(kPGOrderIDField.getValue());
|
||||
}
|
||||
else if (C_Invoice_ID != 0)
|
||||
{
|
||||
MInvoice invoice = new MInvoice (Env.getCtx(), C_Invoice_ID, null);
|
||||
if (invoice.isComplete())
|
||||
mpt.setTrxType(MPayment.TRXTYPE_Sales);
|
||||
}
|
||||
else
|
||||
{
|
||||
MPaymentProcessor paymentProcessor = new MPaymentProcessor(mpt.getCtx(), mpt.getC_PaymentProcessor_ID(), mpt.get_TrxName());
|
||||
if (paymentProcessor.getTrxType() != null)
|
||||
mpt.setTrxType(paymentProcessor.getTrxType());
|
||||
}
|
||||
|
||||
mpt.setC_BPartner_ID(m_C_BPartner_ID);
|
||||
//
|
||||
mpt.setC_Order_ID(C_Order_ID);
|
||||
mpt.setC_Invoice_ID(C_Invoice_ID);
|
||||
mpt.setDateTrx(m_DateAcct);
|
||||
setCustomizeValues();
|
||||
if (!m_mPayment.save()) {
|
||||
if (!mpt.save()) {
|
||||
processMsg = Msg.getMsg(Env.getCtx(), "PaymentNotCreated");
|
||||
return false;
|
||||
} else {
|
||||
approved = m_mPayment.processOnline();
|
||||
info = m_mPayment.getR_RespMsg() + " (" + m_mPayment.getR_AuthCode()
|
||||
+ ") ID=" + m_mPayment.getR_PnRef();
|
||||
m_mPayment.saveEx();
|
||||
|
||||
approved = mpt.processOnline();
|
||||
mpt.saveEx();
|
||||
|
||||
if (approved)
|
||||
{
|
||||
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
|
||||
m_mPayment.saveEx();
|
||||
if (ok)
|
||||
m_needSave = true;
|
||||
if (mpt.getC_Payment_ID() > 0)
|
||||
{
|
||||
m_mPayment = new MPayment(mpt.getCtx(), mpt.getC_Payment_ID(), mpt.get_TrxName());
|
||||
String info = m_mPayment.getR_RespMsg() + " (" + m_mPayment.getR_AuthCode() + ") ID=" + m_mPayment.getR_PnRef();
|
||||
processMsg = info + "\n" + m_mPayment.getDocumentNo();
|
||||
saveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
processMsg = Msg.getMsg(Env.getCtx(), "PaymentNotCreated");
|
||||
error = true;
|
||||
String info = mpt.getR_RespMsg() + " (" + mpt.getR_AuthCode() + ") ID=" + mpt.getR_PnRef();
|
||||
processMsg = info;
|
||||
}
|
||||
saveChanges();
|
||||
}
|
||||
else
|
||||
{
|
||||
processMsg = info;
|
||||
processMsg = mpt.getErrorMessage();
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
@ -257,4 +429,9 @@ public abstract class PaymentFormCreditCard extends PaymentForm {
|
|||
{
|
||||
return getBankAccountProcessor(Env.getCtx(), MPayment.TENDERTYPE_CreditCard, CCType, Env.getAD_Client_ID(Env.getCtx()), m_C_Currency_ID, PayAmt, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApproved() {
|
||||
return m_mPayment.isApproved();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,11 +40,37 @@ import org.compiere.util.Msg;
|
|||
public abstract class PaymentFormDirect extends PaymentForm {
|
||||
private String PAYMENTRULE;
|
||||
|
||||
/** Start Payment */
|
||||
public int m_C_Payment_ID = 0;
|
||||
public MPayment m_mPayment = null;
|
||||
public MPayment m_mPaymentOriginal = null;
|
||||
|
||||
public PaymentFormDirect(int WindowNo, GridTab mTab, boolean isDebit) {
|
||||
super(WindowNo, mTab);
|
||||
PAYMENTRULE = isDebit ? MInvoice.PAYMENTRULE_DirectDebit : MInvoice.PAYMENTRULE_DirectDeposit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
// Existing Payment
|
||||
if (getGridTab().getValue("C_Payment_ID") != null)
|
||||
{
|
||||
m_C_Payment_ID = ((Integer)getGridTab().getValue("C_Payment_ID")).intValue();
|
||||
if (m_C_Payment_ID != 0)
|
||||
{
|
||||
m_mPayment = new MPayment(Env.getCtx(), m_C_Payment_ID, null);
|
||||
m_mPaymentOriginal = new MPayment(Env.getCtx(), m_C_Payment_ID, null); // full copy
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mPayment == null)
|
||||
{
|
||||
m_mPayment = new MPayment (Env.getCtx (), 0, null);
|
||||
m_mPayment.setAD_Org_ID(m_AD_Org_ID);
|
||||
m_mPayment.setAmount (m_C_Currency_ID, m_Amount);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<KeyNamePair> getBPBankAccountList() {
|
||||
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
|
||||
|
||||
|
@ -79,9 +105,25 @@ public abstract class PaymentFormDirect extends PaymentForm {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChanges() {
|
||||
boolean ok = super.saveChanges();
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(null);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(null);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public String processMsg;
|
||||
public boolean save(int newC_BankAccount_ID, String routing, String number)
|
||||
public boolean save(int newC_BankAccount_ID, String routing, String number, String trxName)
|
||||
{
|
||||
// set trxname for class objects
|
||||
if (m_mPayment != null)
|
||||
m_mPayment.set_TrxName(trxName);
|
||||
if (m_mPaymentOriginal != null)
|
||||
m_mPaymentOriginal.set_TrxName(trxName);
|
||||
|
||||
processMsg = null;
|
||||
|
||||
String payTypes = m_Cash_As_Payment ? "KTSDB" : "KTSD";
|
||||
|
@ -162,8 +204,9 @@ public abstract class PaymentFormDirect extends PaymentForm {
|
|||
/***********************
|
||||
* Payments
|
||||
*/
|
||||
m_mPayment.setBankACH(newC_BankAccount_ID, m_isSOTrx, PAYMENTRULE, routing, number);
|
||||
// Set Amount
|
||||
m_mPayment.setAmount(m_C_Currency_ID, payAmount);
|
||||
m_mPayment.setBankACH(newC_BankAccount_ID, m_isSOTrx, PAYMENTRULE, routing, number);
|
||||
m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
|
||||
m_mPayment.setC_Invoice_ID(C_Invoice_ID);
|
||||
if (order != null)
|
||||
|
|
|
@ -36,9 +36,12 @@ public abstract class PaymentFormOnCredit extends PaymentForm {
|
|||
|
||||
public PaymentFormOnCredit(int WindowNo, GridTab mTab) {
|
||||
super(WindowNo, mTab);
|
||||
|
||||
if (mTab.getValue("C_PaymentTerm_ID") != null)
|
||||
m_C_PaymentTerm_ID = ((Integer)mTab.getValue("C_PaymentTerm_ID")).intValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
if (getGridTab().getValue("C_PaymentTerm_ID") != null)
|
||||
m_C_PaymentTerm_ID = ((Integer)getGridTab().getValue("C_PaymentTerm_ID")).intValue();
|
||||
}
|
||||
|
||||
public KeyNamePair selectedPaymentTerm = null;
|
||||
|
|
Loading…
Reference in New Issue