Selaa lähdekoodia

fixed bug where calendar week numeration is unordered

Nico Ruhnke 2 vuotta sitten
vanhempi
commit
bbe4d81ec0

+ 11 - 4
fast_excel_to_bill/transform_excel_data_to_bill_data/time_recorder_format_main.py

@@ -130,8 +130,11 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
             # Calendar Week
             calendar_weeks_list = table_object['Kalenderwoche']
 
+            sortet_calendar_weeks = list(set(calendar_weeks_list))
+            sortet_calendar_weeks.sort()
+
             # Add new Weeks to dict
-            for week in list(set(calendar_weeks_list)):
+            for week in sortet_calendar_weeks:
                 if week in week_keys_to_list_of_keys_dict:
                     pass
                 else:
@@ -148,7 +151,8 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
                 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(sortet_calendar_weeks):
                     if c == 0:
                         week_keys_to_list_of_keys_dict[week][key] = all_weeks[week_indx]
                     else:
@@ -164,6 +168,9 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
         # Calendar Week
         calendar_weeks_list = table_object['Kalenderwoche']
 
+        sortet_calendar_weeks = list(set(calendar_weeks_list))
+        sortet_calendar_weeks.sort()
+
         # Filter Data
         customer_filter_value_indices = []
         for task_value_idx in range(len(table_object['Task'])):
@@ -185,7 +192,7 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
             table_object[key] = [table_object[key][idx] for idx in customer_and_date_filtered_indices]
 
         # Add new Weeks to dict
-        for week in list(set(calendar_weeks_list)):
+        for week in sortet_calendar_weeks:
             if week in week_keys_to_list_of_keys_dict:
                 pass
             else:
@@ -203,7 +210,7 @@ def main_data_collection(pathes, list_of_keys=['Arbeitszeit', 'Task']):
             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(sortet_calendar_weeks):
                 week_keys_to_list_of_keys_dict[week][key] = all_weeks[week_indx]
 
     return week_keys_to_list_of_keys_dict