Пример #1
0
 private Account updateCurrentBalance(Account a, double amount, String operation) {
   if ("add".equals(operation)) {
     a.setCurrentBalance(a.getCurrentBalance() + amount);
   } else {
     a.setCurrentBalance(a.getCurrentBalance() - amount);
   }
   return a;
 }
Пример #2
0
  private Account getAccountFromList(List<Object> toBeSaved, long accId) {
    Account account = new Account();
    account.setAccountId(accId);
    int index;
    if ((index = toBeSaved.indexOf(account)) != -1) {
      account = (Account) toBeSaved.get(index);
    } else {
      account = SearchHelper.getFacade().readModelWithId(Account.class, accId, false);
    }

    return account;
  }
Пример #3
0
  @Override
  public OneTimeData fetchOneTimeData() {
    long uid = getCurrentUser(this.getThreadLocalRequest().getSession());

    OneTimeData otd = new OneTimeData();
    otd.setCurrecnySymbol(getCurrencySymbol());

    List<Tag> mtags = SearchHelper.getFacade().readAllObjects(Tag.class, false, null);
    ArrayList<String> tags = new ArrayList<String>();
    for (Tag tag : mtags) {
      tags.add(tag.getTagName());
    }
    otd.setTags(tags);

    ArrayList<AccountDTO> accs = new ArrayList<AccountDTO>();
    for (Account a :
        SearchHelper.getFacade()
            .getAccountsForUserOfType(
                uid, AccountTypeDatabase.AT_MAIN, AccountTypeDatabase.AT_CREDIT)) {
      AccountDTO acc = new AccountDTO();
      acc.setAccountId(a.getAccountId());
      acc.setAccountName(a.getAccName());
      acc.setAccountType(a.getAccountType().getAtCode());

      accs.add(acc);
    }
    otd.setUserSpecificPayableAccounts(accs);

    ArrayList<TransactionGroupDTO> transactionGroups = new ArrayList<TransactionGroupDTO>();

    Map<String, Object> criteria = new LinkedHashMap<String, Object>();

    for (TransactionGroup tg :
        SearchHelper.getFacade().readAllObjects(TransactionGroup.class, false, uid)) {
      TransactionGroupDTO dto = new TransactionGroupDTO();
      dto.setId(tg.getTxnGroupId());
      dto.setTgName(tg.getTgName());

      criteria.put("transactionGroup.txnGroupId", tg.getTxnGroupId());

      dto.setNoOfRecords(
          SearchHelper.getFacade().getCount(TransactionTable.class, criteria, false));
      transactionGroups.add(dto);
    }

    otd.setTransactionGroups(transactionGroups);

    return otd;
  }
Пример #4
0
  @Override
  public ArrayList<AccountDTO> getAllAccounts() {
    ArrayList<AccountDTO> accounts = new ArrayList<AccountDTO>();

    List<Account> accs =
        SearchHelper.getFacade()
            .getAccountsForUser(
                getCurrentUser(this.getThreadLocalRequest().getSession()), -1, -1, false);
    for (Account a : accs) {
      AccountDTO ad = new AccountDTO();
      ad.setAccountId(a.getAccountId());
      ad.setAccountName(a.getAccName());
      ad.setAccountType(a.getAccountType().getAtCode());
      ad.setCurrentBalance(a.getCurrentBalance());

      accounts.add(ad);
    }

    return accounts;
  }
Пример #5
0
 private AccountDTO getAccDTOFromAcc(Account acc) {
   AccountDTO a = new AccountDTO();
   a.setAccountId(acc.getAccountId());
   a.setAccountName(acc.getAccName());
   return a;
 }