Browse Source

Hanble custom transaction labels in elbank-report.el

* elbank-common.el: Remove method elbank-transaction-elt for `label'.
* elbank-report.el (elbank-report--cell): Handle custom labels.
* test/elbank-common-test.el: Remove old transaction label tests.
master
Nicolas Petton 2 years ago
parent
commit
6dbd21e31f
No known key found for this signature in database GPG Key ID: E8BCD7866AFCF978
3 changed files with 2 additions and 26 deletions
  1. +0
    -13
      elbank-common.el
  2. +1
    -0
      elbank-report.el
  3. +1
    -13
      test/elbank-common-test.el

+ 0
- 13
elbank-common.el View File

@@ -126,19 +126,6 @@ Data is cached to `elbank-data'."
If the result is nil, return DEFAULT."
(map-elt transaction key default))

(cl-defmethod elbank-transaction-elt (transaction (_key (eql label)) &optional default)
"Return the label of TRANSACTION.

The label is defined as the value at symbol `label' if present,
the value at symbol `raw' if not.

Transactions can optionally have a `custom-label', which takes
priority when set.

If all are nil, return DEFAULT."
(or (map-elt transaction 'label nil)
(map-elt transaction 'raw default)))

(cl-defmethod elbank-transaction-elt (transaction (key (eql account)) &optional default)
"Return the account of TRANSACTION.



+ 1
- 0
elbank-report.el View File

@@ -480,6 +480,7 @@ When clicking the button, jump to the transaction."
(with-temp-buffer
(insert (or (elbank-transaction-elt transaction 'custom-label)
(elbank-transaction-elt transaction 'label)
(elbank-transaction-elt transaction 'raw)
""))
(make-text-button (point-at-bol) (point)
'follow-link t


+ 1
- 13
test/elbank-common-test.el View File

@@ -65,19 +65,7 @@
(describe "when asked for label"
(it "returns label if present"
(let ((tr '((label . "foo"))))
(expect (elbank-transaction-elt tr 'label) :to-equal "foo")))

(it "prefers label over raw"
(let ((tr '((label . "foo") (raw . "bar"))))
(expect (elbank-transaction-elt tr 'label) :to-equal "foo")))

(it "returns raw if present and label is not"
(let ((tr '((raw . "foo"))))
(expect (elbank-transaction-elt tr 'label) :to-equal "foo")))

(it "returns default if neither label nor raw are present"
(let ((tr '((something-else . "bar"))))
(expect (elbank-transaction-elt tr 'label "foo") :to-equal "foo")))))
(expect (elbank-transaction-elt tr 'label) :to-equal "foo")))))

(provide 'elbank-common-test)
;;; elbank-common-test.el ends here

Loading…
Cancel
Save