Exemplo n.º 1
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;
  }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
0
 private AccountDTO getAccDTOFromAcc(Account acc) {
   AccountDTO a = new AccountDTO();
   a.setAccountId(acc.getAccountId());
   a.setAccountName(acc.getAccName());
   return a;
 }