IDEMPIERE-1474 The class org.compiere.model.MPaymentValidate is not using translated error messages #resolve #fixversion 10 (#1234)

This commit is contained in:
Layda Salas 2022-03-09 03:35:37 +01:00 committed by GitHub
parent a2f2b0acec
commit ad70efcfa1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 16 deletions

View File

@ -21,6 +21,8 @@ import java.util.StringTokenizer;
import java.util.logging.Level; import java.util.logging.Level;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/** /**
@ -44,7 +46,7 @@ public class MPaymentValidate
{ {
String exp = checkNumeric(mmyy); String exp = checkNumeric(mmyy);
if (exp.length() != 4) if (exp.length() != 4)
return "CreditCardExpFormat"; return Msg.getMsg(Env.getCtx(), "CreditCardExpFormat");
// //
String mmStr = exp.substring(0,2); String mmStr = exp.substring(0,2);
String yyStr = exp.substring(2,4); String yyStr = exp.substring(2,4);
@ -58,7 +60,7 @@ public class MPaymentValidate
} }
catch (Exception e) catch (Exception e)
{ {
return "CreditCardExpFormat"; return Msg.getMsg(Env.getCtx(), "CreditCardExpFormat");
} }
return validateCreditCardExp(mm,yy); return validateCreditCardExp(mm,yy);
} // validateCreditCardExp } // validateCreditCardExp
@ -110,7 +112,7 @@ public class MPaymentValidate
public static String validateCreditCardExp (int mm, int yy) public static String validateCreditCardExp (int mm, int yy)
{ {
if (mm < 1 || mm > 12) if (mm < 1 || mm > 12)
return "CreditCardExpMonth"; return Msg.getMsg(Env.getCtx(), "CreditCardExpMonth");
// Today's date // Today's date
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
@ -118,9 +120,9 @@ public class MPaymentValidate
int month = cal.get(Calendar.MONTH) + 1; // zero based int month = cal.get(Calendar.MONTH) + 1; // zero based
// //
if (yy < year) if (yy < year)
return "CreditCardExpired"; return Msg.getMsg(Env.getCtx(), "CreditCardExpired");
else if (yy == year && mm < month) else if (yy == year && mm < month)
return "CreditCardExpired"; return Msg.getMsg(Env.getCtx(), "CreditCardExpired");
return ""; return "";
} // validateCreditCardExp } // validateCreditCardExp
@ -134,7 +136,7 @@ public class MPaymentValidate
public static String validateCreditCardNumber (String creditCardNumber) public static String validateCreditCardNumber (String creditCardNumber)
{ {
if (creditCardNumber == null || creditCardNumber.length() == 0) if (creditCardNumber == null || creditCardNumber.length() == 0)
return "CreditCardNumberError"; return Msg.getMsg(Env.getCtx(), "CreditCardNumberError");
/** /**
* 1: Double the value of alternate digits beginning with * 1: Double the value of alternate digits beginning with
@ -186,7 +188,7 @@ public class MPaymentValidate
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber - " + creditCardNumber + " -> " if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber - " + creditCardNumber + " -> "
+ ccNumber + ", Luhn=" + sum); + ccNumber + ", Luhn=" + sum);
return "CreditCardNumberError"; return Msg.getMsg(Env.getCtx(), "CreditCardNumberError");
} // validateCreditCardNumber } // validateCreditCardNumber
/** /**
@ -199,7 +201,7 @@ public class MPaymentValidate
public static String validateCreditCardNumber (String creditCardNumber, String creditCardType) public static String validateCreditCardNumber (String creditCardNumber, String creditCardType)
{ {
if (creditCardNumber == null || creditCardType == null) if (creditCardNumber == null || creditCardType == null)
return "CreditCardNumberError"; return Msg.getMsg(Env.getCtx(), "CreditCardNumberError");
// http://www.beachnet.com/~hstiles/cardtype.html // http://www.beachnet.com/~hstiles/cardtype.html
// http://staff.semel.fi/~kribe/document/luhn.htm // http://staff.semel.fi/~kribe/document/luhn.htm
@ -264,7 +266,7 @@ public class MPaymentValidate
{ {
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber Length=" if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardNumber Length="
+ ccLength + " <> " + ccLengthList); + ccLength + " <> " + ccLengthList);
return "CreditCardNumberError"; return Msg.getMsg(Env.getCtx(), "CreditCardNumberError");
} }
/** /**
@ -286,7 +288,7 @@ public class MPaymentValidate
if (check.length() != 0) if (check.length() != 0)
return check; return check;
if (!ccIdentified) if (!ccIdentified)
return "CreditCardNumberProblem?"; return Msg.getMsg(Env.getCtx(), "CreditCardNumberProblem?");
return ""; return "";
} // validateCreditCardNumber } // validateCreditCardNumber
@ -313,7 +315,7 @@ public class MPaymentValidate
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex); if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - " + ex);
} }
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - length=" + length); if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV - length=" + length);
return "CreditCardVVError"; return Msg.getMsg(Env.getCtx(), "CreditCardVVError");
} // validateCreditCardVV } // validateCreditCardVV
/** /**
@ -347,7 +349,7 @@ public class MPaymentValidate
} }
} }
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(4) CC=" + creditCardType + ", length=" + length); if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(4) CC=" + creditCardType + ", length=" + length);
return "CreditCardVVError"; return Msg.getMsg(Env.getCtx(), "CreditCardVVError");
} }
// Visa & MasterCard - 3 digits // Visa & MasterCard - 3 digits
if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa) if (creditCardType.equals(X_C_Payment.CREDITCARDTYPE_Visa)
@ -366,7 +368,7 @@ public class MPaymentValidate
} }
} }
if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(3) CC=" + creditCardType + ", length=" + length); if (s_log.isLoggable(Level.FINE)) s_log.fine("validateCreditCardVV(3) CC=" + creditCardType + ", length=" + length);
return "CreditCardVVError"; return Msg.getMsg(Env.getCtx(), "CreditCardVVError");
} }
// Other // Other
@ -389,7 +391,7 @@ public class MPaymentValidate
// Issue: Bank account country // Issue: Bank account country
if (length > 0) if (length > 0)
return ""; return "";
return "PaymentBankRoutingNotValid"; return Msg.getMsg(Env.getCtx(), "PaymentBankRoutingNotValid");
} // validateBankRoutingNo } // validateBankRoutingNo
/** /**
@ -402,7 +404,7 @@ public class MPaymentValidate
int length = checkNumeric(AccountNo).length(); int length = checkNumeric(AccountNo).length();
if (length > 0) if (length > 0)
return ""; return "";
return "PaymentBankAccountNotValid"; return Msg.getMsg(Env.getCtx(), "PaymentBankAccountNotValid");
} // validateBankAccountNo } // validateBankAccountNo
/** /**
@ -415,7 +417,7 @@ public class MPaymentValidate
int length = checkNumeric(CheckNo).length(); int length = checkNumeric(CheckNo).length();
if (length > 0) if (length > 0)
return ""; return "";
return "PaymentBankCheckNotValid"; return Msg.getMsg(Env.getCtx(), "PaymentBankCheckNotValid");
} // validateBankCheckNo } // validateBankCheckNo
/** /**