From 436110e523e5530e67d8d21410270fe7d495b0ea Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 28 Jul 2022 14:55:12 -0700 Subject: [PATCH] Bug 798578 - MT940 imports broken - all transactions have date of... first transaction It's really the date of the opening balance and it's because AQBanking returns that instead of the value date if a transaction field has no entry date.: https://www.aquamaniac.de/rdm/issues/262 --- gnucash/import-export/aqb/gnc-ab-utils.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c index e8809eed24..f78585680d 100644 --- a/gnucash/import-export/aqb/gnc-ab-utils.c +++ b/gnucash/import-export/aqb/gnc-ab-utils.c @@ -111,7 +111,7 @@ gnc_gwen_date_to_time64 (const GNC_GWEN_DATE* date) * that's the case then back up a day to get a real date for * posting. */ - if (month == 2 && day <= 30 && day > (is_leap_year(year) ? 29 : 28)) + while (month == 2 && day <= 30 && day > (is_leap_year(year) ? 29 : 28)) --day; return gnc_dmy2time64_neutral(day, month, year); #else @@ -600,16 +600,16 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc) * German). The value date is the effective date for financial * calculation purposes and is mandatory, the entry date is the * date that the financial institution posted the - * transaction. Since the entry date is normally closer to the - * date that the customer's book should recognize the transaction - * we prefer that date if present. + * transaction. Unfortunately if the transaction field doesn't + * provide an entry date AQBanking substitutes the date from the + * last balance instead of using the value date or NULL, making + * the field unreliable. */ - post_date = AB_Transaction_GetDate(ab_trans); value_date = AB_Transaction_GetValutaDate(ab_trans); - if (post_date) - post_time = gnc_gwen_date_to_time64(post_date); - else if (value_date) + if (value_date) post_time = gnc_gwen_date_to_time64(value_date); + else if ((post_date = AB_Transaction_GetDate(ab_trans))) // always true + post_time = gnc_gwen_date_to_time64(post_date); else { g_warning("transaction_cb: Import had no transaction date");