use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class FeePanel method getTransactions.
public List<TransactionEntry> getTransactions() {
// adjust the cash balance of the investment account
if (feeList.isEmpty() && feeField.getDecimal().compareTo(BigDecimal.ZERO) != 0) {
// ignore zero balance fees
TransactionEntry fee = new TransactionEntry(account, feeField.getDecimal().abs().negate());
fee.setTransactionTag(TransactionTag.INVESTMENT_FEE);
feeList.add(fee);
}
return feeList;
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class DividendPanel method modifyTransaction.
@Override
public void modifyTransaction(Transaction tran) {
if (!(tran instanceof InvestmentTransaction)) {
throw new IllegalArgumentException("bad tranType");
}
clearForm();
datePanel.setDate(tran.getLocalDate());
List<TransactionEntry> entries = tran.getTransactionEntries();
assert entries.size() <= 2;
for (TransactionEntry e : entries) {
if (e instanceof TransactionEntryDividendX) {
AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoField.setText(e.getMemo());
securityCombo.setSelectedNode(entry.getSecurityNode());
incomeExchangePanel.setSelectedAccount(entry.getDebitAccount());
incomeExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
dividendField.setDecimal(entry.getAmount(getAccount()));
} else if (e.getTransactionTag() == TransactionTag.INVESTMENT_CASH_TRANSFER) {
accountExchangePanel.setSelectedAccount(e.getCreditAccount());
accountExchangePanel.setExchangedAmount(e.getCreditAmount());
} else {
logger.warning("Invalid transaction");
}
}
modTrans = tran;
setReconciledState(tran.getReconciled(getAccount()));
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class ReinvestDividendPanel method modifyTransaction.
@Override
public void modifyTransaction(final Transaction tran) {
if (!(tran instanceof InvestmentTransaction)) {
throw new IllegalArgumentException("bad tranType");
}
clearForm();
datePanel.setDate(tran.getLocalDate());
List<TransactionEntry> entries = tran.getTransactionEntries();
feePanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentFeeEntries());
gainsPanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentGainLossEntries());
entries.stream().filter(e -> e instanceof TransactionEntryReinvestDivX).forEach(e -> {
AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoField.setText(e.getMemo());
priceField.setDecimal(entry.getPrice());
quantityField.setDecimal(entry.getQuantity());
securityCombo.setSelectedNode(entry.getSecurityNode());
});
updateTotalField();
modTrans = tran;
setReconciledState(tran.getReconciled(getAccount()));
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class ReturnOfCapitalPanel method modifyTransaction.
@Override
public void modifyTransaction(Transaction tran) {
if (!(tran instanceof InvestmentTransaction)) {
throw new IllegalArgumentException("bad tranType");
}
clearForm();
datePanel.setDate(tran.getLocalDate());
List<TransactionEntry> entries = tran.getTransactionEntries();
assert entries.size() <= 2;
for (TransactionEntry e : entries) {
if (e instanceof TransactionEntryRocX) {
AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;
memoField.setText(e.getMemo());
securityCombo.setSelectedNode(entry.getSecurityNode());
incomeExchangePanel.setSelectedAccount(entry.getDebitAccount());
incomeExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
dividendField.setDecimal(entry.getAmount(getAccount()));
} else if (e.getTransactionTag() == TransactionTag.INVESTMENT_CASH_TRANSFER) {
accountExchangePanel.setSelectedAccount(e.getCreditAccount());
accountExchangePanel.setExchangedAmount(e.getCreditAmount());
} else {
logger.warning("Invalid transaction");
}
}
modTrans = tran;
setReconciledState(tran.getReconciled(getAccount()));
}
use of jgnash.engine.TransactionEntry in project jgnash by ccavanaugh.
the class LiabilityRegisterPanel method paymentActionDebit.
/* creates the payment transaction relative to the debit account */
private void paymentActionDebit() {
AmortizeObject ao = account.getAmortizeObject();
if (ao != null) {
Transaction tran = null;
DateChkNumberDialog d = new DateChkNumberDialog(ao.getBankAccount(), rb.getString("Title.NewTrans"));
d.setVisible(true);
if (!d.getResult()) {
return;
}
BigDecimal balance = account.getBalance().abs();
double payment = ao.getPayment();
double interest;
if (ao.getUseDailyRate()) {
LocalDate today = d.getDate();
LocalDate last;
if (account.getTransactionCount() > 0) {
last = account.getTransactionAt(account.getTransactionCount() - 1).getLocalDate();
} else {
last = today;
}
// get the interest portion
interest = ao.getIPayment(balance, last, today);
} else {
// get the interest portion
interest = ao.getIPayment(balance);
}
// get debit account
Account bank = ao.getBankAccount();
if (bank != null) {
CommodityNode n = bank.getCurrencyNode();
Transaction transaction = new Transaction();
transaction.setDate(d.getDate());
transaction.setNumber(d.getNumber());
transaction.setPayee(ao.getPayee());
// transaction is made relative to the debit/checking account
TransactionEntry e = new TransactionEntry();
// this entry is the principal payment
e.setCreditAccount(account);
e.setDebitAccount(bank);
e.setAmount(n.round(payment - interest));
e.setMemo(ao.getMemo());
transaction.addTransactionEntry(e);
// handle interest portion of the payment
Account i = ao.getInterestAccount();
if (i != null && interest != 0.0) {
e = new TransactionEntry();
e.setCreditAccount(i);
e.setDebitAccount(bank);
e.setAmount(n.round(interest));
e.setMemo(rb.getString("Word.Interest"));
transaction.addTransactionEntry(e);
//System.out.println(e.getAmount());
}
// a fee has been assigned
if (ao.getFees().compareTo(BigDecimal.ZERO) != 0) {
Account f = ao.getFeesAccount();
if (f != null) {
e = new TransactionEntry();
e.setCreditAccount(f);
e.setDebitAccount(bank);
e.setAmount(ao.getFees());
e.setMemo(rb.getString("Word.Fees"));
transaction.addTransactionEntry(e);
//System.out.println(e.getAmount());
}
}
// the remainder of the balance should be loan principal
tran = transaction;
}
if (tran != null) {
// display the transaction in the register
EditTransactionDialog dlg = new EditTransactionDialog(ao.getBankAccount(), PanelType.DECREASE);
dlg.newTransaction(tran);
dlg.setVisible(true);
} else {
StaticUIMethods.displayWarning(rb.getString("Message.Warn.ConfigAmortization"));
}
} else {
// could not generate the transaction
StaticUIMethods.displayWarning(rb.getString("Message.Warn.ConfigAmortization"));
}
}
Aggregations