@Override
  public boolean withdraw(double amount, String description)
      throws IllegalAccessException, InvocationTargetException {
    boolean isDone = false;

    if (this.getAvailableCredit() >= amount) {
      double interestAmount = amount * this.creditPlan.getCashAdvanceInterest();
      double amountIncludesInterest = amount + interestAmount;

      double updatedAvailableCredit = this.getAvailableCredit();
      updatedAvailableCredit -= amountIncludesInterest;
      this.setAvailableCredit(updatedAvailableCredit);

      try {
        this.updateAccount();
        isDone = true;
        Transaction tr = new Transaction(this, amountIncludesInterest, 0, description);
        tr.saveTransaction();
      } catch (Exception e) {
        return false;
      }
    }
    return isDone;
  }
Beispiel #2
0
 public static Transaction fromBlotterCursor(Cursor c) {
   long id = c.getLong(BlotterColumns._id.ordinal());
   Transaction t = new Transaction();
   t.id = id;
   t.parentId = c.getLong(BlotterColumns.parent_id.ordinal());
   t.fromAccountId = c.getLong(BlotterColumns.from_account_id.ordinal());
   t.toAccountId = c.getLong(BlotterColumns.to_account_id.ordinal());
   t.categoryId = c.getLong(BlotterColumns.category_id.ordinal());
   t.projectId = c.getLong(BlotterColumns.project_id.ordinal());
   t.payeeId = c.getLong(BlotterColumns.payee_id.ordinal());
   t.note = c.getString(BlotterColumns.note.ordinal());
   t.fromAmount = c.getLong(BlotterColumns.from_amount.ordinal());
   t.toAmount = c.getLong(BlotterColumns.to_amount.ordinal());
   t.dateTime = c.getLong(BlotterColumns.datetime.ordinal());
   t.originalCurrencyId = c.getLong(BlotterColumns.original_currency_id.ordinal());
   t.originalFromAmount = c.getLong(BlotterColumns.original_from_amount.ordinal());
   t.locationId = c.getLong(BlotterColumns.location_id.ordinal());
   //		t.provider = c.getString(BlotterColumns.provider.ordinal());
   //		t.accuracy = c.getFloat(BlotterColumns.accuracy.ordinal());
   //		t.latitude = c.getDouble(BlotterColumns.latitude.ordinal());
   //		t.longitude = c.getDouble(BlotterColumns.longitude.ordinal());
   t.isTemplate = c.getInt(BlotterColumns.is_template.ordinal());
   t.templateName = c.getString(BlotterColumns.template_name.ordinal());
   t.recurrence = c.getString(BlotterColumns.recurrence.ordinal());
   t.notificationOptions = c.getString(BlotterColumns.notification_options.ordinal());
   t.status = TransactionStatus.valueOf(c.getString(BlotterColumns.status.ordinal()));
   t.attachedPicture = c.getString(BlotterColumns.attached_picture.ordinal());
   t.isCCardPayment = c.getInt(BlotterColumns.is_ccard_payment.ordinal());
   t.lastRecurrence = c.getLong(BlotterColumns.last_recurrence.ordinal());
   return t;
 }