Implement ledger import

This commit is contained in:
Jeremy Dormitzer 2019-02-27 20:58:11 -05:00
parent 6a01e6d17f
commit 5461528405

View File

@ -791,7 +791,8 @@ Literate programming!
(java . t)
(js . t)
(dot . t)
(ditaa . t)))))
(ditaa . t)
(ledger . t)))))
#+END_SRC
Get rid of the confirmation prompt:
@ -1306,6 +1307,44 @@ This mode requires that [[https://github.com/ledger/ledger][ledger]] be installe
(variable-pitch-mode 0))))
#+END_SRC
** Importing
#+BEGIN_SRC emacs-lisp
(defvar ledger-file (expand-file-name "~/journal.ledger"))
(defvar bank-alist
'(("DCU Checking" . ((acct . "Assets:Checking")
(fid . "9999")))
("DCU Savings" . ((acct . "Assets:Savings")
(fid . "9999")))
("DCU Visa" . ((acct . "Liabilities:DCU Visa")
(fid . "9999")))
("Chase Visa" . ((acct . "Liabilities:Chase Visa")))))
(defun ledger-import-ofx (bank file)
(interactive
(list
(ido-completing-read+ "Bank: "
(mapcar #'car bank-alist))
(ido-read-file-name "OFX file: ")))
(if-let ((ledger-autosync (executable-find "ledger-autosync")))
(let* ((bank-def (alist-get bank bank-alist))
(acct (alist-get 'acct bank-def))
(fid (alist-get 'fid bank-def))
(cmd (concat
ledger-autosync
(if fid (concat " --fid " fid) "")
" --account '" acct "'"
" '" file "'"))
(output (shell-command-to-string cmd)))
(find-file ledger-file)
(goto-char (point-max))
(insert "\n")
(insert output)
(ledger-sort-region (point-min) (point-max))
(ledger-post-align-postings (point-min) (point-max)))
(error "Unable to find ledger-autosync")))
#+END_SRC
* PDFs
#+BEGIN_SRC emacs-lisp
(use-package pdf-tools