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 DnaFormImport(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": ["СК"],
- 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_dna = {
- 'prd': {'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}},
- 'pp': {'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}},
- 'tr': {'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}},
- 'rpna': {'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}},
- 'adv': {'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.l_open_bal_prd = Entry(self)
- 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.parents_with_unadded_children = []
- 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 = {'prd': 0, 'pp': 0, 'tr': 0, 'rpna': 0, 'adv': 0}
- self.user_ns_amo = {'prd': 0, 'pp': 0, 'tr': 0}
- self.assets_re = {'prd': {'inc': 0.0, 'dec': 0.0}, 'pp': {'inc': 0.0, 'dec': 0.0}, 'tr': {'inc': 0.0, 'dec': 0.0}}
- self.amort_re = {'prd': {'inc': 0.0, 'dec': 0.0}, 'pp': {'inc': 0.0, 'dec': 0.0}, 'tr': {'inc': 0.0, 'dec': 0.0}}
- self.pop_message_answer = ''
- self.selected_code = None
- self.title('Нематериални активи') # TODO -> Главен прозорец
- self.geometry('1300x500+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, height and width
- self.tab1 = Frame(self.tabs, width=550, height=399, 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=399, relief=GROOVE, borderwidth=5, bg='white') # bg='lightgrey'
- 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=399, relief=GROOVE, borderwidth=5,
- bg='mint cream') # bg='lightgrey'
- self.tab3.pack(fill='both', expand=1)
- self.tabs.add(self.tab3, text=self.tab_names['act_p'],
- state='hidden') # compound must be none, text, image, center, top, bottom, left, or right
- self.tab4 = Frame(self.tabs, width=550, height=399, relief=GROOVE, borderwidth=5,
- bg='lemon chiffon') # bg='lightgrey'
- 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', 26, 'blue', bg_border='red')
- self.widget_factory.get_label_un(self.tab1, 'Група I.: Нематериални активи', 20, 50, 'w', 26, bg_border='red')
- self.widget_factory.get_label_un(self.tab1, 'НС\n(хил.лв)', 275, 50, 'w', 6, 'black', bg_border='red',
- j='center')
- self.widget_factory.get_label_un(self.tab1, 'НС\n(лева)', 340, 50, 'center', 11, 'black', bg_border='red',
- j='center')
- self.widget_factory.get_label_un(self.tab1, 'с/ка:\n(код)', 460, 50, 'center', 4, 'black', bg_border='green')
- self.widget_factory.get_label_un(self.tab1, 'Продукти от развойна дейност', 20, 100, 'w', 26, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, 'Програмни продукти, концесии,\nи други подобни права', 20, 140,
- 'w', 26, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, 'Търговска репутация', 20, 200, 'w', 20, bg_border='green')
- self.widget_factory.get_label_un(self.tab1, 'Нематериални активи в\n процес на изграждане', 20, 240,
- 'w', 26, bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab1, 'Предоставени аванси', 20, 300, 'w', 26, bg_border='green')
- # TODO -> Entries
- self.user_prd = self.widget_factory.get_entry(self.tab1, 280, 100, 5, 'right')
- self.user_prd.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_prd, "prd", "od"))
- self.l_open_bal_prd = self.widget_factory.get_label_un(self.tab1, '0', 340, 100, 'e', 11, 'black',
- bg_border='green', j='left', name='prd')
- self.e_prd = self.widget_factory.get_entry(self.tab1, 450, 100, 9, 'left', name='prd')
- self.e_prd.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_prd))
- self.e_prd.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_prd))
- self.user_pp = self.widget_factory.get_entry(self.tab1, 280, 150, 5, 'right')
- self.user_pp.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_pp, "pp", "od"))
- self.l_open_balance_pp = self.widget_factory.get_label_un(self.tab1, '0', 340, 150, 'e', 11,
- 'black', bg_border='green', j='left')
- self.e_pp = self.widget_factory.get_entry(self.tab1, 450, 150, 9, name='pp')
- self.e_pp.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_pp))
- self.e_pp.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_pp))
- self.user_tr = self.widget_factory.get_entry(self.tab1, 280, 200, 5, 'right')
- self.user_tr.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_tr, "tr", "od"))
- self.l_open_balance_tr = self.widget_factory.get_label_un(self.tab1, '0', 340, 200, 'e', 11,
- 'black', bg_border='green', j='left')
- self.e_tr = self.widget_factory.get_entry(self.tab1, 450, 200, 9, name='tr')
- self.e_tr.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_tr))
- self.e_tr.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_tr))
- self.user_rpna = self.widget_factory.get_entry(self.tab1, 280, 250, 5, 'right')
- self.user_rpna.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_rpna, "rpna", "od"))
- self.l_open_balance_rpna = self.widget_factory.get_label_un(self.tab1, '0', 340, 250, 'e', 11,
- 'black', bg_border='green', j='left')
- self.e_rpna = self.widget_factory.get_entry(self.tab1, 450, 250, 9, name='rpna')
- self.e_rpna.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_rpna))
- self.e_rpna.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_rpna))
- self.user_adv = self.widget_factory.get_entry(self.tab1, 280, 300, 5, 'right')
- self.user_adv.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_adv, "adv", "od"))
- self.l_open_balance_adv = self.widget_factory.get_label_un(self.tab1, '0', 340, 300, 'e', 11,
- 'black', bg_border='green', j='left')
- self.e_adv = self.widget_factory.get_entry(self.tab1, 450, 300, 9, name='adv')
- self.e_adv.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_adv))
- self.e_adv.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_adv))
- # TODO -> DOWN LABELS
- self.widget_factory.get_label(self.tab1, 90, 350, 'В началното', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 195, 350, 'Увеличение', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 300, 350, 'Намаление', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 410, 350, 'В края', 12, 'e', font=10)
- self.widget_factory.get_label(self.tab1, 20, 370, 'Група I.:', 10, 'w', font=10)
- self.l_open_total = self.widget_factory.get_label(self.tab1, 90, 370, 0.0, 12, 'e', color='black',
- font=10)
- self.l_turn_d_total = self.widget_factory.get_label(self.tab1, 195, 370, 0.0, 12, 'e', color='black',
- font=10)
- self.l_turn_c_total = self.widget_factory.get_label(self.tab1, 300, 370, 0.0, 12, 'e', color='black',
- font=10)
- self.l_close_total = self.widget_factory.get_label(self.tab1, 410, 370, 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, 455, 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, 455)
- self.b_note.bind('<ButtonRelease-1>', lambda e: self.on_correction())
- # Button Помощ
- self.b_help = self.widget_factory.get_help_button(self, 20, 455)
- self.b_help.bind('<ButtonRelease-1>')
- # Button Save
- self.b_save = self.widget_factory.get_ok_button(self, 830, 455)
- self.b_save.bind('<ButtonRelease-1>', lambda e: self.on_save())
- # Button Отказ
- self.b_exit = self.widget_factory.get_correction_esc(self, 930, 455)
- self.b_exit.config(command=self.destroy)
- # TODO AMORTIZATION Амортизации
- self.widget_factory.get_label_un(self.tab2, 'с/ка: АМОРТИЗАЦИИ', 20, 20, 'w', 26, 'red', bg_color='white',
- bg_border='blue')
- self.widget_factory.get_label_un(self.tab2, 'Група I.: Нематериални активи', 20, 50, 'w', 26, bg_color='white',
- bg_border='blue')
- self.widget_factory.get_label_un(self.tab2, 'НС\n(хил.лв)', 275, 50, 'w', 6, 'black', bg_color='white',
- bg_border='blue', j='center')
- self.widget_factory.get_label_un(self.tab2, 'НС\n(лева)', 340, 50, 'center', 11, 'black', bg_color='white',
- bg_border='blue', j='center')
- self.widget_factory.get_label_un(self.tab2, 'с/ка:\n(код)', 460, 50, 'center', 4, 'black', bg_color='white',
- bg_border='green')
- self.widget_factory.get_label_un(self.tab2, 'Продукти от развойна дейност', 20, 100, 'w', 26, bg_color='white',
- bg_border='green')
- self.widget_factory.get_label_un(self.tab2, 'Програмни продукти, концесии,\nи други подобни права', 20, 140,
- 'w', 26, bg_color='white', bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab2, 'Търговска репутация', 20, 200, 'w', 20, bg_color='white',
- bg_border='green')
- # TODO -> Entries
- self.user_amo_prd = self.widget_factory.get_entry(self.tab2, 280, 100, 5, 'right')
- self.user_amo_prd.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_amo_prd, "prd", "oc"))
- self.l_open_amo_prd = self.widget_factory.get_label_un(self.tab2, '0', 340, 100, 'e', 11, 'black',
- bg_color='white', bg_border='green', j='left',
- name='amo_prd')
- self.e_amo_prd = self.widget_factory.get_entry(self.tab2, 450, 100, 9, 'left', name='prd')
- self.e_amo_prd.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_amo_prd))
- self.e_amo_prd.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_amo_prd))
- self.user_amo_pp = self.widget_factory.get_entry(self.tab2, 280, 150, 5, 'right')
- self.user_amo_pp.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_amo_pp, "pp", "oc"))
- self.l_open_amo_pp = self.widget_factory.get_label_un(self.tab2, '0', 340, 150, 'e', 11, 'black',
- bg_color='white', bg_border='green', j='left',
- name='amo_pp')
- self.e_amo_pp = self.widget_factory.get_entry(self.tab2, 450, 150, 9, name='pp')
- self.e_amo_pp.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_amo_pp))
- self.e_amo_pp.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_amo_pp))
- self.user_amo_tr = self.widget_factory.get_entry(self.tab2, 280, 200, 5, 'right')
- self.user_amo_tr.bind("<KeyRelease>", lambda e: self.update_state_open_bal(self.user_amo_tr, "tr", "oc"))
- self.l_open_amo_tr = self.widget_factory.get_label_un(self.tab2, '0', 340, 200, 'e', 11, 'black',
- bg_color='white', bg_border='green', j='left',
- name='amo_pp')
- self.e_amo_tr = self.widget_factory.get_entry(self.tab2, 450, 200, 9, name='tr')
- self.e_amo_tr.bind("<KeyRelease>", lambda e: self.on_entry_key_release(self.e_amo_tr))
- self.e_amo_tr.bind("<FocusIn>", lambda e: self.entry_on_focus(self.e_amo_tr))
- # 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, 350, 'В началното', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 195, 350, 'Увеличение', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 300, 350, 'Намаление', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 410, 350, 'В края', 12, 'e', font=10, bg_color='white')
- self.widget_factory.get_label(self.tab2, 20, 370, 'Група I.:', 10, 'w', font=10, bg_color='white')
- self.l_amo_open_total = self.widget_factory.get_label(self.tab2, 90, 370, 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, 370, 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, 370, 0.0, 12, 'e', color='black',
- font=10, bg_color='white')
- self.l_amo_close_total = self.widget_factory.get_label(self.tab2, 410, 370, 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, 'Група I.: ПРЕОЦЕНКА !', 20, 50, 'w', 26, 'black',
- bg_color='mint cream', bg_border='red')
- self.widget_factory.get_label_un(self.tab3, 'Увеличение\n(лева)', 280, 50, 'w', 10, 'black',
- bg_color='mint cream', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab3, 'Намаление\n(лева)', 370, 50, 'w', 10, 'black',
- bg_color='mint cream', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab3, 'Салдо\n(разлика)', 470, 50, 'w', 7, 'black',
- bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, 'Продукти от развойна дейност', 20, 100, 'w', 26, 'black',
- bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, 'Програмни продукти, концесии,\nи други подобни права', 20, 140,
- 'w', 26, 'black', bg_color='mint cream', bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab3, 'Търговска репутация', 20, 200, 'w', 20, 'black',
- bg_color='mint cream', bg_border='green')
- self.widget_factory.get_label_un(self.tab3, 'Нематериални активи в\n процес на изграждане', 20, 240,
- 'w', 26, bg_color='mint cream', bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab3, 'Предоставени аванси', 20, 300, 'w', 26, bg_color='mint cream',
- bg_border='green')
- # TODO -> Entries
- self.turn_d_prd = self.widget_factory.get_entry(self.tab3, 280, 100, 12, 'right')
- self.turn_d_prd.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_prd, "prd", "inc"))
- self.turn_c_prd = self.widget_factory.get_entry(self.tab3, 370, 100, 12, 'right')
- self.turn_c_prd.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_prd, "prd", "dec"))
- self.prd = self.widget_factory.get_label(self.tab3, 490, 100, '0', 3, 'e', color='red', font=10,
- bg_color='mint cream')
- self.turn_d_pp = self.widget_factory.get_entry(self.tab3, 280, 150, 12, 'right')
- self.turn_d_pp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_pp, "pp", "inc"))
- self.turn_c_pp = self.widget_factory.get_entry(self.tab3, 370, 150, 12, 'right')
- self.turn_c_pp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_pp, "pp", "dec"))
- self.pp = self.widget_factory.get_label(self.tab3, 490, 150, '0', 3, 'e', color='red', font=10,
- bg_color='mint cream')
- self.turn_d_tr = self.widget_factory.get_entry(self.tab3, 280, 200, 12, 'right')
- self.turn_d_tr.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_tr, "tr", "inc"))
- self.turn_c_tr = self.widget_factory.get_entry(self.tab3, 370, 200, 12, 'right')
- self.turn_c_tr.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_tr, "tr", "dec"))
- self.tr = self.widget_factory.get_label(self.tab3, 490, 200, '0', 3, 'e', color='red', font=10,
- bg_color='mint cream')
- self.rpna = self.widget_factory.get_label(self.tab3, 490, 250, '0', 3, 'e', color='red', font=10,
- bg_color='mint cream')
- self.adv = self.widget_factory.get_label(self.tab3, 490, 300, '0', 3, 'e', color='red', font=10,
- bg_color='mint cream')
- # TODO Преоценка Амортизации
- self.widget_factory.get_label_un(self.tab4, 'С/ка: АМОРТИЗАЦИИ', 20, 20, 'w', 26, 'black',
- bg_color='lemon chiffon', bg_border='red')
- self.widget_factory.get_label_un(self.tab4, 'Група I.: ПРЕОЦЕНКА !', 20, 50, 'w', 26, 'black',
- bg_color='lemon chiffon', bg_border='red')
- self.widget_factory.get_label_un(self.tab4, 'Увеличение\n(лева)', 280, 50, 'w', 10, 'black',
- bg_color='lemon chiffon', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab4, 'Намаление\n(лева)', 370, 50, 'w', 10, 'black',
- bg_color='lemon chiffon', bg_border='red', j='center')
- self.widget_factory.get_label_un(self.tab4, 'Салдо\n(разлика)', 470, 50, 'w', 7, 'black',
- bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, 'Продукти от развойна дейност', 20, 100, 'w', 26, 'black',
- bg_color='lemon chiffon', bg_border='green')
- self.widget_factory.get_label_un(self.tab4, 'Програмни продукти, концесии,\nи други подобни права', 20, 140,
- 'w', 26, 'black', bg_color='lemon chiffon', bg_border='green', j='left')
- self.widget_factory.get_label_un(self.tab4, 'Търговска репутация', 20, 200, 'w', 20, 'black',
- bg_color='lemon chiffon', bg_border='green')
- # TODO -> Entries
- self.turn_d_amo_prd = self.widget_factory.get_entry(self.tab4, 280, 100, 12, 'right')
- self.turn_d_amo_prd.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_amo_prd, "prd", "inc"))
- self.turn_c_amo_prd = self.widget_factory.get_entry(self.tab4, 370, 100, 12, 'right')
- self.turn_c_amo_prd.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_amo_prd, "prd", "dec"))
- self.amo_prd = self.widget_factory.get_label(self.tab4, 490, 100, '0', 3, 'e', color='red', font=10,
- bg_color='lemon chiffon')
- self.turn_d_amo_pp = self.widget_factory.get_entry(self.tab4, 280, 150, 12, 'right')
- self.turn_d_amo_pp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_amo_pp, "pp", "inc"))
- self.turn_c_amo_pp = self.widget_factory.get_entry(self.tab4, 370, 150, 12, 'right')
- self.turn_c_amo_pp.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_amo_pp, "pp", "dec"))
- self.amo_pp = self.widget_factory.get_label(self.tab4, 490, 150, '0', 3, 'e', color='red', font=10,
- bg_color='lemon chiffon')
- self.turn_d_amo_tr = self.widget_factory.get_entry(self.tab4, 280, 200, 12, 'right')
- self.turn_d_amo_tr.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_d_amo_tr, "tr", "inc"))
- self.turn_c_amo_tr = self.widget_factory.get_entry(self.tab4, 370, 200, 12, 'right')
- self.turn_c_amo_tr.bind("<KeyRelease>", lambda e: self.revaluations(self.turn_c_amo_tr, "tr", "dec"))
- self.amo_tr = self.widget_factory.get_label(self.tab4, 490, 200, '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_prd.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_prd.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_dna[entry]['ns'] = self.user_ns[entry]
- for entry in self.user_ns_amo:
- self.acc_rec_dna[entry]['ns_amo'] = self.user_ns_amo[entry]
- # TODO -> Попълваме сметките, по Ентрита на активи и амортизации
- if not self.dict_entries: # Речника е празен
- for entry in self.acc_rec_dna:
- self.acc_rec_dna[entry]['assets'].clear()
- if not self.dict_entries_amo: # Речника е празен
- for entry in self.acc_rec_dna:
- self.acc_rec_dna[entry]['amort'].clear()
- for entry in self.dict_entries:
- if self.dict_entries[entry] is None:
- self.dict_entries[entry] = []
- self.acc_rec_dna[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_dna[entry]['amort'] = self.dict_entries_amo[entry]
- # TODO -> попълване на сумите на преоценката
- for entry in self.assets_re:
- for way in self.assets_re[entry]:
- self.acc_rec_dna[entry]['assets_re'][way] = self.assets_re[entry][way]
- for entry in self.amort_re:
- for way in self.amort_re[entry]:
- self.acc_rec_dna[entry]['amort_re'][way] = self.amort_re[entry][way]
- json_file_io = JsonFileIo(file_name=registry['dna_import_form_acc_rec_dna_file_name'])
- json_file_io.write_content(self.acc_rec_dna)
- # 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_bal_prd['text'] = 0
- self.l_open_balance_pp['text'] = 0
- self.l_open_balance_tr['text'] = 0
- self.l_open_balance_rpna['text'] = 0
- self.l_open_balance_adv['text'] = 0
- self.prd['text'] = 0
- self.pp['text'] = 0
- self.tr['text'] = 0
- self.rpna['text'] = 0
- self.adv['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_prd['text'] = 0
- self.l_open_amo_pp['text'] = 0
- self.l_open_amo_tr['text'] = 0
- self.amo_prd['text'] = 0
- self.amo_pp['text'] = 0
- self.amo_tr['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):
- name_entry = open_bal.winfo_name()
- user_1000 = open_bal.get()
- try:
- user_1000 = int(user_1000)
- except:
- user_1000 = 0
- calc = self.get_sum_string(key1, key2)
- 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_prd':
- self.prd['text'] = user_1000 - calc_1000
- self.acc_rec_dna['prd']['assets_re']['diff'] = user_1000 - calc_1000
- elif name_entry == 'user_pp':
- self.pp['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['pp']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_tr':
- self.tr['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['tr']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_rpna':
- self.rpna['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['rpna']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_adv':
- self.adv['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['adv']['assets_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_amo_prd':
- self.amo_prd['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['prd']['amort_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_amo_pp':
- self.amo_pp['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['pp']['amort_re']['diff'] = int(user_1000 - calc_1000)
- elif name_entry == 'user_amo_tr':
- self.amo_tr['text'] = int(user_1000 - calc_1000)
- self.acc_rec_dna['tr']['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 == 'prd':
- self.l_open_bal_prd['text'] = f"{self.get_sums['prd']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_prd, "prd", "od")
- elif entr == 'pp':
- self.l_open_balance_pp['text'] = f"{self.get_sums['pp']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_pp, "pp", "od")
- elif entr == 'tr':
- self.l_open_balance_tr['text'] = f"{self.get_sums['tr']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_tr, "tr", "od")
- elif entr == 'rpna':
- self.l_open_balance_rpna['text'] = f"{self.get_sums['rpna']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_rpna, "rpna", "od")
- elif entr == 'adv':
- self.l_open_balance_adv['text'] = f"{self.get_sums['adv']['od']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_adv, "adv", "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 == 'prd':
- self.l_open_amo_prd['text'] = f"{self.get_sums_amo['prd']['oc']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_amo_prd, "prd", "oc")
- elif entr == 'pp':
- self.l_open_amo_pp['text'] = f"{self.get_sums_amo['pp']['oc']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_amo_pp, "pp", "oc")
- elif entr == 'tr':
- self.l_open_amo_tr['text'] = f"{self.get_sums_amo['tr']['oc']:,.2f}".replace(',', ' ')
- self.update_state_open_bal(self.user_amo_tr, "tr", "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 - > all_parents: ['22', '2']
- self.selected_accs.extend(all_children)
- self.selected_accs.extend(all_parents)
- # TODO -> След добавяне да се изпразват всички ентрита, а не само добавеното !!!!!
- if self.e_prd.get() != '': self.e_prd.delete(0, 'end')
- if self.e_pp.get() != '': self.e_pp.delete(0, 'end')
- if self.e_tr.get() != '': self.e_tr.delete(0, 'end')
- if self.e_rpna.get() != '': self.e_rpna.delete(0, 'end')
- if self.e_adv.get() != '': self.e_adv.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', '205']
- all_parents = self.account_tree.get_all_parents(acc_code) # acc_code = 223 - > all_parents: ['22', '2']
- self.selected_accs_amo.extend(all_children)
- self.selected_accs_amo.extend(all_parents)
- # TODO -> След добавяне да се изпразват всички ентрита, а не само добавеното !!!!!
- if self.e_amo_prd.get() != '': self.e_amo_prd.delete(0, 'end')
- if self.e_amo_pp.get() != '': self.e_amo_pp.delete(0, 'end')
- if self.e_amo_tr.get() != '': self.e_amo_tr.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.selected_code = values[0]
- # if self.last_entry is not None: # TODO -> MAЙ НЕ ВЪРШИ НИКАКВА РАБОТА
- 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 dna(self):
- try:
- json_file_io = JsonFileIo(file_name=registry["dna_import_form_acc_rec_dna_file_name"])
- tmp_acc_rec_dna = json_file_io.read_content()
- if tmp_acc_rec_dna is not None:
- self.acc_rec_dna = tmp_acc_rec_dna
- 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_dna:
- self.dict_entries[entry] = self.acc_rec_dna[entry]['assets']
- for entry in self.acc_rec_dna:
- self.dict_entries_amo[entry] = self.acc_rec_dna[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', '205']
- all_parents = self.account_tree.get_all_parents(acc_code) # acc_code = 223 all_parents:['22', '2']
- 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', '205']
- 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_dna[entry_name]['ns']
- if self.user_ns['prd'] > 0:
- self.user_prd.insert(0, self.user_ns['prd'])
- if self.user_ns['pp'] > 0:
- self.user_pp.insert(0, self.user_ns['pp'])
- if self.user_ns['tr'] > 0:
- self.user_tr.insert(0, self.user_ns['tr'])
- if self.user_ns['rpna'] > 0:
- self.user_rpna.insert(0, self.user_ns['rpna'])
- if self.user_ns['adv'] > 0:
- self.user_adv.insert(0, self.user_ns['adv'])
- for entry_name in self.user_ns_amo:
- self.user_ns_amo[entry_name] = self.acc_rec_dna[entry_name]['ns_amo']
- if self.user_ns_amo['prd'] > 0:
- self.user_amo_prd.insert(0, self.user_ns_amo['prd'])
- if self.user_ns_amo['pp'] > 0:
- self.user_amo_pp.insert(0, self.user_ns_amo['pp'])
- if self.user_ns_amo['tr'] > 0:
- self.user_amo_tr.insert(0, self.user_ns_amo['tr'])
- # TODO -> Попълваме Ентритата с Преоценките
- for entry in self.assets_re:
- for way in self.assets_re[entry]:
- self.assets_re[entry][way] = self.acc_rec_dna[entry]['assets_re'][way]
- if self.assets_re['prd']['inc'] > 0:
- print("self.assets_re['prd']['inc']: ", self.assets_re['prd']['inc'])
- self.turn_d_prd.insert(0, self.assets_re['prd']['inc'])
- if self.assets_re['prd']['dec'] > 0:
- self.turn_c_prd.insert(0, self.assets_re['prd']['dec'])
- if self.assets_re['pp']['inc'] > 0:
- self.turn_d_pp.insert(0, self.assets_re['pp']['inc'])
- if self.assets_re['pp']['dec'] > 0:
- self.turn_c_pp.insert(0, self.assets_re['pp']['dec'])
- if self.assets_re['tr']['inc'] > 0:
- self.turn_d_tr.insert(0, self.assets_re['tr']['inc'])
- if self.assets_re['tr']['dec'] > 0:
- self.turn_c_tr.insert(0, self.assets_re['tr']['dec'])
- for entry in self.amort_re:
- for way in self.amort_re[entry]:
- self.amort_re[entry][way] = self.acc_rec_dna[entry]['amort_re'][way]
- print('self.amort_re след refill: ', self.amort_re)
- if self.amort_re['prd']['inc'] > 0:
- self.turn_d_amo_prd.insert(0, self.amort_re['prd']['inc'])
- if self.amort_re['prd']['dec'] > 0:
- self.turn_c_amo_prd.insert(0, self.amort_re['prd']['dec'])
- if self.amort_re['pp']['inc'] > 0:
- self.turn_d_amo_pp.insert(0, self.amort_re['pp']['inc'])
- if self.amort_re['pp']['dec'] > 0:
- self.turn_c_amo_pp.insert(0, self.amort_re['pp']['dec'])
- if self.amort_re['tr']['inc'] > 0:
- self.turn_d_amo_tr.insert(0, self.amort_re['tr']['inc'])
- if self.amort_re['tr']['dec'] > 0:
- self.turn_c_amo_tr.insert(0, self.amort_re['tr']['dec'])
- print('self.amort_re: ', self.amort_re)
- 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 > 15:
- self.treeview_acc.configure(height=15)
- 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__':
- dna = DnaFormImport()
- dna.dna()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement