Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

moneylog.el
Thursday, October 1st, 2009 at 8:05:07pm MDT 

  1. ;;; moneylog.el --- Provide a way to enter moneylog logs
  2.  
  3. ;; Copyright (C) 2009  Leslie Harlley Watter
  4.  
  5. ;; Author: Leslie Harlley Watter <leslie@watter.org>
  6. ;; Keywords:
  7.  
  8. ;; This file is free software; you can redistribute it and/or modify
  9. ;; it under the terms of the GNU General Public License as published by
  10. ;; the Free Software Foundation; either version 3, or (at your option)
  11. ;; any later version.
  12.  
  13. ;; This file is distributed in the hope that it will be useful,
  14. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ;; GNU General Public License for more details.
  17.  
  18. ;; You should have received a copy of the GNU General Public License
  19. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  20. ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. ;; Boston, MA 02110-1301, USA.
  22.  
  23. ;;; Commentary:
  24.  
  25. ;; This file should be used with moneylog (www.aurelio.net/moneylog)
  26.  
  27. ;;; Code:
  28.  
  29.  
  30.  
  31. (defun i-register (&optional tag)
  32.   "Inserts/format an account record. It should be used with moneylog
  33.    2009.08.15   -29.00     bicicleta    |  Mesa para a bicicleta"
  34.   (interactive)
  35. ;; pre-fills the today variable with today's date
  36.   (setq today (format-time-string "%Y-%m-%d"))
  37.   (setq rdata (read-string "Data (2009.06.15): " today ))
  38.   (unless (equal rdata "")
  39.   (setq rvalor (read-string "Valor (110.00 ou -110.00): "))
  40.   (unless (equal rvalor "")
  41.   (setq rtags (read-string "Tags (poupanca,visa,ccred): " tag))
  42.   (setq rcomentario (read-string "Comentario: "))
  43.   (unless (equal rcomentario "")
  44.     (insert (format "%s\t%s\t%s| %s\n" rdata rvalor rtags rcomentario )) ;
  45. ))))
  46.  
  47.  
  48.  
  49. (defun i-reg-ccredit (&optional tag)
  50.   "Inserts/format an account record. It should be used with moneylog
  51.    2009.08.15   -29.00     visa | Mesa para a bicicleta"
  52.   (interactive)
  53. ;; pre-fills the today variable with today's date
  54. ;; fechamento is the date where the credit card closes it's bills
  55.   (setq fechamento 7)
  56.   (setq diaspgtoaposfechamento 10)
  57.   (setq dia (string-to-number (format-time-string "%d")))
  58.   (if (<= dia fechamento)
  59.       (setq mes (format-time-string "%m"))
  60.       (setq mes (format "%02d" (% (+ (string-to-number (format-time-string "%m")) 1 ) 12 )))
  61.   )
  62.   (setq today (format "%s%s-%s" (format-time-string "%Y-") mes (+ fechamento diaspgtoaposfechamento) ))
  63.   (setq rdata (read-string "Data Vencimento (2009.06.15): " today ))
  64.   (unless (equal rdata "")
  65.   (setq rvalor (read-string "Valor (110.00 ou -110.00): "))
  66.   (unless (equal rvalor "")
  67.   (setq rtags (read-string "Tags (ccred): " tag))
  68.   (setq bdate (format-time-string "%m.%d"))
  69.   (setq rdatacompra (read-string "Data compra (mm.dd): " bdate))
  70.   (unless (equal rdatacompra "")
  71.   (setq rcomentario (read-string "Comentario: "))
  72.   (unless (equal rcomentario "")
  73.   (setq atual (point))
  74.   (goto-char (point-max))
  75.   (goto-char (if (equal (search-backward rdata (point-min) t) nil)
  76.                                  atual
  77.                            (search-backward rdata (point-min))
  78.                            ))
  79.   (beginning-of-line)
  80.   (forward-line 2)
  81.     (insert (format "%s\t%s\t%s| @%s %s\n" rdata rvalor rtags rdatacompra rcomentario )) ;
  82. )))))
  83.  
  84.  
  85. (defun i-reg-gas ()
  86.   "Inserts/format a gas account record. It should be used with moneylog"
  87.   (interactive)
  88. ;; prefills month variable to be concatenated to default tags
  89.   (setq fechamento 7)
  90.   (setq diaspgtoaposfechamento 10)
  91.   (setq dia (string-to-number (format-time-string "%d")))
  92.   (if (<= dia fechamento)
  93.       (setq mes (format-time-string "%m"))
  94.       (setq mes (format "%02d" (% (+ (string-to-number (format-time-string "%m")) 1 ) 12 )))
  95.   )
  96. ;; here starts the real gas function
  97.   (setq tiporeg (read-string "tipo Registro (C|I) (Credito/Imediato): "))
  98.   (unless (equal tiporeg "")
  99.   (if (equal tiporeg "C")
  100.           (i-reg-ccredit (concat (concat "ccred" mes) ", posto, "))
  101.         (i-register (concat (concat "ccred" mes) ", posto, "))
  102.         )
  103.   (setq odomtotal (read-string "Odometro Total: "))
  104.   (unless (equal odomtotal "")
  105.   (setq odomparc (read-string "Odometro Parcial: "))
  106.   (unless (equal odomparc "")
  107.   (setq litabast (read-string "Litros Abastecidos: "))
  108.   (unless (equal litabast "")
  109.   (setq precolitro (read-string "Preço por Litro: "))
  110.   (unless (equal precolitro "")
  111.   (setq kmporlitro (number-to-string (/ (string-to-number odomparc)(string-to-number litabast))))
  112.   (setq tipogas (read-string "Tipo ( aditivada / comum ): "))
  113.   (unless (equal tipogas "")
  114.         (backward-char 1)
  115.     (insert (format " otot}%s} opar(%s) l{%s{ R/l$%s$ km/l _%s_ %s \n"  odomtotal odomparc litabast  precolitro (substring kmporlitro 0 6) tipogas )) ;
  116. )))))))
  117.  
  118.  
  119. (defun i-atualiza-dados-dev ()
  120.   "Atualiza os dados no arquivo moneylog.txt em ../moneylog-dev/."
  121.   (interactive)
  122.   (goto-char (point-min))
  123.   (search-forward "## começo")
  124.    ; grab the current line
  125.   (beginning-of-line)
  126.   (setq myStartPos (line-beginning-position))
  127.  
  128.   (goto-char (point-min))
  129.   (search-forward "## fim")
  130.   ; grab the current line
  131.   (end-of-line)
  132.   (setq myEndPos (line-end-position))
  133.   ; get the strings between start and end point
  134.   (setq myStr (buffer-substring myStartPos myEndPos))
  135. ;;  (message "%s" myStr)
  136.   (pop-to-buffer (find-file-noselect "../moneylog-dev/moneylog.txt"))
  137.  
  138.   (goto-char (point-min))
  139.   (search-forward "## começo")
  140.    ; grab the current line
  141.   (beginning-of-line)
  142.   (setq myStartPos2 (line-beginning-position))
  143.  
  144.   (goto-char (point-min))
  145.   (search-forward "## fim")
  146.   ; grab the current line
  147.   (end-of-line)
  148.   (setq myEndPos2 (line-end-position))
  149.   ;; delete the region
  150.   (delete-region myStartPos2 myEndPos2)
  151.   (goto-char myStartPos2)
  152.   (insert myStr)
  153.   (basic-save-buffer)
  154.   (message "Arquivo Atualizado" )
  155. )
  156.  
  157. (provide 'moneylog)
  158. ;;; moneylog.el ends here

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

fantasy-obligation