Index: /pykota/trunk/pykota/accounters/stupid.py
===================================================================
--- /pykota/trunk/pykota/accounters/stupid.py (revision 1200)
+++ /pykota/trunk/pykota/accounters/stupid.py (revision 1203)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.8  2003/11/23 19:01:37  jalet
+# Job price added to history
+#
 # Revision 1.7  2003/11/21 14:28:46  jalet
 # More complete job history.
@@ -109,5 +112,6 @@
         
         # adds the current job to history    
-        printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options)
+        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0)
+        printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options)
             
         return action
Index: /pykota/trunk/pykota/accounters/external.py
===================================================================
--- /pykota/trunk/pykota/accounters/external.py (revision 1200)
+++ /pykota/trunk/pykota/accounters/external.py (revision 1203)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.10  2003/11/23 19:01:36  jalet
+# Job price added to history
+#
 # Revision 1.9  2003/11/21 14:28:45  jalet
 # More complete job history.
@@ -107,5 +110,6 @@
         
         # adds the current job to history    
-        printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options)
+        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0)
+        printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options)
         
         self.endJob(printer, user)
Index: /pykota/trunk/pykota/storages/pgstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/pgstorage.py (revision 1200)
+++ /pykota/trunk/pykota/storages/pgstorage.py (revision 1203)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.23  2003/11/23 19:01:37  jalet
+# Job price added to history
+#
 # Revision 1.22  2003/11/21 14:28:46  jalet
 # More complete job history.
@@ -282,5 +285,5 @@
         """Extracts a printer's last job information."""
         lastjob = StorageLastJob(self, printer)
-        result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobdate FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident))
+        result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobprice, filename, title, copies, options, jobdate FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident))
         if result :
             fields = result[0]
@@ -290,5 +293,10 @@
             lastjob.PrinterPageCounter = fields.get("pagecounter")
             lastjob.JobSize = fields.get("jobsize")
+            lastjob.JobPrice = fields.get("jobprice")
             lastjob.JobAction = fields.get("action")
+            lastjob.JobFileName = fields.get("filename")
+            lastjob.JobTitle = fields.get("title")
+            lastjob.JobCopies = fields.get("copies")
+            lastjob.JobOptions = fields.get("options")
             lastjob.JobDate = fields.get("jobdate")
             lastjob.Exists = 1
@@ -446,18 +454,18 @@
            self.doModify("UPDATE users SET balance=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(user.ident)))
             
-    def writeLastJobSize(self, lastjob, jobsize) :        
+    def writeLastJobSize(self, lastjob, jobsize, jobprice) :        
         """Sets the last job's size permanently."""
-        self.doModify("UPDATE jobhistory SET jobsize=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(lastjob.ident)))
-        
-    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :    
+        self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident)))
+        
+    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) :    
         """Adds a job in a printer's history."""
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :
-                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options)))
+                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options)))
             else :    
                 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options)))
         else :        
             # here we explicitly want to reset jobsize to NULL if needed
-            self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobdate=now() WHERE id=%s;" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(printer.LastJob.ident)))
+            self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, jobdate=now() WHERE id=%s;" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(printer.LastJob.ident)))
             
     def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) :
Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 1200)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 1203)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.37  2003/11/23 19:01:37  jalet
+# Job price added to history
+#
 # Revision 1.36  2003/11/21 14:28:46  jalet
 # More complete job history.
@@ -407,5 +410,5 @@
             lastjob.lastjobident = result[0][0]
             lastjobident = result[0][1]["pykotaLastJobIdent"][0]
