Search in sources :

Example 46 with TransactionEntry

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

the class AbstractInvIncomeSlipController method modifyTransaction.

@Override
public void modifyTransaction(@NotNull Transaction transaction) {
    if (transaction.getTransactionType() != getTransactionType()) {
        throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
    }
    clearForm();
    datePicker.setValue(transaction.getLocalDate());
    numberComboBox.setValue(transaction.getNumber());
    final List<TransactionEntry> entries = transaction.getTransactionEntries();
    for (final TransactionEntry e : entries) {
        if (e instanceof AbstractInvestmentTransactionEntry && ((AbstractInvestmentTransactionEntry) e).getTransactionType() == getTransactionType()) {
            memoTextField.setText(e.getMemo());
            securityComboBox.setSecurityNode(((AbstractInvestmentTransactionEntry) e).getSecurityNode());
            incomeExchangePane.setSelectedAccount(e.getDebitAccount());
            incomeExchangePane.setExchangedAmount(e.getDebitAmount().abs());
            decimalTextField.setDecimal(e.getAmount(accountProperty().get()));
        } else if (e.getTransactionTag() == TransactionTag.INVESTMENT_CASH_TRANSFER) {
            accountExchangePane.setSelectedAccount(e.getCreditAccount());
            accountExchangePane.setExchangedAmount(e.getCreditAmount());
        } else {
            logger.warning("Invalid transaction");
        }
    }
    modTrans = transaction;
    modTrans = attachmentPane.modifyTransaction(modTrans);
    setReconciledState(transaction.getReconciled(accountProperty().get()));
}
Also used : AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Example 47 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)

Example 48 with TransactionEntry

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

the class BuyShareSlipController method buildTransaction.

@NotNull
@Override
public Transaction buildTransaction() {
    final BigDecimal exchangeRate = accountExchangePane.getExchangeRate();
    final List<TransactionEntry> fees = feePane.getTransactions();
    final Transaction transaction = TransactionFactory.generateBuyXTransaction(accountExchangePane.getSelectedAccount(), accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), exchangeRate, datePicker.getValue(), memoTextField.getText(), fees);
    transaction.setNumber(numberComboBox.getValue());
    transaction.setTags(TransactionEntryBuyX.class, tagPane.getSelectedTags());
    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 49 with TransactionEntry

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

the class FeeDialog method deleteAction.

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

Example 50 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());
    }
    editableProperty().setValue(transactionEntries.isEmpty());
}
Also used : TransactionEntry(jgnash.engine.TransactionEntry)

Aggregations

TransactionEntry (jgnash.engine.TransactionEntry)55 Account (jgnash.engine.Account)16 InvestmentTransaction (jgnash.engine.InvestmentTransaction)16 Transaction (jgnash.engine.Transaction)16 BigDecimal (java.math.BigDecimal)13 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)11 Logger (java.util.logging.Logger)4 FXML (javafx.fxml.FXML)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 LocalDate (java.time.LocalDate)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 JPanel (javax.swing.JPanel)3 Engine (jgnash.engine.Engine)3 TransactionFactory (jgnash.engine.TransactionFactory)3