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 Expenses(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_rx = 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_rx:
- self.max_depth_rx = 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_rx = {
- 'sm': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'vu': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'a': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'po': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'dro': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rd': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'ona': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'ota': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'pr': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'drr': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rod': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rsd': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rtd': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rad': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rud': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rlk': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rldopk': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rdrl': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rov': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rofa': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rora': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'ropfa': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'drfr': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'nzpr': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'nnpr': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'bsna': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'bsta': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'rtax': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'alttax': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0, 'dec': 0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 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, 'dec': 0}, 'pzp': {'inc': 0, 'dec': 0}, 'adas': {'inc': 0, 'dec': 0}, 'pzas': {'inc': 0, 'dec': 0}, 'di': {'inc': 0, 'dec': 0}, 'drz': {'inc': 0, 'dec': 0}, 'isa': {'inc': 0, 'dec': 0}}
- self.amort_re = {'di': {'inc': 0, 'dec': 0}}
- self.pop_message_answer = ''
- # TODO -> Главен прозорец
- self.title('Текущи разходи') # TODO -> Главен прозорец
- self.geometry('1300x630+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=506, 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=506, 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=506, 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'], padding=(2, 10))
- self.tab4 = Frame(self.tabs, width=550, height=506, 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'], padding=(2, 10)) #
- self.tabs.bind('<<NotebookTabChanged>>', self.get_tab)
- # TODO -> LABELS
- self.widget_factory.get_label_un(self.tab1, 'с/ка: Оперативни разходи', 20, 20, 'w', 22, 'blue', bg_border='red')
- self.widget_factory.get_label_un(self.tab1, 'Разходи по вид', 20, 50, 'w', 20, bg_border='red')
- self.widget_factory.get_label_un(self.tab1, 'с/ка\n(сума)', 210, 40, 'w', 6, 'black', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab1, '2022\n(хил.лв)', 275, 40, 'w', 6, 'black', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab1, '2023\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. Суровини и материали', 20, 90, 'w', 24, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '2. Външни услуги', 20, 120, 'w', 24, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '3. Амортизации', 20, 150, 'w', 24, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '4.1 Пенсионни осигуровки', 20, 180, 'w', 24, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '4.2 Други осигуровки', 20, 210, 'w', 24, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, '5. Разходи за данъци', 20, 240, 'w', 24, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, '6.1 Обезценка на нетекущи\n активи', 20, 270, 'w', 24, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '6.2 Обезценка на текущи\n активи', 20, 320, 'w', 24, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, '6.3 Провизии', 20, 370, 'w', 20, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, '10. Други разходи', 20, 400, 'w', 20, bg_border='green')
- # TODO -> Entries
- self.user_adp = self.widget_factory.get_entry(self.tab1, 280, 90, 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, 90, 'e', 11, 'black', bg_border='green', j='left', name='adp')
- self.e_adp = self.widget_factory.get_entry(self.tab1, 450, 90, 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, 120, 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, 120, 'e', 11, 'black', bg_border='green', j='left')
- self.e_pzp = self.widget_factory.get_entry(self.tab1, 450, 120, 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, 150, 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, 150, 'e', 11, 'black', bg_border='green', j='left')
- self.e_adas = self.widget_factory.get_entry(self.tab1, 450, 150, 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, 180, 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, 180, 'e', 11, 'black', bg_border='green', j='left')
- self.e_pzas = self.widget_factory.get_entry(self.tab1, 450, 180, 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, 210, 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, 210, 'e', 11, 'black', bg_border='green', j='left')
- self.e_di = self.widget_factory.get_entry(self.tab1, 450, 210, 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, 240, 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, 240, 'e', 11, 'black', bg_border='green', j='left')
- self.e_drz = self.widget_factory.get_entry(self.tab1, 450, 240, 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, 280, 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, 280, 'e', 11, 'black', bg_border='green', j='left')
- self.e_isa = self.widget_factory.get_entry(self.tab1, 450, 280, 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))
- self.user_i = self.widget_factory.get_entry(self.tab1, 280, 330, 5, 'right', name='user_i')
- self.user_i.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_i, "i", "od"))
- self.l_open_i = self.widget_factory.get_label_un(self.tab1, '0', 340, 330, 'e', 11, 'black', bg_border='green', j='left')
- self.e_i = self.widget_factory.get_entry(self.tab1, 450, 330, 9, name='i')
- self.e_i.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_i))
- self.e_i.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_i))
- self.user_is = self.widget_factory.get_entry(self.tab1, 280, 370, 5, 'right', name='user_is')
- self.user_is.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_isa, "is", "od"))
- self.l_open_is = self.widget_factory.get_label_un(self.tab1, '0', 340, 370, 'e', 11, 'black', bg_border='green', j='left')
- self.e_is = self.widget_factory.get_entry(self.tab1, 450, 370, 9, name='is')
- self.e_is.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_is))
- self.e_is.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_is))
- self.user_a = self.widget_factory.get_entry(self.tab1, 280, 400, 5, 'right', name='user_a')
- self.user_a.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_isa, "a", "od"))
- self.l_open_a = self.widget_factory.get_label_un(self.tab1, '0', 340, 400, 'e', 11, 'black', bg_border='green', j='left')
- self.e_a = self.widget_factory.get_entry(self.tab1, 450, 400, 9, name='a')
- self.e_a.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_a))
- self.e_a.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_a))
- # TODO -> DOWN LABELS
- self.widget_factory.get_label(self.tab1, 240, 450, '2022 година', 10, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 350, 450, '2023 година', 10, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 20, 470, 'Общо разходи:', 12, 'w', font=10)
- self.l_turn_d_total = self.widget_factory.get_label(self.tab1, 220, 470, 0.0, 12, 'e', color='black', font=10)
- self.l_turn_c_total = self.widget_factory.get_label(self.tab1, 330, 470, 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_1 = Checkbutton(self.tab1, variable=self.check_assets, command=lambda: self.act_c1())
- self.check_1.place(x=220, y=180)
- self.check_2 = Checkbutton(self.tab1, variable=self.check_amort, command=lambda: self.act_c1())
- self.check_2.place(x=220, y=210)
- # TODO Разходи по дейност
- self.widget_factory.get_label_un(self.tab2, 'с/ка: Оперативни разходи', 20, 20, 'w', 22, 'blue',
- bg_color='white', bg_border='red')
- self.widget_factory.get_label_un(self.tab2, 'Разходи по дейности', 20, 50, 'w', 22, bg_color='white',
- bg_border='red')
- self.widget_factory.get_label_un(self.tab2, 'НС\n(хил.лв)', 275, 40, 'w', 6, 'black', bg_color='white',
- bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab2, 'НС\n(лева)', 340, 40, 'center', 11, 'black', bg_color='white',
- bg_border='red', 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, '1. Основна дейност - производство\n (на продукция / услуги)',
- 20, 100, 'w', 28, bg_color='white', bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab2, '2. Спомагателна дейност', 20, 150, 'w', 26, bg_color='white',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab2, '3. Търговска дейност', 20, 180, 'w', 26, bg_color='white',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab2, '4.1 Административна дейност', 20, 210, 'w', 26, bg_color='white',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab2, '4.2 Управленска дейност', 20, 240, 'w', 26, bg_color='white',
- bg_border='green')
- # TODO -> Entries
- self.user_rod = self.widget_factory.get_entry(self.tab2, 280, 110, 5, 'right', name='user_rod')
- self.user_rod.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rod, "rod", "td"))
- self.l_open_rod = self.widget_factory.get_label_un(self.tab2, '0', 340, 110, 'e', 11, 'black', bg_color='white',
- bg_border='green', j='left')
- self.e_rod = self.widget_factory.get_entry(self.tab2, 450, 110, 9, name='rod')
- self.e_rod.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rod))
- self.e_rod.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rod))
- self.user_rsd = self.widget_factory.get_entry(self.tab2, 280, 150, 5, 'right', name='user_rsd')
- self.user_rsd.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rsd, "rsd", "td"))
- self.l_open_rsd = self.widget_factory.get_label_un(self.tab2, '0', 340, 150, 'e', 11, 'black', bg_color='white',
- bg_border='green', j='left')
- self.e_rsd = self.widget_factory.get_entry(self.tab2, 450, 150, 9, name='rsd')
- self.e_rsd.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rsd))
- self.e_rsd.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rsd))
- self.user_rtd = self.widget_factory.get_entry(self.tab2, 280, 180, 5, 'right', name='user_rtd')
- self.user_rtd.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rtd, "rtd", "td"))
- self.l_open_rtd = self.widget_factory.get_label_un(self.tab2, '0', 340, 180, 'e', 11, 'black', bg_color='white',
- bg_border='green', j='left')
- self.e_rtd = self.widget_factory.get_entry(self.tab2, 450, 180, 9, name='rtd')
- self.e_rtd.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rtd))
- self.e_rtd.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rtd))
- self.user_rad = self.widget_factory.get_entry(self.tab2, 280, 210, 5, 'right', name='user_rad')
- self.user_rad.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rad, "rad", "td"))
- self.l_open_rad = self.widget_factory.get_label_un(self.tab2, '0', 340, 210, 'e', 11, 'black', bg_color='white',
- bg_border='green', j='left')
- self.e_rad = self.widget_factory.get_entry(self.tab2, 450, 210, 9, name='rad')
- self.e_rad.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rad))
- self.e_rad.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rad))
- self.user_rud = self.widget_factory.get_entry(self.tab2, 280, 240, 5, 'right', name='user_rud')
- self.user_rud.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rud, "rud", "td"))
- self.l_open_rud = self.widget_factory.get_label_un(self.tab2, '0', 340, 240, 'e', 11, 'black', bg_color='white',
- bg_border='green', j='left')
- self.e_rud = self.widget_factory.get_entry(self.tab2, 450, 240, 9, name='rud')
- self.e_rud.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rud))
- self.e_rud.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rud))
- # 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, 'Увеличение\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. Лихви по кредити', 20, 100, 'w', 20, bg_color='mint cream',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab3, '2. Лихви по ДОПК', 20, 130, 'w', 20, bg_color='mint cream',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab3, '3. Други лихви', 20, 160, 'w', 20, bg_color='mint cream',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab3, '4. Обезценка на валута', 20, 190, 'w', 20, bg_color='mint cream',
- bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab3, '5. Обезценка на финансови активи', 20, 220, 'w', 28,
- bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, '6. Провизии на рискови активи', 20, 250, 'w', 28,
- bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, '7. Операции с финансови активи', 20, 280, 'w', 28,
- bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, '8. Други финансови разходи', 20, 310, 'w', 28,
- bg_color='mint cream', bg_border='green')
- # TODO -> Entries
- self.user_rlk = self.widget_factory.get_entry(self.tab3, 280, 100, 5, 'right', name='user_rlk')
- self.user_rlk.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rlk, "rlk", "td"))
- self.l_open_rlk = self.widget_factory.get_label_un(self.tab3, '0', 340, 100, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='rlk')
- self.e_rlk = self.widget_factory.get_entry(self.tab3, 450, 100, 9, 'left', name='rlk')
- self.e_rlk.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rlk))
- self.e_rlk.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rlk))
- self.user_rldopk = self.widget_factory.get_entry(self.tab3, 280, 130, 5, 'right', name='user_rldopk')
- self.user_rldopk.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rldopk, "rldopk", "td"))
- self.l_open_rlk = self.widget_factory.get_label_un(self.tab3, '0', 340, 130, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='rldopk')
- self.e_rldopk = self.widget_factory.get_entry(self.tab3, 450, 130, 9, 'left', name='rldopk')
- self.e_rldopk.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rldopk))
- self.e_rldopk.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rldopk))
- self.user_rdrl = self.widget_factory.get_entry(self.tab3, 280, 160, 5, 'right', name='user_rdrl')
- self.user_rdrl.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rdrl, "rdrl", "td"))
- self.l_open_rlk = self.widget_factory.get_label_un(self.tab3, '0', 340, 160, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='rdrl')
- self.e_rdrl = self.widget_factory.get_entry(self.tab3, 450, 160, 9, 'left', name='rdrl')
- self.e_rdrl.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rdrl))
- self.e_rdrl.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rdrl))
- self.user_rov = self.widget_factory.get_entry(self.tab3, 280, 190, 5, 'right', name='user_rov')
- self.user_rov.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rov, "rov", "td"))
- self.l_open_rlk = self.widget_factory.get_label_un(self.tab3, '0', 340, 190, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='rov')
- self.e_rov = self.widget_factory.get_entry(self.tab3, 450, 190, 9, 'left', name='rov')
- self.e_rov.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rov))
- self.e_rov.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rov))
- self.user_rofa = self.widget_factory.get_entry(self.tab3, 280, 220, 5, 'right', name='user_rofa')
- self.user_rofa.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rofa, "rofa", "td"))
- self.l_open_rofa = self.widget_factory.get_label_un(self.tab3, '0', 340, 220, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='rofa')
- self.e_rofa = self.widget_factory.get_entry(self.tab3, 450, 220, 9, 'left', name='rofa')
- self.e_rofa.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rofa))
- self.e_rofa.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rofa))
- self.user_pra = self.widget_factory.get_entry(self.tab3, 280, 250, 5, 'right', name='user_pra')
- self.user_pra.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_pra, "pra", "td"))
- self.l_open_pra = self.widget_factory.get_label_un(self.tab3, '0', 340, 250, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='pra')
- self.e_pra = self.widget_factory.get_entry(self.tab3, 450, 250, 9, 'left', name='pra')
- self.e_pra.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_pra))
- self.e_pra.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_pra))
- self.user_ofa = self.widget_factory.get_entry(self.tab3, 280, 280, 5, 'right', name='user_ofa')
- self.user_ofa.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_pra, "ofa", "td"))
- self.l_open_ofa = self.widget_factory.get_label_un(self.tab3, '0', 340, 280, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='ofa')
- self.e_ofa = self.widget_factory.get_entry(self.tab3, 450, 280, 9, 'left', name='ofa')
- self.e_ofa.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_ofa))
- self.e_ofa.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_ofa))
- self.user_drfr = self.widget_factory.get_entry(self.tab3, 280, 310, 5, 'right', name='user_drfr')
- self.user_drfr.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_drfr, "drfr", "td"))
- self.l_open_drfr = self.widget_factory.get_label_un(self.tab3, '0', 340, 310, 'e', 11, 'black',
- bg_color='mint cream', bg_border='green', j='left',
- name='drfr')
- self.e_drfr = self.widget_factory.get_entry(self.tab3, 450, 310, 9, 'left', name='drfr')
- self.e_drfr.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_drfr))
- self.e_drfr.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_drfr))
- # TODO Коригиращи суми
- self.widget_factory.get_label_un(self.tab4, 'с/ка: КОРИГИРАЩИ СУМИ', 20, 20, 'w', 24, '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, '1. Намаление на запасите от\n продукция', 20, 100, 'w', 26,
- bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, '2. Намаление на незавършеното\n производство', 20, 150, 'w',
- 26, bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, '3. Балансова стойност на про-\n дадените нетекущи активи', 20,
- 200, 'w', 26, bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, '4. Балансова стойност на про-\n дадените текущи активи', 20,
- 250, 'w', 26, bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, '5. Разходи (премии) за данъци\n от печалбата', 20, 300, 'w',
- 26, bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, '6. Алтернативни данъци', 20, 350, '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')
- # TODO -> CHECKBUTTON
- self.check_3 = Checkbutton(self.tab3, variable=self.check_amort, command=lambda: self.act_c1(), bg='mint cream')
- self.check_3.place(x=220, y=100)
- self.check_4 = Checkbutton(self.tab3, variable=self.check_amort, command=lambda: self.act_c1(), bg='mint cream')
- self.check_4.place(x=220, y=130)
- self.check_5 = Checkbutton(self.tab3, variable=self.check_amort, command=lambda: self.act_c1(), bg='mint cream')
- self.check_5.place(x=220, y=160)
- # 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_rx", self.max_depth_rx)
- self.var_spin_2 = StringVar(self, value=str(self.max_depth_rx))
- self.spin_2 = self.widget_factory.get_spinbox(self, self.min_spin_2, str(self.max_depth_rx), 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, 580, 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, 580)
- self.b_note.bind('<ButtonRelease-1>', lambda e: self.on_correction())
- # Button Помощ
- self.b_help = self.widget_factory.get_help_button(self, 20, 580)
- self.b_help.bind('<ButtonRelease-1>')
- # Button Save
- self.b_save = self.widget_factory.get_ok_button(self, 830, 580)
- self.b_save.bind('<ButtonRelease-1>', lambda e: self.on_save())
- # Button Отказ
- self.b_exit = self.widget_factory.get_correction_esc(self, 930, 580)
- self.b_exit.config(command=self.destroy)
- 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'
- 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_rx[entry]['ns'] = self.user_ns[entry]
- for entry in self.user_ns_amo:
- self.acc_rec_rx[entry]['ns_amo'] = self.user_ns_amo[entry]
- # TODO -> Попълваме сметките, по Ентрита на активи и амортизации
- if not self.dict_entries: # Речника е празен
- for entry in self.acc_rec_rx:
- self.acc_rec_rx[entry]['assets'].clear()
- if not self.dict_entries_amo: # Речника е празен
- for entry in self.acc_rec_rx:
- self.acc_rec_rx[entry]['amort'].clear()
- for entry in self.dict_entries:
- if self.dict_entries[entry] is None:
- self.dict_entries[entry] = []
- self.acc_rec_rx[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_rx[entry]['amort'] = self.dict_entries_amo[entry]
- # TODO -> попълване на сумите на преоценката
- for entry in self.assets_re:
- for dir in self.assets_re[entry]:
- self.acc_rec_rx[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_rx[entry]['amort_re'][dir] = self.amort_re[entry][dir]
- print('self.acc_rec_rx: ', self.acc_rec_rx)
- json_file_io = JsonFileIo(file_name=registry['orx_import_form_acc_rec_orx_file_name'])
- json_file_io.write_content(self.acc_rec_rx)
- # 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 revaluation == '':
- revaluation = 0
- if not revaluation.isdigit() or revaluation.isalpha():
- return
- if self.current_tab == 'Преоценка активи':
- self.assets_re[key1][key2] = int(revaluation)
- elif self.current_tab == 'Преоценка амортизации':
- self.amort_re[key1][key2] = int(revaluation)
- print('self.assets_re in revaluation: ', self.assets_re)
- print('self.amort_re in revaluation: ', self.amort_re)
- # 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_rx", self.acc_rec_rx)
- self.acc_rec_rx['adp']['assets_re']['diff'] = user_1000 - calc_1000
- elif name_entry == 'user_pzp':
- self.pzp['text'] = int(user_1000 - calc_1000)
- self.acc_rec_rx['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_rx['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_rx['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_rx['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_rx['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_rx['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_rx['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']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_adp, "adp", "td")
- elif entr == 'pzp':
- self.l_open_pzp['text'] = f"{self.get_sums['pzp']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_pzp, "pzp", "td")
- elif entr == 'adas':
- self.l_open_adas['text'] = f"{self.get_sums['adas']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_adas, "adas", "td")
- elif entr == 'pzas':
- self.l_open_pzas['text'] = f"{self.get_sums['pzas']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_pzas, "pzas", "td")
- elif entr == 'di':
- self.l_open_di['text'] = f"{self.get_sums['di']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_di, "di", "td")
- elif entr == 'drz':
- self.l_open_drz['text'] = f"{self.get_sums['drz']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_drz, "drz", "td")
- elif entr == 'isa':
- self.l_open_isa['text'] = f"{self.get_sums['isa']['td']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_isa, "isa", "td")
- 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 orx(self):
- try:
- json_file_io = JsonFileIo(file_name=registry["orx_import_form_acc_rec_orx_file_name"])
- tmp_acc_rec_dma = json_file_io.read_content()
- if tmp_acc_rec_dma is not None:
- self.acc_rec_rx = 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_rx:
- self.dict_entries[entry] = self.acc_rec_rx[entry]['assets']
- for entry in self.acc_rec_rx:
- self.dict_entries_amo[entry] = self.acc_rec_rx[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_rx[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_rx[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_rx[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_rx[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 > 20:
- self.treeview_acc.configure(height=20)
- 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 = Expenses()
- dfa.orx()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement