Browse Source

TODO Update
Readme Merge
Added Version requirements

Automatic Bill Updates:
Automatic Datetime-> nearest month, get day length of specific month, Leistungszeitraum

Danny 2 years ago
parent
commit
1729d720f0

+ 0 - 0
Image2PDF/img2pdf_with_package.py → Image2PDF/img2pdf_main.py


+ 0 - 4
fast_excel_to_bill/Readme

@@ -1,4 +0,0 @@
-#Installings
-
-pip install img2pdf
-conda install python-docx

+ 1 - 1
fast_excel_to_bill/bill_doc/docx_builder.py

@@ -21,7 +21,7 @@ class DOCFileBuilder:
 
     # Low Level Functions
     def save_docx(self):
-        if self.docx_save_path != '': # Default
+        if self.docx_save_path == '': # Default
             self.document.save()
         else:
             self.document.save(self.docx_save_path)

+ 6 - 3
fast_excel_to_bill/config_for_custom_bills.py

@@ -1,4 +1,7 @@
 # Docx Builder
-docx_input_path =...
-docx_output_dir_path = r'C:\Users\Danny\Desktop\ssd wichtige dinge D\Tools\fast_excel_to_bill\test_folder'
-list_of_place_holders = ['?Netto?','?zzgl.?', '?gesamt?', '?insert_date?']
+docx_input_path = r'C:\Users\Danny\Desktop\EnD and Investment\Tools\fast_excel_to_bill\test_folder\Templates\templeta.docx'
+docx_output_dir_path = r'C:\Users\Danny\Desktop\EnD and Investment\Tools\fast_excel_to_bill\test_folder'
+list_of_place_holders = ['?Netto?','?zzgl.?', '?gesamt?', '?insert_date?']
+
+# Burden Date
+payment_request_range = 30

+ 38 - 19
fast_excel_to_bill/main.py

@@ -1,34 +1,53 @@
 from fast_excel_to_bill.bill_doc.docx_builder import DOCFileBuilder
 from fast_excel_to_bill import config_for_custom_bills
 from tool_lib import datetime_functions
+from datetime import datetime
 
-
-current_month_year= datetime_functions.get_current_month_year_as_str()
+payment_request_range = config_for_custom_bills.payment_request_range
+year = int(datetime_functions.datetime_to_str(datetime_functions.get_current_date(), '%Y'))
+current_month_year= datetime_functions.datetime_to_str('current', '%m_%Y')
 docx_output_path = config_for_custom_bills.docx_output_dir_path+ r'\bill_{}.docx'.format(current_month_year)
 
 
 def main():
     # Get Data which is necessary for the docx
-    data_from_excel = ...
-    burden_date = ...
-    data_from_excel.append(burden_date)
+    # data_from_excel = ...
+    payment_request_date = datetime_functions.add_days_to_date(datetime_functions.get_current_date(),payment_request_range)
+    payment_request_date = datetime_functions.datetime_to_str(payment_request_date, '%d.%m.%Y')
+    # data_from_excel.append(payment_request_date)
 
     # Create a doc file which is based on a docx template
     builder_obj = DOCFileBuilder(config_for_custom_bills.docx_input_path, docx_output_path)
