mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Prefer the entry date to the value date if present in the import.
The invalid date part of the bug was fixed in 7b1c050
.
This commit is contained in:
parent
d62c6d96e3
commit
7e4fcc7afb
@ -580,8 +580,8 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
|||||||
QofBook *book;
|
QofBook *book;
|
||||||
Transaction *gnc_trans;
|
Transaction *gnc_trans;
|
||||||
const gchar *fitid;
|
const gchar *fitid;
|
||||||
const GNC_GWEN_DATE *valuta_date;
|
const GNC_GWEN_DATE *value_date, *post_date;
|
||||||
time64 current_time;
|
time64 current_time, post_time;
|
||||||
const char *custref;
|
const char *custref;
|
||||||
gchar *description;
|
gchar *description;
|
||||||
Split *split;
|
Split *split;
|
||||||
@ -595,22 +595,28 @@ gnc_ab_trans_to_gnc(const AB_TRANSACTION *ab_trans, Account *gnc_acc)
|
|||||||
xaccTransBeginEdit(gnc_trans);
|
xaccTransBeginEdit(gnc_trans);
|
||||||
|
|
||||||
/* Date / Time */
|
/* Date / Time */
|
||||||
valuta_date = AB_Transaction_GetValutaDate(ab_trans);
|
/* SWIFT import formats (in particular MT940) provide for two
|
||||||
if (!valuta_date)
|
* dates, the entry date and the value date (valuta is value in
|
||||||
{
|
* German). The value date is the effective date for financial
|
||||||
const GNC_GWEN_DATE *normal_date = AB_Transaction_GetDate(ab_trans);
|
* calculation purposes and is mandatory, the entry date is the
|
||||||
if (normal_date)
|
* date that the financial institution posted the
|
||||||
valuta_date = normal_date;
|
* transaction. Since the entry date is normally closer to the
|
||||||
}
|
* date that the customer's book should recognize the transaction
|
||||||
if (valuta_date)
|
* we prefer that date if present.
|
||||||
{
|
*/
|
||||||
time64 secs = gnc_gwen_date_to_time64(valuta_date);
|
post_date = AB_Transaction_GetDate(ab_trans);
|
||||||
xaccTransSetDatePostedSecsNormalized(gnc_trans, secs);
|
value_date = AB_Transaction_GetValutaDate(ab_trans);
|
||||||
}
|
if (post_date)
|
||||||
|
post_time = gnc_gwen_date_to_time64(post_date);
|
||||||
|
else if (value_date)
|
||||||
|
post_time = gnc_gwen_date_to_time64(value_date);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_warning("transaction_cb: Oops, date 'valuta_date' was NULL");
|
g_warning("transaction_cb: Import had no transaction date");
|
||||||
|
post_time = gnc_time (NULL);
|
||||||
}
|
}
|
||||||
|
xaccTransSetDatePostedSecsNormalized(gnc_trans, post_time);
|
||||||
|
|
||||||
xaccTransSetDateEnteredSecs(gnc_trans, gnc_time (NULL));
|
xaccTransSetDateEnteredSecs(gnc_trans, gnc_time (NULL));
|
||||||
|
|
||||||
/* Currency. We take simply the default currency of the gnucash account */
|
/* Currency. We take simply the default currency of the gnucash account */
|
||||||
|
Loading…
Reference in New Issue
Block a user