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
      • applyQueryConstraints

        void applyQueryConstraints​(AbstractTransQuery query)
        Checks that both begin and end date, if any, resides in the data retention period. Updates the date if the begin date is null, setting it to the archiving date. No-op when there's no retention window.
      • 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.
      • getAccountIdsWithTransactions

        Set<Long> getAccountIdsWithTransactions​(Set<UserAccountType> accTypes,
                                                User owner)
        Returns the ids of the accounts that have transactions for the given owner and of the given account types
      • 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
      • hasTransfers

        boolean hasTransfers​(Account account)
        Returns whether the given account has at least a transfer
      • 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.
      • load

        <A extends Account> A load​(InternalAccountOwner owner,
                                   String name)
        Loads an account by name for the given owner. In case the account type couldn't be found then loads the first visible account for the owner.
      • makeBalanceDirty

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

        VoucherTransactionAmountReservation processReservationIfNeeded​(VoucherTransaction voucherTransaction)
        Processes the amount reservation, if needed, for the given voucher transaction. For top-ups, a positive amount. For redeems, a negative amount. If no amount should be reserved, returns null.
      • reactivateAccounts

        void reactivateAccounts​(long accountTypeId,
                                long basicGroupId)
        Reactivates physical accounts of the given type and basic group.
        This is only called by a script triggered by the ProductsGroupServiceLocal
      • 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.
      • reReserveAmountIfNeeded

        VoucherAmountReservation reReserveAmountIfNeeded​(Voucher voucher)
        When the voucher was expired, the amount was de-reserved. If an admin changes the expiration date to the future, the voucher is re-opened. In this case we also must re-reserve the amount that was de-reserved.
      • 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
      • reserveAmount

        TicketAmountReservation reserveAmount​(Ticket ticket)
        Reserves the ticket approved amount, depending on the payment type settings
      • 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​(boolean ignorePeriodsStartingBeforeArchivingDate)
        Resolve the available preselected periods for the logged user configuration
        Parameters:
        ignorePeriodsStartingBeforeArchivingDate -
      • sendStatusPushNotification

        void sendStatusPushNotification​(Account account)
        Sends the push notification event with the current account status. No-op if the parameter isn't an user 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.