IDEMPIERE-447 Abstract Payment Processor from Tenant configuration

This commit is contained in:
Elaine Tan 2012-10-03 18:30:46 +08:00
parent 17a779a61a
commit a5f5d8d972
11 changed files with 2391 additions and 157 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,9 @@ public class Core {
}
//
PaymentProcessor myProcessor = null;
myProcessor = Service.locate(PaymentProcessor.class);
ServiceQuery query = new ServiceQuery();
query.put(ServiceQuery.EXTENSION_ID, className);
myProcessor = Service.locate(PaymentProcessor.class, query);
if (myProcessor == null) {
try {
Class<?> ppClass = Class.forName(className);

View File

@ -101,6 +101,21 @@ public interface I_C_BankAccount
*/
public String getBBAN();
/** Column name C_Bank_ID */
public static final String COLUMNNAME_C_Bank_ID = "C_Bank_ID";
/** Set Bank.
* Bank
*/
public void setC_Bank_ID (int C_Bank_ID);
/** Get Bank.
* Bank
*/
public int getC_Bank_ID();
public org.compiere.model.I_C_Bank getC_Bank() throws RuntimeException;
/** Column name C_BankAccount_ID */
public static final String COLUMNNAME_C_BankAccount_ID = "C_BankAccount_ID";
@ -123,21 +138,6 @@ public interface I_C_BankAccount
/** Get C_BankAccount_UU */
public String getC_BankAccount_UU();
/** Column name C_Bank_ID */
public static final String COLUMNNAME_C_Bank_ID = "C_Bank_ID";
/** Set Bank.
* Bank
*/
public void setC_Bank_ID (int C_Bank_ID);
/** Get Bank.
* Bank
*/
public int getC_Bank_ID();
public org.compiere.model.I_C_Bank getC_Bank() throws RuntimeException;
/** Column name C_Currency_ID */
public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID";
@ -153,6 +153,21 @@ public interface I_C_BankAccount
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException;
/** Column name C_PaymentProcessor_ID */
public static final String COLUMNNAME_C_PaymentProcessor_ID = "C_PaymentProcessor_ID";
/** 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;
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";

View File

@ -31,13 +31,13 @@ public interface I_C_PaymentProcessor
public static final String Table_Name = "C_PaymentProcessor";
/** AD_Table_ID=398 */
public static final int Table_ID = MTable.getTable_ID(Table_Name);
public static final int Table_ID = 398;
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
/** AccessLevel = 3 - Client - Org
/** AccessLevel = 6 - System - Client
*/
BigDecimal accessLevel = BigDecimal.valueOf(3);
BigDecimal accessLevel = BigDecimal.valueOf(6);
/** Load Meta Data */
@ -205,7 +205,7 @@ public interface I_C_PaymentProcessor
*/
public int getAD_Sequence_ID();
public I_AD_Sequence getAD_Sequence() throws RuntimeException;
public org.compiere.model.I_AD_Sequence getAD_Sequence() throws RuntimeException;
/** Column name C_BankAccount_ID */
public static final String COLUMNNAME_C_BankAccount_ID = "C_BankAccount_ID";
@ -220,7 +220,7 @@ public interface I_C_PaymentProcessor
*/
public int getC_BankAccount_ID();
public I_C_BankAccount getC_BankAccount() throws RuntimeException;
public org.compiere.model.I_C_BankAccount getC_BankAccount() throws RuntimeException;
/** Column name C_Currency_ID */
public static final String COLUMNNAME_C_Currency_ID = "C_Currency_ID";
@ -235,7 +235,29 @@ public interface I_C_PaymentProcessor
*/
public int getC_Currency_ID();
public I_C_Currency getC_Currency() throws RuntimeException;
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException;
/** Column name C_PaymentProcessor_ID */
public static final String COLUMNNAME_C_PaymentProcessor_ID = "C_PaymentProcessor_ID";
/** 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();
/** Column name C_PaymentProcessor_UU */
public static final String COLUMNNAME_C_PaymentProcessor_UU = "C_PaymentProcessor_UU";
/** Set C_PaymentProcessor_UU */
public void setC_PaymentProcessor_UU (String C_PaymentProcessor_UU);
/** Get C_PaymentProcessor_UU */
public String getC_PaymentProcessor_UU();
/** Column name Commission */
public static final String COLUMNNAME_Commission = "Commission";
@ -263,19 +285,6 @@ public interface I_C_PaymentProcessor
*/
public BigDecimal getCostPerTrx();
/** Column name C_PaymentProcessor_ID */
public static final String COLUMNNAME_C_PaymentProcessor_ID = "C_PaymentProcessor_ID";
/** 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();
/** Column name Created */
public static final String COLUMNNAME_Created = "Created";

View File

@ -162,10 +162,10 @@ public final class MPayment extends X_C_Payment
super(ctx, rs, trxName);
} // MPayment
/** Temporary Payment Processors */
private MPaymentProcessor[] m_mPaymentProcessors = null;
/** Temporary Payment Processor */
private MPaymentProcessor m_mPaymentProcessor = null;
/** Temporary Bank Accounts & Payment Processors */
private MBankAccount[] m_mBankAccounts = null;
/** Temporary Bank Account & Payment Processor */
private MBankAccount m_mBankAccount = null;
/** Logger */
private static CLogger s_log = CLogger.getCLogger (MPayment.class);
/** Error Message */
@ -466,9 +466,9 @@ public final class MPayment extends X_C_Payment
return true;
}
if (m_mPaymentProcessor == null)
if (m_mBankAccount == null)
setPaymentProcessor();
if (m_mPaymentProcessor == null)
if (m_mBankAccount == null)
{
log.log(Level.WARNING, "No Payment Processor Model");
setErrorMessage("No Payment Processor Model");
@ -479,7 +479,8 @@ public final class MPayment extends X_C_Payment
try
{
PaymentProcessor pp = PaymentProcessor.create(m_mPaymentProcessor, this);
MPaymentProcessor paymentProcessor = new MPaymentProcessor(m_mBankAccount.getCtx(), m_mBankAccount.getC_PaymentProcessor_ID(), m_mBankAccount.get_TrxName());
PaymentProcessor pp = PaymentProcessor.create(paymentProcessor, this);
if (pp == null)
setErrorMessage("No Payment Processor");
else
@ -825,30 +826,33 @@ public final class MPayment extends X_C_Payment
*/
public boolean setPaymentProcessor (String tender, String CCType)
{
m_mPaymentProcessor = null;
m_mBankAccount = null;
// Get Processor List
if (m_mPaymentProcessors == null || m_mPaymentProcessors.length == 0)
m_mPaymentProcessors = MPaymentProcessor.find (getCtx(), tender, CCType, getAD_Client_ID(),
if (m_mBankAccounts == null || m_mBankAccounts.length == 0)
m_mBankAccounts = MPaymentProcessor.find (getCtx(), tender, CCType, getAD_Client_ID(),
getC_Currency_ID(), getPayAmt(), get_TrxName());
// Relax Amount
if (m_mPaymentProcessors == null || m_mPaymentProcessors.length == 0)
m_mPaymentProcessors = MPaymentProcessor.find (getCtx(), tender, CCType, getAD_Client_ID(),
if (m_mBankAccounts == null || m_mBankAccounts.length == 0)
m_mBankAccounts = MPaymentProcessor.find (getCtx(), tender, CCType, getAD_Client_ID(),
getC_Currency_ID(), Env.ZERO, get_TrxName());
if (m_mPaymentProcessors == null || m_mPaymentProcessors.length == 0)
if (m_mBankAccounts == null || m_mBankAccounts.length == 0)
return false;
// Find the first right one
for (int i = 0; i < m_mPaymentProcessors.length; i++)
for (int i = 0; i < m_mBankAccounts.length; i++)
{
if (m_mPaymentProcessors[i].accepts (tender, CCType))
MBankAccount bankAccount = m_mBankAccounts[i];
MPaymentProcessor paymentProcessor = new MPaymentProcessor(bankAccount.getCtx(), bankAccount.getC_PaymentProcessor_ID(), bankAccount.get_TrxName());
if (paymentProcessor.accepts (tender, CCType))
{
m_mPaymentProcessor = m_mPaymentProcessors[i];
m_mBankAccount = m_mBankAccounts[i];
break;
}
}
if (m_mPaymentProcessor != null)
setC_BankAccount_ID (m_mPaymentProcessor.getC_BankAccount_ID());
if (m_mBankAccount != null)
setC_BankAccount_ID (m_mBankAccount.getC_BankAccount_ID());
//
return m_mPaymentProcessor != null;
return m_mBankAccount != null;
} // setPaymentProcessor
@ -871,30 +875,32 @@ public final class MPayment extends X_C_Payment
{
try
{
if (m_mPaymentProcessors == null || m_mPaymentProcessors.length == 0)
m_mPaymentProcessors = MPaymentProcessor.find (getCtx (), null, null,
if (m_mBankAccounts == null || m_mBankAccounts.length == 0)
m_mBankAccounts = MPaymentProcessor.find (getCtx (), null, null,
getAD_Client_ID (), getC_Currency_ID (), amt, get_TrxName());
//
HashMap<String,ValueNamePair> map = new HashMap<String,ValueNamePair>(); // to eliminate duplicates
for (int i = 0; i < m_mPaymentProcessors.length; i++)
for (int i = 0; i < m_mBankAccounts.length; i++)
{
if (m_mPaymentProcessors[i].isAcceptAMEX ())
MBankAccount bankAccount = m_mBankAccounts[i];
MPaymentProcessor paymentProcessor = new MPaymentProcessor(bankAccount.getCtx(), bankAccount.getC_PaymentProcessor_ID(), bankAccount.get_TrxName());
if (paymentProcessor.isAcceptAMEX ())
map.put (CREDITCARDTYPE_Amex, getCreditCardPair (CREDITCARDTYPE_Amex));
if (m_mPaymentProcessors[i].isAcceptDiners ())
if (paymentProcessor.isAcceptDiners ())
map.put (CREDITCARDTYPE_Diners, getCreditCardPair (CREDITCARDTYPE_Diners));
if (m_mPaymentProcessors[i].isAcceptDiscover ())
if (paymentProcessor.isAcceptDiscover ())
map.put (CREDITCARDTYPE_Discover, getCreditCardPair (CREDITCARDTYPE_Discover));
if (m_mPaymentProcessors[i].isAcceptMC ())
if (paymentProcessor.isAcceptMC ())
map.put (CREDITCARDTYPE_MasterCard, getCreditCardPair (CREDITCARDTYPE_MasterCard));
if (m_mPaymentProcessors[i].isAcceptCorporate ())
if (paymentProcessor.isAcceptCorporate ())
map.put (CREDITCARDTYPE_PurchaseCard, getCreditCardPair (CREDITCARDTYPE_PurchaseCard));
if (m_mPaymentProcessors[i].isAcceptVisa ())
if (paymentProcessor.isAcceptVisa ())
map.put (CREDITCARDTYPE_Visa, getCreditCardPair (CREDITCARDTYPE_Visa));
} // for all payment processors
//
ValueNamePair[] retValue = new ValueNamePair[map.size ()];
map.values ().toArray (retValue);
log.fine("getCreditCards - #" + retValue.length + " - Processors=" + m_mPaymentProcessors.length);
log.fine("getCreditCards - #" + retValue.length + " - Processors=" + m_mBankAccounts.length);
return retValue;
}
catch (Exception ex)

View File

@ -43,7 +43,7 @@ public class MPaymentProcessor extends X_C_PaymentProcessor
private static final long serialVersionUID = 8514876566904723695L;
public static MPaymentProcessor[] find (Properties ctx,
public static MBankAccount[] find (Properties ctx,
String tender, String CCType,
int AD_Client_ID, int AD_Org_ID, int C_Currency_ID, BigDecimal Amt, String trxName)
{
@ -61,37 +61,40 @@ public class MPaymentProcessor extends X_C_PaymentProcessor
* @param trxName transaction
* @return Array of BankAccount[0] & PaymentProcessor[1] or null
*/
protected static MPaymentProcessor[] find (Properties ctx,
protected static MBankAccount[] find (Properties ctx,
String tender, String CCType,
int AD_Client_ID, int C_Currency_ID, BigDecimal Amt, String trxName)
{
ArrayList<MPaymentProcessor> list = new ArrayList<MPaymentProcessor>();
StringBuffer sql = new StringBuffer("SELECT * "
+ "FROM C_PaymentProcessor "
+ "WHERE AD_Client_ID=? AND IsActive='Y'" // #1
+ " AND (C_Currency_ID IS NULL OR C_Currency_ID=?)" // #2
+ " AND (MinimumAmt IS NULL OR MinimumAmt = 0 OR MinimumAmt <= ?)"); // #3
ArrayList<MBankAccount> list = new ArrayList<MBankAccount>();
StringBuffer sql = new StringBuffer("SELECT ba.* "
+ "FROM C_PaymentProcessor pp, C_BankAccount ba "
+ "WHERE pp.C_PaymentProcessor_ID = ba.C_PaymentProcessor_ID"
+ " AND ba.AD_Client_ID=? AND ba.IsActive='Y'" // #1
+ " AND pp.IsActive='Y' "
+ " AND (pp.C_Currency_ID IS NULL OR pp.C_Currency_ID=?)" // #2
+ " AND (pp.MinimumAmt IS NULL OR pp.MinimumAmt = 0 OR pp.MinimumAmt <= ?)"); // #3
if (MPayment.TENDERTYPE_DirectDeposit.equals(tender))
sql.append(" AND AcceptDirectDeposit='Y'");
sql.append(" AND pp.AcceptDirectDeposit='Y'");
else if (MPayment.TENDERTYPE_DirectDebit.equals(tender))
sql.append(" AND AcceptDirectDebit='Y'");
sql.append(" AND pp.AcceptDirectDebit='Y'");
else if (MPayment.TENDERTYPE_Check.equals(tender))
sql.append(" AND AcceptCheck='Y'");
sql.append(" AND pp.AcceptCheck='Y'");
// CreditCards
else if (MPayment.CREDITCARDTYPE_ATM.equals(CCType))
sql.append(" AND AcceptATM='Y'");
sql.append(" AND pp.AcceptATM='Y'");
else if (MPayment.CREDITCARDTYPE_Amex.equals(CCType))
sql.append(" AND AcceptAMEX='Y'");
sql.append(" AND pp.AcceptAMEX='Y'");
else if (MPayment.CREDITCARDTYPE_Visa.equals(CCType))
sql.append(" AND AcceptVISA='Y'");
sql.append(" AND pp.AcceptVISA='Y'");
else if (MPayment.CREDITCARDTYPE_MasterCard.equals(CCType))
sql.append(" AND AcceptMC='Y'");
sql.append(" AND pp.AcceptMC='Y'");
else if (MPayment.CREDITCARDTYPE_Diners.equals(CCType))
sql.append(" AND AcceptDiners='Y'");
sql.append(" AND pp.AcceptDiners='Y'");
else if (MPayment.CREDITCARDTYPE_Discover.equals(CCType))
sql.append(" AND AcceptDiscover='Y'");
sql.append(" AND pp.AcceptDiscover='Y'");
else if (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CCType))
sql.append(" AND AcceptCORPORATE='Y'");
sql.append(" AND pp.AcceptCORPORATE='Y'");
sql.append(" ORDER BY ba.IsDefault DESC ");
//
try
{
@ -101,7 +104,7 @@ public class MPaymentProcessor extends X_C_PaymentProcessor
pstmt.setBigDecimal(3, Amt);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
list.add(new MPaymentProcessor (ctx, rs, trxName));
list.add(new MBankAccount (ctx, rs, trxName));
rs.close();
pstmt.close();
}
@ -117,7 +120,7 @@ public class MPaymentProcessor extends X_C_PaymentProcessor
else
s_log.fine("find - #" + list.size() + " - AD_Client_ID=" + AD_Client_ID
+ ", C_Currency_ID=" + C_Currency_ID + ", Amt=" + Amt);
MPaymentProcessor[] retValue = new MPaymentProcessor[list.size()];
MBankAccount[] retValue = new MBankAccount[list.size()];
list.toArray(retValue);
return retValue;
} // find
@ -205,4 +208,27 @@ public class MPaymentProcessor extends X_C_PaymentProcessor
return false;
} // accepts
/**
* @deprecated Use C_BankAccount.C_PaymentProcessor_ID
*/
@Override
public I_C_BankAccount getC_BankAccount() throws RuntimeException {
return super.getC_BankAccount();
}
/**
* @deprecated Use C_BankAccount.C_PaymentProcessor_ID
*/
@Override
public void setC_BankAccount_ID(int C_BankAccount_ID) {
super.setC_BankAccount_ID(C_BankAccount_ID);
}
/**
* @deprecated Use C_BankAccount.C_PaymentProcessor_ID
*/
@Override
public int getC_BankAccount_ID() {
return super.getC_BankAccount_ID();
}
} // MPaymentProcessor

View File

@ -32,7 +32,7 @@ public class X_C_BankAccount extends PO implements I_C_BankAccount, I_Persistent
/**
*
*/
private static final long serialVersionUID = 20120906L;
private static final long serialVersionUID = 20121003L;
/** Standard Constructor */
public X_C_BankAccount (Properties ctx, int C_BankAccount_ID, String trxName)
@ -42,8 +42,8 @@ public class X_C_BankAccount extends PO implements I_C_BankAccount, I_Persistent
{
setAccountNo (null);
setBankAccountType (null);
setC_BankAccount_ID (0);
setC_Bank_ID (0);
setC_BankAccount_ID (0);
setC_Currency_ID (0);
setCreditLimit (Env.ZERO);
setCurrentBalance (Env.ZERO);
@ -143,6 +143,34 @@ public class X_C_BankAccount extends PO implements I_C_BankAccount, I_Persistent
return (String)get_Value(COLUMNNAME_BBAN);
}
public org.compiere.model.I_C_Bank getC_Bank() throws RuntimeException
{
return (org.compiere.model.I_C_Bank)MTable.get(getCtx(), org.compiere.model.I_C_Bank.Table_Name)
.getPO(getC_Bank_ID(), get_TrxName()); }
/** Set Bank.
@param C_Bank_ID
Bank
*/
public void setC_Bank_ID (int C_Bank_ID)
{
if (C_Bank_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_Bank_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_Bank_ID, Integer.valueOf(C_Bank_ID));
}
/** Get Bank.
@return Bank
*/
public int getC_Bank_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Bank_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Bank Account.
@param C_BankAccount_ID
Account at the Bank
@ -180,34 +208,6 @@ public class X_C_BankAccount extends PO implements I_C_BankAccount, I_Persistent
return (String)get_Value(COLUMNNAME_C_BankAccount_UU);
}
public org.compiere.model.I_C_Bank getC_Bank() throws RuntimeException
{
return (org.compiere.model.I_C_Bank)MTable.get(getCtx(), org.compiere.model.I_C_Bank.Table_Name)
.getPO(getC_Bank_ID(), get_TrxName()); }
/** Set Bank.
@param C_Bank_ID
Bank
*/
public void setC_Bank_ID (int C_Bank_ID)
{
if (C_Bank_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_Bank_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_Bank_ID, Integer.valueOf(C_Bank_ID));
}
/** Get Bank.
@return Bank
*/
public int getC_Bank_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_Bank_ID);
if (ii == null)
return 0;
return ii.intValue();
}
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException
{
return (org.compiere.model.I_C_Currency)MTable.get(getCtx(), org.compiere.model.I_C_Currency.Table_Name)
@ -236,6 +236,34 @@ public class X_C_BankAccount extends PO implements I_C_BankAccount, I_Persistent
return ii.intValue();
}
public org.compiere.model.I_C_PaymentProcessor getC_PaymentProcessor() throws RuntimeException
{
return (org.compiere.model.I_C_PaymentProcessor)MTable.get(getCtx(), org.compiere.model.I_C_PaymentProcessor.Table_Name)
.getPO(getC_PaymentProcessor_ID(), get_TrxName()); }
/** Set Payment Processor.
@param C_PaymentProcessor_ID
Payment processor for electronic payments
*/
public void setC_PaymentProcessor_ID (int C_PaymentProcessor_ID)
{
if (C_PaymentProcessor_ID < 1)
set_Value (COLUMNNAME_C_PaymentProcessor_ID, null);
else
set_Value (COLUMNNAME_C_PaymentProcessor_ID, Integer.valueOf(C_PaymentProcessor_ID));
}
/** Get Payment Processor.
@return Payment processor for electronic payments
*/
public int getC_PaymentProcessor_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaymentProcessor_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Credit limit.
@param CreditLimit
Amount of Credit allowed

View File

@ -32,7 +32,7 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
/**
*
*/
private static final long serialVersionUID = 20100614L;
private static final long serialVersionUID = 20121003L;
/** Standard Constructor */
public X_C_PaymentProcessor (Properties ctx, int C_PaymentProcessor_ID, String trxName)
@ -50,10 +50,9 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
setAcceptDiscover (false);
setAcceptMC (false);
setAcceptVisa (false);
setC_BankAccount_ID (0);
setC_PaymentProcessor_ID (0);
setCommission (Env.ZERO);
setCostPerTrx (Env.ZERO);
setC_PaymentProcessor_ID (0);
setHostAddress (null);
setHostPort (0);
setName (null);
@ -70,7 +69,7 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
}
/** AccessLevel
* @return 3 - Client - Org
* @return 6 - System - Client
*/
protected int get_AccessLevel()
{
@ -331,9 +330,9 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
return false;
}
public I_AD_Sequence getAD_Sequence() throws RuntimeException
public org.compiere.model.I_AD_Sequence getAD_Sequence() throws RuntimeException
{
return (I_AD_Sequence)MTable.get(getCtx(), I_AD_Sequence.Table_Name)
return (org.compiere.model.I_AD_Sequence)MTable.get(getCtx(), org.compiere.model.I_AD_Sequence.Table_Name)
.getPO(getAD_Sequence_ID(), get_TrxName()); }
/** Set Sequence.
@ -359,9 +358,9 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
return ii.intValue();
}
public I_C_BankAccount getC_BankAccount() throws RuntimeException
public org.compiere.model.I_C_BankAccount getC_BankAccount() throws RuntimeException
{
return (I_C_BankAccount)MTable.get(getCtx(), I_C_BankAccount.Table_Name)
return (org.compiere.model.I_C_BankAccount)MTable.get(getCtx(), org.compiere.model.I_C_BankAccount.Table_Name)
.getPO(getC_BankAccount_ID(), get_TrxName()); }
/** Set Bank Account.
@ -387,9 +386,9 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
return ii.intValue();
}
public I_C_Currency getC_Currency() throws RuntimeException
public org.compiere.model.I_C_Currency getC_Currency() throws RuntimeException
{
return (I_C_Currency)MTable.get(getCtx(), I_C_Currency.Table_Name)
return (org.compiere.model.I_C_Currency)MTable.get(getCtx(), org.compiere.model.I_C_Currency.Table_Name)
.getPO(getC_Currency_ID(), get_TrxName()); }
/** Set Currency.
@ -415,6 +414,43 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
return ii.intValue();
}
/** Set Payment Processor.
@param C_PaymentProcessor_ID
Payment processor for electronic payments
*/
public void setC_PaymentProcessor_ID (int C_PaymentProcessor_ID)
{
if (C_PaymentProcessor_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_PaymentProcessor_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_PaymentProcessor_ID, Integer.valueOf(C_PaymentProcessor_ID));
}
/** Get Payment Processor.
@return Payment processor for electronic payments
*/
public int getC_PaymentProcessor_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaymentProcessor_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set C_PaymentProcessor_UU.
@param C_PaymentProcessor_UU C_PaymentProcessor_UU */
public void setC_PaymentProcessor_UU (String C_PaymentProcessor_UU)
{
set_Value (COLUMNNAME_C_PaymentProcessor_UU, C_PaymentProcessor_UU);
}
/** Get C_PaymentProcessor_UU.
@return C_PaymentProcessor_UU */
public String getC_PaymentProcessor_UU ()
{
return (String)get_Value(COLUMNNAME_C_PaymentProcessor_UU);
}
/** Set Commission %.
@param Commission
Commission stated as a percentage
@ -455,29 +491,6 @@ public class X_C_PaymentProcessor extends PO implements I_C_PaymentProcessor, I_
return bd;
}
/** Set Payment Processor.
@param C_PaymentProcessor_ID
Payment processor for electronic payments
*/
public void setC_PaymentProcessor_ID (int C_PaymentProcessor_ID)
{
if (C_PaymentProcessor_ID < 1)
set_ValueNoCheck (COLUMNNAME_C_PaymentProcessor_ID, null);
else
set_ValueNoCheck (COLUMNNAME_C_PaymentProcessor_ID, Integer.valueOf(C_PaymentProcessor_ID));
}
/** Get Payment Processor.
@return Payment processor for electronic payments
*/
public int getC_PaymentProcessor_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_C_PaymentProcessor_ID);
if (ii == null)
return 0;
return ii.intValue();
}
/** Set Description.
@param Description
Optional short description of the record

View File

@ -726,7 +726,7 @@ public class VPayment extends CDialog
* Load Bank Accounts
*/
SQL = MRole.getDefault().addAccessSQL(
"SELECT C_BankAccount_ID, Name || ' ' || AccountNo, IsDefault "
"SELECT C_BankAccount_ID, ba.Name || ' ' || AccountNo, IsDefault "
+ "FROM C_BankAccount ba"
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE b.IsActive='Y'",

View File

@ -18,6 +18,7 @@ import java.util.HashMap;
import java.util.Properties;
import org.compiere.model.MBPartner;
import org.compiere.model.MBankAccount;
import org.compiere.model.MOrder;
import org.compiere.model.MOrderLine;
import org.compiere.model.MOrderTax;
@ -396,29 +397,31 @@ public class PosOrderModel extends MOrder {
{
try
{
MPaymentProcessor[] m_mPaymentProcessors = MPaymentProcessor.find (getCtx (), null, null,
MBankAccount[] m_mBankAccounts = MPaymentProcessor.find (getCtx (), null, null,
getAD_Client_ID (), getAD_Org_ID(), getC_Currency_ID (), amt, get_TrxName());
//
HashMap<String,ValueNamePair> map = new HashMap<String,ValueNamePair>(); // to eliminate duplicates
for (int i = 0; i < m_mPaymentProcessors.length; i++)
for (int i = 0; i < m_mBankAccounts.length; i++)
{
if (m_mPaymentProcessors[i].isAcceptAMEX ())
MBankAccount bankAccount = m_mBankAccounts[i];
MPaymentProcessor paymentProcessor = new MPaymentProcessor(bankAccount.getCtx(), bankAccount.getC_PaymentProcessor_ID(), bankAccount.get_TrxName());
if (paymentProcessor.isAcceptAMEX ())
map.put (MPayment.CREDITCARDTYPE_Amex, getCreditCardPair (MPayment.CREDITCARDTYPE_Amex));
if (m_mPaymentProcessors[i].isAcceptDiners ())
if (paymentProcessor.isAcceptDiners ())
map.put (MPayment.CREDITCARDTYPE_Diners, getCreditCardPair (MPayment.CREDITCARDTYPE_Diners));
if (m_mPaymentProcessors[i].isAcceptDiscover ())
if (paymentProcessor.isAcceptDiscover ())
map.put (MPayment.CREDITCARDTYPE_Discover, getCreditCardPair (MPayment.CREDITCARDTYPE_Discover));
if (m_mPaymentProcessors[i].isAcceptMC ())
if (paymentProcessor.isAcceptMC ())
map.put (MPayment.CREDITCARDTYPE_MasterCard, getCreditCardPair (MPayment.CREDITCARDTYPE_MasterCard));
if (m_mPaymentProcessors[i].isAcceptCorporate ())
if (paymentProcessor.isAcceptCorporate ())
map.put (MPayment.CREDITCARDTYPE_PurchaseCard, getCreditCardPair (MPayment.CREDITCARDTYPE_PurchaseCard));
if (m_mPaymentProcessors[i].isAcceptVisa ())
if (paymentProcessor.isAcceptVisa ())
map.put (MPayment.CREDITCARDTYPE_Visa, getCreditCardPair (MPayment.CREDITCARDTYPE_Visa));
} // for all payment processors
//
ValueNamePair[] retValue = new ValueNamePair[map.size ()];
map.values ().toArray (retValue);
log.fine("getCreditCards - #" + retValue.length + " - Processors=" + m_mPaymentProcessors.length);
log.fine("getCreditCards - #" + retValue.length + " - Processors=" + m_mBankAccounts.length);
return retValue;
}
catch (Exception ex)