Class FinAccountHelper

java.lang.Object
org.apache.ofbiz.order.finaccount.FinAccountHelper

public final class FinAccountHelper extends Object
A package of methods for improving efficiency of financial accounts services
  • Constructor Details

    • FinAccountHelper

      protected FinAccountHelper()
  • Method Details

    • getDecimals

      public static int getDecimals()
    • getRounding

      public static RoundingMode getRounding()
    • getZero

      public static BigDecimal getZero()
    • getGiftCertFinAccountTypeId

      public static String 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 value
      transactions - a List of GenericValue objects of transactions
      fieldName - the field name to get the value from the transaction
      decimals - number of decimals
      rounding - 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 characters
      delegator - 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 code
      delegator - 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 id
      asOfDateTime - the validity date
      delegator - 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 id
      asOfDateTime - the validity date
      delegator - the delegator
      Returns:
      returns the net balance (see above) minus the sum of all authorization amounts which are not expired
      Throws:
      GenericEntityException
    • validateFinAccount

      public static boolean validateFinAccount(GenericValue finAccount)
    • validatePin

      public static boolean validatePin(Delegator delegator, String finAccountId, String pinNumber)
      Validates a FinAccount's PIN number
      Parameters:
      delegator - the delegator
      finAccountId - the financial account id
      pinNumber - a pin number
      Returns:
      true if the bin is valid
    • checkFinAccountNumber

      public static boolean checkFinAccountNumber(String number)