|
@@ -1,5 +1,8 @@
|
|
|
|
+from fast_excel_to_bill.config_for_custom_bills import OUTPUT_CUSTOMER, OUTPUT_MONTH, OUTPUT_YEAR
|
|
from tool_lib.read_table import Read_Table
|
|
from tool_lib.read_table import Read_Table
|
|
from tool_lib.create_excel_tables import CreateTable
|
|
from tool_lib.create_excel_tables import CreateTable
|
|
|
|
+import numpy as np
|
|
|
|
+
|
|
|
|
|
|
def add_sum_to_dict(work_time_dict, income_per_hour):
|
|
def add_sum_to_dict(work_time_dict, income_per_hour):
|
|
for key in work_time_dict.keys():
|
|
for key in work_time_dict.keys():
|
|
@@ -38,14 +41,13 @@ def round_worktime_for_week(work_time_dict,overtime_table_path, round_time = 300
|
|
save_overtime_in_excel(overtime_dict,overtime_table_path)
|
|
save_overtime_in_excel(overtime_dict,overtime_table_path)
|
|
return work_time_dict
|
|
return work_time_dict
|
|
|
|
|
|
|
|
+
|
|
def get_task_out_of_tree(work_time_dict):
|
|
def get_task_out_of_tree(work_time_dict):
|
|
for key in work_time_dict.keys():
|
|
for key in work_time_dict.keys():
|
|
work_time_dict[key]['Task'] = ['- ' + last_branch[last_branch.rfind('/')+1:] for last_branch in work_time_dict[key]['Task']]
|
|
work_time_dict[key]['Task'] = ['- ' + last_branch[last_branch.rfind('/')+1:] for last_branch in work_time_dict[key]['Task']]
|
|
return work_time_dict
|
|
return work_time_dict
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def compress_data_by_key_list(*compressable_lists, key_list):
|
|
def compress_data_by_key_list(*compressable_lists, key_list):
|
|
'''
|
|
'''
|
|
function: a list containing different Values, if a Value is more than one time
|
|
function: a list containing different Values, if a Value is more than one time
|
|
@@ -101,6 +103,26 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
|
|
read_table_object = Read_Table(path)
|
|
read_table_object = Read_Table(path)
|
|
table_object = read_table_object.table_to_dict()
|
|
table_object = read_table_object.table_to_dict()
|
|
|
|
|
|
|
|
+ # Filter Data
|
|
|
|
+ customer_filter_value_indices = []
|
|
|
|
+ for task_value_idx in range(len(table_object['Task'])):
|
|
|
|
+ task_value = table_object['Task'][task_value_idx]
|
|
|
|
+ if task_value.startswith('root/' + OUTPUT_CUSTOMER):
|
|
|
|
+ customer_filter_value_indices.append(task_value_idx)
|
|
|
|
+ if OUTPUT_MONTH > 9:
|
|
|
|
+ date_filter = str(OUTPUT_MONTH) + '/' + str(OUTPUT_YEAR)
|
|
|
|
+ else:
|
|
|
|
+ date_filter = '0' + str(OUTPUT_MONTH) + '/' + str(OUTPUT_YEAR)
|
|
|
|
+ date_filter_value_indices = []
|
|
|
|
+ for date_value_idx in range(len(table_object['Datum'])):
|
|
|
|
+ date_value = table_object['Datum'][date_value_idx]
|
|
|
|
+ if date_value.endswith(date_filter):
|
|
|
|
+ date_filter_value_indices.append(date_value_idx)
|
|
|
|
+ customer_and_date_filtered_indices = list(set(customer_filter_value_indices) & set(date_filter_value_indices))
|
|
|
|
+
|
|
|
|
+ for key in table_object:
|
|
|
|
+ table_object[key] = [table_object[key][idx] for idx in customer_and_date_filtered_indices]
|
|
|
|
+
|
|
# Calendar Week
|
|
# Calendar Week
|
|
calendar_weeks_list = table_object['Kalenderwoche']
|
|
calendar_weeks_list = table_object['Kalenderwoche']
|
|
|
|
|
|
@@ -119,6 +141,9 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
|
|
# Compress Data by Calendar week
|
|
# Compress Data by Calendar week
|
|
for key in key_dict.keys():
|
|
for key in key_dict.keys():
|
|
all_weeks = compress_data_by_key_list(key_dict[key], key_list=calendar_weeks_list)
|
|
all_weeks = compress_data_by_key_list(key_dict[key], key_list=calendar_weeks_list)
|
|
|
|
+ if key == 'Task':
|
|
|
|
+ for idx in range(len(all_weeks)):
|
|
|
|
+ all_weeks[idx] = list(set(all_weeks[idx]))
|
|
for week_indx, week in enumerate(list(set(calendar_weeks_list))):
|
|
for week_indx, week in enumerate(list(set(calendar_weeks_list))):
|
|
if c == 0:
|
|
if c == 0:
|
|
week_keys_to_list_of_keys_dict[week][key] = all_weeks[week_indx]
|
|
week_keys_to_list_of_keys_dict[week][key] = all_weeks[week_indx]
|
|
@@ -135,6 +160,26 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
|
|
# Calendar Week
|
|
# Calendar Week
|
|
calendar_weeks_list = table_object['Kalenderwoche']
|
|
calendar_weeks_list = table_object['Kalenderwoche']
|
|
|
|
|
|
|
|
+ # Filter Data
|
|
|
|
+ customer_filter_value_indices = []
|
|
|
|
+ for task_value_idx in range(len(table_object['Task'])):
|
|
|
|
+ task_value = table_object['Task'][task_value_idx]
|
|
|
|
+ if task_value.startswith('root/' + OUTPUT_CUSTOMER):
|
|
|
|
+ customer_filter_value_indices.append(task_value_idx)
|
|
|
|
+ if OUTPUT_MONTH > 9:
|
|
|
|
+ date_filter = str(OUTPUT_MONTH) + '/' + str(OUTPUT_YEAR)
|
|
|
|
+ else:
|
|
|
|
+ date_filter = '0' + str(OUTPUT_MONTH) + '/' + str(OUTPUT_YEAR)
|
|
|
|
+ date_filter_value_indices = []
|
|
|
|
+ for date_value_idx in range(len(table_object['Datum'])):
|
|
|
|
+ date_value = table_object['Datum'][date_value_idx]
|
|
|
|
+ if date_value.endswith(date_filter):
|
|
|
|
+ date_filter_value_indices.append(date_value_idx)
|
|
|
|
+ customer_and_date_filtered_indices = list(set(customer_filter_value_indices) & set(date_filter_value_indices))
|
|
|
|
+
|
|
|
|
+ for key in table_object:
|
|
|
|
+ table_object[key] = [table_object[key][idx] for idx in customer_and_date_filtered_indices]
|
|
|
|
+
|
|
# Add new Weeks to dict
|
|
# Add new Weeks to dict
|
|
for week in list(set(calendar_weeks_list)):
|
|
for week in list(set(calendar_weeks_list)):
|
|
if week in week_keys_to_list_of_keys_dict:
|
|
if week in week_keys_to_list_of_keys_dict:
|
|
@@ -151,6 +196,9 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
|
|
compressed_lists = []
|
|
compressed_lists = []
|
|
for key in key_dict.keys():
|
|
for key in key_dict.keys():
|
|
all_weeks = compress_data_by_key_list(key_dict[key], key_list=calendar_weeks_list)
|
|
all_weeks = compress_data_by_key_list(key_dict[key], key_list=calendar_weeks_list)
|
|
|
|
+ if key == 'Task':
|
|
|
|
+ for idx in range(len(all_weeks)):
|
|
|
|
+ all_weeks[idx] = list(set(all_weeks[idx]))
|
|
for week_indx, week in enumerate(list(set(calendar_weeks_list))):
|
|
for week_indx, week in enumerate(list(set(calendar_weeks_list))):
|
|
week_keys_to_list_of_keys_dict[week][key] = all_weeks[week_indx]
|
|
week_keys_to_list_of_keys_dict[week][key] = all_weeks[week_indx]
|
|
|
|
|