svn6107 mmex

Page 1 of 1
3 posts
svn6107 mmex

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
test opening 5K transaction takes 1 sec

/* , m_splits(Model_Splittransaction::instance().find(Model_Splittransaction::TRANSID(r.TRANSID)))*/
Attachments
mmex.zip
(4.43 MiB) Downloaded 199 times
Re: svn6107 mmex

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
Code: Select all
Index: import_export/export.cpp
===================================================================
--- import_export/export.cpp   (revision 6108)
+++ import_export/export.cpp   (working copy)
@@ -44,9 +44,11 @@
 {
     Model_Checking::Data *transaction = Model_Checking::instance().get(m_transaction_id);
     if (!transaction) return "";
-    Model_Checking::Full_Data full_tran(*transaction);
+    Model_Checking::Full_Data init_data; //TODO:Speedup
+    Model_Checking::Full_Data full_tran(*transaction, init_data.m_allSplits);
     bool out = transaction->ACCOUNTID == m_account_id;
 
+    //TODO:Cleanup
     const Model_Account::Data* account = Model_Account::instance().get(transaction->ACCOUNTID);
     if (account) full_tran.ACCOUNTNAME = account->ACCOUNTNAME;
     if (Model_Checking::type(transaction) == Model_Checking::TRANSFER)
@@ -116,7 +118,9 @@
 {
     Model_Checking::Data *transaction = Model_Checking::instance().get(m_transaction_id);
     if (!transaction) return "";
-    Model_Checking::Full_Data full_tran(*transaction);
+
+    Model_Checking::Full_Data init_data;//TODO: speedup
+    Model_Checking::Full_Data full_tran(*transaction, init_data.m_allSplits);
     bool out = transaction->ACCOUNTID == m_account_id;
 
     const Model_Account::Data* account = Model_Account::instance().get(transaction->ACCOUNTID);
Index: mmcheckingpanel.cpp
===================================================================
--- mmcheckingpanel.cpp   (revision 6109)
+++ mmcheckingpanel.cpp   (working copy)
@@ -204,6 +204,7 @@
     reconciled_balance_ = account_balance_;
     filteredBalance_ = 0.0;
 
+    Model_Checking::Full_Data init_data;
     const auto& trans = Model_Account::transaction(this->m_account);
     for (const auto& tran : trans)
     {
@@ -229,7 +230,7 @@
                 continue;
         }
 
-        Model_Checking::Full_Data full_tran(tran);
+        Model_Checking::Full_Data full_tran(tran, init_data.m_allSplits);
 
         full_tran.PAYEENAME = full_tran.real_payee_name(m_AccountID);
         full_tran.BALANCE = account_balance_;
Index: model/Model_Checking.cpp
===================================================================
--- model/Model_Checking.cpp   (revision 6108)
+++ model/Model_Checking.cpp   (working copy)
@@ -239,11 +239,18 @@
 
 Model_Checking::Full_Data::Full_Data() : Data(0), BALANCE(0)
 {
+    for (const auto &split : Model_Splittransaction::instance().all())
+    {
+        m_allSplits[split.TRANSID] = Model_Splittransaction::instance().find(Model_Splittransaction::TRANSID(split.TRANSID));
+    }
 }
 
-Model_Checking::Full_Data::Full_Data(const Data& r): Data(r), BALANCE(0)
- , m_splits(Model_Splittransaction::instance().find(Model_Splittransaction::TRANSID(r.TRANSID)))
+Model_Checking::Full_Data::Full_Data(const Data& r, const std::map<int /*trans id*/, Model_Splittransaction::Data_Set /*split trans*/ > & splits)
+: Data(r), BALANCE(0)
+/* , m_splits(Model_Splittransaction::instance().find(Model_Splittransaction::TRANSID(r.TRANSID)))*/
 {
+    const auto it = splits.find(this->id());
+    if (it != splits.end()) m_splits = it->second;
     const Model_Account::Data* from_account = Model_Account::instance().get(r.ACCOUNTID);
     if (from_account) this->ACCOUNTNAME = from_account->ACCOUNTNAME;
 
Index: model/Model_Checking.h
===================================================================
--- model/Model_Checking.h   (revision 6108)
+++ model/Model_Checking.h   (working copy)
@@ -39,7 +39,7 @@
     struct Full_Data: public Data
     {
         Full_Data();
-        Full_Data(const Data& r);
+        Full_Data(const Data& r, const std::map<int /*trans id*/, Model_Splittransaction::Data_Set /*split trans*/ > & splits);
 
         ~Full_Data();
         wxString ACCOUNTNAME, TOACCOUNTNAME;
@@ -48,6 +48,7 @@
         double AMOUNT;
         double BALANCE;
         Model_Splittransaction::Data_Set m_splits;
+        std::map <int, Model_Splittransaction::Data_Set> m_allSplits;
         
         wxString real_payee_name(int account_id) const;
         bool has_split() const;
Index: reports/transactions.cpp
===================================================================
--- reports/transactions.cpp   (revision 6108)
+++ reports/transactions.cpp   (working copy)
@@ -184,11 +184,12 @@
 
 void mmReportTransactions::Run(mmFilterTransactionsDialog* dlg)
 {
+    Model_Checking::Full_Data init_data;
     for (const auto& tran : Model_Checking::instance().all())
     {
         if (!dlg->checkAll(tran, refAccountID_)) continue;
 
-        Model_Checking::Full_Data full_tran(tran);
+        Model_Checking::Full_Data full_tran(tran, init_data.m_allSplits);
         Model_Account::Data *account = Model_Account::instance().get(full_tran.ACCOUNTID);
         if (account) full_tran.ACCOUNTNAME = account->ACCOUNTNAME;
         if (Model_Checking::TRANSFER == Model_Checking::type(tran))
Attachments
mmex.zip
(4.43 MiB) Downloaded 197 times
Re: svn6107 mmex

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
Code: Select all
Index: import_export/export.cpp
===================================================================
--- import_export/export.cpp   (revision 6108)
+++ import_export/export.cpp   (working copy)
@@ -40,13 +40,15 @@
 mmExportTransaction::~mmExportTransaction()
 {}
 
-wxString mmExportTransaction::getTransactionQIF()
+wxString mmExportTransaction::getTransactionQIF(const std::map <int, Model_Splittransaction::Data_Set> &splits)
 {
     Model_Checking::Data *transaction = Model_Checking::instance().get(m_transaction_id);
     if (!transaction) return "";
-    Model_Checking::Full_Data full_tran(*transaction);
+    Model_Checking::Full_Data init_data; //TODO:Speedup
+    Model_Checking::Full_Data full_tran(*transaction, splits);
     bool out = transaction->ACCOUNTID == m_account_id;
 
+    //TODO:Cleanup
     const Model_Account::Data* account = Model_Account::instance().get(transaction->ACCOUNTID);
     if (account) full_tran.ACCOUNTNAME = account->ACCOUNTNAME;
     if (Model_Checking::type(transaction) == Model_Checking::TRANSFER)
@@ -93,10 +95,7 @@
     if (!notes.IsEmpty())
         buffer << "M" << notes << "\n";
 
-    Model_Splittransaction::Data_Set splits = Model_Checking::splittransaction(transaction);
-    if (!splits.empty())
-    {
-        for (const auto &split_entry : splits)
+        for (const auto &split_entry : splits.at(transaction->id()))
         {
             double value = split_entry.SPLITTRANSAMOUNT;
             if (Model_Checking::type(transaction) == Model_Checking::WITHDRAWAL)
@@ -106,17 +105,17 @@
             buffer << "S" << split_categ << "\n"
                 << "$" << split_amount << "\n";
         }
-    }
 
     buffer << "^" << "\n";
     return buffer;
 }
 
-wxString mmExportTransaction::getTransactionCSV()
+wxString mmExportTransaction::getTransactionCSV(const std::map <int, Model_Splittransaction::Data_Set> &splits)
 {
     Model_Checking::Data *transaction = Model_Checking::instance().get(m_transaction_id);
     if (!transaction) return "";
-    Model_Checking::Full_Data full_tran(*transaction);
+
+    Model_Checking::Full_Data full_tran(*transaction, splits);
     bool out = transaction->ACCOUNTID == m_account_id;
 
     const Model_Account::Data* account = Model_Account::instance().get(transaction->ACCOUNTID);
@@ -156,10 +155,9 @@
             transNum = wxString::Format("#%i", trans_id);
     }
 
-    Model_Splittransaction::Data_Set splits = Model_Checking::splittransaction(transaction);
-    if (!splits.empty())
+    if (!splits.at(transaction->id()).empty())
     {
-        for (const auto &split_entry : splits)
+        for (const auto &split_entry : splits.at(transaction->id()))
         {
             double value = split_entry.SPLITTRANSAMOUNT;
             if (Model_Checking::type(transaction) == Model_Checking::WITHDRAWAL)
Index: import_export/export.h
===================================================================
--- import_export/export.h   (revision 6108)
+++ import_export/export.h   (working copy)
@@ -20,6 +20,7 @@
 #define _MM_EX_EXPORT_H_
 
 #include "mmOption.h"
+#include "model\Model_Splittransaction.h"
 
 class mmExportBase
 {
@@ -40,8 +41,8 @@
     mmExportTransaction(int accountID);
     mmExportTransaction(int transactionID, int accountID);
 
-    wxString getTransactionQIF();
-    wxString getTransactionCSV();
+    wxString getTransactionQIF(const std::map <int, Model_Splittransaction::Data_Set> &splits);
+    wxString getTransactionCSV(const std::map <int, Model_Splittransaction::Data_Set> &splits);
     wxString getAccountHeaderQIF();
     wxString getCategoriesQIF();
     wxString getCategoriesCSV();
Index: import_export/qif_export.cpp
===================================================================
--- import_export/qif_export.cpp   (revision 6108)
+++ import_export/qif_export.cpp   (working copy)
@@ -393,6 +393,7 @@
                 buffer << header.getAccountHeaderQIF();
             }
 
+            const auto splits = Model_Splittransaction::instance().get_allSplits();
             for (const auto& transaction : Model_Checking::instance().find_or(Model_Checking::ACCOUNTID(account_id)
                 , Model_Checking::TOACCOUNTID(account_id)))
             {
@@ -407,9 +408,9 @@
 
                 mmExportTransaction data(transaction.TRANSID, account_id);
                 if (qif_csv)
-                    buffer << data.getTransactionQIF();
+                    buffer << data.getTransactionQIF(splits);
                 else
-                    buffer << data.getTransactionCSV();
+                    buffer << data.getTransactionCSV(splits);
 
                 if (Model_Checking::type(transaction) == Model_Checking::TRANSFER)
                 {
@@ -421,9 +422,9 @@
                         mmExportTransaction data2(transaction.TRANSID, index);
                         wxString second_part = "";
                         if (qif_csv)
-                            second_part = data2.getTransactionQIF();
+                            second_part = data2.getTransactionQIF(splits);
                         else
-                            second_part = data2.getTransactionCSV();
+                            second_part = data2.getTransactionCSV(splits);
                         transferTransactions[index] += second_part;
                     }
                 }
Index: mmcheckingpanel.cpp
===================================================================
--- mmcheckingpanel.cpp   (revision 6109)
+++ mmcheckingpanel.cpp   (working copy)
@@ -204,6 +204,7 @@
     reconciled_balance_ = account_balance_;
     filteredBalance_ = 0.0;
 
+    const auto split = Model_Splittransaction::instance().get_allSplits();
     const auto& trans = Model_Account::transaction(this->m_account);
     for (const auto& tran : trans)
     {
@@ -229,7 +230,7 @@
                 continue;
         }
 
-        Model_Checking::Full_Data full_tran(tran);
+        Model_Checking::Full_Data full_tran(tran, split);
 
         full_tran.PAYEENAME = full_tran.real_payee_name(m_AccountID);
         full_tran.BALANCE = account_balance_;
Index: model/Model_Checking.cpp
===================================================================
--- model/Model_Checking.cpp   (revision 6108)
+++ model/Model_Checking.cpp   (working copy)
@@ -241,9 +241,12 @@
 {
 }
 
-Model_Checking::Full_Data::Full_Data(const Data& r): Data(r), BALANCE(0)
- , m_splits(Model_Splittransaction::instance().find(Model_Splittransaction::TRANSID(r.TRANSID)))
+Model_Checking::Full_Data::Full_Data(const Data& r
+    , const std::map<int /*trans id*/, Model_Splittransaction::Data_Set /*split trans*/ > & splits)
+: Data(r), BALANCE(0)
 {
+    const auto it = splits.find(this->id());
+    if (it != splits.end()) m_splits = it->second;
     const Model_Account::Data* from_account = Model_Account::instance().get(r.ACCOUNTID);
     if (from_account) this->ACCOUNTNAME = from_account->ACCOUNTNAME;
 
Index: model/Model_Checking.h
===================================================================
--- model/Model_Checking.h   (revision 6108)
+++ model/Model_Checking.h   (working copy)
@@ -39,7 +39,9 @@
     struct Full_Data: public Data
     {
         Full_Data();
-        Full_Data(const Data& r);
+        Full_Data(const Data& r
+            , const std::map<int /*trans id*/
+                , Model_Splittransaction::Data_Set /*split trans*/ > & splits);
 
         ~Full_Data();
         wxString ACCOUNTNAME, TOACCOUNTNAME;
Index: model/Model_Splittransaction.cpp
===================================================================
--- model/Model_Splittransaction.cpp   (revision 6108)
+++ model/Model_Splittransaction.cpp   (working copy)
@@ -53,3 +53,13 @@
     for (auto& r : rows) total += r.SPLITTRANSAMOUNT;
     return total;
 }
+
+std::map<int, Model_Splittransaction::Data_Set> Model_Splittransaction::get_allSplits()
+{
+    std::map<int, Model_Splittransaction::Data_Set> data;
+    for (const auto &split : instance().all())
+    {
+        data[split.TRANSID] = Model_Splittransaction::instance().find(Model_Splittransaction::TRANSID(split.TRANSID));
+    }
+    return data;
+}
\ No newline at end of file
Index: model/Model_Splittransaction.h
===================================================================
--- model/Model_Splittransaction.h   (revision 6108)
+++ model/Model_Splittransaction.h   (working copy)
@@ -45,6 +45,7 @@
 
 public:
     static double get_total(const Data_Set& rows);
+    std::map<int, Model_Splittransaction::Data_Set> get_allSplits();
 };
 
 #endif //
Index: reports/transactions.cpp
===================================================================
--- reports/transactions.cpp   (revision 6108)
+++ reports/transactions.cpp   (working copy)
@@ -184,11 +184,12 @@
 
 void mmReportTransactions::Run(mmFilterTransactionsDialog* dlg)
 {
+    const auto splits = Model_Splittransaction::instance().get_allSplits();
     for (const auto& tran : Model_Checking::instance().all())
     {
         if (!dlg->checkAll(tran, refAccountID_)) continue;
 
-        Model_Checking::Full_Data full_tran(tran);
+        Model_Checking::Full_Data full_tran(tran, splits);
         Model_Account::Data *account = Model_Account::instance().get(full_tran.ACCOUNTID);
         if (account) full_tran.ACCOUNTNAME = account->ACCOUNTNAME;
         if (Model_Checking::TRANSFER == Model_Checking::type(tran))
Attachments
mmex.zip
(4.43 MiB) Downloaded 213 times
Page 1 of 1
Who is online

Users browsing this forum: No registered users and 3 guests

cron