Index: /pykota/trunk/pykota/tool.py
===================================================================
--- /pykota/trunk/pykota/tool.py (revision 927)
+++ /pykota/trunk/pykota/tool.py (revision 929)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.34  2003/04/17 09:26:21  jalet
+# repykota now reports account balances too.
+#
 # Revision 1.33  2003/04/16 12:35:49  jalet
 # Groups quota work now !
@@ -306,4 +309,5 @@
             else :    
                 # TODO : there's no warning (no account balance soft limit)
+                (balance, lifetimepaid) = balance
                 if balance <= 0.0 :
                     action = "DENY"
@@ -381,4 +385,5 @@
             else :    
                 # TODO : there's no warning (no account balance soft limit)
+                (balance, lifetimepaid) = balance
                 if balance <= 0.0 :
                     action = "DENY"
Index: /pykota/trunk/pykota/storages/sql.py
===================================================================
--- /pykota/trunk/pykota/storages/sql.py (revision 927)
+++ /pykota/trunk/pykota/storages/sql.py (revision 929)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.28  2003/04/17 09:26:21  jalet
+# repykota now reports account balances too.
+#
 # Revision 1.27  2003/04/16 12:35:49  jalet
 # Groups quota work now !
@@ -254,17 +257,21 @@
     def getUserBalance(self, userid) :    
         """Returns the current account balance for a given user."""
-        result = self.doQuery("SELECT balance FROM users WHERE id=%s" % self.doQuote(userid))
-        try :
-            return self.doParseResult(result)[0]["balance"]
-        except TypeError :      # Not found    
-            return
+        result = self.doQuery("SELECT balance, lifetimepaid FROM users WHERE id=%s" % self.doQuote(userid))
+        try :
+            result = self.doParseResult(result)[0]
+        except TypeError :      # Not found    
+            return
+        else :    
+            return (result["balance"], result["lifetimepaid"])
         
     def getGroupBalance(self, groupid) :    
         """Returns the current account balance for a given group, as the sum of each of its users' account balance."""
