Bug 799224 - Import of QIF gets Bug detected during duplicates (partial fix)

If the new-splits object is null, it means the new account tree from
the current import has no splits. Therefore the (apply min|max dates)
will fail. Omitting the date query is a simple fix to prevent crashing.

This is a partial fix because the crash is likely a symptom of another
bug which causes the new account-tree to be empty.
This commit is contained in:
Christopher Lam 2024-01-21 12:31:30 +08:00
parent f7e3038e38
commit e8bb8b6146

View File

@ -85,10 +85,14 @@
(dates (map (compose xaccTransGetDate xaccSplitGetParent) new-splits)))
(qof-query-set-book q (gnc-account-get-book old-root))
(xaccQueryAddAccountMatch q old-accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
(xaccQueryAddDateMatchTT q
#t (decdate (apply min dates) WeekDelta)
#t (incdate (apply max dates) WeekDelta)
QOF-QUERY-AND)
(cond
((null? dates)
(gnc:warn "Probable error: the new account tree has no transactions."))
(else
(xaccQueryAddDateMatchTT q
#t (decdate (apply min dates) WeekDelta)
#t (incdate (apply max dates) WeekDelta)
QOF-QUERY-AND)))
(let ((splits (qof-query-run q)))
(qof-query-destroy q)
splits)))