Search in sources :

Example 1 with AccountListDialog

use of jgnash.ui.account.AccountListDialog in project jgnash by ccavanaugh.

the class AdjustmentPanel method convertAction.

/**
     * Helps convert an existing single entry transaction into a double entry transaction
     */
private void convertAction() {
    AccountListDialog d = new AccountListDialog();
    d.disableAccount(getAccount());
    d.disablePlaceHolders();
    d.setVisible(true);
    if (!d.getReturnStatus()) {
        return;
    }
    Account opp = d.getAccount();
    Transaction t = new Transaction();
    t.setDate(datePanel.getLocalDate());
    t.setNumber(numberField.getText());
    t.setPayee(payeeField.getText());
    TransactionEntry entry = new TransactionEntry();
    entry.setMemo(memoField.getText());
    if (amountField.getDecimal().signum() >= 0) {
        entry.setCreditAccount(getAccount());
        entry.setDebitAccount(opp);
    } else {
        entry.setDebitAccount(getAccount());
        entry.setCreditAccount(opp);
    }
    entry.setCreditAmount(amountField.getDecimal().abs());
    entry.setDebitAmount(amountField.getDecimal().abs().negate());
    ReconcileManager.reconcileTransaction(getAccount(), t, getReconciledState());
    t.addTransactionEntry(entry);
    Transaction tran = TransactionDialog.showDialog(getAccount(), t);
    if (tran != null) {
        if (getEngine().removeTransaction(modTrans)) {
            getEngine().addTransaction(tran);
        }
        clearForm();
    }
}
Also used : Account(jgnash.engine.Account) Transaction(jgnash.engine.Transaction) AccountListDialog(jgnash.ui.account.AccountListDialog) TransactionEntry(jgnash.engine.TransactionEntry)

Aggregations

Account (jgnash.engine.Account)1 Transaction (jgnash.engine.Transaction)1 TransactionEntry (jgnash.engine.TransactionEntry)1 AccountListDialog (jgnash.ui.account.AccountListDialog)1