Exemple #1
0
def day_record_to_report_line(day_record, policy):
    return DAY_LINE_TEMPLATE.format(
        day=day_record.day,
        day_type=day_record.day_type,
        checkin=date_to_time_str(day_record.checkin),
        checkout=date_to_time_str(day_record.checkout),
        worked=timedelta_to_str(day_record.worked()),
        balance=timedelta_to_str(policy.day_balance(day_record)),
    )
Exemple #2
0
    def print_timesheet(self):
        for year_record in self.records:
            print 'Year: {}, worked: {}'.format(
                year_record.year,
                timedelta_to_str(year_record.worked())
            )
            print

            for month_record in year_record.records:
                print 'Month: {}, worked: {}'.format(
                    month_record.month,
                    timedelta_to_str(month_record.worked())
                )
                print

                for day_record in month_record.records:
                    print day_record, timedelta_to_str(day_record.worked())
Exemple #3
0
def report(db, policy, path):
    if os.path.exists(path):
        shutil.rmtree(path)
    mkdirp(path)

    with open(os.path.join(path, 'totals.txt'), 'w') as f:
        print >> f, 'Worked: {}'.format(timedelta_to_str(db.worked()))
        print >> f, 'Balance: {}'.format(timedelta_to_str(policy.timesheet_balance(db)))
        if db.adjustments:
            print >> f, 'Adjustments:'
            for a in db.adjustments:
                print >> f, '    ' + a.identifier()

    for year_record in db.records:
        year_path = os.path.join(path, str(year_record.year))
        mkdirp(year_path)

        with open(os.path.join(year_path, 'totals.txt'), 'w') as f:
            print >> f, 'Worked: {}'.format(timedelta_to_str(year_record.worked()))
            print >> f, 'Balance: {}'.format(timedelta_to_str(policy.year_balance(year_record)))

        for month_record in year_record.records:
            month_path = os.path.join(year_path, '{:02d}.txt'.format(month_record.month))

            with open(month_path, 'w') as f:
                print >> f, DAY_HEADER_TEMPLATE
                for day_record in month_record.records:
                    print >> f, day_record_to_report_line(day_record, policy)

                print >> f, 'Worked: {}'.format(timedelta_to_str(month_record.worked()))
                month_balance = timedelta_to_str(policy.month_balance(month_record))
                print >> f, 'Balance: {}'.format(month_balance)

    print 'Balance: {}'.format(timedelta_to_str(policy.timesheet_balance(db)))
Exemple #4
0
 def identifier(self):
     return 'Adjustment of {} [{}]'.format(
         timedelta_to_str(self.delta),
         self.day.strftime('%Y-%m-%d')
     )