[bknr-cvs] hans changed trunk/projects/poll-postbank/poll-postbank.lisp

BKNR Commits bknr at bknr.net
Thu Apr 16 16:42:38 UTC 2009


Revision: 4383
Author: hans
URL: http://bknr.net/trac/changeset/4383

snapshot
U   trunk/projects/poll-postbank/poll-postbank.lisp

Modified: trunk/projects/poll-postbank/poll-postbank.lisp
===================================================================
--- trunk/projects/poll-postbank/poll-postbank.lisp	2009-04-16 06:42:30 UTC (rev 4382)
+++ trunk/projects/poll-postbank/poll-postbank.lisp	2009-04-16 16:42:38 UTC (rev 4383)
@@ -1,5 +1,20 @@
 (in-package :poll-postbank)
 
+(defparameter *header-scanner* (cl-ppcre:create-scanner
+                                "Kontoumsätze Postbank Girokonto
+
+Name: (.*)
+BLZ: (.*)
+Kontonummer: (.*)
+IBAN: (.*)
+		
+Aktueller Kontostand:	(.*) Euro
+Summe vorgemerkter Umsätze:	(.*) Euro
+							
+Datum	Wertstellung	Art	Buchungshinweis	Auftraggeber	Empfänger	Betrag Euro	Saldo Euro"
+                                :multi-line-mode t))
+
+
 (defun poll-postbank (kontonummer password)
   (let ((headers (nth-value 2
                             (drakma:http-request "https://banking.postbank.de/app/login.do"
@@ -17,20 +32,27 @@
 (defun umsatz-xml (kontonummer password)
   (cxml:with-xml-output (cxml:make-character-stream-sink *standard-output*)
     (cxml:with-element "Kontostatus"
-      (let ((in-header t))
-        (cl-ppcre:do-matches-as-strings (line ".*(?>\\r?\\n)" (poll-postbank kontonummer password))
-          (cond
-            (in-header
-             (cond
-               ((cl-ppcre:scan "^Datum" line)
-                (setf in-header nil))))
-            (t
-             (cxml:with-element "Umsatz"
-               (loop
-                  for name in '("Datum" "Wertstellung" "Art" "Buchungshinweis" "Auftraggeber" "Empfaenger" "Betrag" "Saldo")
-                  for value in (cl-ppcre:split "\\t" line)
-                  do (cxml:with-element name
-                       (cxml:text value)))))))))))
+      (let ((status-string (poll-postbank kontonummer password)))
+        (cl-ppcre:do-register-groups (name blz kontonummer iban kontostand summe-vorgemerkt)
+            (*header-scanner* status-string)
+          (cxml:with-element "Name" (cxml:text name))
+          (cxml:with-element "BLZ" (cxml:text blz))
+          (cxml:with-element "Kontonummer" (cxml:text kontonummer))
+          (cxml:with-element "IBAN" (cxml:text iban))
+          (cxml:with-element "Kontostand" (cxml:text kontostand))
+          (cxml:with-element "SummeVorgemerkt" (cxml:text summe-vorgemerkt)))
+        #+(or)
+        (destructuring-bind (nothing bewegungen)
+            (cl-ppcre:split *header-scanner* status-string)
+          (declare (ignore nothing))
+          (cxml:with-element "Bewegungen"
+            (cl-ppcre:do-matches-as-strings (line ".*(?>\\r?\\n)" bewegungen)
+              (cxml:with-element "Umsatz"
+                (loop
+                   for name in '("Datum" "Wertstellung" "Art" "Buchungshinweis" "Auftraggeber" "Empfaenger" "Betrag" "Saldo")
+                   for value in (cl-ppcre:split "\\t" line)
+                   do (cxml:with-element name
+                        (cxml:text value)))))))))))
 
 (defun umsatz-plist (kontonummer password)
   )





More information about the Bknr-cvs mailing list