Browse Source

Ignore custom label when comparing transactions

master
Nicolas Petton 3 years ago
parent
commit
f072f5605f
No known key found for this signature in database GPG Key ID: E8BCD7866AFCF978
4 changed files with 22 additions and 7 deletions
  1. +1
    -2
      elbank-common.el
  2. +5
    -1
      elbank-report.el
  3. +16
    -0
      test/elbank-boobank-test.el
  4. +0
    -4
      test/elbank-common-test.el

+ 1
- 2
elbank-common.el View File

@ -136,8 +136,7 @@ Transactions can optionally have a `custom-label', which takes
priority when set.
If all are nil, return DEFAULT."
(or (map-elt transaction 'custom-label nil)
(map-elt transaction 'label nil)
(or (map-elt transaction 'label nil)
(map-elt transaction 'raw default)))
(cl-defmethod elbank-transaction-elt (transaction (key (eql account)) &optional default)


+ 5
- 1
elbank-report.el View File

@ -478,7 +478,11 @@ Signal an error if there is no transaction at point."
"Return a button text with the label of TRANSACTION.
When clicking the button, jump to the transaction."
(with-temp-buffer
(insert (elbank-transaction-elt transaction 'label ""))
(insert (elbank-transaction-elt transaction
'custom-label
(elbank-transaction-elt transaction
'label
"")))
(make-text-button (point-at-bol) (point)
'follow-link t
'action


+ 16
- 0
test/elbank-boobank-test.el View File

@ -90,6 +90,22 @@
merged)
:to-equal '("1" "2" "3" "3" "3" "3"))))
(it "should ignore custom labels when deduplicating"
(let* ((old '(((label . "1"))
((label . "2"))
((label . "3") (custom-label . "a"))
((label . "3") (custom-label . "b"))))
(new '(((label . "2"))
((label . "3"))
((label . "3"))
((label . "3"))
((label . "3"))))
(elbank-data `((transactions . ,old)))
(merged (elbank-boobank--merge-transactions new)))
(expect (seq-map (lambda (tr) (map-elt tr 'label))
merged)
:to-equal '("1" "2" "3" "3" "3" "3"))))
(it "should ignore categories when deduplicating"
(let* ((elbank-data `((accounts . (((id . "account1") (label . "account 1"))))
(transactions . (((label . "1"))


+ 0
- 4
test/elbank-common-test.el View File

@ -71,10 +71,6 @@
(let ((tr '((label . "foo") (raw . "bar"))))
(expect (elbank-transaction-elt tr 'label) :to-equal "foo")))
(it "prefers custom labels over labels"
(let ((tr '((label . "foo") (custom-label . "bar") (raw . "baz"))))
(expect (elbank-transaction-elt tr 'label) :to-equal "bar")))
(it "returns raw if present and label is not"
(let ((tr '((raw . "foo"))))
(expect (elbank-transaction-elt tr 'label) :to-equal "foo")))


Loading…
Cancel
Save