Browse Source

Merge branch 'add-account-column' into 'master'

Add account column

See merge request nico/elbank!4
custom-labels
Nicolas Petton 3 years ago
parent
commit
c4cf91fe50
3 changed files with 19 additions and 10 deletions
  1. +10
    -0
      elbank-common.el
  2. +2
    -8
      elbank-overview.el
  3. +7
    -2
      elbank-report.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 ()


+ 7
- 2
elbank-report.el View File

@ -61,8 +61,9 @@ Available columns:
- `label'
- `raw' (raw transaction text)
- `category'
- `account'
- `amount'."
:type `(repeat (list (string :tag "Name")
:type `(repeat (list (string :tag "Name")
(string :tag "Category")
(symbol :tag "Group by")
(symbol :tag "Sort by" :value date)
@ -413,7 +414,7 @@ Signal an error if there is no transaction at point."
(elbank-report--truncate str)))
(cl-defmethod elbank-report--cell (transaction (_column (eql label)))
"Return a button text with the label of TRANSACTION.
"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))
@ -424,6 +425,10 @@ When clicking the button, jump to the transaction."
(elbank-show-transaction transaction)))
(elbank-report--truncate (buffer-string))))
(cl-defmethod elbank-report--cell (transaction (_column (eql account)))
"Return the label of the account associated with TRANSACTION."
(elbank-report--truncate (elbank-account-name (elbank-transaction-elt transaction 'account))))
(defun elbank-report--truncate (str)
"Truncate STR to `elbank-report-max-column-width'.
If STR overflows, add an ellipsis."


Loading…
Cancel
Save