From: <vo...@us...> - 2012-09-29 21:04:06
|
Revision: 3007 http://moneymanagerex.svn.sourceforge.net/moneymanagerex/?rev=3007&view=rev Author: vomikan Date: 2012-09-29 21:03:59 +0000 (Sat, 29 Sep 2012) Log Message: ----------- QIF export update Modified Paths: -------------- branches/0.9.9.0/mmex/src/mmex.cpp branches/0.9.9.0/mmex/src/qifimport.cpp branches/0.9.9.0/mmex/src/util.h Modified: branches/0.9.9.0/mmex/src/mmex.cpp =================================================================== --- branches/0.9.9.0/mmex/src/mmex.cpp 2012-09-27 16:25:11 UTC (rev 3006) +++ branches/0.9.9.0/mmex/src/mmex.cpp 2012-09-29 21:03:59 UTC (rev 3007) @@ -3154,7 +3154,7 @@ void mmGUIFrame::OnExportToQIF(wxCommandEvent& /*event*/) { - mmExportQIF(this, m_core.get(), m_db.get()); + mmExportQIF(this, m_core.get()); } //---------------------------------------------------------------------------- Modified: branches/0.9.9.0/mmex/src/qifimport.cpp =================================================================== --- branches/0.9.9.0/mmex/src/qifimport.cpp 2012-09-27 16:25:11 UTC (rev 3006) +++ branches/0.9.9.0/mmex/src/qifimport.cpp 2012-09-29 21:03:59 UTC (rev 3007) @@ -538,7 +538,7 @@ return fromAccountID; } -void mmExportQIF(wxWindow *parent_, mmCoreDB* core, wxSQLite3Database* db_) +void mmExportQIF(wxWindow *parent_, mmCoreDB* core) { if (core->accountList_.getNumAccounts() == 0) { @@ -621,59 +621,44 @@ const wxString acctName = core->accountList_.GetAccountName(fromAccountID); const wxString amtSeparator = core->accountList_.getAccountCurrencyDecimalChar(fromAccountID); - static const char sql[] = - "SELECT TRANSID, TRANSDATE, " - "TRANSCODE, " - "TRANSAMOUNT, TOTRANSAMOUNT, " - " SUBCATEGID, " - "CATEGID, PAYEEID, " - "TRANSACTIONNUMBER, NOTES, TOACCOUNTID, ACCOUNTID " - "FROM CHECKINGACCOUNT_V1 " - "WHERE ACCOUNTID = ? OR TOACCOUNTID = ?" - "ORDER BY TRANSDATE, TRANSID"; - - wxSQLite3Statement st = db_->PrepareStatement(sql); - st.Bind(1, fromAccountID); - st.Bind(2, fromAccountID); - - wxSQLite3ResultSet q1 = st.ExecuteQuery(); - text << wxT("!Account") << endl << wxT("N") << acctName << endl << wxT("TChecking") << endl << wxT("^") << endl << wxT("!Type:Cash") << endl; - while (q1.NextRow()) + + for (size_t i = 0; i < core->bTransactionList_.transactions_.size(); ++i) { - wxString transid = q1.GetString(wxT("TRANSID")); - wxString dateDBString = q1.GetString(wxT("TRANSDATE")); - wxDateTime dtdt = mmGetStorageStringAsDate(dateDBString); - wxString dateString = mmGetDateForDisplay(db_, dtdt); + boost::shared_ptr<mmBankTransaction> pBankTransaction = core->bTransactionList_.transactions_[i]; + if ((pBankTransaction->accountID_ != fromAccountID) && (pBankTransaction->toAccountID_ != fromAccountID)) + continue; - wxString payee = core->payeeList_.GetPayeeName(q1.GetInt(wxT("PAYEEID"))); - wxString type = q1.GetString(wxT("TRANSCODE")); + int transid = pBankTransaction->transactionID(); + wxDateTime dtdt = pBankTransaction->date_; + wxString dateString = mmGetDateForDisplay(core->db_.get(), dtdt); - const int tAccountID = q1.GetInt(wxT("TOACCOUNTID")); - const int fAccountID = q1.GetInt(wxT("ACCOUNTID")); + wxString payee = core->payeeList_.GetPayeeName(pBankTransaction->payeeID_); + wxString type = pBankTransaction->transType_; - wxString amount = adjustedExportAmount(amtSeparator, q1.GetString(wxT("TRANSAMOUNT"))); + const int tAccountID = pBankTransaction->accountID_; + const int fAccountID = pBankTransaction->toAccountID_; + + wxString amount = adjustedExportAmount(amtSeparator, wxString()<<pBankTransaction->amt_); //Amount should be formated double value = 0.0; mmex::formatCurrencyToDouble(amount, value); mmex::formatDoubleToCurrencyEdit(value, amount); - wxString toamount = q1.GetString(wxT("TOTRANSAMOUNT")); + wxString toamount = wxString()<<pBankTransaction->toAmt_; //Amount should be formated value = 0.0; mmex::formatCurrencyToDouble(toamount, value); mmex::formatDoubleToCurrencyEdit(value, toamount); - wxString transNum = q1.GetString(wxT("TRANSACTIONNUMBER")); - wxString categ = core->categoryList_.GetCategoryName(q1.GetInt(wxT("CATEGID"))); - const wxString subcateg = core->categoryList_.GetSubCategoryName( - q1.GetInt(wxT("CATEGID")), q1.GetInt(wxT("SUBCATEGID"))); - wxString notes = (q1.GetString(wxT("NOTES"))); + wxString transNum = pBankTransaction->transNum_; + const wxString categ = pBankTransaction->fullCatStr_; + wxString notes = (pBankTransaction->notes_); notes.Replace(wxT("''"), wxT("'")); notes.Replace(wxT("\n"), wxT(" ")); @@ -693,8 +678,6 @@ else if (type == wxT("Withdrawal")) amount.Prepend(wxT ('-')); - categ += (subcateg.IsEmpty() ? wxT("") : wxString(wxT(":"))<< subcateg); - text << wxT('D') << dateString << endl; text << wxT('T') << amount << endl; if (type != wxT("Transfer")) @@ -708,32 +691,25 @@ if (!notes.IsEmpty()) text << wxT('M') << notes << endl; - //if categ id is empty the transaction has been splited - if (categ.IsEmpty() && subcateg.IsEmpty()) + //if categ id is empty that mean this is split transaction + if (categ.IsEmpty()) { - static const char sql4splitedtrx[] = - "SELECT SUBCATEGID, CATEGID, SPLITTRANSAMOUNT " - "FROM SPLITTRANSACTIONS_V1 " - "WHERE TRANSID = ?"; - - wxSQLite3Statement st2 = db_->PrepareStatement(sql4splitedtrx); - st2.Bind(1, transid); - - wxSQLite3ResultSet q2 = st2.ExecuteQuery(); - - while (q2.NextRow()) + mmSplitTransactionEntries* splits = pBankTransaction->splitEntries_.get(); + pBankTransaction->getSplitTransactions(core, splits); + + for (int i = 0; i < (int)splits->entries_.size(); ++i) { wxString split_amount; - value = q2.GetDouble(wxT("SPLITTRANSAMOUNT"));\ + value = splits->entries_[i]->splitAmount_; //q2.GetDouble(wxT("SPLITTRANSAMOUNT")); if (type == wxT("Withdrawal")) value = -value; mmex::formatDoubleToCurrencyEdit(value, split_amount); - wxString split_categ = core->categoryList_.GetCategoryName(q2.GetInt(wxT("CATEGID"))); + wxString split_categ = core->categoryList_.GetCategoryName(splits->entries_[i]->categID_); const wxString split_subcateg = core->categoryList_.GetSubCategoryName( - q2.GetInt(wxT("CATEGID")), q2.GetInt(wxT("SUBCATEGID"))); + splits->entries_[i]->categID_, splits->entries_[i]->subCategID_); if (!split_subcateg.IsEmpty()) split_categ += wxT(":") + split_subcateg; text << wxT('S') << split_categ << endl; text << wxT('$') << split_amount << endl; @@ -742,18 +718,14 @@ text << wxT('E') << split_categ << wxT(" ") << split_amount << endl; } - q2.Finalize(); } text << wxT('^') << endl; numRecords++; } - - q1.Finalize(); } } const wxString msg = wxString::Format(wxTRANSLATE("Transactions exported: %ld"), numRecords); mmShowErrorMessage(parent_, wxGetTranslation(msg), _("Export to QIF")); } - Modified: branches/0.9.9.0/mmex/src/util.h =================================================================== --- branches/0.9.9.0/mmex/src/util.h 2012-09-27 16:25:11 UTC (rev 3006) +++ branches/0.9.9.0/mmex/src/util.h 2012-09-29 21:03:59 UTC (rev 3007) @@ -94,7 +94,7 @@ void fixFileExt(wxFileName &f, const wxString &ext); int mmImportQIF(wxWindow* parent_, mmCoreDB* core, wxString destinationAccountName = wxEmptyString ); -void mmExportQIF(wxWindow* parent_, mmCoreDB* core, wxSQLite3Database* db_ ); +void mmExportQIF(wxWindow* parent_, mmCoreDB* core); void correctEmptyFileExt(wxString ext, wxString & fileName ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |