Search in sources :

Example 21 with TransactionEntry

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

the class GainLossPane 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> transactionEntries = gainLossDialog.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
                transactionEntries.add((TransactionEntry) e.clone());
            } catch (CloneNotSupportedException e1) {
                Logger.getLogger(GainLossPane.class.getName()).log(Level.SEVERE, e1.getLocalizedMessage(), e1);
            }
            setDecimal(sumGains().abs());
        }
    } else {
        for (final TransactionEntry entry : fees) {
            // clone the provided set's entries
            try {
                transactionEntries.add((TransactionEntry) entry.clone());
            } catch (CloneNotSupportedException e) {
                Logger.getLogger(GainLossPane.class.getName()).log(Level.SEVERE, e.toString(), e);
            }
        }
        setDecimal(sumGains().abs());
    }
    setEditable(transactionEntries.size() < 1);
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Example 22 with TransactionEntry

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

the class ReinvestDividendSlipController method buildTransaction.

@NotNull
@Override
public Transaction buildTransaction() {
    final List<TransactionEntry> gains = gainLossPane.getTransactions();
    final List<TransactionEntry> fees = feePane.getTransactions();
    final Transaction transaction = TransactionFactory.generateReinvestDividendXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText(), fees, gains);
    transaction.setNumber(numberComboBox.getValue());
    return attachmentPane.buildTransaction(transaction);
}
Also used : Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) NotNull(jgnash.util.NotNull)

Example 23 with TransactionEntry

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

the class SellShareSlipController method buildTransaction.

@NotNull
@Override
public Transaction buildTransaction() {
    final BigDecimal exchangeRate = accountExchangePane.getExchangeRate();
    final List<TransactionEntry> gains = gainLossPane.getTransactions();
    final List<TransactionEntry> fees = feePane.getTransactions();
    final Transaction transaction = TransactionFactory.generateSellXTransaction(accountExchangePane.getSelectedAccount(), accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), exchangeRate, datePicker.getValue(), memoTextField.getText(), fees, gains);
    transaction.setNumber(numberComboBox.getValue());
    return attachmentPane.buildTransaction(transaction);
}
Also used : Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) BigDecimal(java.math.BigDecimal) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) NotNull(jgnash.util.NotNull)

Example 24 with TransactionEntry

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

the class SlipController method modifyTransaction.

@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
    if (transaction.areAccountsLocked()) {
        clearForm();
        StaticUIMethods.displayError(resources.getString("Message.TransactionModifyLocked"));
        return;
    }
    // load the form
    newTransaction(transaction);
    // save reference to old transaction
    modTrans = transaction;
    modTrans = attachmentPane.modifyTransaction(modTrans);
    // Set state of memo concatenation
    concatenated.setValue(modTrans.isMemoConcatenated());
    if (!canModifyTransaction(transaction) && transaction.getTransactionType() == TransactionType.SPLITENTRY) {
        for (final TransactionEntry entry : transaction.getTransactionEntries()) {
            if (entry.getCreditAccount().equals(accountProperty().get()) || entry.getDebitAccount().equals(accountProperty().get())) {
                modEntry.setValue(entry);
                // override to allow editing the entry
                concatenated.setValue(false);
                break;
            }
        }
        if (modEntry.get() == null) {
            Logger logger = Logger.getLogger(SlipController.class.getName());
            logger.warning("Was not able to modify the transaction");
        }
    }
}
Also used : Logger(java.util.logging.Logger) TransactionEntry(jgnash.engine.TransactionEntry)

Example 25 with TransactionEntry

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

the class SplitTransactionDialog method deleteAction.

@Override
void deleteAction() {
    final TransactionEntry entry = tableView.getSelectionModel().getSelectedItem();
    if (entry != null) {
        tableView.getSelectionModel().clearSelection();
        ((SplitTransactionSlipController) tabPane.getSelectionModel().getSelectedItem().getUserData()).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