Search in sources :

Example 16 with TransactionEntry

use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.

the class FeePane method setTransactionEntries.

/**
     * Clones a {@code List} of {@code TransactionEntry(s)}.
     *
     * @param fees {@code List} of fees to clone
     */
void setTransactionEntries(final List<TransactionEntry> fees) {
    final List<TransactionEntry> feeList = feeDialog.getTransactionEntries();
    if (fees.size() == 1) {
        TransactionEntry e = fees.get(0);
        if (e.getCreditAccount().equals(e.getDebitAccount())) {
            setDecimal(e.getAmount(accountProperty().get()).abs());
        } else {
            try {
                // copy over the provided set's entry
                feeList.add((TransactionEntry) e.clone());
            } catch (CloneNotSupportedException e1) {
                Logger.getLogger(FeePane.class.getName()).log(Level.SEVERE, e1.getLocalizedMessage(), e1);
            }
            setDecimal(sumFees().abs());
        }
    } else {
        for (final TransactionEntry entry : fees) {
            // clone the provided set's entries
            try {
                feeList.add((TransactionEntry) entry.clone());
            } catch (CloneNotSupportedException e) {
                Logger.getLogger(FeePane.class.getName()).log(Level.SEVERE, e.toString(), e);
            }
        }
        setDecimal(sumFees().abs());
    }
    setEditable(feeList.size() < 1);
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 17 with TransactionEntry

use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.

the class FeePane method getTransactions.

public List<TransactionEntry> getTransactions() {
    final List<TransactionEntry> feeList = feeDialog.getTransactionEntries();
    // adjust the cash balance of the investment account
    if (feeList.isEmpty() && getDecimal().compareTo(BigDecimal.ZERO) != 0) {
        // ignore zero balance fees
        TransactionEntry fee = new TransactionEntry(accountProperty().get(), getDecimal().abs().negate());
        fee.setTransactionTag(TransactionTag.INVESTMENT_FEE);
        feeList.add(fee);
    }
    return feeList;
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 18 with TransactionEntry

use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.

the class FeeTransactionEntrySlipController method buildTransactionEntry.

@Override
TransactionEntry buildTransactionEntry() {
    final TransactionEntry entry = super.buildTransactionEntry();
    entry.setTransactionTag(TransactionTag.INVESTMENT_FEE);
    return entry;
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 19 with TransactionEntry

use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.

the class AdjustmentSlipController method convertAction.

@FXML
private void convertAction() {
    final Optional<Account> accountOptional = StaticAccountsMethods.selectAccount(null, account.get());
    accountOptional.ifPresent(opp -> {
        final Transaction t = new Transaction();
        t.setDate(datePicker.getValue());
        t.setNumber(numberComboBox.getValue());
        t.setPayee(payeeTextField.getText());
        final TransactionEntry entry = new TransactionEntry();
        entry.setMemo(memoTextField.getText());
        if (amountField.getDecimal().signum() >= 0) {
            entry.setCreditAccount(account.get());
            entry.setDebitAccount(opp);
        } else {
            entry.setDebitAccount(account.get());
            entry.setCreditAccount(opp);
        }
        entry.setCreditAmount(amountField.getDecimal().abs());
        entry.setDebitAmount(amountField.getDecimal().abs().negate());
        t.addTransactionEntry(entry);
        ReconcileManager.reconcileTransaction(account.get(), t, getReconciledState());
        TransactionDialog.showAndWait(account.get(), t, transaction -> {
            if (transaction != null) {
                final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
                Objects.requireNonNull(engine);
                if (engine.removeTransaction(modTrans)) {
                    engine.addTransaction(transaction);
                }
                clearForm();
            }
        });
    });
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) TransactionEntry(jgnash.engine.TransactionEntry) Engine(jgnash.engine.Engine) FXML(javafx.fxml.FXML)

Example 20 with TransactionEntry

use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.

the class GainLossDialog method deleteAction.

@Override
void deleteAction() {
    final TransactionEntry entry = tableView.getSelectionModel().getSelectedItem();
    if (entry != null) {
        tableView.getSelectionModel().clearSelection();
        gainLossController.clearForm();
        getTransactionEntries().remove(entry);
    }
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Aggregations

TransactionEntry (jgnash.engine.TransactionEntry)52 InvestmentTransaction (jgnash.engine.InvestmentTransaction)16 Transaction (jgnash.engine.Transaction)16 BigDecimal (java.math.BigDecimal)13 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)12 Account (jgnash.engine.Account)12 List (java.util.List)4 Logger (java.util.logging.Logger)4 TransactionFactory (jgnash.engine.TransactionFactory)4 NotNull (jgnash.util.NotNull)4 CellConstraints (com.jgoodies.forms.layout.CellConstraints)3 FormLayout (com.jgoodies.forms.layout.FormLayout)3 FocusAdapter (java.awt.event.FocusAdapter)3 FocusEvent (java.awt.event.FocusEvent)3 FocusListener (java.awt.event.FocusListener)3 FXML (javafx.fxml.FXML)3 JPanel (javax.swing.JPanel)3 Engine (jgnash.engine.Engine)3 ValidationFactory (jgnash.ui.util.ValidationFactory)3 LocalDate (java.time.LocalDate)2