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;
}
}
}
}
}
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();
}
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);
}
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);
}
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;
}
Aggregations