More workin on it

This commit is contained in:
Jacob Babor 2024-12-15 15:11:11 -06:00
parent 506e6dd377
commit 3fb1e33dbb

View File

@ -7,25 +7,28 @@
# Distributed under terms of the MIT license. # Distributed under terms of the MIT license.
from csv import DictReader from csv import DictReader
from datetime import date import datetime
import glob import glob
import re import re
import requests import requests
import textwrap import textwrap
# Config globals
rate = float(41.00) rate = float(41.00)
timesheet = {} timesheet = {}
# First, acquire a CSV to look at
csv = glob.glob('*.csv') csv = glob.glob('*.csv')
if not csv: if not csv:
print('No csv found!') print('No csv found!')
quit() quit()
# Then, open that CSV and collect its data, storing it in timesheet
with open(csv[0], 'r') as csv: with open(csv[0], 'r') as csv:
items = DictReader(csv) items = DictReader(csv)
for row in items: for row in items:
issue = row["Issue Key"] issue = row["Issue Key"]
date = row["Work date"] date = datetime.datetime.strptime(row["Work date"], '%Y-%m-%d %H:%M').strftime('%Y-%m-%d')
hours = float(row["Hours"]) hours = float(row["Hours"])
if not date in timesheet.keys(): if not date in timesheet.keys():
@ -35,7 +38,23 @@ with open(csv[0], 'r') as csv:
timesheet[date][issue] = 0 timesheet[date][issue] = 0
timesheet[date][issue] += hours timesheet[date][issue] += hours
# Next, construct args for the request we'll make to invoice-generator.com's API
requestbody = {
"from": "JACOB",
"to": "CLIENT",
"number": 9999,
"date": "CURRENT_DATE",
"due_date": "DUE_DATE",
"terms": "Net 14 days",
"items": []
}
for k,v in timesheet.items(): for k,v in timesheet.items():
print(k) print(k)
for i,h in v.items(): for i,h in v.items():
requestbody["items"] += {
"name": f""
}
print(f'{ i } - { h }') print(f'{ i } - { h }')
# Submit said request