Class FinAccountHelper
java.lang.Object
org.apache.ofbiz.order.finaccount.FinAccountHelper
A package of methods for improving efficiency of financial accounts services
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BigDecimal
addFirstEntryAmount
(BigDecimal initialValue, List<GenericValue> transactions, String fieldName, int decimals, RoundingMode rounding) A convenience method which adds transactions.get(0).get(fieldName) to initialValue, all done in BigDecimal to decimals and roundingstatic boolean
checkFinAccountNumber
(String number) static BigDecimal
getAvailableBalance
(String finAccountId, Timestamp asOfDateTime, Delegator delegator) Returns the net balance (see above) minus the sum of all authorization amounts which are not expired and were authorized by the as of datestatic BigDecimal
getBalance
(String finAccountId, Timestamp asOfDateTime, Delegator delegator) Sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions whose transactionDate is before asOfDateTimestatic int
static GenericValue
getFinAccountFromCode
(String finAccountCode, Delegator delegator) Gets the first (and should be only) FinAccount based on finAccountCode, which will be cleaned up to be only uppercase and alphanumericstatic String
static String
getNewFinAccountCode
(int codeLength, Delegator delegator) Returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbersstatic RoundingMode
static BigDecimal
getZero()
static boolean
validateFinAccount
(GenericValue finAccount) static boolean
validatePin
(Delegator delegator, String finAccountId, String pinNumber) Validates a FinAccount's PIN number
-
Constructor Details
-
FinAccountHelper
protected FinAccountHelper()
-
-
Method Details
-
getDecimals
public static int getDecimals() -
getRounding
-
getZero
-
getGiftCertFinAccountTypeId
-
addFirstEntryAmount
public static BigDecimal addFirstEntryAmount(BigDecimal initialValue, List<GenericValue> transactions, String fieldName, int decimals, RoundingMode rounding) throws GenericEntityException A convenience method which adds transactions.get(0).get(fieldName) to initialValue, all done in BigDecimal to decimals and rounding- Parameters:
initialValue
- the initial valuetransactions
- a List of GenericValue objects of transactionsfieldName
- the field name to get the value from the transactiondecimals
- number of decimalsrounding
- how to rounding- Returns:
- the new value in a BigDecimal field
- Throws:
GenericEntityException
-
getNewFinAccountCode
public static String getNewFinAccountCode(int codeLength, Delegator delegator) throws GenericEntityException Returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbers- Parameters:
codeLength
- length of code in number of charactersdelegator
- the delegator- Returns:
- returns a unique randomly generated account code for FinAccount.finAccountCode composed of uppercase letters and numbers
- Throws:
GenericEntityException
-
getFinAccountFromCode
public static GenericValue getFinAccountFromCode(String finAccountCode, Delegator delegator) throws GenericEntityException Gets the first (and should be only) FinAccount based on finAccountCode, which will be cleaned up to be only uppercase and alphanumeric- Parameters:
finAccountCode
- the financial account codedelegator
- the delegator- Returns:
- gets the first financial account by code
- Throws:
GenericEntityException
-
getBalance
public static BigDecimal getBalance(String finAccountId, Timestamp asOfDateTime, Delegator delegator) throws GenericEntityException Sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions whose transactionDate is before asOfDateTime- Parameters:
finAccountId
- the financial account idasOfDateTime
- the validity datedelegator
- the delegator- Returns:
- returns the sum of all DEPOSIT and ADJUSTMENT transactions minus all WITHDRAWAL transactions
- Throws:
GenericEntityException
-
getAvailableBalance
public static BigDecimal getAvailableBalance(String finAccountId, Timestamp asOfDateTime, Delegator delegator) throws GenericEntityException Returns the net balance (see above) minus the sum of all authorization amounts which are not expired and were authorized by the as of date- Parameters:
finAccountId
- the financial account idasOfDateTime
- the validity datedelegator
- the delegator- Returns:
- returns the net balance (see above) minus the sum of all authorization amounts which are not expired
- Throws:
GenericEntityException
-
validateFinAccount
-
validatePin
Validates a FinAccount's PIN number- Parameters:
delegator
- the delegatorfinAccountId
- the financial account idpinNumber
- a pin number- Returns:
- true if the bin is valid
-
checkFinAccountNumber
-