diff --git a/migration/i1.0b-release/oracle/201305311943_IDEMPIERE-860.sql b/migration/i1.0b-release/oracle/201305311943_IDEMPIERE-860.sql new file mode 100644 index 0000000000..aadd2e325c --- /dev/null +++ b/migration/i1.0b-release/oracle/201305311943_IDEMPIERE-860.sql @@ -0,0 +1,27 @@ +-- May 31, 2013 7:34:01 PM SGT +-- IDEMPIERE-860 Review Payment Processors +UPDATE AD_Column SET ReadOnlyLogic='@CustomerPaymentProfileID@!''''',Updated=TO_DATE('2013-05-31 19:34:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5240 +; + +-- May 31, 2013 7:34:10 PM SGT +-- IDEMPIERE-860 Review Payment Processors +UPDATE AD_Column SET ReadOnlyLogic='@CustomerPaymentProfileID@!''''',Updated=TO_DATE('2013-05-31 19:34:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5239 +; + +-- May 31, 2013 7:34:17 PM SGT +-- IDEMPIERE-860 Review Payment Processors +UPDATE AD_Column SET ReadOnlyLogic='@CustomerPaymentProfileID@!''''',Updated=TO_DATE('2013-05-31 19:34:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5232 +; + +-- May 31, 2013 7:35:47 PM SGT +-- IDEMPIERE-860 Review Payment Processors +INSERT INTO AD_Message (AD_Client_ID,EntityType,MsgType,MsgText,AD_Message_ID,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created) VALUES (0,'D','E','Inactive payment processor',200176,'e9638795-bd2f-405b-b3cb-567036b3871d','InactivePaymentProcessor','Y',TO_DATE('2013-05-31 19:35:45','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-05-31 19:35:45','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 31, 2013 7:35:47 PM SGT +-- IDEMPIERE-860 Review Payment Processors +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200176 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +SELECT register_migration_script('201305311943_IDEMPIERE-860.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i1.0b-release/postgresql/201305311943_IDEMPIERE-860.sql b/migration/i1.0b-release/postgresql/201305311943_IDEMPIERE-860.sql new file mode 100644 index 0000000000..ecd0aee6cd --- /dev/null +++ b/migration/i1.0b-release/postgresql/201305311943_IDEMPIERE-860.sql @@ -0,0 +1,27 @@ +-- May 31, 2013 7:34:01 PM SGT +-- IDEMPIERE-860 Review Payment Processors +UPDATE AD_Column SET ReadOnlyLogic='@CustomerPaymentProfileID@!''''',Updated=TO_TIMESTAMP('2013-05-31 19:34:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5240 +; + +-- May 31, 2013 7:34:10 PM SGT +-- IDEMPIERE-860 Review Payment Processors +UPDATE AD_Column SET ReadOnlyLogic='@CustomerPaymentProfileID@!''''',Updated=TO_TIMESTAMP('2013-05-31 19:34:10','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5239 +; + +-- May 31, 2013 7:34:17 PM SGT +-- IDEMPIERE-860 Review Payment Processors +UPDATE AD_Column SET ReadOnlyLogic='@CustomerPaymentProfileID@!''''',Updated=TO_TIMESTAMP('2013-05-31 19:34:17','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=5232 +; + +-- May 31, 2013 7:35:47 PM SGT +-- IDEMPIERE-860 Review Payment Processors +INSERT INTO AD_Message (AD_Client_ID,EntityType,MsgType,MsgText,AD_Message_ID,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created) VALUES (0,'D','E','Inactive payment processor',200176,'e9638795-bd2f-405b-b3cb-567036b3871d','InactivePaymentProcessor','Y',TO_TIMESTAMP('2013-05-31 19:35:45','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-05-31 19:35:45','YYYY-MM-DD HH24:MI:SS')) +; + +-- May 31, 2013 7:35:47 PM SGT +-- IDEMPIERE-860 Review Payment Processors +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200176 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +SELECT register_migration_script('201305311943_IDEMPIERE-860.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/src/org/compiere/model/MBankAccountProcessor.java b/org.adempiere.base/src/org/compiere/model/MBankAccountProcessor.java index 5e2ff72f5e..7135e103ed 100644 --- a/org.adempiere.base/src/org/compiere/model/MBankAccountProcessor.java +++ b/org.adempiere.base/src/org/compiere/model/MBankAccountProcessor.java @@ -22,8 +22,10 @@ import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.exceptions.AdempiereException; import org.compiere.util.CLogger; import org.compiere.util.DB; +import org.compiere.util.Msg; /** * Bank Account Payment Processor @@ -72,26 +74,26 @@ public class MBankAccountProcessor extends X_C_BankAccount_Processor { + " AND (bap.C_Currency_ID IS NULL OR bap.C_Currency_ID=?)" // #2 + " AND (bap.MinimumAmt IS NULL OR bap.MinimumAmt = 0 OR bap.MinimumAmt <= ?)"); // #3 if (MPayment.TENDERTYPE_DirectDeposit.equals(tender)) - sql.append(" AND bap.AcceptDirectDeposit='Y'"); + sql.append(" AND bap.AcceptDirectDeposit='Y' AND pp.AcceptDirectDeposit='Y' "); else if (MPayment.TENDERTYPE_DirectDebit.equals(tender)) - sql.append(" AND bap.AcceptDirectDebit='Y'"); + sql.append(" AND bap.AcceptDirectDebit='Y' AND AND pp.AcceptDirectDebit='Y' "); else if (MPayment.TENDERTYPE_Check.equals(tender)) - sql.append(" AND bap.AcceptCheck='Y'"); + sql.append(" AND bap.AcceptCheck='Y' AND pp.AcceptCheck='Y' "); // CreditCards else if (MPayment.CREDITCARDTYPE_ATM.equals(CCType)) - sql.append(" AND bap.AcceptATM='Y'"); + sql.append(" AND bap.AcceptATM='Y' AND pp.AcceptATM='Y' "); else if (MPayment.CREDITCARDTYPE_Amex.equals(CCType)) - sql.append(" AND bap.AcceptAMEX='Y'"); + sql.append(" AND bap.AcceptAMEX='Y' AND pp.AcceptAMEX='Y' "); else if (MPayment.CREDITCARDTYPE_Visa.equals(CCType)) - sql.append(" AND bap.AcceptVISA='Y'"); + sql.append(" AND bap.AcceptVISA='Y' AND pp.AcceptVISA='Y' "); else if (MPayment.CREDITCARDTYPE_MasterCard.equals(CCType)) - sql.append(" AND bap.AcceptMC='Y'"); + sql.append(" AND bap.AcceptMC='Y' AND pp.AcceptMC='Y' "); else if (MPayment.CREDITCARDTYPE_Diners.equals(CCType)) - sql.append(" AND bap.AcceptDiners='Y'"); + sql.append(" AND bap.AcceptDiners='Y' AND pp.AcceptDiners='Y' "); else if (MPayment.CREDITCARDTYPE_Discover.equals(CCType)) - sql.append(" AND bap.AcceptDiscover='Y'"); + sql.append(" AND bap.AcceptDiscover='Y' AND pp.AcceptDiscover='Y' "); else if (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CCType)) - sql.append(" AND bap.AcceptCORPORATE='Y'"); + sql.append(" AND bap.AcceptCORPORATE='Y' AND pp.AcceptCORPORATE='Y' "); sql.append(" ORDER BY ba.IsDefault DESC "); // PreparedStatement pstmt = null; @@ -157,6 +159,19 @@ public class MBankAccountProcessor extends X_C_BankAccount_Processor { setC_PaymentProcessor_ID(C_PaymentProcessor_ID); // FK } + @Override + protected boolean beforeSave(boolean newRecord) + { + if (getC_PaymentProcessor_ID() > 0 && isActive()) + { + MPaymentProcessor pp = new MPaymentProcessor(getCtx(), getC_PaymentProcessor_ID(), get_TrxName()); + if (!pp.isActive()) + throw new AdempiereException(Msg.translate(getCtx(), "InactivePaymentProcessor") + ". " + pp.toString()); + } + + return true; + } + /** * Does Payment Processor accepts tender / CC * @param TenderType tender type @@ -165,19 +180,40 @@ public class MBankAccountProcessor extends X_C_BankAccount_Processor { */ public boolean accepts (String TenderType, String CreditCardType) { - if ((MPayment.TENDERTYPE_DirectDeposit.equals(TenderType) && isAcceptDirectDeposit()) - || (MPayment.TENDERTYPE_DirectDebit.equals(TenderType) && isAcceptDirectDebit()) - || (MPayment.TENDERTYPE_Check.equals(TenderType) && isAcceptCheck()) - // - || (MPayment.CREDITCARDTYPE_ATM.equals(CreditCardType) && isAcceptATM()) - || (MPayment.CREDITCARDTYPE_Amex.equals(CreditCardType) && isAcceptAMEX()) - || (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CreditCardType) && isAcceptCorporate()) - || (MPayment.CREDITCARDTYPE_Diners.equals(CreditCardType) && isAcceptDiners()) - || (MPayment.CREDITCARDTYPE_Discover.equals(CreditCardType) && isAcceptDiscover()) - || (MPayment.CREDITCARDTYPE_MasterCard.equals(CreditCardType) && isAcceptMC()) - || (MPayment.CREDITCARDTYPE_Visa.equals(CreditCardType) && isAcceptVisa())) - return true; - return false; + if (getC_PaymentProcessor_ID() > 0) + { + MPaymentProcessor pp = new MPaymentProcessor(getCtx(), getC_PaymentProcessor_ID(), get_TrxName()); + + if ((MPayment.TENDERTYPE_DirectDeposit.equals(TenderType) && isAcceptDirectDeposit() && pp.isAcceptDirectDeposit()) + || (MPayment.TENDERTYPE_DirectDebit.equals(TenderType) && isAcceptDirectDebit() && pp.isAcceptDirectDebit()) + || (MPayment.TENDERTYPE_Check.equals(TenderType) && isAcceptCheck() && pp.isAcceptCheck()) + // + || (MPayment.CREDITCARDTYPE_ATM.equals(CreditCardType) && isAcceptATM() && pp.isAcceptATM()) + || (MPayment.CREDITCARDTYPE_Amex.equals(CreditCardType) && isAcceptAMEX() && pp.isAcceptAMEX()) + || (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CreditCardType) && isAcceptCorporate() && pp.isAcceptCorporate()) + || (MPayment.CREDITCARDTYPE_Diners.equals(CreditCardType) && isAcceptDiners() && pp.isAcceptDiners()) + || (MPayment.CREDITCARDTYPE_Discover.equals(CreditCardType) && isAcceptDiscover() && pp.isAcceptDiscover()) + || (MPayment.CREDITCARDTYPE_MasterCard.equals(CreditCardType) && isAcceptMC() && pp.isAcceptMC()) + || (MPayment.CREDITCARDTYPE_Visa.equals(CreditCardType) && isAcceptVisa() && pp.isAcceptVisa())) + return true; + return false; + } + else + { + if ((MPayment.TENDERTYPE_DirectDeposit.equals(TenderType) && isAcceptDirectDeposit()) + || (MPayment.TENDERTYPE_DirectDebit.equals(TenderType) && isAcceptDirectDebit()) + || (MPayment.TENDERTYPE_Check.equals(TenderType) && isAcceptCheck()) + // + || (MPayment.CREDITCARDTYPE_ATM.equals(CreditCardType) && isAcceptATM()) + || (MPayment.CREDITCARDTYPE_Amex.equals(CreditCardType) && isAcceptAMEX()) + || (MPayment.CREDITCARDTYPE_PurchaseCard.equals(CreditCardType) && isAcceptCorporate()) + || (MPayment.CREDITCARDTYPE_Diners.equals(CreditCardType) && isAcceptDiners()) + || (MPayment.CREDITCARDTYPE_Discover.equals(CreditCardType) && isAcceptDiscover()) + || (MPayment.CREDITCARDTYPE_MasterCard.equals(CreditCardType) && isAcceptMC()) + || (MPayment.CREDITCARDTYPE_Visa.equals(CreditCardType) && isAcceptVisa())) + return true; + return false; + } } // accepts public String toString() diff --git a/org.adempiere.base/src/org/compiere/model/MPayment.java b/org.adempiere.base/src/org/compiere/model/MPayment.java index e97e24ccb2..9ddd4f33ba 100644 --- a/org.adempiere.base/src/org/compiere/model/MPayment.java +++ b/org.adempiere.base/src/org/compiere/model/MPayment.java @@ -1011,17 +1011,19 @@ public final class MPayment extends X_C_Payment for (int i = 0; i < m_mBankAccountProcessors.length; i++) { MBankAccountProcessor bankAccountProcessor = m_mBankAccountProcessors[i]; - if (bankAccountProcessor.isAcceptAMEX()) + MPaymentProcessor paymentProcessor = new MPaymentProcessor(getCtx(), bankAccountProcessor.getC_PaymentProcessor_ID(), get_TrxName()); + + if (bankAccountProcessor.isAcceptAMEX() && paymentProcessor.isAcceptAMEX()) map.put (CREDITCARDTYPE_Amex, getCreditCardPair (CREDITCARDTYPE_Amex)); - if (bankAccountProcessor.isAcceptDiners()) + if (bankAccountProcessor.isAcceptDiners() && paymentProcessor.isAcceptDiners()) map.put (CREDITCARDTYPE_Diners, getCreditCardPair (CREDITCARDTYPE_Diners)); - if (bankAccountProcessor.isAcceptDiscover()) + if (bankAccountProcessor.isAcceptDiscover() && paymentProcessor.isAcceptDiscover()) map.put (CREDITCARDTYPE_Discover, getCreditCardPair (CREDITCARDTYPE_Discover)); - if (bankAccountProcessor.isAcceptMC()) + if (bankAccountProcessor.isAcceptMC() && paymentProcessor.isAcceptMC()) map.put (CREDITCARDTYPE_MasterCard, getCreditCardPair (CREDITCARDTYPE_MasterCard)); - if (bankAccountProcessor.isAcceptCorporate()) + if (bankAccountProcessor.isAcceptCorporate() && paymentProcessor.isAcceptCorporate()) map.put (CREDITCARDTYPE_PurchaseCard, getCreditCardPair (CREDITCARDTYPE_PurchaseCard)); - if (bankAccountProcessor.isAcceptVisa()) + if (bankAccountProcessor.isAcceptVisa() && paymentProcessor.isAcceptVisa()) map.put (CREDITCARDTYPE_Visa, getCreditCardPair (CREDITCARDTYPE_Visa)); } // for all payment processors //