* ledger, add-entry
@ 2010-03-17 13:00 henry atting
2010-05-04 18:13 ` Thierry Volpiatto
0 siblings, 1 reply; 2+ messages in thread
From: henry atting @ 2010-03-17 13:00 UTC (permalink / raw)
To: help-gnu-emacs
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
--
http://literaturlatenight.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: ledger, add-entry
2010-03-17 13:00 ledger, add-entry henry atting
@ 2010-05-04 18:13 ` Thierry Volpiatto
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Volpiatto @ 2010-05-04 18:13 UTC (permalink / raw)
To: help-gnu-emacs
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-04 18:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-17 13:00 ledger, add-entry henry atting
2010-05-04 18:13 ` Thierry Volpiatto
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.