-            result = self.doSearch("objectClass=pykotaJob", ["pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE)
+            result = self.doSearch("objectClass=pykotaJob", ["pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE)
             if result :
                 fields = result[0][1]
@@ -415,5 +418,10 @@
                 lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter")[0] or 0)
                 lastjob.JobSize = int(fields.get("pykotaJobSize", [0])[0])
+                lastjob.JobPrice = float(fields.get("pykotaJobPrice", [0.0])[0])
                 lastjob.JobAction = fields.get("pykotaAction")[0]
+                lastjob.JobFileName = fields.get("pykotaFileName")[0]
+                lastjob.JobTitle = fields.get("pykotaTitle")[0]
+                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0])
+                lastjob.JobOptions = fields.get("pykotaOptions")[0]
                 date = fields.get("createTimestamp")[0]
                 year = int(date[:4])
@@ -686,12 +694,13 @@
         return self.doModify(user.idbalance, fields)         
             
-    def writeLastJobSize(self, lastjob, jobsize) :        
+    def writeLastJobSize(self, lastjob, jobsize, jobprice) :        
         """Sets the last job's size permanently."""
         fields = {
                    "pykotaJobSize" : str(jobsize),
+                   "pykotaJobPrice" : str(jobprice),
                  }
         self.doModify(lastjob.ident, fields)         
         
-    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :    
+    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) :
         """Adds a job in a printer's history."""
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
@@ -716,9 +725,9 @@
         if (not self.disablehistory) or (not printer.LastJob.Exists) :
             if jobsize is not None :         
-                fields.update({ "pykotaJobSize" : str(jobsize) })
+                fields.update({ "pykotaJobSize" : str(jobsize), "pykotaJobPrice" : str(jobprice) })
             self.doAdd(dn, fields)
         else :    
             # here we explicitly want to reset jobsize to 'None' if needed
-            fields.update({ "pykotaJobSize" : str(jobsize) })
+            fields.update({ "pykotaJobSize" : str(jobsize), "pykotaJobPrice" : str(jobprice) })
             self.doModify(dn, fields)
             
Index: /pykota/trunk/pykota/storage.py
===================================================================
--- /pykota/trunk/pykota/storage.py (revision 1200)
+++ /pykota/trunk/pykota/storage.py (revision 1203)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.27  2003/11/23 19:01:36  jalet
+# Job price added to history
+#
 # Revision 1.26  2003/11/21 14:28:45  jalet
 # More complete job history.
@@ -214,7 +217,7 @@
         self.LastJob = None
         
-    def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :    
+    def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) :
         """Adds a job to the printer's history."""
-        self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, filename, title, copies, options)
+        self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options)
         # TODO : update LastJob object ? Probably not needed.
         
@@ -314,9 +317,16 @@
         self.JobAction = None
         self.JobDate = None
+        self.JobPrice = None
+        self.JobFileName = None
+        self.JobTitle = None
+        self.JobCopies = None
+        self.JobOptions = None
         
     def setSize(self, jobsize) :
         """Sets the last job's size."""
-        self.parent.writeLastJobSize(self, jobsize)
+        jobprice = (float(self.Printer.PricePerPage or 0.0) * jobsize) + float(self.Printer.PricePerJob or 0.0)
+        self.parent.writeLastJobSize(self, jobsize, jobprice)
         self.JobSize = jobsize
+        self.JobPrice = jobprice
     
 class BaseStorage :
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 1200)
+++ /pykota/trunk/pykota/version.py (revision 1203)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.16alpha11_unofficial"
+__version__ = "1.16alpha12_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/bin/cupspykota
===================================================================
--- /pykota/trunk/bin/cupspykota (revision 1200)
+++ /pykota/trunk/bin/cupspykota (revision 1203)
@@ -24,4 +24,7 @@
 #
 # $Log$
+# Revision 1.13  2003/11/23 19:01:35  jalet
+# Job price added to history
+#
 # Revision 1.12  2003/11/21 14:28:43  jalet
 # More complete job history.
@@ -357,4 +360,5 @@
     # update the quota for the current user on this printer 
     if printer.Exists :
+        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0)
         if jobsize :
             userquota = thebackend.storage.getUserPQuota(user, printer)
@@ -363,5 +367,5 @@
         
         # adds the current job to history    
