예제 #1
0
  /**
   * Writes one bank transaction
   *
   * @param transaction <code>Transaction</code> to write
   */
  private void writeBankTransaction(final Transaction transaction) {
    indentedWriter.println(wrapOpen(STMTTRN), indentLevel++);
    indentedWriter.println(
        wrapOpen(TRNTYPE)
            + (transaction.getAmount(account).compareTo(BigDecimal.ZERO) == 1 ? CREDIT : DEBIT),
        indentLevel);

    indentedWriter.println(wrapOpen(DTPOSTED) + encodeDate(transaction.getDate()), indentLevel);
    indentedWriter.println(
        wrapOpen(TRNAMT) + transaction.getAmount(account).toPlainString(), indentLevel);
    indentedWriter.println(wrapOpen(REFNUM) + transaction.getUuid(), indentLevel);
    indentedWriter.println(wrapOpen(NAME) + transaction.getPayee(), indentLevel);
    indentedWriter.println(wrapOpen(MEMO) + transaction.getMemo(), indentLevel);

    // write the check number if applicable
    if (account.getAccountType() == AccountType.CHECKING && !transaction.getNumber().isEmpty()) {
      indentedWriter.println(wrapOpen(CHECKNUM) + transaction.getNumber(), indentLevel);
    }

    // write out the banks transaction id if previously imported
    writeFitID(transaction);

    indentedWriter.println(wrapClose(STMTTRN), --indentLevel);
  }
예제 #2
0
  private static double generateItemTotal(int itemID, boolean bought, boolean sold) {
    double amount = 0;
    List<Transaction> list;
    if (bought)
      list =
          ChestShop.getDB()
              .find(Transaction.class)
              .where()
              .eq("buy", 1)
              .eq("itemID", itemID)
              .findList();
    else if (sold)
      list =
          ChestShop.getDB()
              .find(Transaction.class)
              .where()
              .eq("buy", 0)
              .eq("itemID", itemID)
              .findList();
    else list = ChestShop.getDB().find(Transaction.class).where().eq("itemID", itemID).findList();

    for (Transaction t : list) amount += t.getAmount();
    return amount;
  }