Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from widget_factory import *
- from mapped_acc_calculations import *
- from json_file_io import JsonFileIo
- from Opiti.from_excel.classes.global_inc import registry
- class DfaFormImport(Tk):
- def __init__(self):
- Tk.__init__(self)
- self.account_tree = AccountTree()
- self.widget_factory = WidgetsFactory()
- self.excel_acc_data = ExcelAccData()
- self.mapped_calculations = MappedCalculations()
- self.excel_acc_data.convert_json_data()
- self.acc_data_bycode = self.excel_acc_data.get_acc_data_bycode()
- self.min_top_group_digits = self.excel_acc_data.get_min_top_group_digits()
- self.max_top_group_digits = self.excel_acc_data.get_max_top_group_digits()
- self.max_groups = self.excel_acc_data.get_max_groups()
- json_file_io = JsonFileIo(file_name=registry["mapped_account_file_name"])
- acc_data_mapped = json_file_io.read_content() # {"121": ["СК"], "121-13": ["СК"], "121-14": ["СК"],
- if acc_data_mapped is None:
- print("?? acc_data_mapped is NONE!!!")
- self.acc_data_mapped_da = {} # Речник с маркираните сметки с вид 'ДА'
- for acc_code in self.acc_data_bycode:
- self.account_tree.add_code(acc_code) # Захранваме наследственото дърво
- self.acc_data = []
- self.max_depth_da = 0
- for acc_code in acc_data_mapped:
- acc_types = acc_data_mapped[acc_code]
- if 'ДА' in acc_types and len(acc_types) == 1:
- self.acc_data_mapped_da[acc_code] = acc_data_mapped[acc_code]
- depth = self.account_tree.get_depth(acc_code)
- if depth > self.max_depth_da:
- self.max_depth_da = depth
- for acc_code in self.acc_data_bycode:
- if acc_code in self.acc_data_mapped_da:
- acc_row = self.acc_data_bycode[acc_code]
- self.acc_data.append(acc_row)
- # -----------------------
- self.acc_rec_dfa = {
- 'adp': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'pzp': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'adas': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'pzas': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'di': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'drz': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'isa': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}}}
- # -------------------------
- self.check_assets = IntVar() # Radiobutton tab - преоценка активи
- self.check_amort = IntVar() # Radiobutton tab - преоценка амортизации
- self.last_entry = Entry() # Четене на Entry code
- self.acc_data = []
- self.scr_bar = None
- self.tab_names = {
- "act": "Активи",
- "amort": "Амортизации",
- "act_p": "Преоценка активи",
- "amort_p": "Преоценка амортизации",
- }
- self.current_tab = ''
- self.open = 'str_open_d'
- self.close = 'str_close_d'
- self.term_dc = 'debit'
- self.term = None
- self.all_accounts = []
- self.list_unadded_accs = []
- self.unadded_spin = ''
- self.selected_accs = [] # Данните, които трябва да се запишат във файл за да се маркират сметките в Treeview
- self.selected_accs_amo = [] # Маркирани сметки в Treeview АМортизации
- self.dict_entries = {} # Списък с Ентритата на Активите
- self.dict_entries_amo = {} # Списък с Ентрита на Амортизации
- self.get_sums = {}
- self.get_sums_amo = {}
- self.get_total = {'total': {'od': 0.0, 'oc': 0.0, 'td': 0.0, 'tc': 0.0, 'cd': 0.0, 'cc': 0.0}}
- self.get_total_amo = {'total': {'od': 0.0, 'oc': 0.0, 'td': 0.0, 'tc': 0.0, 'cd': 0.0, 'cc': 0.0}}
- self.user_ns = {'adp': 0, 'pzp': 0, 'adas': 0, 'pzas': 0, 'di': 0, 'drz': 0, 'isa': 0}
- self.user_ns_amo = {'di': 0}
- self.assets_re = {'adp': {'inc': 0.0, 'dec': 0.0}, 'pzp': {'inc': 0.0, 'dec': 0.0}, 'adas': {'inc': 0.0, 'dec': 0.0}, 'pzas': {'inc': 0.0, 'dec': 0.0}, 'di': {'inc': 0.0, 'dec': 0.0}, 'drz': {'inc': 0.0, 'dec': 0.0}, 'isa': {'inc': 0.0, 'dec': 0.0}}
- self.amort_re = {'di': {'inc': 0.0, 'dec': 0.0}}
- self.pop_message_answer = ''
- # TODO -> Главен прозорец
- self.title('Дългосрочни финансови активи') # TODO -> Главен прозорец
- self.geometry('1300x600+200+150') # 480
- self.resizable(True, False)
- self.attributes('-topmost', 'true')
- # TODO -> Notebook
- self.tabs = ttk.Notebook(self) # TODO -> Табове
- self.tabs.pack(pady=(1, 56), anchor='w') # class_, cursor, padding, relief, style, takefocus
- self.tab1 = Frame(self.tabs, width=550, height=480, relief=GROOVE, borderwidth=5)
- self.tab1.pack() # fill=”X” specifies, fill=”Y”
- self.tabs.add(self.tab1, text=self.tab_names['act'], padding=(2, 10)) #
- self.tab2 = Frame(self.tabs, width=550, height=480, relief=GROOVE, borderwidth=5, bg='white')
- self.tab2.pack(fill='both', expand=1)
- self.tabs.add(self.tab2, text=self.tab_names['amort'], padding=(2, 10))
- self.tab3 = Frame(self.tabs, width=550, height=480, relief=GROOVE, borderwidth=5, bg='mint cream')
- self.tab3.pack(fill='both', expand=1)
- self.tabs.add(self.tab3, text=self.tab_names['act_p'], state='hidden')
- self.tab4 = Frame(self.tabs, width=550, height=480, relief=GROOVE, borderwidth=5, bg='lemon chiffon')
- self.tab4.pack(fill='both', expand=1)
- self.tabs.add(self.tab4, text=self.tab_names['amort_p'], state='hidden') #
- self.tabs.bind('<<NotebookTabChanged>>', self.get_tab)
- # TODO -> LABELS
- self.widget_factory.get_label_un(self.tab1, 'с/ка: АКТИВИ', 20, 20, 'w', 12, 'blue', bg_border='red')
- self.widget_factory.get_label_un(self.tab1, 'Група III.: Дълг. финансови активи', 20, 50, 'w', 28, bg_border='red')
- self.widget_factory.get_label_un(self.tab1, 'НС\n(хил.лв)', 275, 40, 'w', 6, 'black', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab1, 'НС\n(лева)', 340, 40, 'center', 11, 'black', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab1, 'с/ка:\n(код)', 460, 40, 'center', 4, 'black', bg_border='green')
- self.widget_factory.get_label_un(self.tab1, '1. Акции и дялове в предприятия\n от група', 20, 90, 'w', 26, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '2. Предоставени заеми на предприятия\n от група', 20, 140, 'w', 26, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '3. Акции и дялове в асоциирани\n и смесени предприятия', 20, 190, 'w', 26, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '4. Предоставени заеми на асо-\nциирани и смесени предприятия', 20, 240, 'w', 26, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '5. Дългосрочни инвестиции\n(инвестиционни имоти)', 20, 290, 'w', 26, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, '6. Други заеми', 20, 340, 'w', 24, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, '7. Изкупени собствени акции', 20, 370, 'w', 24, bg_border='green')
- # TODO -> Entries
- self.user_adp = self.widget_factory.get_entry(self.tab1, 280, 100, 5, 'right', name='user_adp')
- self.user_adp.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_adp, "adp", "od"))
- self.l_open_adp = self.widget_factory.get_label_un(self.tab1, '0', 340, 100, 'e', 11, 'black', bg_border='green', j='left', name='adp')
- self.e_adp = self.widget_factory.get_entry(self.tab1, 450, 100, 9, 'left', name='adp')
- self.e_adp.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_adp))
- self.e_adp.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_adp))
- self.user_pzp = self.widget_factory.get_entry(self.tab1, 280, 150, 5, 'right', name='user_pzp')
- self.user_pzp.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_pzp, "pzp", "od"))
- self.l_open_pzp = self.widget_factory.get_label_un(self.tab1, '0', 340, 150, 'e', 11, 'black', bg_border='green', j='left')
- self.e_pzp = self.widget_factory.get_entry(self.tab1, 450, 150, 9, name='pzp')
- self.e_pzp.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_pzp))
- self.e_pzp.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_pzp))
- self.user_adas = self.widget_factory.get_entry(self.tab1, 280, 200, 5, 'right', name='user_adas')
- self.user_adas.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_adas, "adas", "od"))
- self.l_open_adas = self.widget_factory.get_label_un(self.tab1, '0', 340, 200, 'e', 11, 'black', bg_border='green', j='left')
- self.e_adas = self.widget_factory.get_entry(self.tab1, 450, 200, 9, name='adas')
- self.e_adas.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_adas))
- self.e_adas.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_adas))
- self.user_pzas = self.widget_factory.get_entry(self.tab1, 280, 250, 5, 'right', name='user_pzas')
- self.user_pzas.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_pzas, "pzas", "od"))
- self.l_open_pzas = self.widget_factory.get_label_un(self.tab1, '0', 340, 250, 'e', 11, 'black', bg_border='green', j='left')
- self.e_pzas = self.widget_factory.get_entry(self.tab1, 450, 250, 9, name='pzas')
- self.e_pzas.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_pzas))
- self.e_pzas.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_pzas))
- self.user_di = self.widget_factory.get_entry(self.tab1, 280, 300, 5, 'right', name='user_di')
- self.user_di.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_di, "di", "od"))
- self.l_open_di = self.widget_factory.get_label_un(self.tab1, '0', 340, 300, 'e', 11, 'black', bg_border='green', j='left')
- self.e_di = self.widget_factory.get_entry(self.tab1, 450, 300, 9, name='di')
- self.e_di.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_di))
- self.e_di.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_di))
- self.user_drz = self.widget_factory.get_entry(self.tab1, 280, 340, 5, 'right', name='user_drz')
- self.user_drz.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_drz, "drz", "od"))
- self.l_open_drz = self.widget_factory.get_label_un(self.tab1, '0', 340, 340, 'e', 11, 'black', bg_border='green', j='left')
- self.e_drz = self.widget_factory.get_entry(self.tab1, 450, 340, 9, name='drz')
- self.e_drz.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_drz))
- self.e_drz.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_drz))
- self.user_isa = self.widget_factory.get_entry(self.tab1, 280, 373, 5, 'right', name='user_isa')
- self.user_isa.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_isa, "isa", "od"))
- self.l_open_isa = self.widget_factory.get_label_un(self.tab1, '0', 340, 373, 'e', 11, 'black', bg_border='green', j='left')
- self.e_isa = self.widget_factory.get_entry(self.tab1, 450, 373, 9, name='isa')
- self.e_isa.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_isa))
- self.e_isa.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_isa))
- # TODO -> DOWN LABELS
- self.widget_factory.get_label(self.tab1, 90, 430, 'В началното', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 195, 430, 'Увеличение', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 300, 430, 'Намаление', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 410, 430, 'В края', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 20, 450, 'Група III.:', 10, 'w', font=10)
- self.l_open_total = self.widget_factory.get_label(self.tab1, 90, 450, 0.0, 12, 'e', color='black', font=10)
- self.l_turn_d_total = self.widget_factory.get_label(self.tab1, 195, 450, 0.0, 12, 'e', color='black', font=10)
- self.l_turn_c_total = self.widget_factory.get_label(self.tab1, 300, 450, 0.0, 12, 'e', color='black', font=10)
- self.l_close_total = self.widget_factory.get_label(self.tab1, 410, 450, 0.0, 12, 'e', color='black', font=10)
- self.widget_factory.get_label_un(self, 'Налични сметки:', 720, 1, 'w', 20, 'blue', bg_color=None, bg_border='red')
- # TODO -> CHECKBUTTON
- self.check_asset = Checkbutton(self.tab1, text="преоценка", variable=self.check_assets, command=lambda: self.act_c1())
- self.check_asset.place(x=275, y=20)
- # TODO TREEVIEW
- self.tv_frame = Frame(self)
- self.tv_frame.place(x=560, y=30)
- self.dict_columns = {"code_i": 'код', "acc_name": 'Сметка', 'open_di': 'НС Дебит', 'turn_di': 'Оборот Дт',
- 'turn_ci': 'Оборот Кт', "close_di": 'КС Дебит'}
- self.treeview_acc = self.widget_factory.get_treeview(self.tv_frame, **self.dict_columns)
- self.treeview_acc.config(selectmode='browse')
- # TODO SCROLLBAR
- self.scr_bar = Scrollbar(self.tv_frame, orient=VERTICAL)
- self.scr_bar.pack(side=RIGHT, fill=Y)
- self.treeview_acc.config(yscrollcommand=self.scr_bar.set)
- self.scr_bar.config(command=self.treeview_acc.yview, bg="red", activebackground="orange")
- self.treeview_acc.bind('<ButtonRelease-1>', lambda e: self.on_selected_acc(self.treeview_acc))
- self.treeview_acc.pack(side=LEFT)
- # TODO Spinboxes
- self.min_spin_2 = self.min_top_group_digits
- self.max_spin_2 = self.max_top_group_digits + self.max_groups
- self.var_spin_1 = StringVar(self)
- self.list_spin_1 = ['всички', 'недобавени']
- self.spin_1 = self.widget_factory.get_list_spinbox(self, self.list_spin_1, 12, 'center',
- self.var_spin_1, 560, 4)
- self.spin_1.configure(command=lambda: self.fill_treeview(term_dc=self.term_dc))
- print("self.min_spin_2", self.min_spin_2, "self.max_depth_da", self.max_depth_da)
- self.var_spin_2 = StringVar(self, value=str(self.max_depth_da))
- self.spin_2 = self.widget_factory.get_spinbox(self, self.min_spin_2, str(self.max_depth_da), 4,
- 'center', self.var_spin_2, 660, 4)
- self.spin_2.configure(command=lambda: self.fill_treeview(term_dc=self.term_dc))
- # TODO Buttons
- # Button Добави
- self.b_add = self.widget_factory.get_save_button(self, 466, 550, text='ДОБАВИ') # 460, 435
- self.b_add.bind('<ButtonRelease-1>', lambda e: self.on_add())
- # Button Корекции
- self.b_note = self.widget_factory.get_correction_button(self, 360, 550)
- self.b_note.bind('<ButtonRelease-1>', lambda e: self.on_correction())
- # Button Помощ
- self.b_help = self.widget_factory.get_help_button(self, 20, 550)
- self.b_help.bind('<ButtonRelease-1>')
- # Button Save
- self.b_save = self.widget_factory.get_ok_button(self, 830, 550)
- self.b_save.bind('<ButtonRelease-1>', lambda e: self.on_save())
- # Button Отказ
- self.b_exit = self.widget_factory.get_correction_esc(self, 930, 550)
- self.b_exit.config(command=self.destroy)
- # TODO AMORTIZATION Амортизации
- self.widget_factory.get_label_un(self.tab2, 'с/ка: АМОРТИЗАЦИИ', 20, 20, 'w', 18, 'red', bg_color='white', bg_border='blue')
- self.widget_factory.get_label_un(self.tab2, 'Група III.: Дълг. финансови активи', 20, 50, 'w', 28, bg_color='white', bg_border='blue')
- self.widget_factory.get_label_un(self.tab2, 'НС\n(хил.лв)', 275, 40, 'w', 6, 'black', bg_color='white', bg_border='blue', j='center')
- self.widget_factory.get_label_un(self.tab2, 'НС\n(лева)', 340, 40, 'center', 11, 'black', bg_color='white', bg_border='blue', j='center')
- self.widget_factory.get_label_un(self.tab2, 'с/ка:\n(код)', 460, 40, 'center', 4, 'black', bg_color='white', bg_border='green')
- self.widget_factory.get_label_un(self.tab2, '5. Дългосрочни инвестиции\n(инвестиционни имоти)', 20, 290, 'w', 26, bg_color='white', bg_border='green')
- # TODO -> Entries
- self.user_amo_di = self.widget_factory.get_entry(self.tab2, 280, 300, 5, 'right', name='user_amo_di')
- self.user_amo_di.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_amo_di, "di", "oc"))
- self.l_open_amo_di = self.widget_factory.get_label_un(self.tab2, '0', 340, 300, 'e', 11, 'black',bg_color='white', bg_border='green', j='left')
- self.e_amo_di = self.widget_factory.get_entry(self.tab2, 450, 300, 9, name='di')
- self.e_amo_di.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_amo_di))
- self.e_amo_di.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_amo_di))
- # TODO Check button Amort
- self.check_b2 = Checkbutton(self.tab2, text="преоценка", bg='white', variable=self.check_amort,
- command=lambda: self.act_c2())
- self.check_b2.place(x=275, y=20)
- # TODO -> DOWN LABELS
- self.widget_factory.get_label(self.tab2, 90, 430, 'В началното', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 195, 430, 'Увеличение', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 300, 430, 'Намаление', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 410, 430, 'В края', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 20, 450, 'Група III.:', 10, 'w', font=10, bg_color='white')
- self.l_amo_open_total = self.widget_factory.get_label(self.tab2, 90, 450, 0.0, 12, 'e', color='black',
- font=10, bg_color='white')
- self.l_amo_turn_d_total = self.widget_factory.get_label(self.tab2, 195, 450, 0.0, 12, 'e', color='black',
- font=10, bg_color='white')
- self.l_amo_turn_c_total = self.widget_factory.get_label(self.tab2, 300, 450, 0.0, 12, 'e', color='black',
- font=10, bg_color='white')
- self.l_amo_close_total = self.widget_factory.get_label(self.tab2, 410, 450, 0.0, 12, 'e', color='black',
- font=10, bg_color='white')
- # TODO Преоценка Активи
- self.widget_factory.get_label_un(self.tab3, 'с/ка: АКТИВИ', 20, 20, 'w', 26, 'black', bg_color='mint cream', bg_border='red')
- self.widget_factory.get_label_un(self.tab3, 'Група III.: ПРЕОЦЕНКА !', 20, 50, 'w', 26, 'black', bg_color='mint cream', bg_border='red')
- self.widget_factory.get_label_un(self.tab3, 'Увеличение\n(лева)', 280, 40, 'w', 10, 'black', bg_color='mint cream', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab3, 'Намаление\n(лева)', 370, 40, 'w', 10, 'black', bg_color='mint cream', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab3, 'Салдо\n(разлика)', 470, 40, 'w', 7, 'black', bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, '1. Акции и дялове в предприятия\n от група', 20, 90, 'w', 26, bg_color='mint cream', bg_border='red', j='left')
- self.widget_factory.get_label_un(self.tab3, '2. Предоставени заеми на предприятия\n от група', 20, 140, 'w', 26, bg_color='mint cream', bg_border='red', j='left')
- self.widget_factory.get_label_un(self.tab3, '3. Акции и дялове в асоциирани\n и смесени предприятия', 20, 190, 'w', 26, bg_color='mint cream', bg_border='red', j='left')
- self.widget_factory.get_label_un(self.tab3, '4. Предоставени заеми на асо-\nциирани и смесени предприятия', 20, 240, 'w', 26, bg_color='mint cream', bg_border='red', j='left')
- self.widget_factory.get_label_un(self.tab3, '5. Дългосрочни инвестиции\n(инвестиционни имоти)', 20, 290, 'w', 26, bg_color='mint cream', bg_border='red')
- self.widget_factory.get_label_un(self.tab3, '6. Други заеми', 20, 340, 'w', 24, bg_color='mint cream', bg_border='red')
- self.widget_factory.get_label_un(self.tab3, '7. Изкупени собствени акции', 20, 370, 'w', 24, bg_color='mint cream', bg_border='red')
- # TODO -> Entries
- self.turn_d_adp = self.widget_factory.get_entry(self.tab3, 280, 100, 12, 'right', name='d_adpr')
- self.turn_d_adp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_adp, "adp", "inc"))
- self.turn_c_adp = self.widget_factory.get_entry(self.tab3, 370, 100, 12, 'right', name='c_adp')
- self.turn_c_adp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_adp, "adp", "dec"))
- self.adp = self.widget_factory.get_label(self.tab3, 490, 100, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- self.turn_d_pzp = self.widget_factory.get_entry(self.tab3, 280, 150, 12, 'right', name='d_pzp')
- self.turn_d_pzp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_pzp, "pzp", "inc"))
- self.turn_c_pzp = self.widget_factory.get_entry(self.tab3, 370, 150, 12, 'right', name='c_pzp')
- self.turn_c_pzp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_pzp, "pzp", "dec"))
- self.pzp = self.widget_factory.get_label(self.tab3, 490, 150, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- self.turn_d_adas = self.widget_factory.get_entry(self.tab3, 280, 200, 12, 'right', name='d_adas')
- self.turn_d_adas.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_adas, "adas", "inc"))
- self.turn_c_adas = self.widget_factory.get_entry(self.tab3, 370, 200, 12, 'right', name='c_adas')
- self.turn_c_adas.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_adas, "adas", "dec"))
- self.adas = self.widget_factory.get_label(self.tab3, 490, 200, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- self.turn_d_pzas = self.widget_factory.get_entry(self.tab3, 280, 250, 12, 'right', name='d_pzas')
- self.turn_d_pzas.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_pzas, "pzas", "inc"))
- self.turn_c_pzas = self.widget_factory.get_entry(self.tab3, 370, 250, 12, 'right', name='c_pzas')
- self.turn_c_pzas.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_pzas, "pzas", "dec"))
- self.pzas = self.widget_factory.get_label(self.tab3, 490, 250, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- self.turn_d_di = self.widget_factory.get_entry(self.tab3, 280, 300, 12, 'right', name='d_di')
- self.turn_d_di.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_di, "di", "inc"))
- self.turn_c_di = self.widget_factory.get_entry(self.tab3, 370, 300, 12, 'right', name='c_di')
- self.turn_c_di.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_di, "di", "dec"))
- self.di = self.widget_factory.get_label(self.tab3, 490, 300, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- self.turn_d_drz = self.widget_factory.get_entry(self.tab3, 280, 340, 12, 'right', name='d_drz')
- self.turn_d_drz.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_drz, "drz", "inc"))
- self.turn_c_drz = self.widget_factory.get_entry(self.tab3, 370, 340, 12, 'right', name='c_drz')
- self.turn_c_drz.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_drz, "drz", "dec"))
- self.drz = self.widget_factory.get_label(self.tab3, 490, 340, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- self.turn_d_isa = self.widget_factory.get_entry(self.tab3, 280, 373, 12, 'right', name='d_isa')
- self.turn_d_isa.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_isa, "isa", "inc"))
- self.turn_c_isa = self.widget_factory.get_entry(self.tab3, 370, 373, 12, 'right', name='c_isa')
- self.turn_c_isa.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_isa, "isa", "dec"))
- self.isa = self.widget_factory.get_label(self.tab3, 490, 373, '0', 3, 'e', color='red', font=10, bg_color='mint cream')
- # TODO Преоценка Амортизации
- self.widget_factory.get_label_un(self.tab4, 'с/ка: АМОРТИЗАЦИИ', 20, 20, 'w', 20, 'black', bg_color='lemon chiffon', bg_border='red')
- self.widget_factory.get_label_un(self.tab4, 'Група I.: ПРЕОЦЕНКА !', 20, 50, 'w', 20, 'black', bg_color='lemon chiffon', bg_border='red')
- self.widget_factory.get_label_un(self.tab4, 'Увеличение\n(лева)', 280, 40, 'w', 10, 'black', bg_color='lemon chiffon', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab4, 'Намаление\n(лева)', 370, 40, 'w', 10, 'black', bg_color='lemon chiffon', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab4, 'Салдо\n(разлика)', 470, 40, 'w', 7, 'black', bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, '5. Дългосрочни инвестиции\n(инвестиционни имоти)', 20, 290, 'w', 26, bg_color='lemon chiffon', bg_border='green')
- # TODO -> Entries
- self.turn_d_amo_di = self.widget_factory.get_entry(self.tab4, 280, 300, 12, 'right', name='d_amo_di')
- self.turn_d_amo_di.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_amo_di, "di", "inc"))
- self.turn_c_amo_di = self.widget_factory.get_entry(self.tab4, 370, 300, 12, 'right', name='c_amo_di')
- self.turn_c_amo_di.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_amo_di, "di", "dec"))
- self.amo_di = self.widget_factory.get_label(self.tab4, 490, 300, '0', 3, 'e', color='red', font=10, bg_color='lemon chiffon')
- def get_tab(self, *args):
- self.current_tab = self.tabs.tab(self.tabs.select(), "text")
- if self.current_tab == 'Активи' or self.current_tab == 'Преоценка активи':
- self.open, self.close = 'str_open_d', 'str_close_d'
- self.treeview_acc.heading('#3', text='НС Дебит ')
- self.treeview_acc.heading('#6', text='КС Дебит ')
- self.term_dc = 'debit'
- if self.current_tab == 'Активи':
- self.treeview_acc.configure(selectmode='browse')
- self.e_adp.focus_set()
- self.b_add['state'] = 'normal'
- self.b_note['state'] = 'normal'
- else:
- self.treeview_acc.configure(selectmode='none')
- self.b_note['state'] = 'disabled'
- else:
- self.open, self.close = 'str_open_c', 'str_close_c'
- self.treeview_acc.heading('#3', text='НС Кредит ')
- self.treeview_acc.heading('#6', text='КС Кредит ')
- self.term_dc = 'credit'
- if self.current_tab == "Амортизации":
- self.treeview_acc.configure(selectmode='browse')
- self.e_amo_di.focus_set()
- self.b_note['state'] = 'normal'
- else:
- self.treeview_acc.configure(selectmode='none')
- self.b_note['state'] = 'disabled'
- self.fill_treeview(term_dc=self.term_dc)
- self.fill_labels()
- def set_pop_message_answer(self, answer):
- self.pop_message_answer = answer
- def on_save(self):
- # TODO -> Попълваме Началното салдо, въведено от потребителя:
- for entry in self.user_ns:
- self.acc_rec_dfa[entry]['ns'] = self.user_ns[entry]
- for entry in self.user_ns_amo:
- self.acc_rec_dfa[entry]['ns_amo'] = self.user_ns_amo[entry]
- # TODO -> Попълваме сметките, по Ентрита на активи и амортизации
- if not self.dict_entries: # Речника е празен
- for entry in self.acc_rec_dfa:
- self.acc_rec_dfa[entry]['assets'].clear()
- if not self.dict_entries_amo: # Речника е празен
- for entry in self.acc_rec_dfa:
- self.acc_rec_dfa[entry]['amort'].clear()
- for entry in self.dict_entries:
- if self.dict_entries[entry] is None:
- self.dict_entries[entry] = []
- self.acc_rec_dfa[entry]['assets'] = self.dict_entries[entry]
- for entry in self.dict_entries_amo:
- if self.dict_entries_amo[entry] is None:
- self.dict_entries_amo[entry] = []
- self.acc_rec_dfa[entry]['amort'] = self.dict_entries_amo[entry]
- # TODO -> попълване на сумите на преоценката
- for entry in self.assets_re:
- for dir in self.assets_re[entry]:
- self.acc_rec_dfa[entry]['assets_re'][dir] = self.assets_re[entry][dir]
- for entry in self.amort_re:
- for dir in self.amort_re[entry]:
- self.acc_rec_dfa[entry]['amort_re'][dir] = self.amort_re[entry][dir]
- print('self.acc_rec_dfa: ', self.acc_rec_dfa)
- json_file_io = JsonFileIo(file_name=registry['dfa_import_form_acc_rec_dfa_file_name'])
- json_file_io.write_content(self.acc_rec_dfa)
- # TODO -> Проверка за недобавена сметка и съобщение !!!!!
- if len(self.list_unadded_accs) > 0:
- # TODO -> Показва pop_message "Има недобавени сметки !
- pop_message = self.widget_factory.get_pop_message(self, lambda answer: self.set_pop_message_answer(answer),
- "Има недобавени сметки !", 1, 'red')
- self.wait_window(pop_message.pop)
- # TODO -> Ако "ДА"
- self.destroy()
- return
- else:
- pop_message = self.widget_factory.get_pop_message(self, lambda answer: self.set_pop_message_answer(answer),
- "Всички сметки са добавени !", 1, 'green')
- self.wait_window(pop_message.pop)
- # TODO -> Ако "ДА"
- self.destroy()
- return
- def on_correction(self):
- if self.b_note['state'] == 'disabled':
- return
- if self.current_tab == 'Активи':
- # TODO -> Махаме маркировката на Treeview и забраната за селекция
- for code in self.selected_accs:
- self.treeview_acc.tag_configure(code, background='lightgrey')
- self.selected_accs.clear()
- # TODO -> Изтриваме стойностите на речника, на ентритата и лейбълите
- self.dict_entries.clear()
- self.get_total = {'total': {'od': 0.0, 'oc': 0.0, 'td': 0.0, 'tc': 0.0, 'cd': 0.0, 'cc': 0.0}}
- self.l_open_adp['text'] = 0
- self.l_open_pzp['text'] = 0
- self.l_open_adas['text'] = 0
- self.l_open_pzas['text'] = 0
- self.l_open_di['text'] = 0
- self.l_open_drz['text'] = 0
- self.l_open_isa['text'] = 0
- # TODO -> На преоценките лейбъли ???
- self.adp['text'] = 0
- self.pzp['text'] = 0
- self.adas['text'] = 0
- self.pzas['text'] = 0
- self.di['text'] = 0
- self.drz['text'] = 0
- self.isa['text'] = 0
- elif self.current_tab == 'Амортизации':
- # TODO -> Махаме маркировката на Treeview и забраната за селекция
- for code in self.selected_accs_amo:
- self.treeview_acc.tag_configure(code, background='lightgrey')
- self.selected_accs_amo.clear()
- # TODO -> Изтриваме стойностите на речника, на ентритата и лейбълите
- self.dict_entries_amo.clear()
- self.get_total_amo = {'total': {'od': 0.0, 'oc': 0.0, 'td': 0.0, 'tc': 0.0, 'cd': 0.0, 'cc': 0.0}}
- self.l_open_amo_di['text'] = 0
- # TODO ?????
- self.amo_di['text'] = 0
- self.fill_labels()
- self.fill_treeview(term_dc=self.term_dc)
- # TODO -> Преоценка
- def revaluations(self, re_val: Entry, key1: str, key2: str):
- revaluation = re_val.get()
- if ' ' in revaluation:
- re_val.delete(0, END)
- re_val.insert(0, revaluation)
- is_good = True
- if revaluation == '':
- revaluation = 0.0
- else:
- try:
- float(revaluation)
- except:
- is_good = False
- revaluation = 0.0
- if is_good:
- re_val.configure(bg='white')
- else:
- re_val.configure(bg='red')
- if self.current_tab == 'Преоценка активи':
- self.assets_re[key1][key2] = float(revaluation)
- elif self.current_tab == 'Преоценка амортизации':
- self.amort_re[key1][key2] = float(revaluation)
- # TODO -> ЗА разлики между НС от потребителя и НС от сметките
- def update_state_open_bal(self, open_bal: Entry, key1: str, key2: str): # self.user_s, s, od
- name_entry = open_bal.winfo_name() # user_s
- print('name_entry: ', name_entry)
- user_1000 = open_bal.get() # 55
- try:
- user_1000 = int(user_1000)
- except:
- user_1000 = 0
- calc = self.get_sum_string(key1, key2) # s od
- calc_1000 = int(round(calc / 1000))
- if user_1000 == calc_1000:
- # TODO оцвети нещо
- open_bal.configure(bg='white')
- else:
- open_bal.configure(bg='red')
- # TODO -> Да се попълни речник с НС, въведени от потребителя !
- if self.current_tab == 'Активи':
- self.user_ns[key1] = user_1000
- elif self.current_tab == 'Амортизации':
- self.user_ns_amo[key1] = user_1000
- if name_entry == 'user_adp':
- self.adp['text'] = user_1000 - calc_1000
- print("self.acc_rec_dfa", self.acc_rec_dfa)
- self.acc_rec_dfa['adp']['assets_re']['diff'] = user_1000 - calc_1000
- elif name_entry == 'user_pzp':
- self.pzp['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['pzp']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_adas':
- self.adas['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['adas']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_pzas':
- self.pzas['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['pzas']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_di':
- self.di['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['di']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_drz':
- self.drz['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['drz']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_isa':
- self.isa['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['isa']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_amo_di':
- self.amo_di['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dfa['di']['amort_re']['diff'] = int(user_1000 - calc_1000)
- def get_sum_string(self, key1, key2):
- if self.current_tab == 'Активи':
- if key1 in self.get_sums:
- return self.get_sums[key1][key2]
- elif self.current_tab == 'Амортизации':
- if key1 in self.get_sums_amo:
- return self.get_sums_amo[key1][key2]
- return 0
- def fill_labels(self):
- for entry in self.dict_entries_amo:
- if self.dict_entries_amo[entry] is None:
- self.dict_entries_amo[entry] = []
- for entry in self.dict_entries:
- if self.dict_entries[entry] is None:
- self.dict_entries[entry] = []
- if self.current_tab == 'Активи':
- if len(self.dict_entries) > 0:
- self.get_sums, self.get_total = self.mapped_calculations.get_sum_list_accounts(self.dict_entries)
- for entr in self.get_sums:
- if entr == 'adp':
- self.l_open_adp['text'] = f"{self.get_sums['adp']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_adp, "adp", "od")
- elif entr == 'pzp':
- self.l_open_pzp['text'] = f"{self.get_sums['pzp']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_pzp, "pzp", "od")
- elif entr == 'adas':
- self.l_open_adas['text'] = f"{self.get_sums['adas']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_adas, "adas", "od")
- elif entr == 'pzas':
- self.l_open_pzas['text'] = f"{self.get_sums['pzas']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_pzas, "pzas", "od")
- elif entr == 'di':
- self.l_open_di['text'] = f"{self.get_sums['di']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_di, "di", "od")
- elif entr == 'drz':
- self.l_open_drz['text'] = f"{self.get_sums['drz']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_drz, "drz", "od")
- elif entr == 'isa':
- self.l_open_isa['text'] = f"{self.get_sums['isa']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_isa, "isa", "od")
- self.l_open_total['text'] = f"{self.get_total['total']['od']:,.2f}".replace(',', ' ')
- self.l_turn_d_total['text'] = f"{self.get_total['total']['td']:,.2f}".replace(',', ' ')
- self.l_turn_c_total['text'] = f"{self.get_total['total']['tc']:,.2f}".replace(',', ' ')
- self.l_close_total['text'] = f"{self.get_total['total']['cd']:,.2f}".replace(',', ' ')
- elif self.current_tab == 'Амортизации':
- if len(self.dict_entries_amo) > 0:
- self.get_sums_amo, self.get_total_amo =\
- self.mapped_calculations.get_sum_list_accounts(self.dict_entries_amo)
- for entr in self.get_sums_amo:
- if entr == 'di':
- self.l_open_amo_di['text'] = f"{self.get_sums_amo['di']['oc']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_amo_di, "di", "oc")
- self.l_amo_open_total['text'] = f"{self.get_total_amo['total']['oc']:,.2f}".replace(',', ' ')
- self.l_amo_turn_d_total['text'] = f"{self.get_total_amo['total']['td']:,.2f}".replace(',', ' ')
- self.l_amo_turn_c_total['text'] = f"{self.get_total_amo['total']['tc']:,.2f}".replace(',', ' ')
- self.l_amo_close_total['text'] = f"{self.get_total_amo['total']['cc']:,.2f}".replace(',', ' ')
- def on_add(self):
- if self.current_tab == 'Активи':
- acc_code = self.last_entry.get() # '203'
- if acc_code is None or acc_code == '':
- return
- self.selected_accs.append(list(self.treeview_acc.selection())) # current_selection: ('200',)
- # TODO -> На името на Entry да добавим сметката
- name_entry = self.last_entry.winfo_name()
- if name_entry not in self.dict_entries:
- self.dict_entries[name_entry] = ()
- self.dict_entries[name_entry] += self.treeview_acc.selection() # Добавям маркираната сметка
- # TODO -> Добавяне на децата и родителите на добавената сметка
- all_children = self.account_tree.get_all_children(acc_code) # all_children: ['200', '203', '205']
- all_parents = self.account_tree.get_all_parents(acc_code) # acc_code = 223
- self.selected_accs.extend(all_children)
- self.selected_accs.extend(all_parents)
- # TODO -> След добавяне да се изпразват всички ентрита, а не само добавеното !!!!!
- if self.e_adp.get() != '': self.e_adp.delete(0, 'end')
- if self.e_pzp.get() != '': self.e_pzp.delete(0, 'end')
- if self.e_adas.get() != '': self.e_adas.delete(0, 'end')
- if self.e_pzas.get() != '': self.e_pzas.delete(0, 'end')
- if self.e_di.get() != '': self.e_di.delete(0, 'end')
- if self.e_drz.get() != '': self.e_drz.delete(0, 'end')
- if self.e_isa.get() != '': self.e_isa.delete(0, 'end')
- elif self.current_tab == 'Амортизации':
- acc_code = self.last_entry.get() # '203'
- if acc_code is None or acc_code == '':
- return
- self.selected_accs_amo.append(list(self.treeview_acc.selection()))
- # TODO -> На името на Entry да добавим сметката
- name_entry = self.last_entry.winfo_name()
- if name_entry not in self.dict_entries_amo:
- self.dict_entries_amo[name_entry] = ()
- self.dict_entries_amo[name_entry] += self.treeview_acc.selection()
- # TODO -> Добавяне на децата и родителите на добавената сметка
- all_children = self.account_tree.get_all_children(acc_code) # all_children: ['200', '203']
- all_parents = self.account_tree.get_all_parents(acc_code) # acc_code = 223
- self.selected_accs_amo.extend(all_children)
- self.selected_accs_amo.extend(all_parents)
- # TODO -> След добавяне да се изпразват всички ентрита, а не само добавеното !!!!!
- if self.e_amo_di.get() != '': self.e_amo_di.delete(0, 'end')
- self.fill_labels()
- # TODO -> Попълваме Treeview
- self.fill_treeview(term_dc=self.term_dc)
- def act_c1(self):
- if self.check_assets.get() == 1: # state: must be normal, disabled, or hidden
- self.tabs.tab(self.tab3, state='normal')
- elif self.check_assets.get() == 0:
- self.tabs.tab(self.tab3, state='hidden')
- def act_c2(self):
- if self.check_amort.get() == 1: # state: must be normal, disabled, or hidden
- self.tabs.tab(self.tab4, state='normal')
- elif self.check_amort.get() == 0:
- self.tabs.tab(self.tab4, state='hidden')
- def verify_selection(self): # Забрана за маркиране
- for code in self.selected_accs:
- if self.treeview_acc.exists(code):
- self.treeview_acc.selection_remove(code)
- for code in self.selected_accs_amo:
- if self.treeview_acc.exists(code):
- self.treeview_acc.selection_remove(code)
- def on_selected_acc(self, source_treeview):
- self.verify_selection()
- current_item = source_treeview.focus()
- if current_item in self.selected_accs or current_item in self.selected_accs_amo: # <class 'tuple'>
- return
- values = source_treeview.item(current_item)["values"]
- if not isinstance(values, list):
- return
- code = values[0]
- self.last_entry.delete(0, END)
- self.last_entry.insert(0, code)
- def entry_on_focus(self, entry):
- self.last_entry = entry
- def on_entry_key_release(self, entry):
- self.last_entry = entry
- entry_text = entry.get()
- if len(entry_text) < 2:
- self.fill_treeview(term_dc=self.term_dc)
- return
- term = entry_text
- self.fill_treeview(term=term, term_dc=self.term_dc)
- def dfa(self):
- try:
- json_file_io = JsonFileIo(file_name=registry["dfa_import_form_acc_rec_dfa_file_name"])
- tmp_acc_rec_dma = json_file_io.read_content()
- if tmp_acc_rec_dma is not None:
- self.acc_rec_dfa = tmp_acc_rec_dma
- self.refill_form()
- self.get_tab() # Рефрешва таба, попълва self.current_tab
- except:
- pass
- self.fill_treeview(term_dc=self.term_dc)
- self.mainloop()
- def refill_form(self):
- # TODO -> Попълваме Treeview с маркирани и забранени за селектиране сметки
- for entry in self.acc_rec_dfa:
- self.dict_entries[entry] = self.acc_rec_dfa[entry]['assets']
- for entry in self.acc_rec_dfa:
- self.dict_entries_amo[entry] = self.acc_rec_dfa[entry]['amort']
- # TODO -> Попълваме сметките, децата и родителите на сметките в self.selected_accs, self.selected_accs_amo
- for entry_name in self.dict_entries:
- for acc_code in self.dict_entries[entry_name]:
- if acc_code not in self.selected_accs:
- self.selected_accs.append(acc_code)
- all_children = self.account_tree.get_all_children(acc_code) # all_children:['200', '203'']
- all_parents = self.account_tree.get_all_parents(acc_code) # acc_code = 223 all_parents:['22',]
- self.selected_accs.extend([a for a in all_children if a not in self.selected_accs])
- self.selected_accs.extend([a for a in all_parents if a not in self.selected_accs])
- for entry_name in self.dict_entries_amo:
- for acc_code in self.dict_entries_amo[entry_name]:
- if acc_code not in self.selected_accs_amo:
- self.selected_accs_amo.append(acc_code)
- all_children = self.account_tree.get_all_children(acc_code) # all_children:['200', '203',]
- all_parents = self.account_tree.get_all_parents(acc_code)
- self.selected_accs_amo.extend([a for a in all_children if a not in self.selected_accs_amo])
- self.selected_accs_amo.extend([a for a in all_parents if a not in self.selected_accs_amo])
- # TODO -> Попълваме Ентритата с НС user_ns и user_ns_amo
- for entry_name in self.user_ns:
- self.user_ns[entry_name] = self.acc_rec_dfa[entry_name]['ns']
- if self.user_ns['adp'] > 0:
- self.user_adp.insert(0, self.user_ns['adp'])
- if self.user_ns['pzp'] > 0:
- self.user_pzp.insert(0, self.user_ns['pzp'])
- if self.user_ns['adas'] > 0:
- self.user_adas.insert(0, self.user_ns['adas'])
- if self.user_ns['pzas'] > 0:
- self.user_pzas.insert(0, self.user_ns['pzas'])
- if self.user_ns['di'] > 0:
- self.user_di.insert(0, self.user_ns['di'])
- if self.user_ns['drz'] > 0:
- self.user_drz.insert(0, self.user_ns['drz'])
- if self.user_ns['isa'] > 0:
- self.user_isa.insert(0, self.user_ns['isa'])
- for entry_name in self.user_ns_amo:
- self.user_ns_amo[entry_name] = self.acc_rec_dfa[entry_name]['ns_amo']
- if self.user_ns_amo['di'] > 0:
- self.user_amo_di.insert(0, self.user_ns_amo['di'])
- # TODO -> Попълваме Ентритата с Преоценките
- print('self.assets_re: ', self.assets_re)
- for entry in self.assets_re:
- for dir in self.assets_re[entry]:
- self.assets_re[entry][dir] = self.acc_rec_dfa[entry]['assets_re'][dir]
- print('self.assets_re след refill: ', self.assets_re)
- if self.assets_re['adp']['inc'] > 0:
- self.turn_d_adp.insert(0, self.assets_re['adp']['inc'])
- if self.assets_re['adp']['dec'] > 0:
- self.turn_c_adp.insert(0, self.assets_re['adp']['dec'])
- if self.assets_re['pzp']['inc'] > 0:
- self.turn_d_pzp.insert(0, self.assets_re['pzp']['inc'])
- if self.assets_re['pzp']['dec'] > 0:
- self.turn_c_pzp.insert(0, self.assets_re['pzp']['dec'])
- if self.assets_re['adas']['inc'] > 0:
- self.turn_d_adas.insert(0, self.assets_re['adas']['inc'])
- if self.assets_re['adas']['dec'] > 0:
- self.turn_c_adas.insert(0, self.assets_re['adas']['dec'])
- if self.assets_re['pzas']['inc'] > 0:
- self.turn_d_pzas.insert(0, self.assets_re['pzas']['inc'])
- if self.assets_re['pzas']['dec'] > 0:
- self.turn_c_pzas.insert(0, self.assets_re['pzas']['dec'])
- if self.assets_re['di']['inc'] > 0:
- self.turn_d_di.insert(0, self.assets_re['di']['inc'])
- if self.assets_re['di']['dec'] > 0:
- self.turn_c_di.insert(0, self.assets_re['di']['dec'])
- if self.assets_re['drz']['inc'] > 0:
- self.turn_d_drz.insert(0, self.assets_re['drz']['inc'])
- if self.assets_re['drz']['dec'] > 0:
- self.turn_c_drz.insert(0, self.assets_re['drz']['dec'])
- if self.assets_re['isa']['inc'] > 0:
- self.turn_d_isa.insert(0, self.assets_re['isa']['inc'])
- if self.assets_re['isa']['dec'] > 0:
- self.turn_c_isa.insert(0, self.assets_re['isa']['dec'])
- for entry in self.amort_re:
- for dir in self.amort_re[entry]:
- self.amort_re[entry][dir] = self.acc_rec_dfa[entry]['amort_re'][dir]
- print('self.amort_re след refill: ', self.amort_re)
- if self.amort_re['di']['inc'] > 0:
- self.turn_d_amo_di.insert(0, self.amort_re['di']['inc'])
- if self.amort_re['di']['dec'] > 0:
- self.turn_c_amo_di.insert(0, self.amort_re['di']['dec'])
- def fill_treeview(self, term=None, term_dc='debit'):
- self.treeview_acc.delete(*self.treeview_acc.get_children()) # Вградена функция за изтриване на Treeview
- # TODO -> Spinboxes
- self.unadded_spin = self.var_spin_1.get() # Взима стойността на спинбокса за недобавени
- spin_2 = int(self.var_spin_2.get())
- self.all_accounts.extend(self.selected_accs)
- self.all_accounts.extend(self.selected_accs_amo)
- self.list_unadded_accs = self.account_tree.get_unadded_acc(self.all_accounts, self.acc_data_mapped_da)
- count_rows = 0
- for acc_code in self.acc_data_bycode:
- if acc_code not in self.acc_data_mapped_da:
- continue
- if term_dc is not None and term_dc == 'debit':
- if self.acc_data_bycode[acc_code]['open_c'] > 0 or self.acc_data_bycode[acc_code]['close_c'] > 0:
- continue
- elif term_dc is not None and term_dc == 'credit':
- if self.acc_data_bycode[acc_code]['open_d'] > 0 or self.acc_data_bycode[acc_code]['close_d'] > 0:
- continue
- if term is not None: # Искаме само сметките дето кода им започва с term
- term_len = len(term)
- code_piece = self.acc_data_bycode[acc_code]['code'][0:term_len]
- # Ако сметката не започва с term
- if term != code_piece:
- continue # прескачаме тая сметка, не отговаря на търсеното
- # TODO -> Ако spin_1 = 'недобавени' -> извежда само недобавените сметки в ентритата
- if self.unadded_spin == 'недобавени':
- if acc_code not in self.list_unadded_accs:
- continue
- # TODO -> spin_2 type of spin_2: <class 'int'>
- groups_in_acc_code = re.findall('[0-9]+', acc_code) # Връща list със групите на сметката
- top_group = groups_in_acc_code[0]
- depth = self.account_tree.get_depth(acc_code)
- if len(top_group) > spin_2 or depth > spin_2:
- continue
- count_rows += 1
- row = [self.acc_data_bycode[acc_code]['code'],
- self.acc_data_bycode[acc_code]['name'],
- self.acc_data_bycode[acc_code][self.open],
- self.acc_data_bycode[acc_code]['str_turn_d'],
- self.acc_data_bycode[acc_code]['str_turn_c'],
- self.acc_data_bycode[acc_code][self.close]]
- tags = acc_code
- iid = acc_code
- self.treeview_acc.insert('', END, values=row, tags=tags, iid=iid) # ????
- self.treeview_acc.config(height=count_rows)
- if count_rows > 19:
- self.treeview_acc.configure(height=19)
- for code in self.selected_accs: # Оцветяване на добавените сметки
- if self.treeview_acc.exists(code):
- self.treeview_acc.tag_configure(code, background='powderblue')
- for code in self.selected_accs_amo: # Оцветяване на добавените сметки
- if self.treeview_acc.exists(code):
- self.treeview_acc.tag_configure(code, background='powderblue')
- if __name__ == '__main__':
- dfa = DfaFormImport()
- dfa.dfa()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement