Exemple #1
0
  @Override
  public boolean deleteTransactionGroup(Long tgId) {
    TransactionGroup tg =
        SearchHelper.getFacade().readModelWithId(TransactionGroup.class, tgId, true);
    List<Object> toBeDeleted = new ArrayList<Object>();
    List<Object> toBeSaved = new ArrayList<Object>();

    for (TransactionTable tt : tg.getTransactions()) {
      toBeDeleted.add(tt);

      // TODO not working code.. since it is not required in this release.. so need to worry.. :)
      Map<String, List<Object>> modifiedMap =
          modifedMapAfterDeletingTransaction(getTransactionEntriesWithoutTT(tt.getTxnId()));
      toBeDeleted.addAll(modifiedMap.get("toBeDeleted"));
      toBeSaved.addAll(modifiedMap.get("toBeSaved"));
    }

    for (Object o : toBeDeleted) {
      if (o instanceof TransactionTable) {
        tg.getTransactions().remove(o);
      }
    }

    toBeDeleted.add(tg);

    return SearchHelper.getFacade().saveDeleteModels(toBeSaved, toBeDeleted);
  }
Exemple #2
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;
  }