Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- from tkinter import ttk
- # from cells_table import Cells
- from acc_rec_calculations import *
- # from json_file_io import JsonFileIo
- # from Opiti.from_excel.classes.global_inc import registry
- from pdf_dna_assets import *
- import copy
- class DnaRounding:
- def __init__(self):
- self.acc_rec_calculations = AccRecCalculations()
- self.pdf_dna = DaPdfReport
- self.widgets = Cells()
- self.string_vars = Cells()
- #self.diffs = Cells() # Съдържа разликите като числа след последната проверка
- self.diffs1 = Cells() # Съдържа True ако поне 1 проверка е червена и False ако е ОК/зелена
- self.locks = Cells() # Съдържа True ако клетката е заключена
- self.span_cols = Cells()
- self.heights = Cells()
- self.error_cell = Cells() # Съдържа клетките в червено след дадена проверка
- self.step = ''
- self.da = {'row_0': {'col_0': {'val_0': 'ПОКАЗАТЕЛИ'}, 'col_1': {'val_1': 'Отчетна стойност\nна нетекущите активи'},
- 'col_2': {'val_2': ''}, 'col_3': {'val_3': ''}, 'col_4': {'val_4': ''}, 'col_5': {'val_5': ''},
- 'col_6': {'val_6': ''}, 'col_7': {'val_7': ''}, 'col_8': {'val_8': 'Амортизации'},
- 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''},
- 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''},
- 'col_15': {'val_15': 'Балансова\nстойност\nв края'}},
- 'row_1': {'col_0': {'val_0': ''}, 'col_1': {'val_1': 'В началото\nна периода'},
- 'col_2': {'val_2': 'Постъпили\nпрез периода'}, 'col_3': {'val_3': 'Излезли\nпрез периода'},
- 'col_4': {'val_4': 'В края на\nпериода'}, 'col_5': {'val_5': 'Преоценка в\nувеличение'},
- 'col_6': {'val_6': 'Преоценка в\n намаление'}, 'col_7': {'val_7': 'Преоценена\nстойност'},
- 'col_8': {'val_8': 'В началото\nна периода'}, 'col_9': {'val_9': 'Начислена\nпрез периода'},
- 'col_10': {'val_10': 'Отписана\nпрез периода'}, 'col_11': {'val_11': 'В края на\nпериода'},
- 'col_12': {'val_12': 'Преоценка в\nувеличение'}, 'col_13': {'val_13': 'Преоценка в\nнамаление'},
- 'col_14': {'val_14': 'Преоценена\nамортизация'}, 'col_15': {'val_15': ''}},
- 'row_2': {'col_0': {'val_0': ['а']}, 'col_1': {'val_1': ['1']}, 'col_2': {'val_2': ['2', ' ']},
- 'col_3': {'val_3': ['3', ' ']}, 'col_4': {'val_4': '4'}, 'col_5': {'val_5': ['5', ' ']},
- 'col_6': {'val_6': ['6', ' ']}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'},
- 'col_9': {'val_9': ['9', ' ']}, 'col_10': {'val_10': ['10', ' ']}, 'col_11': {'val_11': '11'},
- 'col_12': {'val_12': ['12', ' ']}, 'col_13': {'val_13': ['13', ' ']},
- 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15 = 7-14'}},
- 'row_3': {'col_0': {'val_0': ['I. Нематериални активи', ' ']}, 'col_1': {'val_1': ''},
- 'col_2': {'val_2': ''}, 'col_3': {'val_3': ''}, 'col_4': {'val_4': ''}, 'col_5': {'val_5': ''},
- 'col_6': {'val_6': ''}, 'col_7': {'val_7': ''}, 'col_8': {'val_8': ''}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': ''}},
- 'row_4': {'col_0': {'val_0': [' 1. Продукти от развойна дейност', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': '5'},
- 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'},
- 'col_9': {'val_9': '9'}, 'col_10': {'val_10': []}, 'col_11': {'val_11': []},
- 'col_12': {'val_12': []}, 'col_13': {'val_13': []}, 'col_14': {'val_14': []},
- 'col_15': {'val_15': []}},
- 'row_5': {'col_0': {'val_0': [' 2. Концесии, патенти, търговски\nмарки, програмни продукти и\nдруги подобни права и активи', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': f'n'}, 'col_3': {'val_3': '3'},
- 'col_4': {'val_4': '4'}, 'col_5': {'val_5': '5'}, 'col_6': {'val_6': '6'},
- 'col_7': {'val_7': '7'}, 'col_8': {'val_8': []}, 'col_9': {'val_9': []},
- 'col_10': {'val_10': []}, 'col_11': {'val_11': []}, 'col_12': {'val_12': []},
- 'col_13': {'val_13': []}, 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_6': {'col_0': {'val_0': [' 3. Търговска репутация', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': '5'},
- 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'},
- 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'},
- 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'},
- 'col_15': {'val_15': []}},
- 'row_7': {
- 'col_0': {'val_0': [' 4. Предоставени аванси и нематериални\nактиви в процес на изграждане', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': '3'}, 'col_4': {'val_4': '4'},
- 'col_5': {'val_5': 'x'}, 'col_6': {'val_6': ''}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': 'x'},
- 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_8': {'col_0': {'val_0': [' - в т.ч.: предоставени аванси', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': 'x'},
- 'col_6': {'val_6': ''}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': 'x'},
- 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''},
- 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''},
- 'col_15': {'val_15': '15'}},
- 'row_9': {'col_0': {'val_0': 'Общо за група I.'}, 'col_1': {'val_1': []}, 'col_2': {'val_2': []},
- 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []}, 'col_6': {'val_6': '6'},
- 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'},
- 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'},
- 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'}, 'col_15': {'val_15': []}},
- 'row_10': {'col_0': {'val_0': ['II. Материални дълготрайни активи', ' ']}, 'col_1': {'val_1': ''},
- 'col_2': {'val_2': ''}, 'col_3': {'val_3': ''}, 'col_4': {'val_4': ''}, 'col_5': {'val_5': ''},
- 'col_6': {'val_6': ''}, 'col_7': {'val_7': ''}, 'col_8': {'val_8': ''}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': ''}},
- 'row_11': {'col_0': {'val_0': [' 1. Земи и сгради, включително права в т.ч.:', ' ']},
- 'col_1': {'val_1': f'n'}, 'col_2': {'val_2': f'n'}, 'col_3': {'val_3': []},
- 'col_4': {'val_4': '4'}, 'col_5': {'val_5': '5'}, 'col_6': {'val_6': '6'},
- 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'},
- 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'},
- 'col_13': {'val_13': '13'}, 'col_14': {'val_14': []}, 'col_15': {'val_15': '15'}},
- 'row_12': {'col_0': {'val_0': [' - земи', ' ']}, 'col_1': {'val_1': []}, 'col_2': {'val_2': []},
- 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []},
- 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': ' '},
- 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''},
- 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''},
- 'col_15': {'val_15': '15'}},
- 'row_13': {'col_0': {'val_0': [' - подобрения върху земите', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []},
- 'col_5': {'val_5': '5'}, 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'},
- 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'},
- 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'},
- 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_14': {'col_0': {'val_0': [' - сгради', ' ']}, 'col_1': {'val_1': []}, 'col_2': {'val_2': []},
- 'col_3': {'val_3': []}, 'col_4': {'val_4': '4'}, 'col_5': {'val_5': '5'},
- 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'},
- 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'},
- 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'},
- 'col_15': {'val_15': '15'}},
- 'row_15': {'col_0': {'val_0': [' 2. Машини, производствено оборудване\n и апаратура', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': []},
- 'col_4': {'val_4': '4'}, 'col_5': {'val_5': '5'}, 'col_6': {'val_6': '6'},
- 'col_7': {'val_7': '7'}, 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'},
- 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'},
- 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_16': {'col_0': {'val_0': [' 3. Съоръжения и други', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': '4'},
- 'col_5': {'val_5': '5'}, 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'},
- 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'},
- 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'},
- 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_17': {'col_0': {'val_0': [' - в т.ч.: транспортни средства', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []},
- 'col_5': {'val_5': '5'}, 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'},
- 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'},
- 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'},
- 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_18': {'col_0': {
- 'val_0': [' 4. Предоставени аванси и дълготрайни мате-\nриални активи в процес на изграждане', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': '3'},
- 'col_4': {'val_4': '4'}, 'col_5': {'val_5': 'x'}, 'col_6': {'val_6': ''},
- 'col_7': {'val_7': '7'}, 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_19': {'col_0': {'val_0': [' - в т.ч.: предоставени аванси', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': '4'},
- 'col_5': {'val_5': 'x'}, 'col_6': {'val_6': ''}, 'col_7': {'val_7': []},
- 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''},
- 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''},
- 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_20': {'col_0': {'val_0': ['Общо за група II.', ' ']}, 'col_1': {'val_1': []}, 'col_2': {'val_2': []},
- 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []}, 'col_6': {'val_6': []},
- 'col_7': {'val_7': []}, 'col_8': {'val_8': []}, 'col_9': {'val_9': []},
- 'col_10': {'val_10': []}, 'col_11': {'val_11': []}, 'col_12': {'val_12': '12'},
- 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_21': {'col_0': {'val_0': ['III. Дългосрочни финансови активи', ' ']}, 'col_1': {'val_1': ''},
- 'col_2': {'val_2': ''}, 'col_3': {'val_3': ''}, 'col_4': {'val_4': ''}, 'col_5': {'val_5': ''},
- 'col_6': {'val_6': ''}, 'col_7': {'val_7': ''}, 'col_8': {'val_8': ''}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': ''}},
- 'row_22': {'col_0': {'val_0': [' 1. Акции и дялове в предприятия от група', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': []},
- 'col_4': {'val_4': '4'}, 'col_5': {'val_5': []}, 'col_6': {'val_6': []},
- 'col_7': {'val_7': []}, 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_23': {'col_0': {'val_0': [' 2. Предоставени заеми на предприятия\n от група', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': []},
- 'col_4': {'val_4': '4'}, 'col_5': {'val_5': '5'}, 'col_6': {'val_6': []},
- 'col_7': {'val_7': '7'}, 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_24': {'col_0': {'val_0': [' 3. Акции и дялове в асоциирани и\n смесени предприятия', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []},
- 'col_5': {'val_5': []}, 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'},
- 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''},
- 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''},
- 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_25': {
- 'col_0': {'val_0': [' 4. Предоставени заеми, свързани с\nасоциирани и смесени предприятия', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []},
- 'col_5': {'val_5': []}, 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': 'x'},
- 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_26': {'col_0': {'val_0': [' 5. Дългосрочни инвестиции\n(инвестиционни имоти)', ' ']},
- 'col_1': {'val_1': []}, 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []},
- 'col_5': {'val_5': []}, 'col_6': {'val_6': '6'}, 'col_7': {'val_7': '7'},
- 'col_8': {'val_8': '8'}, 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'},
- 'col_11': {'val_11': '11'}, 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'},
- 'col_14': {'val_14': '14'}, 'col_15': {'val_15': '15'}},
- 'row_27': {'col_0': {'val_0': [' 6. Други заеми', ' ']}, 'col_1': {'val_1': []}, 'col_2': {'val_2': []},
- 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []}, 'col_6': {'val_6': []},
- 'col_7': {'val_7': []}, 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''},
- 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''},
- 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_28': {'col_0': {'val_0': [' 7. Изкупени собствени акции', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []},
- 'col_6': {'val_6': []}, 'col_7': {'val_7': '7'}, 'col_8': {'val_8': 'x'},
- 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''}, 'col_11': {'val_11': ''},
- 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''}, 'col_14': {'val_14': ''},
- 'col_15': {'val_15': '15'}},
- 'row_29': {'col_0': {'val_0': ['Общо за група III.', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []},
- 'col_6': {'val_6': []}, 'col_7': {'val_7': []}, 'col_8': {'val_8': '8'},
- 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'},
- 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'},
- 'col_15': {'val_15': '15'}},
- 'row_30': {'col_0': {'val_0': ['IV. Отсрочени данъци', ' ']}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': '4'},
- 'col_5': {'val_5': []}, 'col_6': {'val_6': []}, 'col_7': {'val_7': []},
- 'col_8': {'val_8': 'x'}, 'col_9': {'val_9': ''}, 'col_10': {'val_10': ''},
- 'col_11': {'val_11': ''}, 'col_12': {'val_12': ''}, 'col_13': {'val_13': ''},
- 'col_14': {'val_14': ''}, 'col_15': {'val_15': '15'}},
- 'row_31': {'col_0': {'val_0': 'Общо нетекущи (дълготрайни) активи'}, 'col_1': {'val_1': []},
- 'col_2': {'val_2': []}, 'col_3': {'val_3': []}, 'col_4': {'val_4': []}, 'col_5': {'val_5': []},
- 'col_6': {'val_6': []}, 'col_7': {'val_7': []}, 'col_8': {'val_8': '8'},
- 'col_9': {'val_9': '9'}, 'col_10': {'val_10': '10'}, 'col_11': {'val_11': '11'},
- 'col_12': {'val_12': '12'}, 'col_13': {'val_13': '13'}, 'col_14': {'val_14': '14'},
- 'col_15': {'val_15': []}},
- }
- self.round1000 = self.acc_rec_calculations.get_round1000()
- self.exact = self.acc_rec_calculations.get_exact()
- self.acc_rec_da = self.acc_rec_calculations.get_acc_rec_da()
- self.prints = Cells()
- for r in range(4, 31 + 1):
- for c in range(1, 15 + 1):
- row_key = f"row_{r}"
- col_key = f"col_{c}"
- val_key = f"val_{c}"
- val = self.round1000.getItem(r, c) # val = None
- if r in [30]:
- pass
- if val is None:
- continue
- da_value = [val]
- diff = self.get_acc_rec_diff(r, c)
- if diff: diff = abs(diff)
- if val == 0 and diff == 0:
- pass
- else:
- bar = 2
- if diff:
- bar += diff
- for extra_val in range(val - bar, val+bar+1):
- if extra_val < 0: continue # Не искаме отрицателни
- if extra_val == val: continue # Самата val сме я добавили по-горе на първо място
- da_value.append(extra_val)
- self.da[row_key][col_key][val_key] = da_value
- self.da["row_31"]["col_9"]["val_9"] = self.round1000.getNumber(31, 9)
- self.da["row_31"]["col_15"]["val_15"] = self.round1000.getNumber(31, 15)
- self.round1000_sums_row_31 = {} # Ще има по 1 стойност за всяка колона
- for c in range(1, 15 + 1):
- self.round1000_sums_row_31[c] = self.round1000.getNumber(9, c) + self.round1000.getNumber(20, c) + self.round1000.getNumber(29, c) + self.round1000.getNumber(30, c)
- # Речник със разликите межди *:7 - *:14
- self.round1000_sums_col_15 = {} # Ще има по 1 стойност за всеки ред
- for r in range(4, 31 + 1):
- self.round1000_sums_col_15[r] = self.round1000.getNumber(r, 7) - self.round1000.getNumber(r, 14)
- self.change_color_submassive()
- def create_window(self):
- self.my_win = tk.Tk()
- self.my_win.geometry('1400x850+100+50')
- self.my_win.title('Comboboxes')
- self.my_win.configure(background='lightgrey')
- butt3 = tk.Button(self.my_win, text="ПОПЪЛНИ", fg='green', command=self.get_da_print)
- butt3.grid(row=40, column=10, pady=(20, 1))
- self.col_locks_bvars = {}
- for c in [4, 7, 11, 14, 15]:
- self.col_locks_bvars[c] = tk.BooleanVar(self.my_win, value=True)
- self.check_butt_4 = tk.Checkbutton(self.my_win, variable=self.col_locks_bvars[c], text='ключ', width=6,
- justify='left', anchor='w', command=lambda c=c: self.apply_locks_on_column(c))
- self.check_butt_4.grid(row=40, column=c, pady=(20, 1))
- # CheckButton for Exact
- self.exact_bvars = {}
- self.exact_pop_wins = {}
- self.exact_checkbuttons = {}
- for r in [4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 30, 31]:
- self.exact_bvars[r] = tk.BooleanVar(self.my_win, value=False)
- self.exact_checkbuttons[r] = tk.Checkbutton(self.my_win, variable=self.exact_bvars[r], width=0, height=0, font=("Times", 2), borderwidth=1,
- justify='left', anchor='w', command = lambda r=r: self.on_change_exact(r))
- self.exact_checkbuttons[r].grid(row=r, column=20, pady=(0, 0), padx=(1, 0))
- self.init_locks()
- self.create_table()
- self.on_window_ready()
- self.my_win.mainloop()
- # CheckButton for Exact
- def on_change_exact(self, row):
- bvar = self.exact_bvars[row]
- pop_win = None
- if row in self.exact_pop_wins:
- pop_win = self.exact_pop_wins[row]
- if bvar.get():
- # Искаме да отворим прозореца
- if pop_win:
- # Вече има прозорец -- или го убиваме и отваряме наново, или го "викаме" да дойде отпред
- pop_win.destroy()
- self.exact_pop_wins[row] = self.get_exact_pop_win(row)
- else:
- # Искаме да затворим прозореца
- if pop_win:
- # Прозорец наистина има, затваряме го
- pop_win.destroy()
- def get_exact_pop_win(self, row):
- pop_win = tk.Toplevel(self.my_win)
- win_title = self.da[f"row_{row}"]["col_0"]["val_0"]
- if isinstance(win_title, list):
- win_title = win_title[0]
- pop_win.title(win_title)
- y_pos = row * 25
- pop_win.geometry(f'+860+{y_pos}')
- pop_win.attributes('-topmost', 'true')
- captions = {
- 2: "Активи: +",
- 3: "-",
- 4: "салдо:",
- 9: "Амотизация: +",
- 10: "-",
- 11: "салдо",
- 15: "баланс:"}
- items = []
- for c in [2, 3, 4, 9, 10, 11, 15]:
- exact = self.exact.getNumber(row, c)
- exact1 = f"{exact:,.0f}".replace(',', ' ')
- items.append(f"{captions[c]} {exact1}")
- label_content = " ".join(items)
- label = tk.Label(pop_win, text=label_content, font=('Times New Roman', 10), bg='yellow',
- anchor="w", fg='black', justify='center')
- label.grid(row=0, column=0, padx=(1, 1), pady=(1, 1), sticky='nswe')
- return pop_win
- def updateCellStatus(self, row, col, diff):
- #self.diffs.setItem(row, col, diff)
- old_bool = self.diffs1.getItem(row, col)
- if old_bool == True:
- pass
- else:
- if diff == 0:
- self.diffs1.setItem(row, col, False)
- else:
- self.diffs1.setItem(row, col, True)
- new_bool = self.diffs1.getItem(row, col)
- # print('new_bool ', new_bool)
- widget = self.widgets.getItem(row, col)
- if widget:
- if new_bool:
- widget.configure(bg='red')
- else:
- widget.configure(bg='green')
- def create_widget(self, place_on, r, c, w, span_row, span_col, text, height, anc):
- pos = tk.RIGHT
- type_w = None
- if r in [0, 1, 3, 9, 10, 20, 21, 29, 31]:
- type_w = "label"
- anc = tk.E
- if (r in [3, 10, 21, 31] and c == 0):
- anc = tk.W
- if c == 0:
- pos = tk.LEFT
- if c == 1 or c == 4 or c == 7 or c == 8 or c == 11 or c == 14 or c == 15 or (r in [7, 8, 18, 19] and 5 <= c <= 6 ):
- type_w = "label"
- anc = tk.E
- if r in [0, 2]:
- pos = tk.CENTER
- anc = tk.CENTER
- if r in [7, 8, 12, 18, 19, 22, 23, 24, 25, 27, 28, 30] and 8 <= c <= 14:
- type_w = 'label'
- if r in [2] and c == 0:
- type_w = 'label'
- if r == 31 and c > 0:
- anc = tk.E
- if r in [31]:
- pass
- if type_w == "label":
- if isinstance(text, list):
- if len(text) < 1:
- text_label = 0 # Подразбираща се стойност ако списъка е празн
- else:
- text_label = text[0] # Ще се замести с първия елемент, ако има поне един
- return self.create_label(place_on, r, c, span_row, span_col, height, text_label, anc)
- return self.create_label(place_on, r, c, span_row, span_col, height, text, anc)
- return self.create_combobox(place_on, r, c, w, span_row, span_col, text, j=pos)
- def create_label(self, place_on, row_x, col_y, span_row=1, span_col=1, height=3, text='', anc=tk.CENTER):
- label_var = tk.StringVar(self.my_win, value=text)
- label = tk.Label(place_on, text=text, font=('Times New Roman', 10, 'bold'), bg='white', height=height,
- anchor=anc, fg='black', justify='center', textvariable=label_var)
- label.grid(row=row_x, column=col_y, padx=(1, 1), pady=(1, 1), sticky='nswe', rowspan=span_row, columnspan=span_col)
- self.string_vars.setItem(row_x, col_y, label_var)
- self.widgets.setItem(row_x, col_y, label)
- return label
- def on_cell_change(self):
- self.refresh_table()
- self.check_sums()
- def on_lock_change(self):
- self.refresh_table()
- self.check_sums()
- def on_window_ready(self):
- self.check_sums()
- def create_combobox(self, place_on, r, c, w, span_row, span_col, text, j=tk.RIGHT):
- var = tk.StringVar(self.my_win)
- self.string_vars.setItem(r, c, var)
- if isinstance(text, list) and len(text) < 1:
- text = [0]
- widget = ttk.Combobox(place_on, values=text, textvariable=var, width=w, justify=j)
- # Прави комбобокса да не реагира на колецето на мишката
- widget.unbind_class("TCombobox", "<MouseWheel>") # Windows & OSX
- widget.unbind_class("TCombobox", "<ButtonPress-4>") # Linux and other *nix systems:
- widget.unbind_class("TCombobox", "<ButtonPress-5>") # Linux and other *nix systems:
- widget.bind("<<ComboboxSelected>>", lambda e: self.on_cell_change())
- widget.set(text[0])
- self.widgets.setItem(r, c, widget)
- widget.grid(row=r, column=c, padx=(1, 1), pady=(1, 1), sticky='nswe', rowspan=span_row, columnspan=span_col)
- return widget
- def create_table(self):
- row_n = 0
- span_row = 1
- span_col = 1
- width_c = 6
- height = 1
- for row in self.da: # Редове 'row_1'
- col_n = 0
- for column in self.da[row]: # Колони
- for val in self.da[row][column]: # val = val_1
- text = self.da[row][column][val]
- if text == '' or text is None:
- col_n += 1
- continue
- elif text == 'ПОКАЗАТЕЛИ' or text == 'Балансова\nстойност\nв края':
- span_row = 2
- height = 5
- elif text == 'Отчетна стойност\nна нетекущите активи' or text == 'Амортизации':
- span_col = 7
- height = 2
- elif (row == 'row_7' and column == 'col_8' and val == 'val_8') or (row == 'row_8' and
- column == 'col_8' and val == 'val_8') or (row == 'row_12' and column == 'col_8' and
- val == 'val_8') or (row == 'row_18' and column == 'col_8' and val == 'val_8') or\
- (row == 'row_19' and column == 'col_8' and val == 'val_8')\
- or (row == 'row_22' and column == 'col_8' and val == 'val_8')\
- or (row == 'row_23' and column == 'col_8' and val == 'val_8') or\
- (row == 'row_24' and column == 'col_8' and val == 'val_8') or (row == 'row_25' and
- column == 'col_8' and val == 'val_8') or (row == 'row_27' and column == 'col_8' and
- val == 'val_8') or (row == 'row_28' and column == 'col_8' and val == 'val_8') or\
- (row == 'row_30' and column == 'col_8' and val == 'val_8'):
- span_col = 7
- elif (row == 'row_7' and column == 'col_5' and val == 'val_5') or (row == 'row_8' and column == 'col_5' and val == 'val_5') or\
- (row == 'row_18' and column == 'col_5' and val == 'val_5') or (row == 'row_19' and column == 'col_5' and val == 'val_5'):
- span_col = 2
- if row == 'row_1':
- height = 3
- if row == 'row_3' or row == 'row_10' or row == 'row_21':
- span_col = 16
- v = 1
- self.span_cols.setItem(row_n, col_n, span_col)
- self.heights.setItem(row_n, col_n, height)
- widget = self.create_widget(place_on=self.my_win, r=row_n, c=col_n, w=width_c, span_row=span_row, span_col=span_col, text=text, height=height, anc='center')
- height = 1
- col_n += 1
- span_col = 1
- span_row = 1
- v += 1
- row_n += 1
- def refresh_table(self):
- self.refresh_group1()
- self.refresh_group2()
- self.refresh_group3()
- self.refresh_tax_row()
- self.refresh_total_row()
- def refresh_group1(self):
- col = 4
- for r in range(4, 8+1):
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 1) + self.get_string_var_number(r, 2) - self.get_string_var_number(r, 3))
- col = 7
- for r in range(4, 8+1):
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 4) + self.get_string_var_number(r, 5) - self.get_string_var_number(r, 6))
- col = 11
- for r in range(4, 8+1):
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 8) + self.get_string_var_number(r, 9) - self.get_string_var_number(r, 10))
- col = 14
- for r in range(4, 8+1):
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 11) + self.get_string_var_number(r, 12) - self.get_string_var_number(r, 13))
- col = 15
- for r in range(4, 8+1):
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14))
- row = 9
- for c in range(2, 15+1):
- svar = self.string_vars.getItem(row, c)
- if svar is None: continue
- tot = 0
- for r in [4, 5, 6, 7]:
- tot += self.get_string_var_number(r, c)
- if not self.locks.getItem(row, c):
- svar.set(tot)
- def refresh_group2(self):
- col = 4
- sub_rows = range(11, 19+1)
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 1) + self.get_string_var_number(r, 2) - self.get_string_var_number(r, 3))
- col = 7
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 4) + self.get_string_var_number(r, 5) - self.get_string_var_number(r, 6))
- col = 11
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 8) + self.get_string_var_number(r, 9) - self.get_string_var_number(r, 10))
- col = 14
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 11) + self.get_string_var_number(r, 12) - self.get_string_var_number(r, 13))
- col = 15
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- res = self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14)
- svar.set(self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14))
- row = 20
- for c in range(2, 15+1):
- svar = self.string_vars.getItem(row, c)
- if svar is None: continue
- tot = 0
- for r in [11, 15, 16, 18]:
- tot += self.get_string_var_number(r, c)
- if not self.locks.getItem(row, c):
- svar.set(tot)
- def refresh_group3(self):
- col = 4
- sub_rows = range(22, 28+1)
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 1) + self.get_string_var_number(r, 2) - self.get_string_var_number(r, 3))
- col = 7
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 4) + self.get_string_var_number(r, 5) - self.get_string_var_number(r, 6))
- col = 11
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 8) + self.get_string_var_number(r, 9) - self.get_string_var_number(r, 10))
- col = 14
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 11) + self.get_string_var_number(r, 12) - self.get_string_var_number(r, 13))
- col = 15
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- res = self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14)
- svar.set(self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14))
- row = 29
- for c in range(2, 15+1):
- svar = self.string_vars.getItem(row, c)
- if self.locks.getItem(row, c): continue
- if svar is None: continue
- tot = 0
- for r in range(22, 28+1):
- tot += self.get_string_var_number(r, c)
- svar.set(tot)
- def refresh_tax_row(self):
- col = 4
- sub_rows = [30]
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 1) + self.get_string_var_number(r, 2) - self.get_string_var_number(r, 3))
- col = 7
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- svar.set(self.get_string_var_number(r, 4) + self.get_string_var_number(r, 5) - self.get_string_var_number(r, 6))
- col = 15
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar and not self.locks.getItem(r, col):
- res = self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14)
- svar.set(self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14))
- def refresh_total_row(self):
- tot_row = 31
- for c in range(2, 14+1):
- if c == 9: continue
- if c == 15: continue
- svar = self.string_vars.getItem(tot_row, c)
- if svar and not self.locks.getItem(tot_row, c):
- tot = self.get_string_var_number(9, c) + self.get_string_var_number(20, c) + self.get_string_var_number(29, c) + self.get_string_var_number(30, c)
- svar.set(tot)
- def reset_diffs(self):
- #self.diffs = Cells() # Разлика между
- self.diffs1 = Cells()
- def check_sums(self):
- self.reset_diffs()
- self.check_Rx15() # Дали *:15 = *:7 - *:14
- for c in range(1, 14+1):
- self.check_subsums_rows_row_col([4, 5, 6, 7], 9, c) # Група 1
- self.check_subsums_rows_row_col([11, 15, 16, 18], 20, c) # Група 2
- self.check_subsums_rows_row_col([22, 23, 24, 25, 26, 27, 28], 29, c) # Група 3
- self.check_sums_col_4()
- self.check_sums_col_7()
- self.check_sums_col_11()
- self.check_sums_col_14()
- self.check_sums_row_31()
- self.change_color_assets_vs_amort()
- self.change_color_submassive()
- def change_color_submassive(self):
- self.step = 'step'
- wdgs = [ self.widgets.getItem(18, 3), self.widgets.getItem(19, 3)]
- if self.get_string_var_number(19, 3) <= self.get_string_var_number(18, 3):
- for wdg in wdgs:
- if wdg:
- for r in [18, 19]:
- self.error_cell.setItemErrors(r, 3, self.step, False)
- self.update_cell_color(r, 3)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [18, 19]:
- self.error_cell.setItemErrors(r, 3, self.step, True)
- self.update_cell_color(r, 3)
- self.step = 'step_1'
- wdgs = [ self.widgets.getItem(7, 3), self.widgets.getItem(8, 3)]
- if self.get_string_var_number(8, 3) <= self.get_string_var_number(7, 3):
- for wdg in wdgs:
- if wdg:
- for r in [7, 8]:
- self.error_cell.setItemErrors(r, 3, self.step, False)
- self.update_cell_color(r, 3)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [7, 8]:
- self.error_cell.setItemErrors(r, 3, self.step, True)
- self.update_cell_color(r, 3)
- self.step = 'step_2'
- wdgs = [ self.widgets.getItem(16, 3), self.widgets.getItem(17, 3)]
- if self.get_string_var_number(17, 3) <= self.get_string_var_number(16, 3):
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 3, self.step, False)
- self.update_cell_color(r, 3)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 3, self.step, True)
- self.update_cell_color(r, 3)
- self.step = 'step_3'
- wdgs = [ self.widgets.getItem(16, 10), self.widgets.getItem(17, 10)]
- if self.get_string_var_number(17, 10) <= self.get_string_var_number(16, 10):
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 10, self.step, False)
- self.update_cell_color(r, 10)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 10, self.step, True)
- self.update_cell_color(r, 10)
- self.step = 'step_4'
- wdgs = [ self.widgets.getItem(11, 3), self.widgets.getItem(12, 3), self.widgets.getItem(13, 3), self.widgets.getItem(14, 3)]
- if self.get_string_var_number(12, 3) + self.get_string_var_number(13, 3) + self.get_string_var_number(14, 3) <= self.get_string_var_number(11, 3):
- for wdg in wdgs:
- if wdg:
- for r in [11, 12, 13, 14]:
- self.error_cell.setItemErrors(r, 3, self.step, False)
- self.update_cell_color(r, 3)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [11, 12, 13, 14]:
- self.error_cell.setItemErrors(r, 3, self.step, True)
- self.update_cell_color(r, 3)
- self.step = 'step_5'
- wdgs = [ self.widgets.getItem(11, 10), self.widgets.getItem(13, 10), self.widgets.getItem(14, 10)]
- if self.get_string_var_number(13, 10) + self.get_string_var_number(14, 10) <= self.get_string_var_number(11, 10):
- for wdg in wdgs:
- if wdg:
- for r in [11, 13, 14]:
- self.error_cell.setItemErrors(r, 10, self.step, False)
- self.update_cell_color(r, 10)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [11, 13, 14]:
- self.error_cell.setItemErrors(r, 10, self.step, True)
- self.update_cell_color(r, 10)
- self.step = 'step_6'
- wdgs = [ self.widgets.getItem(11, 9), self.widgets.getItem(13, 9), self.widgets.getItem(14, 9)]
- if self.get_string_var_number(13, 9) + self.get_string_var_number(14, 9) <= self.get_string_var_number(11, 9):
- for wdg in wdgs:
- if wdg:
- for r in [11, 13, 14]:
- self.error_cell.setItemErrors(r, 9, self.step, False)
- self.update_cell_color(r, 9)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [11, 13, 14]:
- self.error_cell.setItemErrors(r, 9, self.step, True)
- self.update_cell_color(r, 9)
- self.step = 'step_7'
- wdgs = [self.widgets.getItem(11, 2), self.widgets.getItem(12, 2), self.widgets.getItem(13, 2), self.widgets.getItem(14, 2)]
- if self.get_string_var_number(13, 2) + self.get_string_var_number(14, 2) <= self.get_string_var_number(11, 2):
- for wdg in wdgs:
- if wdg:
- for r in [11, 12, 13, 14]:
- self.error_cell.setItemErrors(r, 2, self.step, False)
- self.update_cell_color(r, 2)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [11, 12, 13, 14]:
- self.error_cell.setItemErrors(r, 2, self.step, True)
- self.update_cell_color(r, 2)
- self.step = 'step_8'
- wdgs = [ self.widgets.getItem(16, 9), self.widgets.getItem(17, 9)]
- if self.get_string_var_number(17, 9) <= self.get_string_var_number(16, 9):
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 9, self.step, False)
- self.update_cell_color(r, 9)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 9, self.step, True)
- self.update_cell_color(r, 9)
- self.step = 'step_9'
- wdgs = [ self.widgets.getItem(16, 2), self.widgets.getItem(17, 2)]
- if self.get_string_var_number(17, 2) <= self.get_string_var_number(16, 2):
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 2, self.step, False)
- self.update_cell_color(r, 2)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [16, 17]:
- self.error_cell.setItemErrors(r, 2, self.step, True)
- self.update_cell_color(r, 2)
- self.step = 'step'
- wdgs = [ self.widgets.getItem(18, 2), self.widgets.getItem(19, 2)]
- if self.get_string_var_number(19, 2) <= self.get_string_var_number(18, 2):
- for wdg in wdgs:
- if wdg:
- for r in [18, 19]:
- self.error_cell.setItemErrors(r, 2, self.step, False)
- self.update_cell_color(r, 2)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [18, 19]:
- self.error_cell.setItemErrors(r, 2, self.step, True)
- self.update_cell_color(r, 2)
- self.step = 'step_1'
- wdgs = [ self.widgets.getItem(7, 2), self.widgets.getItem(8, 2)]
- if self.get_string_var_number(8, 2) <= self.get_string_var_number(7, 2):
- for wdg in wdgs:
- if wdg:
- for r in [7, 8]:
- self.error_cell.setItemErrors(r, 2, self.step, False)
- self.update_cell_color(r, 2)
- else:
- for wdg in wdgs:
- if wdg:
- for r in [7, 8]:
- self.error_cell.setItemErrors(r, 3, self.step, True)
- self.update_cell_color(r, 3)
- def change_color_assets_vs_amort(self):
- self.step = 'step_1'
- for r in [4, 5, 6, 11, 13, 14, 15, 16, 17, 26]:
- wdgs = [self.widgets.getItem(r, 10), self.widgets.getItem(r, 3)]
- if self.get_string_var_number(r, 10) <= self.get_string_var_number(r, 3):
- for wdg in wdgs:
- if wdg:
- for col in [3, 10]:
- self.error_cell.setItemErrors(r, col, self.step, False)
- self.update_cell_color(r, col)
- else:
- for wdg in wdgs:
- if wdg:
- for col in [3, 10]:
- self.error_cell.setItemErrors(r, col, self.step, True) # error_sels {16: {10: True, 3: True}, 17: {10: True, 3: True}}
- self.update_cell_color(r, col)
- def update_cell_color(self, r, c):
- cells = self.error_cell.getCells()
- is_error = 0
- for step in cells[r][c]:
- status = self.error_cell.getItemErrors(r, c, step)
- if status:
- is_error += 1
- widget = self.widgets.getItem(r, c)
- if is_error > 0:
- if widget:
- widget.configure(foreground='red')
- else:
- if widget:
- widget.configure(foreground='black')
- def try_to_lock_tax_row(self):
- can_lock = True
- r = 30
- for c in [4, 7, 15]:
- if self.diffs1.getItem(r, c):
- can_lock = False
- break
- if can_lock:
- r = 31
- for c in [1, 2, 3, 4, 5, 6, 7, 15]:
- if self.diffs1.getItem(r, c):
- can_lock = False
- break
- if can_lock:
- r = 31
- for c in range(1, 15 + 1):
- if self.diffs1.getItem(r, c):
- can_lock = False
- break
- if can_lock:
- r = 30
- for c in range(1, 7+1):
- widget = self.widgets.getItem(r, c)
- if widget and isinstance(widget, ttk.Combobox):
- widget.config(state='disabled')
- def get_string_var_number(self, row, col):
- svar = self.string_vars.getItem(row, col)
- if svar is None:
- return 0
- svar_value_str = svar.get()
- try:
- return int(svar_value_str)
- except:
- return 0
- def check_sums_col_4(self):
- col = 4
- for r in range(4, 31+1):
- svar_value = self.get_string_var_number(r, col)
- tot = self.get_string_var_number(r, 1) + self.get_string_var_number(r, 2) - self.get_string_var_number(r, 3)
- diff = svar_value - tot
- self.updateCellStatus(r, col, diff)
- def check_sums_col_7(self):
- col = 7
- for r in range(4, 31+1):
- svar_value = self.get_string_var_number(r, col)
- tot = self.get_string_var_number(r, 4) + self.get_string_var_number(r, 5) - self.get_string_var_number(r, 6)
- diff = svar_value - tot
- self.updateCellStatus(r, col, diff)
- def check_sums_col_11(self):
- col = 11
- for r in range(4, 31+1):
- svar_value = self.get_string_var_number(r, col)
- tot = self.get_string_var_number(r, 8) + self.get_string_var_number(r, 9) - self.get_string_var_number(r, 10)
- diff = svar_value - tot
- self.updateCellStatus(r, col, diff)
- def check_sums_col_14(self):
- col = 14
- for r in range(4, 31+1):
- svar_value = self.get_string_var_number(r, col)
- tot = self.get_string_var_number(r, 11) + self.get_string_var_number(r, 12) - self.get_string_var_number(r, 13)
- diff = svar_value - tot
- self.updateCellStatus(r, col, diff)
- def check_sums_row_31(self):
- tot_row = 31
- for c in range(1, 15+1):
- svar_value = self.get_string_var_number(31, c)
- tot = self.get_string_var_number(9, c) + self.get_string_var_number(20, c) + self.get_string_var_number(29, c) + self.get_string_var_number(30, c)
- self.updateCellStatus(tot_row, c, tot - svar_value)
- # Проверка дали *:15 =?= *:7 - *:14
- # Оцветява *15
- def check_Rx15(self):
- tot_col = 15
- for r in range(4, 31+1):
- svar_value = self.get_string_var_number(r, 15)
- tot = self.get_string_var_number(r, 7) - self.get_string_var_number(r, 14)
- self.updateCellStatus(r, tot_col, tot - svar_value)
- # Проверява дали tot_row*col e сума от sub_rows*col
- # Оцветява tot_row:col
- def check_subsums_rows_row_col(self, sub_rows, tot_row, col):
- tot = 0
- for r in sub_rows:
- svar = self.string_vars.getItem(r, col)
- if svar is None: continue
- svar_value_str = svar.get()
- try:
- svar_value = int(svar_value_str)
- except:
- continue
- tot += svar_value
- svar = self.string_vars.getItem(tot_row, col)
- if svar:
- val_RxC_str = svar.get()
- val_RxC = int(val_RxC_str)
- diff = val_RxC - tot
- self.updateCellStatus(tot_row, col, diff)
- def apply_locks_on_column(self, col):
- lock_state = self.col_locks_bvars[col].get() # True/False
- for r in range(4, 31+1):
- self.locks.setItem(r, col, lock_state)
- self.on_lock_change()
- def init_locks(self):
- self.locks.setItem(31, 15, True)
- self.locks.setItem(31, 9, True)
- self.col_locks_bvars[4].set(True); self.apply_locks_on_column(4)
- self.col_locks_bvars[7].set(True); self.apply_locks_on_column(7)
- self.col_locks_bvars[11].set(True); self.apply_locks_on_column(11)
- self.col_locks_bvars[14].set(True); self.apply_locks_on_column(14)
- self.col_locks_bvars[15].set(True); self.apply_locks_on_column(15)
- def get_da_print(self):
- # Проверка за грешки в крайните суми
- for r in range(4, 32):
- for c in range(1, 16):
- if self.diffs1.getItem(r, c):
- self.pop_up_errors()
- return
- # Проверка за грешки в междинните суми
- cells = self.error_cell.getCells()
- for r in cells:
- for c in cells[r]:
- for step in cells[r][c]:
- if self.error_cell.getItemErrors(r, c, step):
- self.pop_up_errors()
- return
- for r in range(0, 31+1):
- for c in range(0, 15+1):
- value = self.get_string_var_number(r, c)
- self.prints.setItem(r, c, value)
- zero_rows = []
- for r in range(0, 31+1):
- row_is_zero = True
- for c in range(0, 15+1):
- value = self.prints.getItem(r, c)
- if value != 0:
- row_is_zero = False
- break
- if row_is_zero:
- zero_rows.append(r)
- zero_cols = []
- for c in range(0, 15+1):
- col_is_zero = True
- for r in range(4, 31 + 1):
- value = self.prints.getItem(r, c)
- if value != 0:
- col_is_zero = False
- break
- if col_is_zero:
- zero_cols.append(c)
- remove_rows = []
- # Група 1
- group_title_row = 3
- group_rows = list(range(4, 9+1))
- group_zero_rows = set(group_rows).intersection(zero_rows)
- if len(group_zero_rows) == len(group_rows):
- remove_rows.append(group_title_row)
- remove_rows.extend(group_zero_rows)
- # Група 2
- group_title_row = 10
- group_rows = list(range(11, 20+1))
- group_zero_rows = set(group_rows).intersection(zero_rows)
- if len(group_zero_rows) == len(group_rows):
- remove_rows.append(group_title_row)
- remove_rows.extend(group_zero_rows)
- # Група 3
- group_title_row = 21
- group_rows = list(range(22, 29+1))
- group_zero_rows = set(group_rows).intersection(zero_rows)
- if len(group_zero_rows) == len(group_rows):
- remove_rows.append(group_title_row)
- remove_rows.extend(group_zero_rows)
- # Група 4 (данъци)
- if 30 in zero_rows:
- remove_rows.append(30)
- remove_cols = []
- # За да се ползва ф-ция intersection, трябва да се използва ф-ция SET.
- cols_allow_to_remove = [2, 3, 5, 6, 9, 10, 12, 13]
- section = set(cols_allow_to_remove).intersection(zero_cols)
- remove_cols.extend(section)
- if 5 in zero_cols and 6 in zero_cols:
- remove_cols.append(7)
- if 12 in zero_cols and 13 in zero_cols:
- remove_cols.append(14)
- da_print = copy.deepcopy(self.da)
- # --------------------------
- for r in range(0, 31+1):
- for c in range(0, 15+1):
- if c in remove_cols:
- del da_print[f"row_{r}"][f"col_{c}"] # KeyError: 'col_5'
- for r in remove_rows:
- del da_print[f"row_{r}"]
- # В comboboxo-вете има листове, от които взимаме само 0-вата позиция
- for r in range(0, 31+1):
- for c in range(0, 15+1):
- r_idx = f"row_{r}"; c_idx = f"col_{c}"; v_idx = f"val_{c}"
- if r_idx in da_print and c_idx in da_print[r_idx]:
- svar = self.string_vars.getItem(r, c)
- if svar:
- da_print[r_idx][c_idx][v_idx] = svar.get()
- elif isinstance(da_print[r_idx][c_idx][v_idx], list):
- # Заместваме списъка със стринга, който е първа стойност в списъка
- da_print[r_idx][c_idx][v_idx] = da_print[r_idx][c_idx][v_idx][0]
- json_file_io = JsonFileIo(file_name=registry['da_print_combobox_test_file_name'])
- json_file_io.write_content(da_print)
- # da_print.clear()
- balance_assets_rec = {
- "na": {
- "prd": {
- "balans": da_print["row_4"]["col_15"]["val_15"],
- "ns": int(da_print["row_4"]["col_1"]["val_1"]) - int(da_print["row_4"]["col_8"]["val_8"]),
- }
- }
- }
- json_file_io = JsonFileIo(file_name=registry['balance_assets_rec_file_name'])
- json_file_io.write_content(balance_assets_rec)
- self.pdf_dna()
- quit()
- def pop_up_errors(self):
- error_message = tk.Toplevel(self.my_win, background='orange')
- error_message.geometry('400x130+600+300')
- error_message.wm_overrideredirect(True)
- error_message.attributes('-topmost', 'true')
- error_label = tk.Label(error_message, text='В ТАБЛИЦАТА СА ОТКРИТИ ГРЕШКИ !!!', background='yellow', foreground='red', font=('Timesbg', 12))
- error_label.place(relx=.5, rely=.4, anchor='center')
- error_button = tk.Button(error_message, text='ОК', command=error_message.destroy, justify='center', foreground='black', width=6)
- error_button.place(relx=0.5, rely=0.7, anchor='center')
- def get_acc_rec_diff(self, r, c):
- if c in [2, 3] and r == 4: return self.acc_rec_da["prd"]["assets_re"]["diff"]
- if c in [2, 3] and r == 5: return self.acc_rec_da["pp"]["assets_re"]["diff"]
- if c in [2, 3] and r == 6: return self.acc_rec_da["tr"]["assets_re"]["diff"]
- if c in [2, 3] and r == 7: return self.acc_rec_da["rpna"]["assets_re"]["diff"]
- if c in [2, 3] and r == 8: return self.acc_rec_da["adv"]["assets_re"]["diff"]
- if c in [2, 3] and r == 11: return self.acc_rec_da["pdr"]["assets_re"]["diff"]
- if c in [2, 3] and r == 12: return self.acc_rec_da["z"]["assets_re"]["diff"]
- if c in [2, 3] and r == 13: return self.acc_rec_da["pz"]["assets_re"]["diff"]
- if c in [2, 3] and r == 14: return self.acc_rec_da["s"]["assets_re"]["diff"]
- if c in [2, 3] and r == 15: return self.acc_rec_da["m"]["assets_re"]["diff"]
- if c in [2, 3] and r == 16: return self.acc_rec_da["sdr"]["assets_re"]["diff"]
- if c in [2, 3] and r == 17: return self.acc_rec_da["ts"]["assets_re"]["diff"]
- if c in [2, 3] and r == 18: return self.acc_rec_da["rpma"]["assets_re"]["diff"]
- if c in [2, 3] and r == 19: return self.acc_rec_da["advm"]["assets_re"]["diff"]
- if c in [2, 3] and r == 22: return self.acc_rec_da["adp"]["assets_re"]["diff"]
- if c in [2, 3] and r == 23: return self.acc_rec_da["pzp"]["assets_re"]["diff"]
- if c in [2, 3] and r == 24: return self.acc_rec_da["adas"]["assets_re"]["diff"]
- if c in [2, 3] and r == 25: return self.acc_rec_da["pzas"]["assets_re"]["diff"]
- if c in [2, 3] and r == 26: return self.acc_rec_da["di"]["assets_re"]["diff"]
- if c in [2, 3] and r == 27: return self.acc_rec_da["drz"]["assets_re"]["diff"]
- if c in [2, 3] and r == 28: return self.acc_rec_da["isa"]["assets_re"]["diff"]
- if c in [2, 3] and r == 30: return self.acc_rec_da["ltax"]["assets_re"]["diff"]
- if c in [9, 10] and r == 4: return self.acc_rec_da["prd"]["amort_re"]["diff"]
- if c in [9, 10] and r == 5: return self.acc_rec_da["pp"]["amort_re"]["diff"]
- if c in [9, 10] and r == 6: return self.acc_rec_da["tr"]["amort_re"]["diff"]
- if c in [9, 10] and r == 7: return self.acc_rec_da["rpna"]["amort_re"]["diff"]
- if c in [9, 10] and r == 8: return self.acc_rec_da["adv"]["amort_re"]["diff"]
- if c in [9, 10] and r == 11: return self.acc_rec_da["pdr"]["amort_re"]["diff"]
- if c in [9, 10] and r == 12: return self.acc_rec_da["z"]["amort_re"]["diff"]
- if c in [9, 10] and r == 13: return self.acc_rec_da["pz"]["amort_re"]["diff"]
- if c in [9, 10] and r == 14: return self.acc_rec_da["s"]["amort_re"]["diff"]
- if c in [9, 10] and r == 15: return self.acc_rec_da["m"]["amort_re"]["diff"]
- if c in [9, 10] and r == 16: return self.acc_rec_da["sdr"]["amort_re"]["diff"]
- if c in [9, 10] and r == 17: return self.acc_rec_da["ts"]["amort_re"]["diff"]
- if c in [9, 10] and r == 18: return self.acc_rec_da["rpma"]["amort_re"]["diff"]
- if c in [9, 10] and r == 19: return self.acc_rec_da["advm"]["amort_re"]["diff"]
- if c in [9, 10] and r == 22: return self.acc_rec_da["adp"]["amort_re"]["diff"]
- if c in [9, 10] and r == 23: return self.acc_rec_da["pzp"]["amort_re"]["diff"]
- if c in [9, 10] and r == 24: return self.acc_rec_da["adas"]["amort_re"]["diff"]
- if c in [9, 10] and r == 25: return self.acc_rec_da["pzas"]["amort_re"]["diff"]
- if c in [9, 10] and r == 26: return self.acc_rec_da["di"]["amort_re"]["diff"]
- if c in [9, 10] and r == 27: return self.acc_rec_da["drz"]["amort_re"]["diff"]
- if c in [9, 10] and r == 28: return self.acc_rec_da["isa"]["amort_re"]["diff"]
- if c in [9, 10] and r == 30: return self.acc_rec_da["ltax"]["amort_re"]["diff"]
- return 0
- if __name__ == '__main__':
- da_win = DnaRounding()
- da_win.create_window()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement