Compare commits

..

4 Commits

Author SHA1 Message Date
Jacob Babor
456f9007b1 Use ydotool to just type it into a web field 2024-12-15 15:44:54 -06:00
Jacob Babor
36413aafd0 Submit a thing that works but isn't what I want 2024-12-15 15:23:03 -06:00
Jacob Babor
3fb1e33dbb More workin on it 2024-12-15 15:11:11 -06:00
Jacob Babor
506e6dd377 Workin on it 2024-12-15 15:02:08 -06:00

53
invoice.py Executable file
View File

@@ -0,0 +1,53 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2024 Jacob Babor <jacob@babor.tech>
#
# Distributed under terms of the MIT license.
from csv import DictReader
import datetime
import glob
import json
import os
import re
import subprocess
import textwrap
import time
# Config globals
rate = float(41.00)
timesheet = {}
# First, acquire a CSV to look at
csv = glob.glob('*.csv')
if not csv:
print('No csv found!')
quit()
# Then, open that CSV and collect its data, storing it in timesheet
with open(csv[0], 'r') as csv:
items = DictReader(csv)
for row in items:
issue = row["Issue Key"]
date = datetime.datetime.strptime(row["Work date"], '%Y-%m-%d %H:%M').strftime('%Y-%m-%d')
hours = float(row["Hours"])
if not date in timesheet.keys():
timesheet[date] = {}
if not issue in timesheet[date].keys():
timesheet[date][issue] = 0
timesheet[date][issue] += hours
for k,v in timesheet.items():
print(k)
for i,h in v.items():
print(f' { i } - { h }')
# Now actually do the work
subprocess.run(["ydotool", "type", f"{k} - {i}\t{round(h,2)}\t{rate}\t"])
time.sleep(0.10)
subprocess.run(["ydotool", "type", "\n"])
time.sleep(0.10)