ALEXANDAR_GEORGIEV

main_file_new

Jun 5th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.86 KB | Source Code | 0 0
  1. # import tkinter as tk
  2. # import re
  3. from trial_balance_import import *
  4. from new_company import *
  5. from accountant import *
  6. from trial_balance import *
  7. from mapped_acc_calc import *
  8.  
  9.  
  10. def main():
  11.     root = tk.Tk()
  12.     h = 160
  13.     screen_width = root.winfo_screenwidth()
  14.     main_window = Window(root, 'ИЗГОТВЯНЕ НА ФИНАНСОВИ ОТЧЕТИ', f'{screen_width}x{h}+0+0',
  15.                          ("-topmost"), resizable_h=False, resizable_w=True)
  16.     return None
  17.  
  18.  
  19. class Window:
  20.     def __init__(self, root, title, geometry, attributes, resizable_h, resizable_w):
  21.         self.window = root
  22.         self.window.title(title)
  23.         self.window.geometry(geometry)
  24.         self.window.resizable(height=resizable_h, width=resizable_w)
  25.         self.window.attributes(attributes, 'true')
  26.         self.screen_width = self.window.winfo_screenwidth()
  27.  
  28.         self.sk_label_sum = tk.StringVar(self.window, value='n/a')
  29.         self.balance_amount = tk.StringVar(self.window, value='n/a')
  30.         # Calculator
  31.         self.photo1 = tk.PhotoImage(file=r"32x32.png")
  32.         self.bt1 = tk.Button(self.window, image=self.photo1, relief='raised', height=30, width=30, highlightthickness=4, activebackground='red')
  33.         self.bt1.place(x=self.screen_width-80, y=0)
  34.         self.bt1.bind('<ButtonRelease-1>',)
  35.         # ------Take Pictures
  36.         self.butt_pict = tk.Button(self.window, text='Снимка на\nактивния\nпрозорец', font=('Bookman Old Style Bold', 8), fg='green')
  37.         self.butt_pict.place(x=self.screen_width-200, y=0)
  38.         self.butt_pict.bind('<ButtonRelease-1>',  self.passport_com)
  39.         # # Buttons - referenceс
  40.         self.butt_balance = tk.Button(self.window, text='БАЛАНС', font=('Bookman Old Style Bold', 8), fg='green', width=10)
  41.         self.butt_balance.place(x=350 , y=0)
  42.         self.butt_balance.bind('<ButtonRelease-1>', None)
  43.         self.butt_income = tk.Button(self.window, text='ОПР', font=('Bookman Old Style Bold', 8), fg='darkred', width=10)
  44.         self.butt_income.place(x=470 , y=0)
  45.         self.butt_income.bind('<ButtonRelease-1>', None)
  46.         self.butt_income = tk.Button(self.window, text='КАПИТАЛ', font=('Bookman Old Style Bold', 8), fg='blue', width=10)
  47.         self.butt_income.place(x=590 , y=0)
  48.         self.butt_income.bind('<ButtonRelease-1>', None)
  49.         self.butt_income = tk.Button(self.window, text='ОПП', font=('Bookman Old Style Bold', 8), fg='darkblue', width=10)
  50.         self.butt_income.place(x=710 , y=0)
  51.         self.butt_income.bind('<ButtonRelease-1>', None)
  52.         self.butt_income = tk.Button(self.window, text='ДА', font=('Bookman Old Style Bold', 8), fg='black', width=10)
  53.         self.butt_income.place(x=830 , y=0)
  54.         self.butt_income.bind('<ButtonRelease-1>', None)
  55.         # -----LABELS
  56.         self.sk_label_sum, self.balance_amount = self.get_sum_labes()
  57.         sum_a = self.sk_label_sum.get()
  58.         # print('sum_a', sum_a)
  59.         self.label_sk = tk.Label(self.window, text='Собствен капитал: ', font=('Times', 8, 'italic'), fg='green', width=16, anchor='w')
  60.         self.label_sk.place(x=350 , y=30)
  61.         self.label_sk_sum = tk.Label(self.window, textvariable=self.sk_label_sum, text=sum_a, font=('Times', 8, 'italic'), fg='black', width=14, anchor='e')
  62.         self.label_sk_sum.place(x=350 , y=45)
  63.         self.label_a = tk.Label(self.window, text='Балансово число: ', font=('Times', 8, 'italic'), fg='green', width=16, anchor='w')
  64.         self.label_a.place(x=350 , y=60)
  65.         self.label_a_sum = tk.Label(self.window, textvariable=self.balance_amount, text='10 000 999.00 ', font=('Times', 8, 'italic'), fg='black', width=14, anchor='e')
  66.         self.label_a_sum.place(x=350 , y=75)
  67.         self.label_inc = tk.Label(self.window, text='Приходи: ', font=('Times', 8, 'italic'), fg='darkred', width=16, anchor='w')
  68.         self.label_inc.place(x=470 , y=30)
  69.         self.label_inc_sum = tk.Label(self.window, text='19 000 999.00 ', font=('Times', 8, 'italic'), fg='black', width=14, anchor='e')
  70.         self.label_inc_sum.place(x=470 , y=45)
  71.         self.label_cap = tk.Label(self.window, text='Дивиденти: ', font=('Times', 8, 'italic'), fg='blue', width=16, anchor='w')
  72.         self.label_cap.place(x=590 , y=30)
  73.         self.label_cap_sum = tk.Label(self.window, text='1 000 999.00 ', font=('Times', 8, 'italic'), fg='black', width=14, anchor='e')
  74.         self.label_cap_sum.place(x=590 , y=45)
  75.         self.label_money = tk.Label(self.window, text='Налични пари: ', font=('Times', 8, 'italic'), fg='darkblue', width=16, anchor='w')
  76.         self.label_money.place(x=710 , y=30)
  77.         self.label_money_sum = tk.Label(root, text='1 000 999.00 ', font=('Times', 8, 'italic'), fg='black', width=14, anchor='e')
  78.         self.label_money_sum.place(x=710 , y=45)
  79.         self.label_long_assets = tk.Label(self.window, text='Нетекущи активи: ', font=('Times', 8, 'italic'), fg='black', width=16, anchor='w')
  80.         self.label_long_assets.place(x=830 , y=30)
  81.         self.label_long_assets_sum = tk.Label(self.window, text='10 000 999.00 ', font=('Times', 8, 'italic'), fg='black', width=14, anchor='e')
  82.         self.label_long_assets_sum.place(x=830 , y=45)
  83.         # ----- MENU
  84.         self.menubar = tk.Menu(self.window, background='yellow', foreground='black', activebackground='green', activeforeground='black')
  85.         root.config(menu=self.menubar)
  86.         # Create a File menu
  87.         file_menu = tk.Menu(self.menubar, tearoff=0, background='white', foreground='blue', font='Times, 12')    # tearoff - маха прекъснатата линия
  88.         # add menu item to menubar
  89.         file_menu.add_command(label="Отвори")
  90.         file_menu.add_command(label="Item1")
  91.         file_menu.add_command(label="Item2")
  92.         file_menu.add_command(label="Изход", command=root.destroy)
  93.         self.menubar.add_cascade(label="Файл", menu=file_menu)   # add the File_menu to the menubar
  94.         # Import menu
  95.         import_menu = tk.Menu(self.menubar, tearoff=0)
  96.         import_menu.add_command(label="Оборотна ведомост", command=lambda: None)
  97.         import_menu.add_command(label="Парични средтсва")
  98.         import_menu.add_command(label="Приходни сметки")
  99.         self.menubar.add_cascade(label="Импорт", menu=import_menu)  # add the File_menu to the menubar
  100.         # Ръчно въвеждане ДА
  101.         act_menu = tk.Menu(self.menubar, tearoff=0)
  102.         act_menu.add_command(label="I. Нематериални активи", command=self.import_dna)
  103.         act_menu.add_command(label="II. Дълготрайни материални активи")
  104.         act_menu.add_command(label="III. Дългосрочни финансови активи")
  105.         act_menu.add_command(label="IV. Отсрочени данъци")
  106.         act_menu.add_command(label="- Платени аванси на доставчици")
  107.         act_menu.add_command(label="- Активи в процес на придобиване")
  108.         act_menu.add_command(label="- Преоценени активи")
  109.         self.menubar.add_cascade(label="Въвеждане", menu=act_menu)  # add the File_menu to the menubar
  110.         # Нова фирма
  111.         new_company = tk.Menu(self.menubar, tearoff=0)
  112.         new_company.add_command(label='Ново предприятие', command=lambda: self.passport_com())
  113.         new_company.add_command(label='Съставител на ФО', command=lambda: self.accountancy())
  114.         new_company.add_command(label='Начални салда', command=lambda: None)
  115.         new_company.add_command(label='Видове сметки', command=lambda: self.type_acc())
  116.         self.menubar.add_cascade(label='Нови данни', menu=new_company)
  117.         # Справки
  118.         reference = tk.Menu(self.menubar, tearoff=0)
  119.         reference.add_command(label='Оборотна ведомост', command=lambda: None)
  120.         reference.add_command(label='Кореспонденция на приходите', command=lambda: None)
  121.         reference.add_command(label='Сметки за нетекущи активи', command=lambda: None)
  122.         reference.add_command(label='Движение на парични средства', command=lambda: None)
  123.         self.menubar.add_cascade(label='Справки', menu=reference)
  124.  
  125.         self.window.mainloop()
  126.  
  127.     def get_sum_labes(self):
  128.         mapped_calc = MappedCalculations()
  129.         check = mapped_calc.are_all_acc_mapped()
  130.         print('check', check)
  131.         if check:
  132.             # Собствен капитал
  133.             # TODO -> Да получа целия речник sums {} и да направя сметките diff = sums["cc"] - sums["cd"]
  134.             sk = mapped_calc.get_equity()
  135.             sk = f'{sk:,.2f}'.replace(',', ' ')
  136.             self.sk_label_sum.set(sk)
  137.             # Балансово число
  138.             # TODO -> Вече имам: sums["cd"] на СК и трябва само да взема sums["cc"] на Всички сметки
  139.             bal_amount = mapped_calc.get_balance_amount()
  140.             bal_amount = f'{bal_amount:,.2f}'.replace(',', ' ')
  141.             self.balance_amount.set(bal_amount)
  142.             print('bal_amount', bal_amount)
  143.             # print('self.sk_label_sum', self.sk_label_sum)
  144.         return self.sk_label_sum, self.balance_amount
  145.  
  146.     def passport_com(self):
  147.         imp_win = InputCompany()
  148.         imp_win.open_comp()
  149.  
  150.     def accountancy(self):
  151.         inp_acc = AccountCompany()
  152.         inp_acc.open_acc()
  153.  
  154.     def type_acc(self):     # TODO Treeview_acc
  155.         trial_balance = TrialBalance()
  156.         trial_balance.main()
  157.  
  158.     def import_trial(self):
  159.         open_trial_balance()
  160.  
  161.     def import_dna(self):
  162.         pass
  163.  
  164.  
  165. if __name__ == '__main__':
  166.     main()
  167.  
  168.  
Add Comment
Please, Sign In to add comment