Search in sources :

Example 6 with NotNull

use of jgnash.util.NotNull in project jgnash by ccavanaugh.

the class SplitMergeSharesSlipController method buildTransaction.

@NotNull
@Override
public Transaction buildTransaction() {
    final Transaction transaction;
    if (tranType == TransactionType.SPLITSHARE) {
        transaction = TransactionFactory.generateSplitXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText());
    } else {
        transaction = TransactionFactory.generateMergeXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText());
    }
    transaction.setNumber(numberComboBox.getValue());
    return attachmentPane.buildTransaction(transaction);
}
Also used : Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) NotNull(jgnash.util.NotNull)

Example 7 with NotNull

use of jgnash.util.NotNull in project jgnash by ccavanaugh.

the class ReinvestDividendSlipController method modifyTransaction.

@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
    if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.REINVESTDIV) {
        throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
    }
    clearForm();
    datePicker.setValue(transaction.getLocalDate());
    numberComboBox.setValue(transaction.getNumber());
    feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
    gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
    transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntryReinvestDivX).forEach(e -> {
        final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
        memoTextField.setText(e.getMemo());
        priceField.setDecimal(entry.getPrice());
        quantityField.setDecimal(entry.getQuantity());
        securityComboBox.setSecurityNode(entry.getSecurityNode());
    });
    modTrans = transaction;
    modTrans = attachmentPane.modifyTransaction(modTrans);
    setReconciledState(transaction.getReconciled(accountProperty().get()));
}
Also used : FXML(javafx.fxml.FXML) BigDecimal(java.math.BigDecimal) List(java.util.List) NotNull(jgnash.util.NotNull) Transaction(jgnash.engine.Transaction) InvestmentTransaction(jgnash.engine.InvestmentTransaction) ChangeListener(javafx.beans.value.ChangeListener) TransactionEntry(jgnash.engine.TransactionEntry) TransactionEntryReinvestDivX(jgnash.engine.TransactionEntryReinvestDivX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionFactory(jgnash.engine.TransactionFactory) TransactionType(jgnash.engine.TransactionType) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntryReinvestDivX(jgnash.engine.TransactionEntryReinvestDivX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Example 8 with NotNull

use of jgnash.util.NotNull in project jgnash by ccavanaugh.

the class SellShareSlipController method modifyTransaction.

@Override
public void modifyTransaction(@NotNull final Transaction transaction) {
    if (!(transaction instanceof InvestmentTransaction) || transaction.getTransactionType() != TransactionType.SELLSHARE) {
        throw new IllegalArgumentException(resources.getString("Message.Error.InvalidTransactionType"));
    }
    clearForm();
    datePicker.setValue(transaction.getLocalDate());
    numberComboBox.setValue(transaction.getNumber());
    feePane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentFeeEntries());
    gainLossPane.setTransactionEntries(((InvestmentTransaction) transaction).getInvestmentGainLossEntries());
    transaction.getTransactionEntries().stream().filter(e -> e instanceof TransactionEntrySellX).forEach(e -> {
        final AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
        memoTextField.setText(e.getMemo());
        priceField.setDecimal(entry.getPrice());
        quantityField.setDecimal(entry.getQuantity());
        securityComboBox.setSecurityNode(entry.getSecurityNode());
        if (entry.getCreditAccount().equals(accountProperty().get())) {
            accountExchangePane.setSelectedAccount(entry.getDebitAccount());
            accountExchangePane.setExchangedAmount(entry.getDebitAmount().abs());
        } else {
            Logger.getLogger(SellShareSlipController.class.getName()).warning("was not expected");
        }
    });
    modTrans = transaction;
    modTrans = attachmentPane.modifyTransaction(modTrans);
    setReconciledState(transaction.getReconciled(accountProperty().get()));
}
Also used : NotNull(jgnash.util.NotNull) Transaction(jgnash.engine.Transaction) Logger(java.util.logging.Logger) TransactionEntry(jgnash.engine.TransactionEntry) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry) TransactionType(jgnash.engine.TransactionType) FXML(javafx.fxml.FXML) BigDecimal(java.math.BigDecimal) List(java.util.List) TransactionEntrySellX(jgnash.engine.TransactionEntrySellX) InvestmentTransaction(jgnash.engine.InvestmentTransaction) ChangeListener(javafx.beans.value.ChangeListener) TransactionFactory(jgnash.engine.TransactionFactory) InvestmentTransaction(jgnash.engine.InvestmentTransaction) TransactionEntrySellX(jgnash.engine.TransactionEntrySellX) AbstractInvestmentTransactionEntry(jgnash.engine.AbstractInvestmentTransactionEntry)

