[office/kmymoney] 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 e1beb42e826f47ffcdb13613dee8954ff8f1893c by Thomas Baumgart.
Committed on 10/08/2026 at 07:03.
Pushed by tbaumgart into branch 'master'.

Keep statement balance from QIF import

BUG: 337405
FIXED-IN: 5.2.3

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

https://invent.kde.org/office/kmymoney/-/commit/e1beb42e826f47ffcdb13613dee8954ff8f1893c

diff --git a/kmymoney/plugins/qif/import/mymoneyqifreader.cpp b/kmymoney/plugins/qif/import/mymoneyqifreader.cpp
index 69ac1e6be..d9b137539 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.