main.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from fast_excel_to_bill.bill_doc.docx_builder import DOCFileBuilder
  2. from fast_excel_to_bill import config_for_custom_bills
  3. from tool_lib import datetime_functions
  4. current_month_year= datetime_functions.get_current_month_year_as_str()
  5. docx_output_path = config_for_custom_bills.docx_output_dir_path+ r'\bill_{}.docx'.format(current_month_year)
  6. def main():
  7. # Get Data which is necessary for the docx
  8. data_from_excel = ...
  9. burden_date = ...
  10. data_from_excel.append(burden_date)
  11. # Create a doc file which is based on a docx template
  12. builder_obj = DOCFileBuilder(config_for_custom_bills.docx_input_path, docx_output_path)
  13. place_holders = config_for_custom_bills.list_of_place_holders
  14. for place_holder in place_holders:
  15. builder_obj.replace_custom_placeholder_in_doc(place_holder, data_from_excel)
  16. builder_obj.replace_dates_string_in_standard_text('03.11.2022')
  17. builder_obj.replace_dates_string_in_all_tables('03.11.2022')
  18. keys = ['KW', 'Leistung', 'Zeit in Stunden', 'Betrag in Euro']
  19. example_tuple = [(123123, 213123, 12312312, 445235)]
  20. key_table = builder_obj.search_table_with_key_columns(keys)
  21. builder_obj.replace_rows(key_table, example_tuple)
  22. builder_obj.delete_empty_rows_in_table(key_table, 4)
  23. builder_obj.document.add_page_break()
  24. key_table = builder_obj.search_table_with_key_columns(['KW', 'Leistungsübersicht'])
  25. builder_obj.delete_empty_rows_in_table(key_table, 2)
  26. data_to_bill_doc = ...
  27. # Transform the doc file to a pdf file
  28. doc_to_pdf = ...
  29. if __name__ == '__main__':
  30. main()