Search in sources :

Example 6 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class ExchangeBasketDialog method doExchangeBasket.

private void doExchangeBasket() throws InterruptedException {
    int memberCount = otapiJNI.OTAPI_Basic_Basket_GetMemberCount(assetID);
    boolean bSure = true;
    if (otapiJNI.OTAPI_Basic_GetNym_TransactionNumCount(serverID, nymID) < (2 + memberCount)) {
        bSure = Helpers.getTransactionNumbers(serverID, nymID);
    }
    if (!bSure || otapiJNI.OTAPI_Basic_GetNym_TransactionNumCount(serverID, nymID) < (2 + memberCount)) {
        System.out.println("IN doExchangeBasket , failed to get transaction numbers, OT_API_GetNym_TransactionNumCount:" + otapiJNI.OTAPI_Basic_GetNym_TransactionNumCount(serverID, nymID));
        return;
    }
    OpenTransactionAccount otAccount = new OpenTransactionAccount();
    String exchangeRequest = otAccount.getExchangeBasketRequest(serverID, nymID, assetID, accountID, Integer.parseInt(jTextField1.getText()));
    for (int i = 0; i < memberCount; i++) {
        String memberAssetID = otapiJNI.OTAPI_Basic_Basket_GetMemberType(assetID, i);
        System.out.println("In doExchangeBasket,memberAssetID:" + memberAssetID + " assetID:" + assetID + " nymID:" + nymID + " serverID:" + serverID);
        new ExchangeBasketAcctDialog(null, true, memberAssetID, serverID, nymID).setVisible(true);
        if (Helpers.isBasketXCancelled()) {
            Helpers.setBasketXCancelled(false);
            JOptionPane.showMessageDialog(null, "The basket exchange has been cancelled", "Basket Exchange Canellation", JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        String memberAccountID = Helpers.getBasketXAcct();
        exchangeRequest = otapiJNI.OTAPI_Basic_AddBasketExchangeItem(serverID, nymID, exchangeRequest, memberAssetID, memberAccountID);
    }
    String xchangeType = inXchange == true ? "IN" : "OUT";
    if (!otAccount.exchangeBasket(assetID, serverID, nymID, exchangeRequest, inXchange, memberCount, accountID)) {
        JOptionPane.showMessageDialog(null, "Exchange basket failed", "Server Error", JOptionPane.ERROR_MESSAGE);
    } else {
        JOptionPane.showMessageDialog(null, xchangeType + " Exchange of basket currency done successfully", "Basket Exchange Success", JOptionPane.INFORMATION_MESSAGE);
    }
}
Also used : OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount)

Example 7 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class OpenTransactionAccountBottomPanel method ProcessInbox.

@Action
public void ProcessInbox() {
    try {
        OpenTransactionAccount openTransaction = new OpenTransactionAccount();
        Map selectedIndices = new HashMap();
        List finalReceiptRefNo = new ArrayList();
        for (int i = 0; i < jTable_Inbox.getRowCount(); i++) {
            String key = (String) jTable_Inbox.getModel().getValueAt(i, 9);
            if (!Utility.VerifyStringVal(key))
                key = new String("");
            if ((Boolean) jTable_Inbox.getModel().getValueAt(i, 7)) {
                selectedIndices.put(key, true);
            }
            if ((Boolean) jTable_Inbox.getModel().getValueAt(i, 8)) {
                selectedIndices.put(key, false);
            }
            if ("finalReceipt".equalsIgnoreCase((String) jTable_Inbox.getModel().getValueAt(i, 3)) && (Boolean) jTable_Inbox.getModel().getValueAt(i, 7)) {
                finalReceiptRefNo.add((String) jTable_Inbox.getModel().getValueAt(i, 1));
            }
        }
        System.out.println("selectedIndices:" + selectedIndices.entrySet());
        if (jTable_Inbox.getRowCount() < 1 || selectedIndices.size() < 1) {
            JOptionPane.showMessageDialog(this, "Please check some transactions to process", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        for (int j = 0; j < finalReceiptRefNo.size(); j++) {
            String referenceNo = (String) finalReceiptRefNo.get(j);
            for (int i = 0; i < jTable_Inbox.getRowCount(); i++) {
                if (referenceNo.equals((String) jTable_Inbox.getModel().getValueAt(i, 1)) && !(Boolean) jTable_Inbox.getModel().getValueAt(i, 7)) {
                    JOptionPane.showMessageDialog(this, "To close a finalReceipt, you must also close the other receipts that have the same reference number", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
            }
        }
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        boolean success = openTransaction.processInbox(accountID, selectedIndices);
        if (success) {
            JOptionPane.showMessageDialog(this, "Inbox processed successfully", "Processing Success", JOptionPane.INFORMATION_MESSAGE);
            Helpers.reloadOTDetails(accountID);
            MainPage.reLoadAccount();
            Helpers.setLoadNymTrades(true);
        } else {
            JOptionPane.showMessageDialog(this, "Error in processing Inbox", "Server Error", JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) Action(org.jdesktop.application.Action)

Example 8 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class OpenTransactionAccountTopPanel method jButton_OutActionPerformed.

//GEN-LAST:event_jButton_InActionPerformed
private void jButton_OutActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton_OutActionPerformed
    try {
        OpenTransactionAccount otAccount = new OpenTransactionAccount();
        String basket = otAccount.showBasket(jTextField_ServerID.getText(), jTextField_NymID.getText(), jTextField_AssetID.getText());
        if (basket != null && basket.length() > 0) {
            new ExchangeBasketDialog(null, true, basket, false, jTextField_ServerID.getText(), jTextField_NymID.getText(), jTextField_AccountID.getText(), jTextField_AssetID.getText()).setVisible(true);
        } else {
            JOptionPane.showMessageDialog(null, "Error getting basket curreny list", "Error", JOptionPane.ERROR_MESSAGE);
        }
    } catch (InterruptedException ex) {
        Logger.getLogger(OpenTransactionAccountTopPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : ExchangeBasketDialog(com.moneychanger.ui.dialogs.ExchangeBasketDialog) OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount)

Example 9 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class OpenTransactionAccountTopPanel method jButton_DownloadAccountFilesActionPerformed.

//GEN-LAST:event_jButton_SendTransferActionPerformed
private void jButton_DownloadAccountFilesActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton_DownloadAccountFilesActionPerformed
    String accountID = jTextField_AccountID.getText();
    try {
        OpenTransactionAccount openTransaction = new OpenTransactionAccount();
        setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        // download the data.
        boolean isSuccess = Helpers.getInboxOutboxAccount(accountID, true);
        if (isSuccess) {
            JOptionPane.showMessageDialog(this, "Files downloaded successfully", "Processing Success", JOptionPane.INFORMATION_MESSAGE);
            OpenTransactionAccountBottomPanel.setOTTables(openTransaction.getInboxData(accountID), openTransaction.getOutboxData(accountID));
        } else {
            JOptionPane.showMessageDialog(this, "Error in downloading latest account files", "Server Error", JOptionPane.ERROR_MESSAGE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        setCursor(Cursor.getDefaultCursor());
    }
}
Also used : OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount)

Example 10 with OpenTransactionAccount

use of com.moneychanger.core.OpenTransactionAccount in project otapij by FellowTraveler.

the class OpenTransactionAccountTopPanel method jButton_VerifyFilesActionPerformed.

//GEN-LAST:event_jButton_DownloadAccountFilesActionPerformed
private void jButton_VerifyFilesActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_jButton_VerifyFilesActionPerformed
    OpenTransactionAccount otAccount = new OpenTransactionAccount();
    int isSuccess = otAccount.verifyFiles(jTextField_ServerID.getText(), jTextField_NymID.getText(), jTextField_AccountID.getText());
    if (isSuccess == 0) {
        JOptionPane.showMessageDialog(null, "The intermediary files for this account have all been VERIFIED against the last signed receipt", "Verified", JOptionPane.INFORMATION_MESSAGE);
    } else if (isSuccess == 1) {
        JOptionPane.showMessageDialog(null, "The intermediary files for this account have FAILED to verify against the last signed receipt", "Error", JOptionPane.ERROR_MESSAGE);
    } else if (isSuccess == 2) {
        JOptionPane.showMessageDialog(null, "There is no receipt for this account", "Empty", JOptionPane.INFORMATION_MESSAGE);
    }
}
Also used : OpenTransactionAccount(com.moneychanger.core.OpenTransactionAccount)

Aggregations

OpenTransactionAccount (com.moneychanger.core.OpenTransactionAccount)22 Account (com.moneychanger.core.Account)5 AWTException (java.awt.AWTException)5 Point (java.awt.Point)5 RippleAccount (com.moneychanger.core.RippleAccount)4 OTDetails (com.moneychanger.core.dataobjects.OTDetails)2 ComboObject (com.moneychanger.core.util.ComboObject)2 ExchangeBasketDialog (com.moneychanger.ui.dialogs.ExchangeBasketDialog)2 AccountTableModel (com.moneychanger.ui.model.AccountTableModel)2 OtherTabAccountModel (com.moneychanger.ui.model.OtherTabAccountModel)2 CardLayout (java.awt.CardLayout)2 JPanel (javax.swing.JPanel)2 ListSelectionEvent (javax.swing.event.ListSelectionEvent)2 ListSelectionListener (javax.swing.event.ListSelectionListener)2 Contract (com.moneychanger.core.Contract)1 NYM (com.moneychanger.core.NYM)1 BitcoinDetails (com.moneychanger.core.dataobjects.BitcoinDetails)1 CashPurseDetails (com.moneychanger.core.dataobjects.CashPurseDetails)1 DepositCashDialog (com.moneychanger.ui.dialogs.DepositCashDialog)1 BlankPanel (com.moneychanger.ui.panels.BlankPanel)1