branch: elpa/csv2ledger commit 59ba8418055359018f5ecb0e1aa12168b1eb4a39 Author: Joost Kremers <joostkrem...@fastmail.fm> Commit: Joost Kremers <joostkrem...@fastmail.fm>
Guard against empty payee and sender in c2l-title-is-payee-or-sender --- csv2ledger.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/csv2ledger.el b/csv2ledger.el index e30b42a890..2861bf615b 100644 --- a/csv2ledger.el +++ b/csv2ledger.el @@ -242,11 +242,16 @@ should contain values for `payee' and `sender'. If the value of otherwise the payee is returned." (let ((payee (alist-get 'payee transaction)) (sender (alist-get 'sender transaction))) - (if (stringp c2l-account-holder) - (if (string-match-p c2l-account-holder payee) - sender - payee) - payee))) + (cond + ((and (string-empty-p payee) + (string-empty-p sender)) + "Unknown") + ((string-empty-p payee) sender) + ((string-empty-p sender) payee) + ((and (stringp c2l-account-holder) + (string-match-p c2l-account-holder payee)) + sender) + (t payee)))) (defun c2l-title-is-counterpart (transaction) "Return the counterpart of an entry.