Changeset 1203

Show
Ignore:
Timestamp:
11/23/03 20:01:37 (21 years ago)
Author:
jalet
Message:

Job price added to history

Location:
pykota/trunk
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1200 r1203  
    2424# 
    2525# $Log$ 
     26# Revision 1.13  2003/11/23 19:01:35  jalet 
     27# Job price added to history 
     28# 
    2629# Revision 1.12  2003/11/21 14:28:43  jalet 
    2730# More complete job history. 
     
    357360    # update the quota for the current user on this printer  
    358361    if printer.Exists : 
     362        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 
    359363        if jobsize : 
    360364            userquota = thebackend.storage.getUserPQuota(user, printer) 
     
    363367         
    364368        # adds the current job to history     
    365         printer.addJobToHistory(thebackend.jobid, user, thebackend.accounter.getLastPageCounter(), action, jobsize, thebackend.preserveinputfile, thebackend.title, thebackend.copies, thebackend.options) 
     369        printer.addJobToHistory(thebackend.jobid, user, thebackend.accounter.getLastPageCounter(), action, jobsize, jobprice, thebackend.preserveinputfile, thebackend.title, thebackend.copies, thebackend.options) 
    366370     
    367371    return retcode # return (retcode or gotSigTerm) shouldn't be needed 
  • pykota/trunk/initscripts/ldap/pykota.schema

    r1200 r1203  
    163163        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 
    164164         
     165# pykotaJobPrice 
     166attributetype ( 1.3.6.1.4.1.16868.1.1.23 NAME 'pykotaJobPrice' 
     167        DESC 'Price of a particular job in the history, float' 
     168        EQUALITY caseIgnoreIA5Match 
     169        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) 
     170 
    165171#         
    166172# PyKota Object Classes 
     
    201207        DESC 'An entry in the job history for a printer' 
    202208        MUST ( cn $ pykotaUserName $ pykotaPrinterName $ pykotaJobId ) 
    203         MAY  ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions ) ) 
     209        MAY  ( pykotaPrinterPageCounter $ pykotaJobSize $ pykotaAction $ pykotaJobPrice $ pykotaFileName $ pykotaTitle $ pykotaCopies $ pykotaOptions ) ) 
    204210         
    205211# pykotaAccountBalance 
  • pykota/trunk/initscripts/postgresql/pykota-postgresql.sql

    r1200 r1203  
    2020-- 
    2121-- $Log$ 
     22-- Revision 1.6  2003/11/23 19:01:36  jalet 
     23-- Job price added to history 
     24-- 
    2225-- Revision 1.5  2003/11/21 14:28:45  jalet 
    2326-- More complete job history. 
     
    111114                        pagecounter INT4 DEFAULT 0, 
    112115                        jobsize INT4, 
     116                        jobprice FLOAT, 
    113117                        action TEXT, 
    114118                        filename TEXT, 
  • pykota/trunk/initscripts/postgresql/README.postgresql

    r1200 r1203  
    6969    This script adds some fields to the print job history, so that 
    7070    more complete information will be known. The fields that 
    71     are added are : filename, title, copies and print command options. 
    72     Also some indexes are created to speed things up. 
     71    are added are : jobprice, filename, title, copies and print  
     72    command options. Also some indexes are created to speed things up. 
    7373   
    7474What is below is for historical reasons only, real people don't use   
  • pykota/trunk/initscripts/postgresql/upgrade-to-1.16.sql

    r1201 r1203  
    2020-- 
    2121-- $Log$ 
     22-- Revision 1.2  2003/11/23 19:01:36  jalet 
     23-- Job price added to history 
     24-- 
    2225-- Revision 1.1  2003/11/21 14:29:14  jalet 
    2326-- Forgot to add this file... 
     
    3942-- Modify the old database schema 
    4043-- 
     44ALTER TABLE jobhistory ADD COLUMN jobprice FLOAT; 
    4145ALTER TABLE jobhistory ADD COLUMN filename TEXT; 
    4246ALTER TABLE jobhistory ADD COLUMN title TEXT; 
  • pykota/trunk/NEWS

    r1200 r1203  
    2222PyKota NEWS : 
    2323 
     24    - 1.16alpha12 : 
     25     
     26        - Job price added to job history, to keep accounting correct 
     27          if a printer price per page or per job is modified and the 
     28          history is not reset : the history would have given a false 
     29          amount of money charged before the printer's prices were 
     30          modified, this addition solves the problem. 
     31           
    2432    - 1.16alpha11 : 
    2533     
  • pykota/trunk/pykota/accounters/external.py

    r1200 r1203  
    2222# 
    2323# $Log$ 
     24# Revision 1.10  2003/11/23 19:01:36  jalet 
     25# Job price added to history 
     26# 
    2427# Revision 1.9  2003/11/21 14:28:45  jalet 
    2528# More complete job history. 
     
    107110         
    108111        # adds the current job to history     
    109         printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
     112        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 
     113        printer.addJobToHistory(self.filter.jobid, user, self.getLastPageCounter(), action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
    110114         
    111115        self.endJob(printer, user) 
  • pykota/trunk/pykota/accounters/stupid.py

    r1200 r1203  
    2222# 
    2323# $Log$ 
     24# Revision 1.8  2003/11/23 19:01:37  jalet 
     25# Job price added to history 
     26# 
    2427# Revision 1.7  2003/11/21 14:28:46  jalet 
    2528# More complete job history. 
     
    109112         
    110113        # adds the current job to history     
    111         printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
     114        jobprice = (float(printer.PricePerPage or 0.0) * jobsize) + float(printer.PricePerJob or 0.0) 
     115        printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize, jobprice, self.filter.preserveinputfile, self.filter.title, self.filter.copies, self.filter.options) 
    112116             
    113117        return action 
  • pykota/trunk/pykota/storage.py

    r1200 r1203  
    2222# 
    2323# $Log$ 
     24# Revision 1.27  2003/11/23 19:01:36  jalet 
     25# Job price added to history 
     26# 
    2427# Revision 1.26  2003/11/21 14:28:45  jalet 
    2528# More complete job history. 
     
    214217        self.LastJob = None 
    215218         
    216     def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :     
     219    def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 
    217220        """Adds a job to the printer's history.""" 
    218         self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, filename, title, copies, options) 
     221        self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options) 
    219222        # TODO : update LastJob object ? Probably not needed. 
    220223         
     
    314317        self.JobAction = None 
    315318        self.JobDate = None 
     319        self.JobPrice = None 
     320        self.JobFileName = None 
     321        self.JobTitle = None 
     322        self.JobCopies = None 
     323        self.JobOptions = None 
    316324         
    317325    def setSize(self, jobsize) : 
    318326        """Sets the last job's size.""" 
    319         self.parent.writeLastJobSize(self, jobsize) 
     327        jobprice = (float(self.Printer.PricePerPage or 0.0) * jobsize) + float(self.Printer.PricePerJob or 0.0) 
     328        self.parent.writeLastJobSize(self, jobsize, jobprice) 
    320329        self.JobSize = jobsize 
     330        self.JobPrice = jobprice 
    321331     
    322332class BaseStorage : 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1200 r1203  
    2222# 
    2323# $Log$ 
     24# Revision 1.37  2003/11/23 19:01:37  jalet 
     25# Job price added to history 
     26# 
    2427# Revision 1.36  2003/11/21 14:28:46  jalet 
    2528# More complete job history. 
     
    407410            lastjob.lastjobident = result[0][0] 
    408411            lastjobident = result[0][1]["pykotaLastJobIdent"][0] 
    409             result = self.doSearch("objectClass=pykotaJob", ["pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 
     412            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) 
    410413            if result : 
    411414                fields = result[0][1] 
     
    415418                lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter")[0] or 0) 
    416419                lastjob.JobSize = int(fields.get("pykotaJobSize", [0])[0]) 
     420                lastjob.JobPrice = float(fields.get("pykotaJobPrice", [0.0])[0]) 
    417421                lastjob.JobAction = fields.get("pykotaAction")[0] 
     422                lastjob.JobFileName = fields.get("pykotaFileName")[0] 
     423                lastjob.JobTitle = fields.get("pykotaTitle")[0] 
     424                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
     425                lastjob.JobOptions = fields.get("pykotaOptions")[0] 
    418426                date = fields.get("createTimestamp")[0] 
    419427                year = int(date[:4]) 
     
    686694        return self.doModify(user.idbalance, fields)          
    687695             
    688     def writeLastJobSize(self, lastjob, jobsize) :         
     696    def writeLastJobSize(self, lastjob, jobsize, jobprice) :         
    689697        """Sets the last job's size permanently.""" 
    690698        fields = { 
    691699                   "pykotaJobSize" : str(jobsize), 
     700                   "pykotaJobPrice" : str(jobprice), 
    692701                 } 
    693702        self.doModify(lastjob.ident, fields)          
    694703         
    695     def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :     
     704    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 
    696705        """Adds a job in a printer's history.""" 
    697706        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
     
    716725        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
    717726            if jobsize is not None :          
    718                 fields.update({ "pykotaJobSize" : str(jobsize) }) 
     727                fields.update({ "pykotaJobSize" : str(jobsize), "pykotaJobPrice" : str(jobprice) }) 
    719728            self.doAdd(dn, fields) 
    720729        else :     
    721730            # here we explicitly want to reset jobsize to 'None' if needed 
    722             fields.update({ "pykotaJobSize" : str(jobsize) }) 
     731            fields.update({ "pykotaJobSize" : str(jobsize), "pykotaJobPrice" : str(jobprice) }) 
    723732            self.doModify(dn, fields) 
    724733             
  • pykota/trunk/pykota/storages/pgstorage.py

    r1200 r1203  
    2222# 
    2323# $Log$ 
     24# Revision 1.23  2003/11/23 19:01:37  jalet 
     25# Job price added to history 
     26# 
    2427# Revision 1.22  2003/11/21 14:28:46  jalet 
    2528# More complete job history. 
     
    282285        """Extracts a printer's last job information.""" 
    283286        lastjob = StorageLastJob(self, printer) 
    284         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)) 
     287        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)) 
    285288        if result : 
    286289            fields = result[0] 
     
    290293            lastjob.PrinterPageCounter = fields.get("pagecounter") 
    291294            lastjob.JobSize = fields.get("jobsize") 
     295            lastjob.JobPrice = fields.get("jobprice") 
    292296            lastjob.JobAction = fields.get("action") 
     297            lastjob.JobFileName = fields.get("filename") 
     298            lastjob.JobTitle = fields.get("title") 
     299            lastjob.JobCopies = fields.get("copies") 
     300            lastjob.JobOptions = fields.get("options") 
    293301            lastjob.JobDate = fields.get("jobdate") 
    294302            lastjob.Exists = 1 
     
    446454           self.doModify("UPDATE users SET balance=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(user.ident))) 
    447455             
    448     def writeLastJobSize(self, lastjob, jobsize) :         
     456    def writeLastJobSize(self, lastjob, jobsize, jobprice) :         
    449457        """Sets the last job's size permanently.""" 
    450         self.doModify("UPDATE jobhistory SET jobsize=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(lastjob.ident))) 
    451          
    452     def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, filename=None, title=None, copies=None, options=None) :     
     458        self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident))) 
     459         
     460    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) :     
    453461        """Adds a job in a printer's history.""" 
    454462        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
    455463            if jobsize is not None : 
    456                 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))) 
     464                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))) 
    457465            else :     
    458466                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))) 
    459467        else :         
    460468            # here we explicitly want to reset jobsize to NULL if needed 
    461             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))) 
     469            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))) 
    462470             
    463471    def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : 
  • pykota/trunk/pykota/version.py

    r1200 r1203  
    2222# 
    2323 
    24 __version__ = "1.16alpha11_unofficial" 
     24__version__ = "1.16alpha12_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""