Updating save-receipt-link

This is tax season here in the United States. My Org-based tax record keeping enabled me to send everything to my accountant as soon as I had all the proper forms from employers, banks, and other sources of income to the vast Irreal empire. As usual, once I’d finished with all the paperwork, I reviewed my procedures to see if there was anything I could do to reduce friction and make things easier.

Five years ago, I wrote about one such improvement: a bit of Elisp to save links to scanned receipts in my Org files. Here, for reference, is that Elisp from the above link:

(defconst current-tax-file "tax12")

(defun save-receipt-link (doc)
  "Make a link to a receipt in the current tax file."
  (interactive "sDocument Name: ")
  (insert (concat "[[file:~/tax/" current-tax-file "/receipts/" doc
                  "][receipt]]")))

The save-receipt-link function worked well and I’ve been using it throughout the last 5 years as I get receipts that I need to save for tax purposes. There are, however, a couple of problems with it. The first is that I often get the file name of the scanned receipt wrong. Most often this involves leaving off the .pdf at the end. I could solve most instances of that problem by just programmatically adding the .pdf but some documents have a different extension and sometimes I just mistype the name so appending the .pdf doesn’t really solve the problem.

The other problem appeared at the beginning of the year. I was still getting receipts from the previous year but also getting receipts for the current year. That meant I had to hand-edit the receipt links.

Obviously, since I’ve been using this method for 5 years, neither of these problems is fatal but they do inject a bit of friction. This year I decided to fix things. I did that by changing save-receipt-link to be

(defconst prev-tax-file "~/tax/tax16/receipts")
(defconst current-tax-file "~/tax/tax17/receipts")

(defun save-receipt-link (prevp)
  "Make a link to a receipt in the current or previous tax file.
Use the previous tax file if called with the universal argument."
  (interactive "P")
  (insert (format "[[file:%s][receipt]]"
                  (completing-read "Document: "
                                   (directory-files
                                    (if prevp prev-tax-file current-tax-file) t)))))

By adding the completing-read, I get a list of the files and merely have to pick the correct one. That makes the entry faster while eliminating the errors I kept making with the old version.

If I call save-receipt-link with the universal argument, I will use last year’s directory instead of the current year’s. That eliminates the confusion at the change of year.

None of this is going to make dealing with taxes pleasurable, of course, but it does make it a little easier.

This entry was posted in General and tagged . Bookmark the permalink.