Changeset 9:2457f4022c60 in stamper


Ignore:
Timestamp:
Jul 8, 2014, 10:40:51 AM (6 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Added show_totals method, to render totals and stamp details

File:
1 edited

Legend:

Unmodified
Added
Removed
  • stamper/stamper.py

    r8 r9  
    148148            totals[day] = str(timedelta(seconds=totals[day]))
    149149        return details, totals
     150
     151    def show_stamps(self, customer=None, stamp_filter=None, verbose=False):
     152        if stamp_filter:
     153            stamp_filter = self.validate_filter(stamp_filter)
     154
     155        totals = self.totals(stamp_filter)
     156
     157        if customer:
     158            total = timedelta(seconds=totals.get(customer, 0))
     159            print(' %(customer)s: %(total)s' % {'customer': customer,
     160                                                'total': total})
     161        else:
     162            for c in totals:
     163                total = timedelta(seconds=totals[c])
     164                print(' %(customer)s: %(total)s' % {'customer': c,
     165                                                    'total': total})
     166
     167        if verbose:
     168            if customer:
     169                details, totals = self.details_by_customer(customer)
     170            else:
     171                details, totals = self.details()
     172            for day in details:
     173                print('------ %(day)s ------' % {'day': day})
     174                for line in details[day]:
     175                    print(line)
     176                print(' Total: %(total)s' % {'total': totals[day]})
Note: See TracChangeset for help on using the changeset viewer.