-        result = self.doQuery("SELECT SUM(balance) AS balance FROM users WHERE id in (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(groupid))
-        try :
-            return self.doParseResult(result)[0]["balance"]
-        except TypeError :      # Not found    
-            return
+        result = self.doQuery("SELECT SUM(balance) AS balance, SUM(lifetimepaid) AS lifetimepaid FROM users WHERE id in (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(groupid))
+        try :
+            result = self.doParseResult(result)[0]
+        except TypeError :      # Not found    
+            return
+        else :    
+            return (result["balance"], result["lifetimepaid"])
         
     def getUserLimitBy(self, userid) :    
@@ -286,5 +293,5 @@
     def setUserBalance(self, userid, balance) :    
         """Sets the account balance for a given user to a fixed value."""
-        current = self.getUserBalance(userid)
+        (current, lifetimepaid) = self.getUserBalance(userid)
         difference = balance - current
         self.increaseUserBalance(userid, difference)
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 927)
+++ /pykota/trunk/pykota/version.py (revision 929)
@@ -21,5 +21,5 @@
 #
 
-__version__ = "1.03beta-unofficial"
+__version__ = "1.03beta2-unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS."""
Index: /pykota/trunk/bin/repykota
===================================================================
--- /pykota/trunk/bin/repykota (revision 927)
+++ /pykota/trunk/bin/repykota (revision 929)
@@ -23,4 +23,7 @@
 #
 # $Log$
+# Revision 1.27  2003/04/17 09:26:21  jalet
+# repykota now reports account balances too.
+#
 # Revision 1.26  2003/04/16 12:35:49  jalet
 # Groups quota work now !
@@ -177,19 +180,28 @@
             print _("Pages grace time: %idays") % self.config.getGraceDelay(printer)
             total = 0
+            totalmoney = 0.0
             if options["groups"] :
-                print _("Group            used     soft     hard   grace        total")
-                print "------------------------------------------------------------"
+                print _("Group           used    soft    hard    balance grace         total       paid") 
+                print "------------------------------------------------------------------------------"
                 for (ident, name) in self.storage.getPrinterGroups(printerid) :
                     quota = self.storage.getGroupPQuota(ident, printerid) 
-                    total += self.printQuota(name, quota)
+                    balance = self.storage.getGroupBalance(ident)
+                    limitby = self.storage.getGroupLimitBy(ident)
+                    (pages, money) = self.printQuota(name, quota, balance, limitby)
+                    total += pages
+                    totalmoney += money
             else :
                 # default is user quota report
-                print _("User             used     soft     hard   grace        total")
-                print "------------------------------------------------------------"
+                print _("User            used    soft    hard    balance grace         total       paid") 
+                print "------------------------------------------------------------------------------"
                 for (ident, name) in self.storage.getPrinterUsers(printerid) :
                     quota = self.storage.getUserPQuota(ident, printerid)
-                    total += self.printQuota(name, quota)
-            if total :        
-                print (" " * 43) + (_("Total : %9i") % total)
+                    balance = self.storage.getUserBalance(ident)
+                    limitby = self.storage.getUserLimitBy(ident)
+                    (pages, money) = self.printQuota(name, quota, balance, limitby)
+                    total += pages
+                    totalmoney += money
+            if total or totalmoney :        
+                print (" " * 50) + (_("Total : %9i") % total) + (" %-12.12s" % ("%7.2f" % totalmoney)[:12])
             printerpagecounter = self.storage.getPrinterPageCounter(printerid)
             try :
@@ -197,8 +209,10 @@
             except TypeError :     
                 msg = _("unknown")
-            print (" " * 44) + (_("Real : %s") % msg)
+            print (" " * 51) + (_("Real : %s") % msg)
             print        
+        if options["groups"] :    
+            print _("Totals may be inaccurate if some users are members of several groups.")
                         
-    def printQuota(self, name, quota) :
+    def printQuota(self, name, quota, balance, limitby) :
         """Prints the quota information."""
         if quota is not None :
@@ -208,4 +222,8 @@
             hardlimit = quota["hardlimit"]
             datelimit = quota["datelimit"]
+            if balance is not None :
+                (balance, lifetimepaid) = balance
+            else :    
+                (balance, lifetimepaid) = 0.0
             if datelimit is not None :
                 now = DateTime.now()
@@ -215,7 +233,12 @@
             else :    
                 datelimit = ""
-            reached = ((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-"
-            print "%-10.10s %c %8i %8s %8s %10s %9i" % (name, reached, pagecounter, str(softlimit), str(hardlimit), str(datelimit)[:10], lifepagecounter)
-            return lifepagecounter
+            if limitby == "balance" :    
+                reached = (((balance <= 0) and "+") or "-") + "B"
+            else :
+                reached = (((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-") + "Q"
+            strbalance = ("%5.2f" % balance)[:10]
+            strlifetimepaid = ("%6.2f" % lifetimepaid)[:11]
+            print "%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %-11.11s" % (name, reached, pagecounter, str(softlimit), str(hardlimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid)
+            return (lifepagecounter, lifetimepaid)
         
                     
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 927)
+++ /pykota/trunk/NEWS (revision 929)
@@ -22,4 +22,8 @@
 PyKota NEWS :
 
+    - 1.03beta2 :
+    
+        -  repykota now reports account balances too.
+        
     - 1.03beta :
     
Index: /pykota/trunk/po/en/pykota.po
===================================================================
--- /pykota/trunk/po/en/pykota.po (revision 927)
+++ /pykota/trunk/po/en/pykota.po (revision 929)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.19  2003/04/17 09:26:21  jalet
+# repykota now reports account balances too.
+#
 # Revision 1.18  2003/04/16 12:35:49  jalet
 # Groups quota work now !
@@ -145,5 +148,5 @@
 msgstr ""
 
-msgid "Group            used     soft     hard   grace        total"
+msgid "Group           used    soft    hard    balance grace         total       paid"
 msgstr ""
 
@@ -160,5 +163,5 @@
 msgstr ""
 
-msgid "User             used     soft     hard   grace        total"
+msgid "User            used    soft    hard    balance grace         total       paid"
 msgstr ""
 
@@ -304,2 +307,5 @@
 "your group Print Quota is almost reached on printer %s."
 msgstr ""
+
+msgid "Totals may be inaccurate if some users are members of several groups."
+msgstr ""
Index: /pykota/trunk/po/fr/pykota.po
===================================================================
--- /pykota/trunk/po/fr/pykota.po (revision 927)
+++ /pykota/trunk/po/fr/pykota.po (revision 929)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.17  2003/04/17 09:26:21  jalet
+# repykota now reports account balances too.
+#
 # Revision 1.16  2003/04/16 12:35:49  jalet
 # Groups quota work now !
@@ -146,7 +149,6 @@
 msgstr "Valeur %s invalide pour la limite dure."
 
-msgid "Group            used     soft     hard   grace        total"
-msgstr "Groupe           used     soft     hard   grace        total"
-
+msgid  "Group           used    soft    hard    balance grace         total       paid"
+msgstr "Groupe          util    soft    hard    solde   gr�         total       pay�
 msgid "There's no printer matching %s"
 msgstr "Aucune imprimante ne correspond �s"
@@ -161,7 +163,6 @@
 msgstr "Nom de groupe %s invalide"
 
-msgid "User             used     soft     hard   grace        total"
-msgstr "Utilisateur      used     soft     hard   grace        total"
-
+msgid  "User            used    soft    hard    balance grace         total       paid"
+msgstr "Utilisateur     util    soft    hard    solde   gr�         total       pay�
 msgid "Invalid printer name %s"
 msgstr "Nom d'imprimante %s invalide"
@@ -316,2 +317,5 @@
 "Vous n'aurez bient�lus le droit d'imprimer car\n"
 "le Quota d'Impression de votre groupe sur l'imprimante %s est presque atteint."
+
+msgid "Totals may be inaccurate if some users are members of several groups."
+msgstr "Les totaux peuvent �e faux si des utilisateurs sont dans plusieurs groupes."
Index: /pykota/trunk/po/pykota.pot
===================================================================
--- /pykota/trunk/po/pykota.pot (revision 927)
+++ /pykota/trunk/po/pykota.pot (revision 929)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.19  2003/04/17 09:26:21  jalet
+# repykota now reports account balances too.
+#
 # Revision 1.18  2003/04/16 12:35:49  jalet
 # Groups quota work now !
@@ -145,5 +148,5 @@
 msgstr ""
 
-msgid "Group            used     soft     hard   grace        total"
+msgid "Group           used    soft    hard    balance grace         total       paid"
 msgstr ""
 
@@ -160,5 +163,5 @@
 msgstr ""
 
-msgid "User             used     soft     hard   grace        total"
+msgid "User            used    soft    hard    balance grace         total       paid"
 msgstr ""
 
@@ -304,2 +307,5 @@
 "your group Print Quota is almost reached on printer %s."
 msgstr ""
+
+msgid "Totals may be inaccurate if some users are members of several groups."
+msgstr ""