Example 9 with NotNull

use of jgnash.util.NotNull in project jgnash by ccavanaugh.

the class DividendSlipController method buildTransaction.

@NotNull
@Override
public Transaction buildTransaction() {
    BigDecimal incomeExchangedAmount = decimalTextField.getDecimal().negate();
    BigDecimal accountExchangedAmount = decimalTextField.getDecimal();
    if (!incomeExchangePane.getSelectedAccount().getCurrencyNode().equals(accountProperty().get().getCurrencyNode())) {
        incomeExchangedAmount = incomeExchangePane.exchangeAmountProperty().get().negate();
    }
    if (!accountExchangePane.getSelectedAccount().getCurrencyNode().equals(accountProperty().get().getCurrencyNode())) {
        accountExchangedAmount = accountExchangePane.exchangeAmountProperty().get();
    }
    final Transaction transaction = TransactionFactory.generateDividendXTransaction(incomeExchangePane.getSelectedAccount(), accountProperty().get(), accountExchangePane.getSelectedAccount(), securityComboBox.getValue(), decimalTextField.getDecimal(), incomeExchangedAmount, accountExchangedAmount, datePicker.getValue(), memoTextField.getText());
    transaction.setNumber(numberComboBox.getValue());
    return transaction;
}
Also used : Transaction(jgnash.engine.Transaction) BigDecimal(java.math.BigDecimal) NotNull(jgnash.util.NotNull)

Example 10 with NotNull

use of jgnash.util.NotNull in project jgnash by ccavanaugh.

the class TableViewManager method retrieveOldColumnWidths.

@NotNull
private double[] retrieveOldColumnWidths() {
    // zero length array instead of null to protect against NPE
    double[] columnWidths = new double[0];
    // no need to retrieve old column widths more than once
    if (preferenceKeyFactory.get() != null) {
        final String uuid = preferenceKeyFactory.get().get();
        final Preferences preferences = Preferences.userRoot().node(preferencesUserRoot + PREF_NODE_REG_WIDTH);
        final String widths = preferences.get(uuid, null);
        if (widths != null) {
            columnWidths = EncodeDecode.decodeDoubleArray(widths);
        }
    }
    return columnWidths;
}
Also used : Preferences(java.util.prefs.Preferences) NotNull(jgnash.util.NotNull)

Aggregations

NotNull (jgnash.util.NotNull)17 Transaction (jgnash.engine.Transaction)13 BigDecimal (java.math.BigDecimal)10 InvestmentTransaction (jgnash.engine.InvestmentTransaction)9 List (java.util.List)6 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)6 TransactionEntry (jgnash.engine.TransactionEntry)6 ChangeListener (javafx.beans.value.ChangeListener)4 FXML (javafx.fxml.FXML)4 LocalDate (java.time.LocalDate)3 ArrayList (java.util.ArrayList)3 TransactionFactory (jgnash.engine.TransactionFactory)3 TransactionType (jgnash.engine.TransactionType)3 Collections (java.util.Collections)2 Objects (java.util.Objects)2 ResourceBundle (java.util.ResourceBundle)2 ExecutionException (java.util.concurrent.ExecutionException)2 Logger (java.util.logging.Logger)2 Preferences (java.util.prefs.Preferences)2 Collectors (java.util.stream.Collectors)2