Browse Source

Add two account-related functions to elbank-common.el

* elbank-common.el: Add elbank-account-name and elbank-account-group.

* elbank-overview.el: Adapt to new functions.
custom-labels
Damien Cassou 3 years ago
parent
commit
3b3a612ba9
No known key found for this signature in database GPG Key ID: A7123815F5DCE914
2 changed files with 12 additions and 8 deletions
  1. +10
    -0
      elbank-common.el
  2. +2
    -8
      elbank-overview.el

+ 10
- 0
elbank-common.el View File

@ -110,6 +110,16 @@ Data is cached to `elbank-data'."
id))
(map-elt elbank-data 'accounts)))
(defun elbank-account-name (account)
"Return a human-readable name for ACCOUNT."
(format "%s@%s"
(elbank-account-group account)
(map-elt account 'label)))
(defun elbank-account-group (account)
"Return the group into which ACCOUNT is classified."
(cadr (split-string (map-elt account 'id) "@")))
(cl-defgeneric elbank-transaction-elt (transaction key &optional default)
"Return the value of TRANSACTION at KEY.


+ 2
- 8
elbank-overview.el View File

@ -157,10 +157,6 @@ If nothing important is at point, return nil."
(propertize "\n" 'face '(:underline t)
'display '(space :align-to 999)))))
(defun elbank-overview-account-group (account)
"Return the group into which ACCOUNT is classified."
(cadr (split-string (map-elt account 'id) "@")))
(defun elbank-overview--insert-accounts ()
"Insert all accounts informations in the current buffer."
(seq-do (lambda (group)
@ -168,7 +164,7 @@ If nothing important is at point, return nil."
(seq-map #'elbank-overview--insert-account
(cdr group))
(insert "\n"))
(seq-group-by #'elbank-overview-account-group (map-elt elbank-data 'accounts))))
(seq-group-by #'elbank-account-group (map-elt elbank-data 'accounts))))
(defun elbank-overview--insert-bank (bankname)
"Insert BANKNAME into the current buffer as a header."
@ -196,9 +192,7 @@ If nothing important is at point, return nil."
(insert " "))
(elbank--insert-amount balance (map-elt account 'currency))
(put-text-property (point-at-bol) (point-at-eol) 'elbank-account account)
(put-text-property (point-at-bol) (point-at-eol) 'imenu-name (format "%s@%s"
(elbank-overview-account-group account)
(map-elt account 'label)))
(put-text-property (point-at-bol) (point-at-eol) 'imenu-name (elbank-account-name account))
(insert "\n")))
(defun elbank-overview--insert-saved-reports ()


Loading…
Cancel
Save