Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from json_file_io import JsonFileIo
- from Opiti.from_excel.classes.global_inc import registry
- from cells_table import Cells
- from mapped_acc_calculations import *
- class AccRecCalculations:
- def __init__(self):
- self.acc_rec_da = self.get_acc_rec_da_init_values()
- self.exact = Cells()
- self.round1000 = Cells()
- try:
- json_file_io = JsonFileIo(file_name=registry["acc_rec_da_file_name"])
- tmp_acc_rec_da = json_file_io.read_content()
- if tmp_acc_rec_da is not None:
- self.acc_rec_da = tmp_acc_rec_da
- except:
- pass
- mapped_calculations = MappedCalculations()
- da_keys = {
- 4: "prd", 5: "pp", 6: "tr", 7: "rpna", 8: "adv",
- 11: "pdr", 12: "z", 13: "pz", 14: "s", 15: "m",
- 16: "sdr", 17: "ts", 18: "rpma", 19: "advm",
- 22: "adp", 23: "pzp", 24: "adas", 25: "pzas", 26: "di", 27:"drz", 28: "isa", 30: "ltax"
- }
- for r_idx, da_key in da_keys.items():
- debug_rows = [5]
- assets = mapped_calculations.sum_by_accs(self.acc_rec_da[da_key]["assets"]) # 6 суми в лв.ст
- amort = mapped_calculations.sum_by_accs(self.acc_rec_da[da_key]["amort"]) # 6 суми в лв.ст
- if r_idx in debug_rows:
- print(f"r_idx {r_idx} self.acc_rec_da[{da_key}] {self.acc_rec_da[da_key]}")
- self.exact.setItem(r_idx, 1, self.acc_rec_da[da_key]["ns"] * 1000)
- self.exact.setItem(r_idx, 2, assets["td"])
- self.exact.setItem(r_idx, 3, assets["tc"])
- self.exact.setItem(r_idx, 4, assets["cd"])
- if r_idx in [7, 8, 18, 19]:
- pass
- else:
- self.exact.setItem(r_idx, 5, self.acc_rec_da[da_key]["assets_re"]["inc"])
- self.exact.setItem(r_idx, 6, self.acc_rec_da[da_key]["assets_re"]["dec"])
- self.exact.setItem(r_idx, 7, self.exact.getNumber(r_idx, 4) + self.exact.getNumber(r_idx, 5) - self.exact.getNumber(r_idx, 6))
- if r_idx in [7, 8, 12, 18, 19, 22, 23, 24, 25, 27, 28, 30]:
- pass
- else:
- self.exact.setItem(r_idx, 8, self.acc_rec_da[da_key]["ns_amo"] * 1000)
- self.exact.setItem(r_idx, 9, amort["tc"])
- self.exact.setItem(r_idx, 10, amort["td"])
- self.exact.setItem(r_idx, 11, amort["cc"])
- self.exact.setItem(r_idx, 12, self.acc_rec_da[da_key]["amort_re"]["inc"])
- self.exact.setItem(r_idx, 13, self.acc_rec_da[da_key]["amort_re"]["dec"])
- self.exact.setItem(r_idx, 14, self.exact.getNumber(r_idx, 11) + self.exact.getNumber(r_idx, 12) - self.exact.getNumber(r_idx, 13))
- self.exact.setItem(r_idx, 15, self.exact.getNumber(r_idx, 7) - self.exact.getNumber(r_idx, 14)) # TODO -> k.15 е най-вярно закръглена !!!!
- for c in range(1, 16):
- exactItem = self.exact.getItem(r_idx, c)
- if isinstance(exactItem, float) or isinstance(exactItem, int):
- self.round1000.setItem(r_idx, c, round(self.exact.getNumber(r_idx, c) / 1000))
- for c_idx in range(1, 15+1):
- if self.exact.getItem(4, c_idx) is not None:
- self.exact.setItem(9, c_idx, self.exact.getNumber(4, c_idx) + self.exact.getNumber(5, c_idx) + self.exact.getNumber(6, c_idx) + self.exact.getNumber(7, c_idx))
- self.round1000.setItem(9, c_idx, round(self.exact.getItem(9, c_idx) / 1000))
- if self.exact.getItem(11, c_idx) is not None:
- self.exact.setItem(20, c_idx, self.exact.getNumber(11, c_idx) + self.exact.getNumber(15, c_idx) + self.exact.getNumber(16, c_idx) + self.exact.getNumber(18, c_idx))
- self.round1000.setItem(20, c_idx, round(self.exact.getNumber(20, c_idx) / 1000))
- sum29 = sum([self.exact.getNumber(r_idx, c_idx) for r_idx in range(22, 28+1)])
- self.exact.setItem(29, c_idx, sum29)
- self.round1000.setItem(29, c_idx, round(self.exact.getItem(29, c_idx) / 1000))
- sum31 = sum([self.exact.getNumber(r_idx, c_idx) for r_idx in [9, 20, 29, 30]])
- self.exact.setItem(31, c_idx, sum31)
- self.round1000.setItem(31, c_idx, round(self.exact.getItem(31, c_idx) / 1000))
- self.exact.setItem(31, 9, mapped_calculations.get_amort_expenses())
- self.round1000.setItem(31, 9, round(self.exact.getItem(31, 9) / 1000))
- self.exact.setItem(31, 15, mapped_calculations.get_long_assets())
- self.round1000.setItem(31, 15, round(self.exact.getItem(31, 15) / 1000))
- def get_round1000(self):
- return self.round1000
- def get_exact(self):
- return self.exact
- def get_acc_rec_da(self):
- return self.acc_rec_da
- def get_acc_rec_da_init_values(self):
- return {
- '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}},
- # -------------------------------------------------------------------
- 'pdr': {'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}},
- 'z': {'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}},
- 'pz': {'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}},
- 's': {'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}},
- 'm': {'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}},
- 'sdr': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': .00, 'diff': 0}},
- 'ts': {'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}},
- 'rpma': {'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}},
- 'advm': {'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}},
- # -------------------------------------------------------------------
- 'adp': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0, 'dec': 0, 'diff': 0}},
- 'pzp': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'adas': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'pzas': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'di': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'drz': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- 'isa': {'ns': 0, 'ns_amo': 0, 'assets': [], 'amort': [], 'assets_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0},
- 'amort_re': {'inc': 0.0, 'dec': 0.0, 'diff': 0}},
- # --------------------------
- 'ltax': {'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}}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement