tadd name param, better month total handling - timesheetpy - simple timesheet generator (HTM) git clone git://parazyd.org/timesheetpy.git (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit adf8a9ad6bee2dff49228c23698e54b4f1326f2d (DIR) parent d55a89902b6c7740f0e375558855d5e0189dee41 (HTM) Author: parazyd <parazyd@dyne.org> Date: Tue, 25 Oct 2016 18:48:06 +0200 add name param, better month total handling Diffstat: M timesheet | 96 ++++++++++++++++---------------- 1 file changed, 48 insertions(+), 48 deletions(-) --- (DIR) diff --git a/timesheet b/timesheet t@@ -1,5 +1,4 @@ #!/usr/bin/env python2 -# # Copyright (c) 2016 Dyne.org Foundation # timesheetpy is written and maintained by parazyd <parazyd@dyne.org> # t@@ -25,6 +24,7 @@ import datetime import sys import xlsxwriter +## TODO: name parameter now = datetime.date.today() t@@ -41,6 +41,9 @@ parser.add_argument("-em", "--end-month", parser.add_argument("-ey", "--end-year", help="ending year, ex: 2016", type=int) +parser.add_argument("-n", "--name", + help="name of person, ex: 'John Doe'", + type=str) parser.add_argument("-o", "--output-file", help="output file, ex: timesheet.xlsx", default="timesheet.xlsx", t@@ -64,21 +67,21 @@ format_days = workbook.add_format({ 'border': True, 'bg_color': 'eeeeee', 'align': 'right', - 'font_name': 'Ubuntu Mono' + 'font_name': 'Inconsolata' }) format_timegridWhite = workbook.add_format({ 'border': True, 'bg_color': 'ffffff', 'align': 'center', - 'font_name': 'Ubuntu Mono' + 'font_name': 'Inconsolata' }) format_timegridGrey = workbook.add_format({ 'border': True, 'bg_color': 'eeeeee', 'align': 'center', - 'font_name': 'Ubuntu Mono' + 'font_name': 'Inconsolata' }) format_bold = workbook.add_format({ t@@ -119,16 +122,23 @@ def putDefaults(mm, yy): worksheet.set_row(2, 30) worksheet.write('A3', 'Name:', format_centerbigger) - worksheet.write('B3', '', format_centerbigger) + if args.name: + worksheet.merge_range('B3:C3', args.name, format_centerbigger) + #worksheet.write('B3', args.name, format_centerbigger) #worksheet.merge_range('E3:F3', 'Total hrs. worked:', format_bold) worksheet.set_row(5, 30) - worksheet.merge_range('B6:G6', 'PROJECT CODING', format_centerbigger) + worksheet.merge_range('B6:G6', 'TIMESHEET', format_centerbigger) for i in range(1,7): ## cells for project codes worksheet.write(6, i, '', format_centerbold) - fieldx = 7 + worksheet.write('A7', 'Project', format_bold) + worksheet.write('A8', 'W.P.', format_bold) + worksheet.write('A9', 'Tag', format_bold) + + ## space from above + fieldx = 10 fieldy = 0 for day in calendar(mm, yy): if fieldx % 2 == 0: t@@ -146,56 +156,46 @@ def putDefaults(mm, yy): fieldx += 1 ## Bottom: Signature, Date, Free text space - worksheet.set_row(39, 30) - worksheet.write('A40', 'Signature:', format_vcenterbold) - - worksheet.set_row(40, 30) - worksheet.write('A41', 'Date:', format_vcenterbold) - worksheet.write('B41', now.isoformat(), format_vcenterbold) + worksheet.set_row(43, 30) + worksheet.write('A44', 'Signature:', format_vcenterbold) - worksheet.set_row(41, 30) - worksheet.write('A42', 'Free text space:', format_vcenterbold) + #worksheet.set_row(43, 30) + #worksheet.write('A44', 'Date:', format_vcenterbold) + #worksheet.write('B44', now.isoformat(), format_vcenterbold) + worksheet.set_row(45, 30) + worksheet.write('A46', 'Free text space:', format_vcenterbold) ## calculations - worksheet.write('H7', 'Total', format_centerbold) + worksheet.write('H10', 'Total', format_centerbold) - ## month of 30 days + writetotals() + +def writetotals(): + uno = str(0) + tre = str(0) + due = str(11) if total == 30: - worksheet.write('B38', '=SUM(B8:B37)', format_centerbold) - worksheet.write('C38', '=SUM(C8:C37)', format_centerbold) - worksheet.write('D38', '=SUM(D8:D37)', format_centerbold) - worksheet.write('E38', '=SUM(E8:E37)', format_centerbold) - worksheet.write('F38', '=SUM(F8:F37)', format_centerbold) - worksheet.write('G38', '=SUM(G8:G37)', format_centerbold) - worksheet.write('H38', '=SUM(H8:H37)', format_timegridGrey) - ## month of 31 days + uno = str(41) + tre = str(40) + elif total == 31: - worksheet.write('B39', '=SUM(B8:B38)', format_centerbold) - worksheet.write('C39', '=SUM(C8:C38)', format_centerbold) - worksheet.write('D39', '=SUM(D8:D38)', format_centerbold) - worksheet.write('E39', '=SUM(E8:E38)', format_centerbold) - worksheet.write('F39', '=SUM(F8:F38)', format_centerbold) - worksheet.write('G39', '=SUM(G8:G38)', format_centerbold) - worksheet.write('H39', '=SUM(H8:H38)', format_timegridGrey) - ## month of 28 days + uno = str(42) + tre = str(41) + elif total == 28: - worksheet.write('B36', '=SUM(B8:B35)', format_centerbold) - worksheet.write('C36', '=SUM(C8:C35)', format_centerbold) - worksheet.write('D36', '=SUM(D8:D35)', format_centerbold) - worksheet.write('E36', '=SUM(E8:E35)', format_centerbold) - worksheet.write('F36', '=SUM(F8:F35)', format_centerbold) - worksheet.write('G36', '=SUM(G8:G35)', format_centerbold) - worksheet.write('H36', '=SUM(H8:H35)', format_timegridGrey) - ## month of 29 days + uno = str(39) + tre = str(38) + elif total == 29: - worksheet.write('B37', '=SUM(B8:B36)', format_centerbold) - worksheet.write('C36', '=SUM(C8:C35)', format_centerbold) - worksheet.write('D36', '=SUM(D8:D35)', format_centerbold) - worksheet.write('E36', '=SUM(E8:E35)', format_centerbold) - worksheet.write('F36', '=SUM(F8:F35)', format_centerbold) - worksheet.write('G36', '=SUM(G8:G35)', format_centerbold) - worksheet.write('H36', '=SUM(H8:H35)', format_timegridGrey) + uno = str(40) + tre = str(39) + + fmt = format_centerbold + for col in range(66,73): + if col == 72: + fmt = format_timegridGrey + worksheet.write(chr(col)+uno, '=SUM('+chr(col)+due+':'+chr(col)+tre+')', fmt) def calendar(mm, yy): month = monthrange(yy, mm)