Show
Ignore:
Timestamp:
04/17/03 11:26:21 (21 years ago)
Author:
jalet
Message:

repykota now reports account balances too.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/repykota

    r927 r929  
    2323# 
    2424# $Log$ 
     25# Revision 1.27  2003/04/17 09:26:21  jalet 
     26# repykota now reports account balances too. 
     27# 
    2528# Revision 1.26  2003/04/16 12:35:49  jalet 
    2629# Groups quota work now ! 
     
    177180            print _("Pages grace time: %idays") % self.config.getGraceDelay(printer) 
    178181            total = 0 
     182            totalmoney = 0.0 
    179183            if options["groups"] : 
    180                 print _("Group            used     soft     hard   grace        total") 
    181                 print "------------------------------------------------------------" 
     184                print _("Group           used    soft    hard    balance grace         total       paid")  
     185                print "------------------------------------------------------------------------------" 
    182186                for (ident, name) in self.storage.getPrinterGroups(printerid) : 
    183187                    quota = self.storage.getGroupPQuota(ident, printerid)  
    184                     total += self.printQuota(name, quota) 
     188                    balance = self.storage.getGroupBalance(ident) 
     189                    limitby = self.storage.getGroupLimitBy(ident) 
     190                    (pages, money) = self.printQuota(name, quota, balance, limitby) 
     191                    total += pages 
     192                    totalmoney += money 
    185193            else : 
    186194                # default is user quota report 
    187                 print _("User             used     soft     hard   grace        total") 
    188                 print "------------------------------------------------------------" 
     195                print _("User            used    soft    hard    balance grace         total       paid")  
     196                print "------------------------------------------------------------------------------" 
    189197                for (ident, name) in self.storage.getPrinterUsers(printerid) : 
    190198                    quota = self.storage.getUserPQuota(ident, printerid) 
    191                     total += self.printQuota(name, quota) 
    192             if total :         
    193                 print (" " * 43) + (_("Total : %9i") % total) 
     199                    balance = self.storage.getUserBalance(ident) 
     200                    limitby = self.storage.getUserLimitBy(ident) 
     201                    (pages, money) = self.printQuota(name, quota, balance, limitby) 
     202                    total += pages 
     203                    totalmoney += money 
     204            if total or totalmoney :         
     205                print (" " * 50) + (_("Total : %9i") % total) + (" %-12.12s" % ("%7.2f" % totalmoney)[:12]) 
    194206            printerpagecounter = self.storage.getPrinterPageCounter(printerid) 
    195207            try : 
     
    197209            except TypeError :      
    198210                msg = _("unknown") 
    199             print (" " * 44) + (_("Real : %s") % msg) 
     211            print (" " * 51) + (_("Real : %s") % msg) 
    200212            print         
     213        if options["groups"] :     
     214            print _("Totals may be inaccurate if some users are members of several groups.") 
    201215                         
    202     def printQuota(self, name, quota) : 
     216    def printQuota(self, name, quota, balance, limitby) : 
    203217        """Prints the quota information.""" 
    204218        if quota is not None : 
     
    208222            hardlimit = quota["hardlimit"] 
    209223            datelimit = quota["datelimit"] 
     224            if balance is not None : 
     225                (balance, lifetimepaid) = balance 
     226            else :     
     227                (balance, lifetimepaid) = 0.0 
    210228            if datelimit is not None : 
    211229                now = DateTime.now() 
     
    215233            else :     
    216234                datelimit = "" 
    217             reached = ((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-" 
    218             print "%-10.10s %c %8i %8s %8s %10s %9i" % (name, reached, pagecounter, str(softlimit), str(hardlimit), str(datelimit)[:10], lifepagecounter) 
    219             return lifepagecounter 
     235            if limitby == "balance" :     
     236                reached = (((balance <= 0) and "+") or "-") + "B" 
     237            else : 
     238                reached = (((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-") + "Q" 
     239            strbalance = ("%5.2f" % balance)[:10] 
     240            strlifetimepaid = ("%6.2f" % lifetimepaid)[:11] 
     241            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) 
     242            return (lifepagecounter, lifetimepaid) 
    220243         
    221244