Search in sources :

Example 51 with Transaction

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

the class AbstractSlipController method handlePayeeFocusChange.

private void handlePayeeFocusChange() {
    if (modTrans == null && Options.useAutoCompleteProperty().get() && payeeTextField.getLength() > 0) {
        if (payeeTextField.autoCompleteModelObjectProperty().get() != null) {
            // The auto complete model may return multiple solutions.  Choose the first solution that works
            final List<Transaction> transactions = new ArrayList<>(payeeTextField.autoCompleteModelObjectProperty().get().getAllExtraInfo(payeeTextField.getText()));
            // reverse the transactions, most recent first
            Collections.reverse(transactions);
            for (final Transaction transaction : transactions) {
                if (canModifyTransaction(transaction)) {
                    try {
                        modifyTransaction(modifyTransactionForAutoComplete((Transaction) transaction.clone()));
                    } catch (final CloneNotSupportedException e) {
                        Logger.getLogger(getClass().getName()).log(Level.SEVERE, e.getMessage(), e);
                    }
                    // clear the modTrans field  TODO: use new transaction instead?
                    modTrans = null;
                    break;
                }
            }
        }
    }
}
Also used : Transaction(jgnash.engine.Transaction) ArrayList(java.util.ArrayList)

Example 52 with Transaction

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

the class AbstractSlipController method handleEnterAction.

@FXML
@Override
public void handleEnterAction() {
    if (modTrans == null) {
        // new transaction
        Transaction newTrans = buildTransaction();
        ReconcileManager.reconcileTransaction(account.get(), newTrans, getReconciledState());
        // chain the transaction build
        newTrans = attachmentPane.buildTransaction(newTrans);
        final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
        if (engine != null) {
            if (!engine.addTransaction(newTrans)) {
                StaticUIMethods.displayError(resources.getString("Message.Error.TranAddFail"));
            }
        }
    } else {
        Transaction newTrans = buildTransaction();
        // restore the reconciled state of the previous old transaction
        for (final Account a : modTrans.getAccounts()) {
            if (!a.equals(account.get())) {
                ReconcileManager.reconcileTransaction(a, newTrans, modTrans.getReconciled(a));
            }
        }
        /*
                 * Reconcile the modified transaction for this account.
                 * This must be performed last to ensure consistent results per the ReconcileManager rules
                 */
        ReconcileManager.reconcileTransaction(account.get(), newTrans, getReconciledState());
        // chain the transaction build
        newTrans = attachmentPane.buildTransaction(newTrans);
        final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
        if (engine != null && engine.removeTransaction(modTrans)) {
            engine.addTransaction(newTrans);
        }
    }
    clearForm();
    focusFirstComponent();
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) Engine(jgnash.engine.Engine) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Example 53 with Transaction

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

the class AdjustSharesSlipController method buildTransaction.

@NotNull
@Override
public Transaction buildTransaction() {
    final Transaction transaction;
    if (tranType == TransactionType.ADDSHARE) {
        transaction = TransactionFactory.generateAddXTransaction(accountProperty().get(), securityComboBox.getValue(), priceField.getDecimal(), quantityField.getDecimal(), datePicker.getValue(), memoTextField.getText());
    } else {
        transaction = TransactionFactory.generateRemoveXTransaction(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 54 with Transaction

use of jgnash.engine.Transaction 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());
    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 55 with Transaction

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

the class PayeePieChart method getTransactions.

private List<TranTuple> getTransactions(final Account account, final List<TranTuple> transactions, final LocalDate startDate, final LocalDate endDate) {
    for (final Transaction t : account.getTransactions(startDate, endDate)) {
        TranTuple tuple = new TranTuple(account, t);
        transactions.add(tuple);
    }
    for (final Account child : account.getChildren(Comparators.getAccountByCode())) {
        getTransactions(child, transactions, startDate, endDate);
    }
    return transactions;
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction)

Aggregations

Transaction (jgnash.engine.Transaction)81 InvestmentTransaction (jgnash.engine.InvestmentTransaction)39 Account (jgnash.engine.Account)27 BigDecimal (java.math.BigDecimal)24 Engine (jgnash.engine.Engine)22 TransactionEntry (jgnash.engine.TransactionEntry)18 NotNull (jgnash.util.NotNull)13 List (java.util.List)10 LocalDate (java.time.LocalDate)9 FXML (javafx.fxml.FXML)9 AbstractInvestmentTransactionEntry (jgnash.engine.AbstractInvestmentTransactionEntry)9 ArrayList (java.util.ArrayList)7 TransactionType (jgnash.engine.TransactionType)7 ResourceBundle (java.util.ResourceBundle)6 TransactionFactory (jgnash.engine.TransactionFactory)6 NumberFormat (java.text.NumberFormat)5 Objects (java.util.Objects)5 ChangeListener (javafx.beans.value.ChangeListener)5 EngineFactory (jgnash.engine.EngineFactory)5 Message (jgnash.engine.message.Message)5