all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: ledger, add-entry
Date: Tue, 04 May 2010 20:13:11 +0200	[thread overview]
Message-ID: <8739y7o7rc.fsf@tux.homenetwork> (raw)
In-Reply-To: 87y6hrrtlz.fsf@online.de

henry atting <nsmp_01@online.de> writes:

> Maybe someone can answer this question here; since I have no google
> account the ledger group is inaccessible for me.
>
> When I add an entry to my ledger file (ledger-add-entry) a new entry
> will be created according to an older one with the same payee. As far as
> good but how can I suppress the price to be filled in either. As
> the price usually differs you always have to delete the old rate first.
>
> henry
Here functions i use here, they are for my personal use and work fine
here but no guarantee it will work on your side, adapt for yourself.
They use anything-comp-read that replace completing-read, so if you
don't use anything, replace anything-comp-read by completing-read.

,----
| (defun ledger-add-expense (date payee categorie type amount)
|   (interactive
|    (list (read-string "Date: " (tv-cur-date-string :separator "/"))
|          (read-string "Payee: ")
|          (anything-comp-read "Categorie: " (ledger-collect-categories))
|          (anything-comp-read "Type: " '("Visa" "Check" "Tip" "Prelevement"))
|          (read-string "Amount: ")))
|   (let (numcheck defnumcheck)
|     (with-current-buffer (find-file-noselect (getenv "LEDGER_FILE"))
|       (goto-char (point-max))
|       (when (string= type "Check")
|         (setq defnumcheck (save-excursion
|                             (when
|                                 (re-search-backward
|                                  "\\(^[0-9]\\{4\\}/[0-9/]*\\)\\(.*\\)\\(\([0-9]*\)\\)" nil t)
|                               (replace-regexp-in-string "\(\\|\)" "" (match-string 3)))))
|         (setq defnumcheck (int-to-string (1+ (string-to-number defnumcheck))))
|         (setq numcheck (read-string "CheckNumber: " defnumcheck)))
|       (insert (concat
|                date " " payee (or (and numcheck (concat " (" numcheck ")")) "") "\n    "
|                "Expenses:" categorie (make-string 8 ? ) "€ " amount "\n    "
|                "Liabilities:Socgen:" type "\n\n"))
|       (goto-char (point-min))
|       (ledger-align-device 1)
|       (save-buffer))))
| 
| (defun ledger-add-income (date payee categorie account amount)
|   (interactive
|    (list (read-string "Date: " (tv-cur-date-string :separator "/"))
|          (read-string "Payee: ")
|          (anything-comp-read "Categorie: " (ledger-collect-categories))
|          (anything-comp-read "Account: " '("Socgen:Checking")) ;; TODO add completion here
|          (read-string "Amount: ")))
|     (with-current-buffer (find-file-noselect (getenv "LEDGER_FILE"))
|       (goto-char (point-max))
|       (insert (concat
|                date " " payee "\n    "
|                "Assets:" account (make-string 8 ? ) "€ " amount "\n    "
|                "Income:" categorie "\n\n"))
|       (goto-char (point-min))
|       (ledger-align-device 1)
|       (save-buffer)))
| 
| (defun ledger-collect-categories ()
|   (let (categories result)
|     (with-current-buffer (find-file-noselect (getenv "LEDGER_FILE"))
|       (goto-char (point-min))
|       (while
|           (re-search-forward
|            "\\(^ *Expenses\\|Income\\):\\([^ €0-9\n]*\\)" (point-max) t)
|         (setq result (match-string 2))
|         (unless (or (member result categories)
|                     (string= result ""))
|           (push result categories))))
|     categories))
`----


-- 
Thierry Volpiatto
Gpg key: http://pgp.mit.edu/





      reply	other threads:[~2010-05-04 18:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-17 13:00 ledger, add-entry henry atting
2010-05-04 18:13 ` Thierry Volpiatto [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8739y7o7rc.fsf@tux.homenetwork \
    --to=thierry.volpiatto@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.