Show
Ignore:
Timestamp:
02/08/07 21:13:03 (17 years ago)
Author:
jerome
Message:

Make start= and end= filters also work with payments. For an unknown
reason it didn't already work (not implemented !)...
Ensures that these filters are only allowed for payments and
history, otherwise an SQL syntax error could have occured.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/sql.py

    r3139 r3142  
    187187    def extractPayments(self, extractonly={}) : 
    188188        """Extracts all payment records.""" 
     189        startdate = extractonly.get("start") 
     190        enddate = extractonly.get("end") 
     191        for limit in ("start", "end") : 
     192            try : 
     193                del extractonly[limit] 
     194            except KeyError :     
     195                pass 
    189196        thefilter = self.createFilter(extractonly) 
    190197        if thefilter : 
    191198            thefilter = "AND %s" % thefilter 
     199        (startdate, enddate) = self.cleanDates(startdate, enddate) 
     200        if startdate :  
     201            thefilter = "%s AND date>=%s" % (thefilter, self.doQuote(startdate)) 
     202        if enddate :  
     203            thefilter = "%s AND date<=%s" % (thefilter, self.doQuote(enddate)) 
    192204        result = self.doRawSearch("SELECT username,payments.* FROM users,payments WHERE users.id=payments.userid %s ORDER BY payments.id ASC" % thefilter) 
    193205        return self.prepareRawResult(result)