Index: pykota/trunk/pykota/storage.py
===================================================================
--- pykota/trunk/pykota/storage.py (revision 3445)
+++ pykota/trunk/pykota/storage.py (revision 3470)
@@ -475,21 +475,4 @@
     def refund(self, reason) :
         """Refund a particular print job."""
-        if (not self.JobSize) or (self.JobAction in ("DENY", "CANCEL", "REFUND")) :
-            return
-        try :
-            loginname = os.getlogin()
-        except OSError :
-            import pwd
-            loginname = pwd.getpwuid(os.getuid()).pw_name
-        basereason = _("Refunded %i pages and %.3f credits by %s (%s) on %s") \
-                        % (self.JobSize,
-                           self.JobPrice,
-                           self.parent.tool.effectiveUserName,
-                           loginname,
-                           str(DateTime.now())[:19])
-        if reason :
-            reason = "%s : %s" % (basereason, reason)
-        else :
-            reason = basereason
         self.parent.tool.logdebug("Refunding job %s..." % self.ident)
         self.parent.beginTransaction()
Index: pykota/trunk/bin/pkrefund
===================================================================
--- pykota/trunk/bin/pkrefund (revision 3434)
+++ pykota/trunk/bin/pkrefund (revision 3470)
@@ -29,4 +29,6 @@
 import time
 import cStringIO
+
+from mx import DateTime
 
 try :
@@ -236,4 +238,8 @@
                                             end=end,
                                             limit=0)
+        try :
+            loginname = os.getlogin()
+        except OSError :
+            loginname = pwd.getpwuid(os.getuid()).pw_name
 
         peruser = {}
@@ -246,11 +252,26 @@
         for job in jobs :
             if job.JobSize and (job.JobAction not in ("DENY", "CANCEL", "REFUND")) :
+                if options.info :
+                    reason = "%s : %s" % (options.info % { "nbpages" : job.JobSize,
+                                                           "nbcredits" : job.JobPrice,
+                                                           "effectiveuser" : self.effectiveUserName,
+                                                           "loginname" : loginname,
+                                                           "date" : str(DateTime.now())[:19],
+                                                         },
+                                          options.reason)
+                else :
+                    reason = options.reason
+
                 if options.force :
                     nbpages += job.JobSize
                     nbcredits += job.JobPrice
-                    counters = peruser.setdefault(job.UserName, { "nbjobs" : 0, "nbpages" : 0, "nbcredits" : 0.0 })
+                    counters = peruser.setdefault(job.UserName,
+                                                  { "nbjobs" : 0,
+                                                    "nbpages" : 0,
+                                                    "nbcredits" : 0.0,
+                                                  })
                     counters["nbpages"] += job.JobSize
                     counters["nbcredits"] += job.JobPrice
-                    job.refund(options.reason)
+                    job.refund(reason)
                     counters["nbjobs"] += 1
                     nbjobs += 1
@@ -273,8 +294,12 @@
                             nbpages += job.JobSize
                             nbcredits += job.JobPrice
-                            counters = peruser.setdefault(job.UserName, { "nbjobs" : 0, "nbpages" : 0, "nbcredits" : 0.0 })
+                            counters = peruser.setdefault(job.UserName,
+                                                          { "nbjobs" : 0,
+                                                            "nbpages" : 0,
+                                                            "nbcredits" : 0.0,
+                                                          })
                             counters["nbpages"] += job.JobSize
                             counters["nbcredits"] += job.JobPrice
-                            job.refund(options.reason)
+                            job.refund(reason)
                             counters["nbjobs"] += 1
                             nbjobs += 1
@@ -282,5 +307,5 @@
                         elif answer == _("N") :
                             break
-                    print
+                    sys.stdout.write("\n")
         if outfname != "-" :
             percent.done()
@@ -289,5 +314,5 @@
                          outfname,
                          options.number,
-                         options.reason,
+                         options.reason, # We don't want the full reason here.
                          options.unit or _("Credits"))
         if outfname != "-" :
@@ -302,16 +327,14 @@
                             dest="force",
                             action="store_true",
-                            help=_("Doesn't ask for confirmation before refunding."))
+                            help=_("Doesn't ask for confirmation before refunding. Only needed if you specify a filename for the PDF receipts. If you send such receipts to stdout, --force is assumed to be set."))
+    parser.add_option("-i", "--info",
+                            dest="info",
+                            type="string",
+                            default=_("Refunded %(nbpages)i pages and %(nbcredits).3f credits by %(effectiveuser)s (%(loginname)s) on %(date)s"),
+                            help=_("The informations to be prepended to the refunding reason, which can include some of Python's string interpolations to access to certain internal values. If you don't want such information, set this explicitely to an empty string. The default is '''%default'''"))
     parser.add_option("-l", "--logo",
                             dest="logo",
                             default=u"/usr/share/pykota/logos/pykota.jpeg",
                             help=_("The image to use as a logo. The logo will be drawn at the center top of the page. The default logo is %default."))
-    parser.add_option("-p", "--pagesize",
-                            type="string",
-                            action="callback",
-                            callback=checkandset_pagesize,
-                            dest="pagesize",
-                            default=u"A4",
-                            help=_("Set the size of the page. Most well known page sizes are recognized, like 'A4' or 'Letter' to name a few. The default page size is %default."))
     parser.add_option("-n", "--number",
                             dest="number",
@@ -325,5 +348,12 @@
                             type="string",
                             default=u"-",
-                            help=_("The name of the file to which the PDF receipts will be written. If not set or set to '%default', the PDF document will be sent to the standard output."))
+                            help=_("The name of the file to which the PDF receipts will be written. If not set or set to '%default', the PDF document will be sent to the standard output, and --force will be assumed to be set."))
+    parser.add_option("-p", "--pagesize",
+                            type="string",
+                            action="callback",
+                            callback=checkandset_pagesize,
+                            dest="pagesize",
+                            default=u"A4",
+                            help=_("Set the size of the page. Most well known page sizes are recognized, like 'A4' or 'Letter' to name a few. The default page size is %default."))
     parser.add_option("-r", "--reason",
                             dest="reason",
