[office/kmymoney/5.2] kmymoney/plugins/qif/import: Keep statement balance from QIF import

Thomas Baumgart <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 6131258bfc9f55f4c29d38c08887a9474de2523f by Thomas Baumgart.
Committed on 10/08/2026 at 07:10.
Pushed by tbaumgart into branch '5.2'.

Keep statement balance from QIF import

BUG: 337405
FIXED-IN: 5.2.3
(cherry picked from commit e1beb42e826f47ffcdb13613dee8954ff8f1893c)

M  +16   -7    kmymoney/plugins/qif/import/mymoneyqifreader.cpp

https://invent.kde.org/office/kmymoney/-/commit/6131258bfc9f55f4c29d38c08887a9474de2523f

diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
index 28d711a33..9f608df87 100644
--- a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
+++ b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
@@ -1906,20 +1906,21 @@ const QString MyMoneyQifReader::processAccountEntry(bool resetAccountId)
     MyMoneyFile* file = MyMoneyFile::instance();
 
     MyMoneyAccount account;
-    QString tmp;
 
     account.setName(extractLine('N'));
     //   qDebug("Process account '%s'", account.name().data());
 
     account.setDescription(extractLine('D'));
 
-    tmp = extractLine('$');
-    if (tmp.length() > 0)
-        account.setValue("lastStatementBalance", tmp);
+    const auto balanceValue = extractLine('$');
+    if (!balanceValue.isEmpty()) {
+        account.setValue("lastStatementBalance", balanceValue);
+    }
 
-    tmp = extractLine('/');
-    if (tmp.length() > 0)
-        account.setLastReconciliationDate(m_qifProfile.date(tmp));
+    const auto balanceDate = extractLine('/');
+    if (!balanceDate.isEmpty()) {
+        account.setLastReconciliationDate(m_qifProfile.date(balanceDate));
+    }
 
     QifEntryTypeE transactionType = EntryTransaction;
     static const auto whiteSpaceRegex = QRegularExpression(QLatin1String("\\s+"));
@@ -2004,6 +2005,14 @@ const QString MyMoneyQifReader::processAccountEntry(bool resetAccountId)
         m_account = acc;
         d->st.m_accountId = m_account.id(); //                      needed here for account selection
         d->transactionType = transactionType;
+
+        // keep closing balance information
+        if (!balanceValue.isEmpty()) {
+            d->st.m_closingBalance = m_qifProfile.value('T', balanceValue);
+        }
+        if (!balanceDate.isEmpty()) {
+            d->st.m_dateEnd = m_qifProfile.date(balanceDate);
+        }
     }
     return acc.id();
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.