from time_recoder.time_recoder_config import HOURLY_WAGE_IN_EURO, PATH, NAME from personal_income_calculator.income_calculator_main import calc_income_by_time_in_euro from tool_lib import create_excel_tables from os import path from time import time from datetime import date def create_recorded_time_dict(worked_time, income, sales_taxes): return {'Name': NAME, 'Datum': str(date.today()), 'Arbeitszeit' : worked_time, 'Einkommen': income, 'Umsatzsteuern': sales_taxes} def table_exists(path_): return path.isfile(path_) def get_current_time_as_timestamp(): return int(time()) def add_to_xlsx_table(table_object): table_object.append_df_to_xlsx(table_object.dataframes) def create_xlsx_table(table_object): table_object.export_to_excel(table_object.create_writer()) def save_recorded_time_in_table(worked_time_in_minutes): income, sales_taxes = calc_income_by_time_in_euro(worked_time_in_minutes, HOURLY_WAGE_IN_EURO) table_dict = create_recorded_time_dict(worked_time_in_minutes, income, sales_taxes) xlsx_table = create_excel_tables.CreateTable(table_dict, path=PATH) if table_exists(PATH): add_to_xlsx_table(xlsx_table) else: create_xlsx_table(xlsx_table)