-    place_holders = config_for_custom_bills.list_of_place_holders
-    for place_holder in place_holders:
-        builder_obj.replace_custom_placeholder_in_doc(place_holder, data_from_excel)
-    builder_obj.replace_dates_string_in_standard_text('03.11.2022')
-    builder_obj.replace_dates_string_in_all_tables('03.11.2022')
-
-    keys = ['KW', 'Leistung', 'Zeit in Stunden', 'Betrag in Euro']
-    example_tuple = [(123123, 213123, 12312312, 445235)]
-    key_table = builder_obj.search_table_with_key_columns(keys)
-    builder_obj.replace_rows(key_table, example_tuple)
-    builder_obj.delete_empty_rows_in_table(key_table, 4)
-    builder_obj.document.add_page_break()
-    key_table = builder_obj.search_table_with_key_columns(['KW', 'Leistungsübersicht'])
-    builder_obj.delete_empty_rows_in_table(key_table, 2)
+
+    # Set Date of Template
+    current_date = datetime_functions.datetime_to_str(datetime_functions.get_current_date(), '%d.%m.%Y')
+    builder_obj.replace_dates_string_in_standard_text(current_date)
+    builder_obj.replace_dates_string_in_all_tables(current_date)
+
+    # Set Leistungszeitraum
+    last_month = datetime_functions.get_current_month_number()-1
+    month_range = datetime_functions.get_count_of_days_for_specific_month(year=year, month_number=last_month)
+    if last_month>9:
+        start_date = '01.'+ str(last_month) +'.'+ str(year)
+    else:
+        start_date = '01.' + '0' + str(last_month) + '.' + str(year)
+    end_date = datetime_functions.add_days_to_date(datetime.strptime(start_date,'%d.%m.%Y'), month_range-1)
+    end_date = datetime_functions.datetime_to_str(end_date, '%d.%m.%Y')
+    builder_obj.replace_Leistungszeitraum(start_date, end_date)
+    builder_obj.save_docx()
+    # Replace Placeholders
+    # place_holders = config_for_custom_bills.list_of_place_holders
+    # for place_holder in place_holders:
+    #     builder_obj.replace_custom_placeholder_in_doc(place_holder, data_from_excel)
+
+    # keys = ['KW', 'Leistung', 'Zeit in Stunden', 'Betrag in Euro']
+    # example_tuple = [(123123, 213123, 12312312, 445235)]
+    # key_table = builder_obj.search_table_with_key_columns(keys)
+    # builder_obj.replace_rows(key_table, example_tuple)
+    # builder_obj.delete_empty_rows_in_table(key_table, 4)
+    # builder_obj.document.add_page_break()
+    # key_table = builder_obj.search_table_with_key_columns(['KW', 'Leistungsübersicht'])
+    # builder_obj.delete_empty_rows_in_table(key_table, 2)
     data_to_bill_doc = ...
 
     # Transform the doc file to a pdf file

+ 0 - 1
time_recoder/Readme

@@ -1 +0,0 @@
-pip install styleframe xlsxwriter pysimplegui datetime SQLAlchemy

+ 2 - 1
time_recoder/time_recoder_config.py

@@ -1,4 +1,5 @@
+DB_PATH = r'C:\Users\Danny\Desktop\EnD and Investment\Tools\time_recoder\time_recorder_database'
 HOURLY_WAGE_IN_EURO = 28
-PATH = r'C:\Users\Danny\Desktop\ssd wichtige dinge D\Tools\time_recoder\time_recorded_tables\worked_time_table.xlsx'
+PATH = r'C:\Users\Danny\Desktop\EnD and Investment\Tools\time_recoder\time_recorded_tables\work_time_danny.xlsx'
 TEST_CASE = True
 NAME = 'Daniel Krauel'

+ 1 - 1
time_recoder/time_recoder_gui/time_recorder_gui_config.py

@@ -1,4 +1,4 @@
-
+DB_PATH = r'C:\Users\Danny\Desktop\EnD and Investment\Tools\time_recoder\time_recorder_database'
 PAUSE_BUTTON_TEXT = 'Pause Timer'
 START_BUTTON_TEXT = 'Start Timer'
 STOP_BUTTON_TEXT = 'Stop Timer'

BIN
time_recoder/time_recorded_tables/worked_time_table.xlsx


+ 35 - 5
tool_lib/datetime_functions.py

@@ -1,12 +1,42 @@
 import datetime
+from calendar import monthrange, month_name
 
-def get_calendarweek_from_datetime(datetime_obj):
-    return datetime_obj.strftime('%V')
+
+
+def datetime_to_str(datetime_obj, format):
+    '''
+    :param format:
+    %V = Calendar Week
+    %d/%m%Y
+    :return:
+    '''
+    if datetime_obj == 'current':
+        datetime_obj = datetime.datetime.now()
+        return datetime_obj.strftime(format)
+    else:
+        return datetime_obj.strftime(format)
 
 def get_current_date():
-    return datetime.date.today()
+    return datetime.datetime.now()
 
-def get_current_month_year_as_str():
+def get_current_month_number():
     current_date = datetime.datetime.now()
-    return current_date.strftime("%m/%Y")
+    return int(current_date.strftime("%m"))
+
+def add_days_to_date(datetime_obj,count):
+    return datetime_obj + datetime.timedelta(days= count)
+
+def substract_days_to_current_date(count):
+    return datetime.datetime.now() - datetime.timedelta(days= count)
+
+def get_count_of_days_for_specific_month(year, month_number):
+    '''
+    :param year: As Int, ex. 2012
+    :param month_number:  As Int, ex. February == 2
+    :return:
+    '''
+    return monthrange(year,month_number)[1] # [0] contains the week day
+
+
+