-        printer.addJobToHistory(thebackend.jobid, user, thebackend.accounter.getLastPageCounter(), action, jobsize, thebackend.preserveinputfile, thebackend.title, thebackend.copies, thebackend.options)
+        printer.addJobToHistory(thebackend.jobid, user, thebackend.accounter.getLastPageCounter(), action, jobsize, jobprice, thebackend.preserveinputfile, thebackend.title, thebackend.copies, thebackend.options)
     
     return retcode # return (retcode or gotSigTerm) shouldn't be needed
Index: /pykota/trunk/initscripts/ldap/pykota.schema
===================================================================
--- /pykota/trunk/initscripts/ldap/pykota.schema (revision 1200)
+++ /pykota/trunk/initscripts/ldap/pykota.schema (revision 1203)
@@ -163,4 +163,10 @@
         SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
         
+# pykotaJobPrice
+attributetype ( 1.3.6.1.4.1.16868.1.1.23 NAME 'pykotaJobPrice'
+        DESC 'Price of a particular job in the history, float'
+        EQUALITY caseIgnoreIA5Match
+        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
+
 #        
 # PyKota Object Classes
@@ -201,5 +207,5 @@
         DESC 'An entry in the job history for a printer'
         MUST ( cn $ pykotaUserName $ pykotaPrinterName $ pykotaJobId )
-        MAY  ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions ) )
+        MAY  ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaJobPrice $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions ) )
         
 # pykotaAccountBalance
Index: /pykota/trunk/initscripts/postgresql/README.postgresql
===================================================================
--- /pykota/trunk/initscripts/postgresql/README.postgresql (revision 1200)
+++ /pykota/trunk/initscripts/postgresql/README.postgresql (revision 1203)
@@ -69,6 +69,6 @@
     This script adds some fields to the print job history, so that
     more complete information will be known. The fields that
-    are added are : filename, title, copies and print command options.
-    Also some indexes are created to speed things up.
+    are added are : jobprice, filename, title, copies and print 
+    command options. Also some indexes are created to speed things up.
   
 What is below is for historical reasons only, real people don't use  
Index: /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql
===================================================================
--- /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1200)
+++ /pykota/trunk/initscripts/postgresql/pykota-postgresql.sql (revision 1203)
@@ -20,4 +20,7 @@
 --
 -- $Log$
+-- Revision 1.6  2003/11/23 19:01:36  jalet
+-- Job price added to history
+--
 -- Revision 1.5  2003/11/21 14:28:45  jalet
 -- More complete job history.
@@ -111,4 +114,5 @@
                         pagecounter INT4 DEFAULT 0,
                         jobsize INT4,
+                        jobprice FLOAT,
                         action TEXT,
                         filename TEXT,
Index: /pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql
===================================================================
--- /pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql (revision 1201)
+++ /pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql (revision 1203)
@@ -20,4 +20,7 @@
 --
 -- $Log$
+-- Revision 1.2  2003/11/23 19:01:36  jalet
+-- Job price added to history
+--
 -- Revision 1.1  2003/11/21 14:29:14  jalet
 -- Forgot to add this file...
@@ -39,4 +42,5 @@
 -- Modify the old database schema
 --
+ALTER TABLE jobhistory ADD COLUMN jobprice FLOAT;
 ALTER TABLE jobhistory ADD COLUMN filename TEXT;
 ALTER TABLE jobhistory ADD COLUMN title TEXT;
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1200)
+++ /pykota/trunk/NEWS (revision 1203)
@@ -22,4 +22,12 @@
 PyKota NEWS :
 
+    - 1.16alpha12 :
+    
+        - Job price added to job history, to keep accounting correct
+          if a printer price per page or per job is modified and the
+          history is not reset : the history would have given a false
+          amount of money charged before the printer's prices were
+          modified, this addition solves the problem.
+          
     - 1.16alpha11 :
     
