Changeset 1285
- Timestamp:
- 01/12/04 23:43:40 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1280 r1285 24 24 # 25 25 # $Log$ 26 # Revision 1.22 2004/01/12 22:43:40 jalet 27 # New formula to compute a job's price 28 # 26 29 # Revision 1.21 2004/01/12 18:17:36 jalet 27 30 # Denied jobs weren't stored into the history anymore, this is now fixed. … … 192 195 193 196 # update the quota for the current user on this printer 194 jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 195 if jobsize : 196 self.logdebug("Updating user %s's quota on printer %s" % (user.Name, printer.Name)) 197 userpquota.increasePagesUsage(jobsize) 197 self.logdebug("Updating user %s's quota on printer %s" % (user.Name, printer.Name)) 198 jobprice = userpquota.increasePagesUsage(jobsize) 198 199 199 200 # adds the current job to history -
pykota/trunk/bin/pykotme
r1257 r1285 24 24 # 25 25 # $Log$ 26 # Revision 1.7 2004/01/12 22:43:40 jalet 27 # New formula to compute a job's price 28 # 26 29 # Revision 1.6 2004/01/08 14:10:32 jalet 27 30 # Copyright year changed. … … 157 160 print _("Job size : %i pages") % nbpages 158 161 for printer in printers : 159 cost = (nbpages * float(printer.PricePerPage or 0)) + float(printer.PricePerJob or 0) 162 userpquota = self.storage.getUserPQuota(user, printer) 163 cost = userpquota.computeJobPrice(nbpages) 160 164 print _("Cost on printer %s : %.2f") % (printer.Name, cost) 161 165 -
pykota/trunk/NEWS
r1284 r1285 22 22 PyKota NEWS : 23 23 24 - 1.16alpha26 : 25 26 - Job price is now computed like this : 27 28 SUM((NbPages * PricePerPage) + PricePerJob) 29 30 For current printer and all the printers groups it is 31 a member of. 32 33 This may be difficult to grasp, but offers unprecedented 34 flexibility. 35 24 36 - 1.16alpha25 : 25 37 -
pykota/trunk/pykota/accounter.py
r1272 r1285 22 22 # 23 23 # $Log$ 24 # Revision 1.13 2004/01/12 22:43:40 jalet 25 # New formula to compute a job's price 26 # 24 27 # Revision 1.12 2004/01/11 23:43:31 jalet 25 28 # Bug wrt number of copies with CUPS should be fixed. … … 131 134 132 135 # adds the current job to history 133 jobprice = (float(userpquota.Printer.PricePerPage or 0.0) * jobsize) + float(userpquota.Printer.PricePerJob or 0.0)136 jobprice = userpquota.computeJobPrice(jobsize) 134 137 userpquota.Printer.addJobToHistory(self.filter.jobid, userpquota.User, self.getLastPageCounter(), action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 135 138 self.endJob(userpquota) -
pykota/trunk/pykota/storage.py
r1274 r1285 22 22 # 23 23 # $Log$ 24 # Revision 1.38 2004/01/12 22:43:40 jalet 25 # New formula to compute a job's price 26 # 24 27 # Revision 1.37 2004/01/12 14:35:01 jalet 25 28 # Printing history added to CGI script. … … 300 303 self.PageCounter = 0 301 304 302 def increasePagesUsage(self, nbpages) : 305 def computeJobPrice(self, jobsize) : 306 """Computes the job price as the sum of all parent printers' prices + current printer's ones.""" 307 totalprice = 0.0 308 if jobsize : 309 for upq in [ self ] + self.ParentPrintersUserPQuota : 310 price = (float(upq.Printer.PricePerPage or 0.0) * jobsize) + float(upq.Printer.PricePerJob or 0.0) 311 totalprice += price 312 return totalprice 313 314 def increasePagesUsage(self, jobsize) : 303 315 """Increase the value of used pages and money.""" 304 jobprice = (float(self.Printer.PricePerPage or 0.0) * nbpages) + float(self.Printer.PricePerJob or 0.0)305 self.parent.beginTransaction()306 try :307 if nbpages:316 jobprice = self.computeJobPrice(jobsize) 317 if jobsize : 318 self.parent.beginTransaction() 319 try : 308 320 self.User.consumeAccountBalance(jobprice) 309 321 for upq in [ self ] + self.ParentPrintersUserPQuota : 310 self.parent.increaseUserPQuotaPagesCounters(upq, nbpages) 311 upq.PageCounter = int(upq.PageCounter or 0) + nbpages 312 upq.LifePageCounter = int(upq.LifePageCounter or 0) + nbpages 313 except PyKotaStorageError, msg : 314 self.parent.rollbackTransaction() 315 raise PyKotaStorageError, msg 316 else : 317 self.parent.commitTransaction() 322 self.parent.increaseUserPQuotaPagesCounters(upq, jobsize) 323 upq.PageCounter = int(upq.PageCounter or 0) + jobsize 324 upq.LifePageCounter = int(upq.LifePageCounter or 0) + jobsize 325 except PyKotaStorageError, msg : 326 self.parent.rollbackTransaction() 327 raise PyKotaStorageError, msg 328 else : 329 self.parent.commitTransaction() 330 return jobprice 318 331 319 332 class StorageGroupPQuota(StorageObject) : … … 366 379 def setSize(self, jobsize) : 367 380 """Sets the last job's size.""" 368 jobprice = (float(self.Printer.PricePerPage or 0.0) * jobsize) + float(self.Printer.PricePerJob or 0.0)381 jobprice = self.parent.getUserPQuota(self.User, self.Printer).computeJobPrice(jobsize) 369 382 self.parent.writeLastJobSize(self, jobsize, jobprice) 370 383 self.JobSize = jobsize -
pykota/trunk/pykota/version.py
r1284 r1285 22 22 # 23 23 24 __version__ = "1.16alpha2 5_unofficial"24 __version__ = "1.16alpha26_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""