Interface AccountServiceLocal

    • Method Detail

      • accountNumberExistsOrIsReserved

        boolean accountNumberExistsOrIsReserved​(AccountNumberConfiguration accountNumberConfiguration,
                                                String accountNumber)
        Returns true if the given account number is used in an existing account or is reserved to be used for a pending user
      • dereserveAmountIfNeeded

        VoucherAmountReservation dereserveAmountIfNeeded​(Voucher voucher)
        If the voucher pack had an amount reservation, dereserve the amount for the given voucher
      • findByNumber

        Account findByNumber​(String number)
        Returns the account with the given number
        Throws:
        EntityNotFoundException - If there are is no account with the given number
      • generateNumber

        String generateNumber​(AccountType type,
                              InternalAccountOwner owner)
        Generates an unique account number for the given type and owner. This method can not only be internally used when an account is created, but scripts could benefit from it to generate numbers for existing accounts.
      • getAvailableBalance

        BigDecimal getAvailableBalance​(Account account,
                                       Date date)
        Returns the available balance for the given account at the given date
      • getAverageBalance

        BigDecimal getAverageBalance​(Account account,
                                     BigDecimal balanceDiff,
                                     DatePeriod period,
                                     boolean positive,
                                     BigDecimal freebase)
        Returns the balance average for the given account over the given period. It is calculated per day, having the balance at the end of each day, averaging by the number of days the balance was unchanged. It can be calculated either over positive or negative balances, and taking the free base into account (which is subtracted from each day's balance when calculating the total). If present, the balanceDiff is summed to the initial balance when performing calculations.
      • getBalance

        BigDecimal getBalance​(Account account,
                              Date date)
        Returns the raw balance for the given account at the given time
      • getBalanceLimitLog

        AccountBalanceLimitLog getBalanceLimitLog​(Account account,
                                                  Date date)
        Returns the limit log which is valid on the given time. When the time is null, the current time is assumed
      • getCreditLimit

        BigDecimal getCreditLimit​(Account account,
                                  Date date)
        Returns the credit limit of the given account at the given date
      • getCurrentAvailableBalance

        BigDecimal getCurrentAvailableBalance​(Account account,
                                              NativeAccountStatus status)
        Returns the available balance for the given account, given that the native account status was already fetched
      • getFrontendDashbordAcccount

        FrontendDashboardAccountVO getFrontendDashbordAcccount​(Account account,
                                                               int lastTransfers)
        Returns data for an account to be used in the new frontend dashboard
      • getManagedFlows

        List<TransferStatusFlow> getManagedFlows​(Account account)
        Returns the managed transfer status flows for the logged user over the given account
      • getNativeAccountStatus

        NativeAccountStatus getNativeAccountStatus​(Account account,
                                                   Date date)
        Returns the native account status for the given account
      • getOwnerName

        String getOwnerName​(Account account)
        Returns the owner name: if is a system account, get the system account type. otherwise, the name / username of the owner user
      • getRetrictedOperatorAccessibleAccounts

        RestrictedOperatorAccessibleAccounts getRetrictedOperatorAccessibleAccounts()
        Returns which owner user accounts types are accessible and how by the logged restricted operator. If not logged-in as a restricted operator, returns null.
      • getUpperCreditLimit

        BigDecimal getUpperCreditLimit​(Account account,
                                       Date date)
        Returns the upper credit limit of the given account at the given date
      • getUserAccountsData

        List<UserAccountData> getUserAccountsData​(User user)
        Returns the user's accounts data visible in profile
      • getVisibleFlows

        List<TransferStatusFlow> getVisibleFlows​(Account account)
        Returns the visible transfer status flows for the logged user over the given account
      • hasAccess

        boolean hasAccess​(Account account)
        Returns whether the given account is accessible by the logged user
        See Also:
        hasVisibility(Account)
      • hasVisibility

        boolean hasVisibility​(Account account)
        Returns whether the given account is visible by the logged user or not.
        An account is visible if it's accessible and the associated AccountAccessibility allow view it. If an user can access an account then it can operate with it (e.g make/receive payments) regardless it's visible or not.

        The visibility is taken into account only in cases the account is shown (as informative data), to know:
      • isActive

        boolean isActive​(IAccount account)
        Returns whether the given account is active. System accounts are always active. User accounts are active if the owner is not pending or removed and have at least one product that enables that account type.
      • load

        <A extends Account> A load​(AccountLocator locator)
        Loads an account for the given locator, without checking permissions for the logged user For user accounts, if the account is not found yet, returns a transient account.
      • load

        <A extends Account> A load​(InternalAccountOwner owner,
                                   AccountType type)
        Loads an account for the given owner / type, without checking permissions for the logged user For user accounts, if the account is not found yet, returns a transient account.
      • load

        <A extends Account> A load​(InternalAccountOwner owner,
                                   AccountType type,
                                   boolean allowDisposed)
        Loads an account for the given owner / type, without checking permissions for the logged user. Depending on the flag will return an account even if it was disposed. For user accounts, if the account is not found yet, returns a transient account.
      • makeBalanceDirty

        void makeBalanceDirty​(Account account,
                              Transfer transfer)
        Marks the balance of the given account as dirty for given transfer.
      • removeLastClosedAccountBalances

        void removeLastClosedAccountBalances​(Transfer transfer)
        Removes all the closes from the initial date to now of the from and to account of the transfer. Also removes the account_balance row for both accounts
      • require

        <A extends Account> A require​(InternalAccountOwner owner,
                                      AccountType type)
        Loads an account for the given owner / type, without checking permissions for the logged user. For user accounts, if the account is not found yet, will physically create one.
      • reserveAmount

        CustomAmountReservation reserveAmount​(Account account,
                                              BigDecimal amount)
        Reserves the given amount for an account checking its available balance.
        WARNING: Intended to be used via scripts (it can't be removed after a static analysis).
        Returns:
        If the amount is zero returns null, otherwise the reservation.
        Throws:
        InsufficientBalanceException - When there is not enough funds on the expected account to reserve
      • reserveAmount

        CustomAmountReservation reserveAmount​(Account account,
                                              BigDecimal amount,
                                              boolean ignoreAccountLimits)
        Reserves the given amount for an account ignoring the limits only if ignoreAccountLimits is true.
        WARNING: Intended to be used via scripts (it can't be removed after a static analysis).
        Returns:
        If the amount is zero returns null, otherwise the reservation.
        Throws:
        InsufficientBalanceException - When there is not enough funds on the expected account to reserve
      • reserveAmountIfNeeded

        VoucherPackAmountReservation reserveAmountIfNeeded​(VoucherPack voucherPack)
        Reserves the total amount for the given voucher pack (count * amount) on the source account of the redeem type, if that account is limited. If it is an unlimited account, just returns null.
        Throws:
        InsufficientBalanceException - When there is not enough funds on the expected account to reserve
        IllegalActionException - When the given voucher pack is not in a state which allows reserving amount
      • resolvePreselectedPeriods

        List<PeriodPreselectorOptionData> resolvePreselectedPeriods()
        Resolve the available preselected periods for the logged user configuration
        Parameters:
        account -
      • shouldAdjustAccountsWhenAssigning

        boolean shouldAdjustAccountsWhenAssigning​(MemberProduct product)
        Indicates whether user accounts should be adjusted if the given member product is assigned to a group / group set
      • toAccountWithStatus

        AccountWithStatusVO toAccountWithStatus​(Account account,
                                                Date date,
                                                Date paymentsSince,
                                                boolean includeRates)
        Converts the given account with AccountWithStatusVO, getting the status at the given time point. If paymentsSince is not null, will also return the sum of incoming payments since the given date
      • updateBalance

        void updateBalance​(Account account,
                           BigDecimal balance,
                           Long[] dirtyTransferIds)
        Updates the current account balance. IMPORTANT! This method should only be called after acquiring a lock for the given account, to ensure consistency. This method calls the native update_balance function.