Changeset 8:0b63f5eb49b3 in stamper for stamper
- Timestamp:
- Jul 8, 2014, 10:40:05 AM (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
stamper/stamper.py
r7 r8 93 93 return customers 94 94 95 def total _by_customer(self, customer):96 total = 095 def totals(self, stamp_filter=None): 96 totals = {} 97 97 for stamp in self.stamps: 98 if stamp['customer'] == customer: 99 total += self.worktime(stamp['start'], stamp['end']) 100 total = timedelta(seconds=total) 101 return str(total) 98 customer = stamp['customer'] 99 if customer: 100 # c will be None for "start" stamps, having no end time 101 if customer not in totals: 102 totals[customer] = 0 103 totals[customer] += self.worktime(stamp['start'], stamp['end']) 104 return totals 102 105 103 def totals(self): 106 def details(self): 107 details = {} 104 108 totals = {} 105 for customer in self.customers(): 106 totals[customer] = self.total_by_customer(customer) 107 return totals 109 for stamp in self.stamps: 110 if stamp['customer']: 111 # avoid "start" stamps 112 start_day = stamp['start'].split(' ')[0] 113 if start_day not in details: 114 details[start_day] = [] 115 if start_day not in totals: 116 totals[start_day] = 0 117 worktime = self.worktime(stamp['start'], stamp['end']) 118 details[start_day].append( 119 ' -> %(worktime)s %(customer)s %(action)s' % { 120 'worktime': str(timedelta(seconds=worktime)), 121 'customer': stamp['customer'], 122 'action': stamp['action'] 123 }) 124 totals[start_day] += worktime 125 for day in totals: 126 totals[day] = str(timedelta(seconds=totals[day])) 127 return details, totals 108 128 109 129 def details_by_customer(self, customer):
Note:
See TracChangeset
for help on using the changeset viewer.