# from libs import lib_mariadb as mdb # from libs import lib_csv as csv from libs import reporting_finance as report from libs.reporting_finance import Budget, FinanceDBConnection from configparser import ConfigParser as cp import os from sankeyflow import Sankey import matplotlib.pyplot as plt import matplotlib.patches as mpatches import re import datetime import numpy as np from colorsys import hls_to_rgb #node_central = 'total' def main(path_b:str, client:FinanceDBConnection, save_dir:str): budget = Budget(path_b) budget.sort_des_table(0) #create_budget_sankey(budget,save_dir) #create_accounting_sankey(client.get_conn(), save_dir) finances, last_update = report.import_finances(client.get_conn()) finances = report.sort_des_budget(finances, 0) tot_rev = report.get_total_revenues(finances) tot_ch = report.get_total_charges(finances) totals = report.get_totals_lists_for_charts( tot_ch_bud = report.get_total_charges(budget), tot_ch_real = tot_ch, tot_re_bud = report.get_total_revenues(budget), tot_re_real = tot_rev ) revenue_ratios = report.get_revenue_ratios(tot_rev, finances) charge_ratios = report.get_charge_ratios(tot_ch, finances) report.create_total_diagram(save_dir, totals, last_update) report.create_pie_diagrams(save_dir, revenue_ratios, charge_ratios, last_update) print('oucou') #connection à la db # Lister les comptes qui m'intéressent # Pour chaque compte 7 puis 6 : # - calculer somme entre le 1 er janvier et ajd # - ajouter valeur dans flow et nodes if __name__ == "__main__": VERBOSE = False conf = cp() conf.read('config') path_b = conf['path']['budget'] path_save = conf['path']['save_directory'] db_client = DBConnection(conf) if os.path.exists(path_b): print("les 2 fichiers budget et wp-config ont été trouvé") main(path_b, db_client, path_save) else : if not os.path.exists(path_b) : msg = "le chemin indiqué pour le paramètre budget dans le fichier config est incorrect. Le document a été supprimé ou déplacer. Merci de préciser un autre chemin" print(msg) print(f'budget = {path_b}') if VERBOSE : respo = input('Appuyer sur entrée pour terminer')