www.pudn.com > code_source_compiere_erp_crm_logiciel_java.zip > MPayment.java
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.util.*;
import java.sql.*;
import java.math.*;
import java.io.Serializable;
import org.apache.log4j.Logger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.process.*;
/**
* Payment Model.
* - retrieve and create payments for invoice
*
* Event chain
* - Payment inserted
* C_Payment_Trg fires
* update DocumentNo with payment summary
* - Payment posted (C_Payment_Post)
* create allocation line
* C_Allocation_Trg fires
* Update C_BPartner Open Item Amount
* update invoice (IsPaid)
* link invoice-payment if batch
*
* Lifeline:
* - Created by VPayment or directly
* - When changed in VPayment
* - old payment is reversed
* - new payment created
*
* When Payment is posed, the Allocation is made
*
* @author Jorg Janke
* @version $Id: MPayment.java,v 1.19 2003/04/28 04:18:58 jjanke Exp $
*/
public final class MPayment extends PO
implements ProcessCall, Serializable
{
/**
* Default Constructor
* @param ctx context
* @param C_Payment_ID payment to load, (0 create new payment)
*/
public MPayment (Properties ctx, int C_Payment_ID)
{
super (ctx, C_Payment_ID);
// New
if (C_Payment_ID == 0)
{
setDocAction("CO");
setDocStatus("DR");
//
setR_AvsAddr (AVS_UNAVAILABLE);
setR_AvsZip (AVS_UNAVAILABLE);
//
setReceipt (true);
setProcessed(false);
setApproved (false);
setPosted (false);
setReconciled (false);
setAllocated(false);
setOnline (false);
//
setPayAmt(Env.ZERO);
setDiscountAmt(Env.ZERO);
setTaxAmt(Env.ZERO);
setWriteOffAmt(Env.ZERO);
setOverUnderPayment (false);
setOverUnderAmt(Env.ZERO);
//
setDateTrx (new Timestamp(System.currentTimeMillis()));
}
} // MPayment
/**
* Load Constructor
* @param ctx context
* @param rs result set record
*/
public MPayment (Properties ctx, ResultSet rs)
{
super (ctx, rs);
} // MPayment
/**
* Initialize and return PO_Info
* @param ctx context
* @return POInfo
*/
protected POInfo initPO (Properties ctx)
{
int AD_Table_ID = 335;
POInfo poi = POInfo.getPOInfo (ctx, AD_Table_ID);
return poi;
} // initPO
// Tender Types
public final static String TENDER_ACH = "A";
public final static String TENDER_CREDITCARD = "C";
public final static String TENDER_CHECK = "K";
// Trx Type
public final static String TRX_AUTHORIZATION = "A";
public final static String TRX_CREDIT = "C";
public final static String TRX_DELAYED = "D";
public final static String TRX_VOICE = "F";
public final static String TRX_SALES = "S"; // default
public final static String TRX_VOID = "V";
// AVS
public final static String AVS_NOMATCH = "N";
public final static String AVS_MATCH = "Y";
public final static String AVS_UNAVAILABLE = "X";
// Credit Card Type
public final static String CC_AMEX = "A";
public final static String CC_MASTERCARD = "M";
public final static String CC_VISA = "V";
public final static String CC_DISCOVER = "N";
public final static String CC_DINERS = "D";
public final static String CC_PURCHASE = "P";
// Temporary
private MPaymentProcessor m_mpp = null;
private static Logger s_log = Logger.getLogger (MPayment.class);
private String m_errorMessage = null;
/*************************************************************************/
/**
* Set Credit Card.
* Need to set PatmentProcessor after Amount/Currency Set
*
* @param TrxType Transaction Type see TRX_
* @param creditCardType CC type
* @param creditCardNumber CC number
* @param creditCardVV CC verification
* @param creditCardExpMM CC Exp MM
* @param creditCardExpYY CC Exp YY
* @return true if valid
*/
public boolean setCreditCard (String TrxType, String creditCardType, String creditCardNumber,
String creditCardVV, int creditCardExpMM, int creditCardExpYY)
{
setTenderType(TENDER_CREDITCARD);
setTrxType(TrxType);
//
setCreditCardType (creditCardType);
setCreditCardNumber (creditCardNumber);
setCreditCardVV (creditCardVV);
setCreditCardExpMM (creditCardExpMM);
setCreditCardExpYY (creditCardExpYY);
//
int check = validateCreditCardNumber(creditCardNumber, creditCardType).length()
+ validateCreditCardExp(creditCardExpMM, creditCardExpYY).length();
if (creditCardVV.length() > 0)
check += validateCreditCardVV(creditCardVV, creditCardType).length();
return check == 0;
} // setCreditCard
/**
* Set Credit Card - Exp.
* Need to set PatmentProcessor after Amount/Currency Set
*
* @param TrxType Transaction Type see TRX_
* @param creditCardType CC type
* @param creditCardNumber CC number
* @param creditCardVV CC verification
* @param creditCardExp CC Exp
* @return true if valid
*/
public boolean setCreditCard (String TrxType, String creditCardType, String creditCardNumber,
String creditCardVV, String creditCardExp)
{
return setCreditCard(TrxType, creditCardType, creditCardNumber,
creditCardVV, getCreditCardExpMM(creditCardExp), getCreditCardExpYY(creditCardExp));
} // setCreditCard
/**
* Set ACH BankAccount Info
*
* @param C_BankAccount_ID bank account
* @param isReceipt true if receipt
* @return true if valid
*/
public boolean setBankACH (int C_BankAccount_ID, boolean isReceipt)
{
return setBankACH(C_BankAccount_ID, isReceipt);
} // setBankACH
/**
* Set ACH BankAccount Info
*
* @param C_BankAccount_ID bank account
* @param isReceipt true if receipt
* @param routingNo routing
* @param accountNo account
* @return true if valid
*/
public boolean setBankACH (int C_BankAccount_ID, boolean isReceipt, String routingNo, String accountNo)
{
setTenderType (TENDER_ACH);
setReceipt (isReceipt);
//
if (C_BankAccount_ID > 0
&& (routingNo == null || routingNo.length() == 0 || accountNo == null || accountNo.length() == 0))
setBankAccountDetails(C_BankAccount_ID);
else
{
setC_BankAccount_ID(C_BankAccount_ID);
setBankRoutingNo (routingNo);
setBankAccountNo (accountNo);
}
setBankCheckNo ("");
//
int check = validateBankRoutingNo(routingNo).length()
+ validateBankAccountNo(accountNo).length();
return check == 0;
} // setBankACH
/**
* Set Check BankAccount Info
*
* @param C_BankAccount_ID bank account
* @param isReceipt true if receipt
* @param checkNo chack no
* @return true if valid
*/
public boolean setBankCheck (int C_BankAccount_ID, boolean isReceipt, String checkNo)
{
return setBankCheck (C_BankAccount_ID, isReceipt, null, null, checkNo);
} // setBankCheck
/**
* Set Check BankAccount Info
*
* @param C_BankAccount_ID bank account
* @param isReceipt true if receipt
* @param routingNo routing no
* @param accountNo account no
* @param checkNo chack no
* @return true if valid
*/
public boolean setBankCheck (int C_BankAccount_ID, boolean isReceipt, String routingNo, String accountNo, String checkNo)
{
setTenderType (TENDER_CHECK);
setReceipt (isReceipt);
//
if (C_BankAccount_ID > 0
&& (routingNo == null || routingNo.length() == 0 || accountNo == null || accountNo.length() == 0))
setBankAccountDetails(C_BankAccount_ID);
else
{
setC_BankAccount_ID(C_BankAccount_ID);
setBankRoutingNo (routingNo);
setBankAccountNo (accountNo);
}
setBankCheckNo (checkNo);
//
int check = validateBankRoutingNo(routingNo).length()
+ validateBankAccountNo(accountNo).length()
+ validateBankCheckNo(checkNo).length();
return check == 0; // no error message
} // setBankCheck
/**
* Set Bank Account Details.
* Look up Routing No & Bank Acct No
* @param C_BankAccount_ID bank account
*/
public void setBankAccountDetails (int C_BankAccount_ID)
{
if (C_BankAccount_ID == 0)
return;
setC_BankAccount_ID(C_BankAccount_ID);
//
String sql = "SELECT b.RoutingNo, ba.AccountNo "
+ "FROM C_BankAccount ba"
+ " INNER JOIN C_Bank b ON (ba.C_Bank_ID=b.C_Bank_ID) "
+ "WHERE C_BankAccount_ID=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, C_BankAccount_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
{
setBankRoutingNo (rs.getString(1));
setBankAccountNo (rs.getString(2));
}
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.error("setsetBankAccountDetails", e);
}
} // setBankAccountDetails
/**
* Set Account Address
*
* @param name name
* @param street street
* @param city city
* @param state state
* @param zip zip
* @param country country
*/
public void setAccountAddress (String name, String street,
String city, String state, String zip, String country)
{
setA_Name (name);
setA_Street (street);
setA_City (city);
setA_State (state);
setA_Zip (zip);
setA_Country(country);
} // setAccountAddress
/*************************************************************************/
/**
* Process Payment
* @return true if approved
*/
public boolean processOnline()
{
log.info ("processOnline - " + getPayAmt());
setOnline(true);
setErrorMessage(null);
// prevent charging twice
if (isApproved())
{
log.info("processOnline - already processed - " + getR_Result() + " - " + getR_RespMsg());
setErrorMessage("Payment already Processed");
return true;
}
if (m_mpp == null)
setPaymentProcessor();
if (m_mpp == null)
{
log.error("processOnline - No Payment Processor Model");
setErrorMessage("No Payment Processor Model");
return false;
}
boolean approved = false;
try
{
PaymentProcessor pp = PaymentProcessor.create(m_mpp, this);
if (pp == null)
setErrorMessage("No Payment Processor");
else
{
approved = pp.processCC ();
if (approved)
setErrorMessage(null);
else
setErrorMessage(getR_RespMsg());
}
}
catch (Exception e)
{
log.error("processOnline", e);
setErrorMessage("Payment Processor Error");
}
setApproved(approved);
return approved;
} // processOnline
/**
* 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
* @return true if the next process should be performed
*/
public boolean startProcess (Properties ctx, ProcessInfo pi)
{
log.info("startProcess - " + pi.Record_ID);
boolean retValue = false;
//
if (pi.Record_ID != getID())
{
log.error("startProcess - Not same Payment - " + pi.Record_ID);
return false;
}
// Process it
retValue = processOnline();
save();
return retValue; // Payment processed
} // startProcess
/**
* Save
* @return true if success
*/
public boolean save ()
{
log.info("save");
//
if (getC_DocType_ID() == 0)
setC_DocType_ID();
if (getDocumentNo() == null)
setDocumentNo();
return super.save();
} // save
/**
* Post Payment
* @return true if success
*/
public boolean post()
{
if (!save()) // save first
return false;
log.info("post");
boolean retValue = false;
try
{
CallableStatement cstmt = DB.prepareCall("{CALL C_Payment_Post(NULL,?)}");
cstmt.setInt(1, getID());
retValue = cstmt.execute();
cstmt.close();
}
catch (SQLException e)
{
log.error("post", e);
}
load();
return retValue;
} // post
/**
* Cancel Payment
* @return true if cancelled
*/
public boolean cancel()
{
log.info("cancel");
// Check Status
if (!"CO".equals(getDocStatus()))
return false;
// Set Action
setDocAction ("RC");
save();
return post();
} // Cancel
/*************************************************************************/
/**
* Set Error Message
* @param errorMessage error message
*/
public void setErrorMessage(String errorMessage)
{
m_errorMessage = errorMessage;
} // setErrorMessage
/**
* Get Error Message
* @return error message
*/
public String getErrorMessage()
{
return m_errorMessage;
} // getErrorMessage
/**
* Get Payment
* @return C_Payment_ID
*/
public int getC_Payment_ID()
{
return getID();
} // getC_Payment_ID
/**
* Set Transaction Type if valid
* @param TrxType trx type
*/
public void setTrxType (String TrxType)
{
if (TrxType == null)
return;
if (TrxType.equals(TRX_AUTHORIZATION)
|| TrxType.equals(TRX_CREDIT)
|| TrxType.equals(TRX_DELAYED)
|| TrxType.equals(TRX_SALES)
|| TrxType.equals(TRX_VOICE)
|| TrxType.equals(TRX_VOID))
{
setValue("TrxType", TrxType);
if (TrxType.equals(TRX_SALES))
setReceipt(true);
}
} // setTrxType
/**
* Get Trx Type
* @return TrxType
*/
public String getTrxType()
{
return (String)getValue("TrxType");
} // getTrxType
/**
* Set Bank Account for Payment.
* @param C_BankAccount_ID C_BankAccount_ID
*/
public void setC_BankAccount_ID (int C_BankAccount_ID)
{
if (C_BankAccount_ID == 0)
{
setPaymentProcessor();
if (getC_BankAccount_ID() == 0)
throw new IllegalArgumentException("MPayment.setC_BankAccount_ID - can't find Bank Account");
}
else
setValue ("C_BankAccount_ID", new Integer(C_BankAccount_ID));
} // setC_BankAccount_ID
/**
* Get Bank Account
* @return C_BankAccount_ID
*/
public int getC_BankAccount_ID()
{
Integer ii = (Integer)getValue("C_BankAccount_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_BankAccount_ID
/**
* Set BankAccount and PaymentProcessor
* @return true if found
*/
public boolean setPaymentProcessor ()
{
return setPaymentProcessor (getTenderType(), getCreditCardType());
} // setPaymentProcessor
/**
* Set BankAccount and PaymentProcessor
* @param tender TenderType see TENDER_
* @param CCType CC Type see CC_
* @return true if found
*/
public boolean setPaymentProcessor (String tender, String CCType)
{
m_mpp = findPaymentProcessor (getCtx(), tender, CCType, getAD_Client_ID(),
getC_Currency_ID(), getPayAmt());
if (m_mpp != null)
setC_BankAccount_ID (m_mpp.getC_BankAccount_ID());
//
return m_mpp != null;
} // setPaymentProcessor
/**
* Get BankAccount & PaymentProcessor
* @param ctx context
* @param tender Tender see TENDER_
* @param CCType CC Type see CC_
* @param AD_Client_ID Client
* @param C_Currency_ID Currency (ignored)
* @param Amt Amount (ignored)
* @return Array of BankAccount[0] & PaymentProcessor[1] or null
*/
public static int findBankAccount (Properties ctx,
String tender, String CCType,
int AD_Client_ID, int C_Currency_ID, BigDecimal Amt)
{
MPaymentProcessor mpp = findPaymentProcessor(ctx,
tender, CCType, AD_Client_ID, C_Currency_ID, Amt);
if (mpp == null)
return 0;
return mpp.getC_BankAccount_ID();
} // findBankAccount
/**
* Get BankAccount & PaymentProcessor
* @param ctx context
* @param tender Tender see TENDER_
* @param CCType CC Type see CC_
* @param AD_Client_ID Client
* @param C_Currency_ID Currency (ignored)
* @param Amt Amount (ignored)
* @return Array of BankAccount[0] & PaymentProcessor[1] or null
*/
protected static MPaymentProcessor findPaymentProcessor (Properties ctx,
String tender, String CCType,
int AD_Client_ID, int C_Currency_ID, BigDecimal Amt)
{
StringBuffer sql = new StringBuffer("SELECT * "
+ "FROM C_PaymentProcessor "
+ "WHERE AD_Client_ID=? AND IsActive='Y'");
if (tender.equals(TENDER_ACH))
sql.append(" AND AcceptACH='Y'");
else if (tender.equals(TENDER_CHECK))
sql.append(" AND AcceptCheck='Y'");
// CreditCards
else if (CCType.equals(CC_AMEX))
sql.append(" AND AcceptAMEX='Y'");
else if (CCType.equals(CC_DINERS))
sql.append(" AND AcceptDiners='Y'");
else if (CCType.equals(CC_DISCOVER))
sql.append(" AND AcceptDiscover='Y'");
else if (CCType.equals(CC_MASTERCARD))
sql.append(" AND AcceptMC='Y'");
else if (CCType.equals(CC_PURCHASE))
sql.append(" AND AcceptCORPORATE='Y'");
else if (CCType.equals(CC_VISA))
sql.append(" AND AcceptVISA='Y'");
//
// sql.append(" AND (C_Currency_ID IS NULL OR C_Currency_ID=?)");
MPaymentProcessor retValue = null;
try
{
PreparedStatement pstmt = DB.prepareStatement(sql.toString());
pstmt.setInt(1, AD_Client_ID);
// pstmt.setInt(2, C_Currency_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = new MPaymentProcessor (ctx, rs);
else
s_log.warn("findPaymentProcessor - no found - " + sql + ", AD_Client_ID=" + AD_Client_ID);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
s_log.error("findPaymentProcessor", e);
return null;
}
return retValue;
} // findPaymentProcessor
/*************************************************************************/
/**
* Set Tender Type if valid
* @param TenderType Tender Type see TENDER_
*/
public void setTenderType (String TenderType)
{
if (TenderType == null)
return;
if (TenderType.equals(TENDER_ACH)
|| TenderType.equals(TENDER_CHECK)
|| TenderType.equals(TENDER_CREDITCARD))
setValue ("TenderType", TenderType);
} // setTenderType
/**
* Get Tender Type.
* See TENDER_
* @return Tender Type
*/
public String getTenderType()
{
return (String)getValue("TenderType");
} // getTenderYupe
/**
* Set Credit Card if valid
*
* @param CreditCardType credit card type see CC_
*/
public void setCreditCardType (String CreditCardType)
{
if (CreditCardType == null)
return;
if (CreditCardType.equals(CC_AMEX)
|| CreditCardType.equals(CC_DINERS)
|| CreditCardType.equals(CC_DISCOVER)
|| CreditCardType.equals(CC_MASTERCARD)
|| CreditCardType.equals(CC_PURCHASE)
|| CreditCardType.equals(CC_VISA))
setValue ("CreditCardType", CreditCardType);
} // setCreditCardType
/**
* Get Credit Card Type
* @return Credit Card Type see CC_
*/
public String getCreditCardType()
{
return (String)getValue("CreditCardType");
} // getCreditCardType
/*************************************************************************/
/**
* Credit Card Number
* @param CreditCardNumber CreditCard Number
*/
public void setCreditCardNumber (String CreditCardNumber)
{
setValue("CreditCardNumber", checkNumeric(CreditCardNumber));
} // setCreditCardNumber
/**
* Get Credit Card Number
* @return CC Number
*/
public String getCreditCardNumber()
{
return (String)getValue("CreditCardNumber");
} // getCreditCardNumber
/**
* Validate Credit Card Number.
* - Based on LUHN formula
* @param creditCardNumber credit card number
* @return "" or Error AD_Message
*/
public static String validateCreditCardNumber (String creditCardNumber)
{
if (creditCardNumber == null || creditCardNumber.length() == 0)
return "CreditCardNumberError";
/**
* 1: Double the value of alternate digits beginning with
* the first right-hand digit (low order).
* 2: Add the individual digits comprising the products
* obtained in step 1 to each of the unaffected digits
* in the original number.
* 3: Subtract the total obtained in step 2 from the next higher
* number ending in 0 [this in the equivalent of calculating
* the "tens complement" of the low order digit (unit digit)
* of the total].
* If the total obtained in step 2 is a number ending in zero
* (30, 40 etc.), the check digit is 0.
* Example:
* Account number: 4992 73 9871 6
*
* 4 9 9 2 7 3 9 8 7 1 6
* x2 x2 x2 x2 x2
* -------------------------------
* 4 18 9 4 7 6 9 16 7 2 6
*
* 4 + 1 + 8 + 9 + 4 + 7 + 6 + 9 + 1 + 6 + 7 + 2 + 6 = 70
* 70 % 10 = 0
*/
// Clean up number
String ccNumber1 = checkNumeric(creditCardNumber);
int ccLength = ccNumber1.length();
// Reverse string
StringBuffer buf = new StringBuffer();
for (int i = ccLength; i != 0; i--)
buf.append(ccNumber1.charAt(i-1));
String ccNumber = buf.toString();
int sum = 0;
for (int i = 0; i < ccLength; i++)
{
int digit = Character.getNumericValue(ccNumber.charAt(i));
if (i % 2 == 1)
{
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
}
if (sum % 10 == 0)
return "";
s_log.debug("validateCreditCardNumber - " + creditCardNumber + " -> "
+ ccNumber + ", Luhn=" + sum);
return "CreditCardNumberError";
} // validateCreditCardNumber
/**
* Validate Credit Card Number.
* - Check Card Type and Length
* @param creditCardNumber CC Number
* @param creditCardType CC Type
* @return "" or Error AD_Message
*/
public static String validateCreditCardNumber (String creditCardNumber, String creditCardType)
{
if (creditCardNumber == null || creditCardType == null)
return "CreditCardNumberError";
// http://www.beachnet.com/~hstiles/cardtype.html
// http://staff.semel.fi/~kribe/document/luhn.htm
String ccStartList = ""; // comma separated list of starting numbers
String ccLengthList = ""; // comma separated list of lengths
//
if (creditCardType.equals(CC_MASTERCARD))
{
ccStartList = "51,52,53,54,55";
ccLengthList = "16";
}
else if (creditCardType.equals(CC_VISA))
{
ccStartList = "4";
ccLengthList = "13,16";
}
else if (creditCardType.equals(CC_AMEX))
{
ccStartList = "34,37";
ccLengthList = "15";
}
else if (creditCardType.equals(CC_AMEX))
{
ccStartList = "30,36,38";
ccLengthList = "14";
}
else if (creditCardType.equals(CC_DISCOVER))
{
ccStartList = "6011";
ccLengthList = "16";
}
else if (creditCardType.equals(CC_DINERS))
{
ccStartList = "300,301,302,303,304,305,36,38";
ccLengthList = "14";
}
else
{
// enRouteCard
ccStartList = "2014,2149";
ccLengthList = "15";
// JCBCard
ccStartList += ",3088,3096,3112,3158,3337,3528";
ccLengthList += ",16";
// JCBCard
ccStartList += ",2131,1800";
ccLengthList += ",15";
}
// Clean up number
String ccNumber = checkNumeric(creditCardNumber);
/**
* Check Length
*/
int ccLength = ccNumber.length();
boolean ccLengthOK = false;
StringTokenizer st = new StringTokenizer(ccLengthList, ",", false);
while (st.hasMoreTokens() && !ccLengthOK)
{
int l = Integer.parseInt(st.nextToken());
if (ccLength == l)
ccLengthOK = true;
}
if (!ccLengthOK)
{
s_log.debug("validateCreditCardNumber Length="
+ ccLength + " <> " + ccLengthList);
return "CreditCardNumberError";
}
/**
* Check Start Digits
*/
boolean ccIdentified = false;
st = new StringTokenizer(ccStartList, ",", false);
while (st.hasMoreTokens() && !ccIdentified)
{
if (ccNumber.startsWith(st.nextToken()))
ccIdentified = true;
}
if (!ccIdentified)
s_log.debug("validateCreditCardNumber Type="
+ creditCardType + " <> " + ccStartList);
//
String check = validateCreditCardNumber(ccNumber);
if (check.length() != 0)
return check;
if (!ccIdentified)
return "CreditCardNumberProblem?";
return "";
} // validateCreditCardNumber
/*************************************************************************/
/**
* Verification Code
* @param newCreditCardVV CC verification
*/
public void setCreditCardVV(String newCreditCardVV)
{
setValue ("CreditCardVV", checkNumeric(newCreditCardVV));
} // setCreditCardVV
/**
* Get CC Verification Code
* @return CC Verification Code
*/
public String getCreditCardVV()
{
return (String)getValue("CreditCardVV");
} // getCreditCardVV
/**
* Validate Validation Code
* @param creditCardVV CC Verification Code
* @return "" or Error AD_Message
*/
public static String validateCreditCardVV (String creditCardVV)
{
if (creditCardVV == null)
return "";
int length = checkNumeric(creditCardVV).length();
if (length == 3 || length == 4)
return "";
try
{
Integer.parseInt (creditCardVV);
return "";
}
catch (NumberFormatException ex)
{
s_log.debug("validateCreditCardVV - " + ex);
}
s_log.debug("validateCreditCardVV - length=" + length);
return "CreditCardVVError";
} // validateCreditCardVV
/**
* Validate Validation Code
* @param creditCardVV CC Verification Code
* @param creditCardType CC Type see CC_
* @return "" or Error AD_Message
*/
public static String validateCreditCardVV (String creditCardVV, String creditCardType)
{
// no data
if (creditCardVV == null || creditCardVV.length() == 0
|| creditCardType == null || creditCardType.length() == 0)
return "";
int length = checkNumeric(creditCardVV).length();
// Amex = 4 digits
if (creditCardType.equals(CC_AMEX))
{
if (length == 4)
{
try
{
Integer.parseInt (creditCardVV);
return "";
}
catch (NumberFormatException ex)
{
s_log.debug("validateCreditCardVV - " + ex);
}
}
s_log.debug("validateCreditCardVV(4) CC=" + creditCardType + ", length=" + length);
return "CreditCardVVError";
}
// Visa & MasterCard - 3 digits
if (creditCardType.equals(CC_VISA) || creditCardType.equals(CC_MASTERCARD))
{
if (length == 3)
{
try
{
Integer.parseInt (creditCardVV);
return "";
}
catch (NumberFormatException ex)
{
s_log.debug("validateCreditCardVV - " + ex);
}
}
s_log.debug("validateCreditCardVV(3) CC=" + creditCardType + ", length=" + length);
return "CreditCardVVError";
}
// Other
return "";
} // validateCreditCardVV
/*************************************************************************/
/**
* Two Digit CreditCard MM
* @param CreditCardExpMM Exp month
* @return true if valid
*/
public boolean setCreditCardExpMM (int CreditCardExpMM)
{
if (CreditCardExpMM < 1 || CreditCardExpMM > 12)
return false;
setValue ("CreditCardExpMM", new Integer (CreditCardExpMM));
return true;
} // setCreditCardExpMM
/**
* Get Exp month
* @return Exp month
*/
public int getCreditCardExpMM()
{
Integer ii = (Integer)getValue("CreditCardExpMM");
if (ii == null)
return 0;
return ii.intValue();
} // getCreditCardExpMM
/**
* Two digit CreditCard YY (til 2020)
* @param newCreditCardExpYY 2 or 4 digit year
* @return true if valid
*/
public boolean setCreditCardExpYY (int newCreditCardExpYY)
{
int CreditCardExpYY = newCreditCardExpYY;
if (newCreditCardExpYY > 1999)
CreditCardExpYY = newCreditCardExpYY-2000;
setValue ("CreditCardExpYY", new Integer(CreditCardExpYY));
return true;
} // setCreditCardExpYY
/**
* Two digit CreditCard YY
* @return Two digit CreditCard YY
*/
public int getCreditCardExpYY()
{
Integer ii = (Integer)getValue("CreditCardExpYY");
if (ii == null)
return 0;
return ii.intValue();
} // getCreditCardExpYY
/**
* CreditCard Exp MMYY
* @param mmyy Exp in form of mmyy
* @return true if valid
*/
public boolean setCreditCardExp (String mmyy)
{
if (validateCreditCardExp(mmyy).length() != 0)
return false;
//
String exp = checkNumeric(mmyy);
String mmStr = exp.substring(0,2);
String yyStr = exp.substring(2,4);
setCreditCardExpMM (Integer.parseInt(mmStr));
setCreditCardExpYY (Integer.parseInt(yyStr));
return true;
} // setCreditCardExp
/**
* Is this a valid Credit Card Exp Date?
* @param mmyy Exp in form of mmyy
* @return "" or Error AD_Message
*/
public static String validateCreditCardExp (String mmyy)
{
String exp = checkNumeric(mmyy);
if (exp.length() != 4)
return "CreditCardExpFormat";
//
String mmStr = exp.substring(0,2);
String yyStr = exp.substring(2,4);
//
int mm = 0;
int yy = 0;
try
{
mm = Integer.parseInt(mmStr);
yy = Integer.parseInt(yyStr);
}
catch (Exception e)
{
return "CreditCardExpFormat";
}
return validateCreditCardExp(mm,yy);
} // validateCreditCardExp
/**
* Return Month of Exp
* @param mmyy Exp in form of mmyy
* @return month
*/
public static int getCreditCardExpMM (String mmyy)
{
String mmStr = mmyy.substring(0,2);
int mm = 0;
try
{
mm = Integer.parseInt(mmStr);
}
catch (Exception e)
{
}
return mm;
} // getCreditCardExpMM
/**
* Return Year of Exp
* @param mmyy Exp in form of mmyy
* @return year
*/
public static int getCreditCardExpYY (String mmyy)
{
String yyStr = mmyy.substring(2);
int yy = 0;
try
{
yy = Integer.parseInt(yyStr);
}
catch (Exception e)
{
}
return yy;
} // getCreditCardExpYY
/**
* Is this a valid Credit Card Exp Date?
* @param mm month
* @param yy year
* @return "" or Error AD_Message
*/
public static String validateCreditCardExp (int mm, int yy)
{
if (mm < 1 || mm > 12)
return "CreditCardExpMonth";
// if (yy < 0 || yy > EXP_YEAR)
// return "CreditCardExpYear";
// Today's date
Calendar cal = Calendar.getInstance();
int year = cal.get(Calendar.YEAR) - 2000; // two digits
int month = cal.get(Calendar.MONTH) + 1; // zero based
//
if (yy < year)
return "CreditCardExpired";
else if (yy == year && mm < month)
return "CreditCardExpired";
return "";
} // validateCreditCardExp
/**
* CreditCard Exp MMYY
* @return Exp
*/
public String getCreditCardExp()
{
String mm = String.valueOf(getCreditCardExpMM());
String yy = String.valueOf(getCreditCardExpYY());
StringBuffer retValue = new StringBuffer();
if (mm.length() == 1)
retValue.append("0");
retValue.append(mm);
if (yy.length() == 1)
retValue.append("0");
retValue.append(yy);
//
return (retValue.toString());
} // getCreditCardExp
/**
* MICR
* @param MICR MICR
*/
public void setBankMICR (String MICR)
{
setValue ("MICR", checkNumeric(MICR));
} // setBankMICR
/**
* Get MICR
* @return MICR
*/
public String getBankMICR()
{
return (String)getValue("MICR");
} // getBankMICR
/**
* Routing No
* @param RoutingNo Routing No
*/
public void setBankRoutingNo(String RoutingNo)
{
setValue ("RoutingNo", checkNumeric(RoutingNo));
} // setBankRoutingNo
/**
* Get Routing No
* @return Routing No
*/
public String getBankRoutingNo()
{
return (String)getValue("RoutingNo");
} // getBankRoutingNo
/**
* Validate Routing Number
* @param routingNo Routing No
* @return "" or Error AD_Message
*/
public static String validateBankRoutingNo (String routingNo)
{
int length = checkNumeric(routingNo).length();
// US - length 9
// Germany - length 8
if (length == 8 || length == 9)
return "";
return "PaymentBankRoutingNotValid";
} // validateBankRoutingNo
/**
* Account No
* @param AccountNo AccountNo
*/
public void setBankAccountNo (String AccountNo)
{
setValue ("AccountNo", checkNumeric(AccountNo));
} // setBankAccountNo
/**
* Get Account No
* @return Account No
*/
public String getBankAccountNo()
{
return (String)getValue("AccountNo");
} // getBankAccountNo
/**
* Validate Account No
* @param AccountNo AccountNo
* @return "" or Error AD_Message
*/
public static String validateBankAccountNo (String AccountNo)
{
int length = checkNumeric(AccountNo).length();
if (length > 0)
return "";
return "PaymentBankAccountNotValid";
} // validateBankAccountNo
/**
* Check No
* @param CheckNo Check No
*/
public void setBankCheckNo(String CheckNo)
{
setValue("CheckNo", checkNumeric(CheckNo));
} // setBankCheckNo
/**
* Get Chack No
* @return CheckNo
*/
public String getBankCheckNo()
{
return (String)getValue ("CheckNo");
} // getBankCheckNo
/**
* Validate Check No
* @param CheckNo CheckNo
* @return "" or Error AD_Message
*/
public static String validateBankCheckNo (String CheckNo)
{
int length = checkNumeric(CheckNo).length();
if (length > 0)
return "";
return "PaymentBankCheckNotValid";
} // validateBankCheckNo
/**
* Account Name
* @param A_Name name
*/
public void setA_Name(String A_Name)
{
setValue ("A_Name", A_Name);
} // setA_Name
/**
* Get Account Name
* @return name
*/
public String getA_Name()
{
return (String)getValue("A_Name");
} // getA_Name
/**
* Set Account Street
* @param A_Street street
*/
public void setA_Street (String A_Street)
{
setValue ("A_Street", A_Street);
}
public String getA_Street()
{
return (String)getValue("A_Street");
}
/**
* Set Account City
* @param A_City city
*/
public void setA_City (String A_City)
{
setValue ("A_City", A_City);
}
public String getA_City()
{
return (String)getValue("A_City");
}
/**
* Set Account State
* @param A_State state
*/
public void setA_State(String A_State)
{
setValue ("A_State", A_State);
}
public String getA_State()
{
return (String)getValue("A_State");
}
/**
* Set Account Zip
* @param A_ZIP zip
*/
public void setA_Zip (String A_ZIP)
{
setValue ("A_Zip", A_ZIP);
}
public String getA_Zip()
{
return (String)getValue("A_Zip");
}
/**
* Set Account Country
* @param A_Country country
*/
public void setA_Country (String A_Country)
{
setValue ("A_Country", A_Country);
}
public String getA_Country()
{
return (String)getValue("A_Country");
}
/**
* Account Driver Licence
* @param A_Ident_DL Driver License
*/
public void setA_Ident_DL (String A_Ident_DL)
{
setValue ("A_Ident_DL", A_Ident_DL);
}
public String getA_Ident_DL()
{
return (String)getValue("A_Ident_DL");
}
/**
* Account SSN
* @param A_Ident_SSN SSN
*/
public void setA_Ident_SSN (String A_Ident_SSN)
{
setValue ("A_Ident_SSN", A_Ident_SSN);
}
public String getA_Ident_SSN()
{
return (String)getValue("A_Ident_SSN");
}
/**
* Account EMail
* @param A_EMail email
*/
public void setA_EMail (String A_EMail)
{
setValue ("A_EMail", A_EMail);
}
public String getA_EMail()
{
return (String)getValue("A_EMail");
}
/**
* Voice Auth Code
* @param VoiceAuthCode Voice Auth Code
*/
public void setVoiceAuthCode (String VoiceAuthCode)
{
setValue ("VoiceAuthCode", VoiceAuthCode);
}
public String getVoiceAuthCode()
{
return (String)getValue("VoiceAuthCode");
}
/**
* Original Trx ID
* @param Orig_TrxID Orig TrxID
*/
public void setOrig_TrxID (String Orig_TrxID)
{
setValue ("Orig_TrxID", Orig_TrxID);
}
public String getOrig_TrxID()
{
return (String)getValue("Orig_TrxID");
}
/**
* PO Number
* @param PONum PO Num
*/
public void setPONum(String PONum)
{
setValue ("PONum", PONum);
}
public String getPONum()
{
return (String)getValue("PONum");
}
/**
* Set DocumentNo to Payment info
*/
protected void setDocumentNo()
{
String DocumentNo = null;
if (TENDER_CREDITCARD.equals(getTenderType()))
DocumentNo = getCreditCardType() + " " + getCreditCardNumber() + " " + getCreditCardExpMM() + "/" + getCreditCardExpYY();
else
{
DocumentNo = getBankRoutingNo() + " " + getBankAccountNo();
if (TENDER_CHECK.equals(getTenderType()))
DocumentNo += " " + getBankCheckNo();
}
if (DocumentNo.length() == 0)
DocumentNo = ".";
if (DocumentNo.length() > 30)
DocumentNo = DocumentNo.substring(0,29);
//
setValue("DocumentNo", DocumentNo);
} // setDocumentNo
/**
* Get Document No
* @return documentNo
*/
public String getDocumentNo()
{
return (String)getValue("DocumentNo");
} // getDocumentNo
/**
* Date Trx
* @param DateTrx transaction date
*/
public void setDateTrx (Timestamp DateTrx)
{
setValue ("DateTrx", DateTrx);
} // setDateTrx
/**
* Get Trx Date
* @return DateTrx
*/
public Timestamp getDateTrx()
{
return (Timestamp)getValue("DateTrx");
} // getDateTrx
// ---------------
public String getR_PnRef()
{
return (String)getValue("R_PnRef");
}
void setR_PnRef (String R_PNRef)
{
setValueNoCheck ("R_PnRef", R_PNRef);
}
public String getR_Result()
{
return (String)getValue("R_Result");
}
void setR_Result (String R_Result)
{
setValueNoCheck ("R_Result", R_Result);
}
public String getR_Info()
{
return (String)getValue("R_Info");
}
void setR_Info (String R_Info)
{
if (R_Info != null && R_Info.length() > 2000)
setValueNoCheck ("R_Info", R_Info.substring(0,1999));
else
setValueNoCheck ("R_Info", R_Info);
}
public String getR_RespMsg()
{
return (String)getValue("R_RespMsg");
}
void setR_RespMsg (String R_RespMsg)
{
if (R_RespMsg != null && R_RespMsg.length() > 60)
setValueNoCheck ("R_RespMsg", R_RespMsg.substring(0,59));
else
setValueNoCheck ("R_RespMsg", R_RespMsg);
}
public String getR_AuthCode()
{
return (String)getValue("R_AuthCode");
}
void setR_AuthCode (String R_AuthCode)
{
setValueNoCheck ("R_AuthCode", R_AuthCode);
}
public String getR_AvsAddr()
{
return (String)getValue("R_AvsAddr");
}
void setR_AvsAddr (String R_AvsAddr)
{
setValueNoCheck ("R_AvsAddr", R_AvsAddr);
}
public String getR_AvsZip()
{
return (String)getValue("R_AvsZip");
}
void setR_AvsZip (String R_AvsZip)
{
setValueNoCheck ("R_AvsZip", R_AvsZip);
}
/**
* Set BPartner Bank Account No
* @param C_BP_BankAccount_ID BP_BankAccount
*/
public void setC_BP_BankAccount_ID (int C_BP_BankAccount_ID)
{
setValue("C_BP_BankAccount_ID", new Integer(C_BP_BankAccount_ID));
} // setC_BP_BankAccount_ID
/**
* Get BP_BankAccount
* @return C_BP_BankAccount_ID
*/
public int getC_BP_BankAccount_ID()
{
Integer ii = (Integer)getValue("C_BP_BankAccount_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_BP_BankAccount_ID
/**
* Set Currency
* @param C_Currency_ID Currency_ID
*/
public void setC_Currency_ID (int C_Currency_ID)
{
setValue ("C_Currency_ID", new Integer(C_Currency_ID));
} // setC_Currency_ID
/**
* Get Currency
* @return C_Currency_ID
*/
public int getC_Currency_ID()
{
Integer ii = (Integer)getValue("C_Currency_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_Currency_ID
/**
* Get PaymentBatch
* @return C_PaymentBatch_ID
*/
public int getC_PaymentBatch_ID()
{
Integer ii = (Integer)getValue("C_PaymentBatch_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_PaymentBatch_ID
/**
* Set Payment Amount
* @param PayAmt Pay Amt
*/
public void setPayAmt (BigDecimal PayAmt)
{
setValue ("PayAmt", PayAmt == null ? Env.ZERO : PayAmt);
}
public BigDecimal getPayAmt()
{
BigDecimal bd = (BigDecimal)getValue ("PayAmt");
if (bd == null)
return Env.ZERO;
return bd;
}
/**
* Set Payment Amount
*
* @param C_Currency_ID currency
* @param payAmt amount
*/
public void setAmount (int C_Currency_ID, BigDecimal payAmt)
{
setC_Currency_ID(C_Currency_ID);
setPayAmt(payAmt);
} // setAmount
/**
* Discount Amt
* @param DiscountAmt Discount
*/
public void setDiscountAmt (BigDecimal DiscountAmt)
{
setValue ("DiscountAmt", DiscountAmt == null ? Env.ZERO : DiscountAmt);
}
public BigDecimal getDiscountAmt()
{
BigDecimal bd = (BigDecimal)getValue("DiscountAmt");
if (bd == null)
return Env.ZERO;
return bd;
}
/**
* WriteOff Amt
* @param WriteOffAmt WriteOff
*/
public void setWriteOffAmt (BigDecimal WriteOffAmt)
{
setValue ("WriteOffAmt", WriteOffAmt == null ? Env.ZERO : WriteOffAmt);
}
public BigDecimal getWriteOffAmt()
{
BigDecimal bd = (BigDecimal)getValue("WriteOffAmt");
if (bd == null)
return Env.ZERO;
return bd;
}
/**
* OverUnder Amt
* @param OverUnderAmt OverUnder
*/
public void setOverUnderAmt (BigDecimal OverUnderAmt)
{
setValue ("OverUnderAmt", OverUnderAmt == null ? Env.ZERO : OverUnderAmt);
}
public BigDecimal getOverUnderAmt()
{
BigDecimal bd = (BigDecimal)getValue("OverUnderAmt");
if (bd == null)
return Env.ZERO;
return bd;
}
/**
* Tax Amt
* @param TaxAmt Tax
*/
public void setTaxAmt (BigDecimal TaxAmt)
{
setValue ("TaxAmt", TaxAmt == null ? Env.ZERO : TaxAmt);
}
public BigDecimal getTaxAmt()
{
BigDecimal bd = (BigDecimal)getValue("TaxAmt");
if (bd == null)
return Env.ZERO;
return bd;
}
/**
* Invoice
* @param C_Invoice_ID invoice
*/
public void setC_Invoice_ID (int C_Invoice_ID)
{
setValue("C_Invoice_ID", new Integer(C_Invoice_ID));
} // setC_Invoice_ID
/**
* Invoice
* @return C_Invoice_ID
*/
public int getC_Invoice_ID()
{
Integer ii = (Integer)getValue("C_Invoice_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_Invoice_ID
/**
* C_Partner_ID
* @param C_BPartner_ID partner
*/
public void setC_BPartner_ID (int C_BPartner_ID)
{
setValue ("C_BPartner_ID", new Integer(C_BPartner_ID));
} // setC_BPartner_ID
/**
* Get BPartner
* @return C_BPartner_ID
*/
public int getC_BPartner_ID()
{
Integer ii = (Integer)getValue("C_BPartner_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_BPartner_ID
/**
* Set Info from BP Bank Account
* @param ba BP bank account
*/
public void setBP_BankAccount (MBP_BankAccount ba)
{
log.debug("setBP_BankAccount - " + ba);
if (ba == null)
return;
setC_BPartner_ID(ba.getC_BPartner_ID());
setAccountAddress(ba.getA_Name(), ba.getA_Street(), ba.getA_City(),
ba.getA_State(), ba.getA_Zip(), ba.getA_Country());
setA_EMail(ba.getA_EMail());
setA_Ident_DL(ba.getA_Ident_DL());
setA_Ident_SSN(ba.getA_Ident_SSN());
// CC
setCreditCardType(ba.getCreditCardType());
setCreditCardNumber(ba.getCreditCardNumber());
setCreditCardExpMM(ba.getCreditCardExpMM());
setCreditCardExpYY(ba.getCreditCardExpYY());
setCreditCardVV(ba.getCreditCardVV());
// Bank
setBankAccountNo(ba.getAccountNo());
setBankRoutingNo(ba.getRoutingNo());
} // setBP_BankAccount
/**
* Save Info from BP Bank Account
* @param ba BP bank account
* @return true if saved
*/
public boolean saveToBP_BankAccount (MBP_BankAccount ba)
{
if (ba == null)
return false;
ba.setA_Name(getA_Name());
ba.setA_Street(getA_Street());
ba.setA_City(getA_City());
ba.setA_State(getA_State());
ba.setA_Zip(getA_Zip());
ba.setA_Country(getA_Country());
ba.setA_EMail(getA_EMail());
ba.setA_Ident_DL(getA_Ident_DL());
ba.setA_Ident_SSN(getA_Ident_SSN());
// CC
ba.setCreditCardType(getCreditCardType());
ba.setCreditCardNumber(getCreditCardNumber());
ba.setCreditCardExpMM(getCreditCardExpMM());
ba.setCreditCardExpYY(getCreditCardExpYY());
ba.setCreditCardVV(getCreditCardVV());
// Bank
ba.setAccountNo(getBankAccountNo());
ba.setRoutingNo(getBankRoutingNo());
// Trx
ba.setR_AvsAddr(getR_AvsAddr());
ba.setR_AvsZip(getR_AvsZip());
//
boolean ok = ba.save();
log.debug("saveToBP_BankAccount - " + ba);
return ok;
} // setBP_BankAccount
/**
* Set Doc Type
* @param C_DocType_ID DocType_ID
*/
public void setC_DocType_ID (int C_DocType_ID)
{
setValue("C_DocType_ID", new Integer(C_DocType_ID));
} // setC_DocType_ID
/**
* Set Doc Type bases on IsReceipt
*/
private void setC_DocType_ID ()
{
setC_DocType_ID(isReceipt());
} // setC_DocType_ID
/**
* Set Doc Type
* @param isReceipt is receipt
*/
public void setC_DocType_ID (boolean isReceipt)
{
setReceipt(isReceipt);
String sql = "SELECT C_DocType_ID FROM C_DocType WHERE AD_Client_ID=? AND DocBaseType=?";
try
{
PreparedStatement pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, getAD_Client_ID());
if (isReceipt)
pstmt.setString(2, "ARR");
else
pstmt.setString(2, "APP");
ResultSet rs = pstmt.executeQuery();
if (rs.next())
setC_DocType_ID(rs.getInt(1));
else
log.warn ("setDocType - NOT found - isReceipt=" + isReceipt);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.error("setDocType", e);
}
} // setC_DocType_ID
/**
* Get Document Type
* @return C_DocType_ID
*/
public int getC_DocType_ID()
{
Integer ii = (Integer)getValue("C_DocType_ID");
if (ii == null)
return 0;
return ii.intValue();
} // getC_DocType_ID
/**
* Set Doc Status
* @param DocStatus status
*/
public void setDocStatus (String DocStatus)
{
setValueNoCheck("DocStatus", DocStatus);
}
public String getDocStatus()
{
return (String)getValue("DocStatus");
}
/**
* Set Doc Action
* @param DocAction action
*/
public void setDocAction (String DocAction)
{
setValue("DocAction", DocAction);
}
public String getDocAction()
{
return (String)getValue("DocAction");
}
/**
* Is Receipt
* @return true if receipt
*/
public boolean isReceipt()
{
Boolean bb = (Boolean)getValue("IsReceipt");
if (bb == null)
return false;
return bb.booleanValue();
} // isReceipt
/**
* Set Receipt
* @param receipt true if receipt
*/
public void setReceipt (boolean receipt)
{
setValue("IsReceipt", new Boolean (receipt));
} // setReceipt
/**
* Processed
* @return true if processed
*/
public boolean isProcessed()
{
Boolean bb = (Boolean)getValue("Processed");
if (bb == null)
return false;
return bb.booleanValue();
} // isProcessed
void setProcessed (boolean processed)
{
setValueNoCheck("Processed", new Boolean (processed));
} // setReceipt
/**
* Posted
* @return true if posted
*/
public boolean isPosted()
{
Boolean bb = (Boolean)getValue("Posted");
if (bb == null)
return false;
return bb.booleanValue();
} // isPosted
void setPosted (boolean posted)
{
setValueNoCheck("Posted", new Boolean(posted));
} // setPosted
/**
* Reconciled
* @return true if reconciled
*/
public boolean isReconciled()
{
Boolean bb = (Boolean)getValue("IsReconciled");
if (bb == null)
return false;
return bb.booleanValue();
} // isReconciled
void setReconciled (boolean reconciled)
{
setValueNoCheck("IsReconciled", new Boolean (reconciled));
} // setReceipt
/**
* Is it online approved?
* @return true if approved
*/
public boolean isApproved()
{
Boolean bb = (Boolean)getValue("IsApproved");
if (bb == null)
return false;
return bb.booleanValue();
} // isApproved
void setApproved (boolean approved)
{
setValueNoCheck("IsApproved", new Boolean (approved));
} // setReceipt
/**
* Is it online ?
* @return true if online
*/
public boolean isOnline()
{
Boolean bb = (Boolean)getValue("IsOnline");
if (bb == null)
return false;
return bb.booleanValue();
} // isOnline
public void setOnline (boolean online)
{
setValue("IsOnline", new Boolean (online));
} // setReceipt
/**
* Is it allocated?
* @return true if allocated
*/
public boolean isAllocated()
{
Boolean bb = (Boolean)getValue("IsAllocated");
if (bb == null)
return false;
return bb.booleanValue();
} // isAllocated
void setAllocated (boolean allocated)
{
setValueNoCheck("IsAllocated", new Boolean (allocated));
} // setReceipt
/**
* Is it over/under payment
* @return true if uner/over payment
*/
public boolean isOverUnderPayment()
{
Boolean bb = (Boolean)getValue("IsOverUnderPayment");
if (bb == null)
return false;
return bb.booleanValue();
} // isOverUnderPayment
public void setOverUnderPayment (boolean overUnderPayment)
{
setValue("IsOverUnderPayment", new Boolean (overUnderPayment));
} // setReceipt
/*************************************************************************/
/**
* Check Numeric
* @param data input
* @return the digits of the data - ignore the rest
*/
public static String checkNumeric (String data)
{
if (data == null || data.length() == 0)
return "";
// Remove all non Digits
StringBuffer sb = new StringBuffer();
for (int i = 0; i < data.length(); i++)
{
if (Character.isDigit(data.charAt(i)))
sb.append(data.charAt(i));
}
return sb.toString();
} // checkNumeric
} // MPayment