Esempio n. 1
0
    def get_result(listable_companies: List[str] = None) -> dict:
        """ Address book """
        result = {"companies": []}

        for comp in Company.get_companies()["companies"]:
            if listable_companies is not None and len(listable_companies) > 0:
                if comp["name"] not in listable_companies:
                    continue
            comp_obj = Company(comp["name"])
            comp["address"] = comp_obj.address
            comp["phone"] = comp_obj.phone
            comp["email"] = comp_obj.email
            result["companies"].append(comp)

        for comp in result["companies"]:
            if "locations" not in comp:
                comp["locations"] = []
            if "ibans" not in comp:
                comp["ibans"] = []
            if len(comp["ibans"]) > 0:
                comp["default_iban"] = comp["ibans"][0]["name"] + " - " + comp[
                    "ibans"][0]["number"]
            else:
                comp["default_iban"] = ""
            if "activity_emails" not in comp:
                comp["activity_emails"] = []
            if "tax_number" in comp:
                comp["tax_number"] = comp["tax_number"].replace(" ", "")
        return result
Esempio n. 2
0
    def __init__(self, parent: tkinter.Toplevel, label_text: str, x_pos: int,
                 y_pos: int):
        self._companies = Company.get_companies()

        self._combo_val = []
        for cmp in self._companies["companies"]:
            self._combo_val.append(cmp["name"])

        self._combo = LabeledCombobox(parent, label_text, self._combo_val,
                                      x_pos, y_pos)
Esempio n. 3
0
def get_locations() -> dict:
    """ Returns all locations defined in JSON files """
    output = {}
    companies = Company.get_companies()

    for comp in companies["companies"]:
        try:
            locs = comp["locations"]
        except Exception:
            continue

        for loc in locs:
            location_key = comp["name"] + " - " + loc
            output[location_key] = location_key

    return output
Esempio n. 4
0
def get_companies_without_payment() -> List[Company]:
    """ Companies without payment
    Those may be considered deletable, in case
    they won't be needed in the future
    """
    output = []
    all_companies = Company.get_companies()
    all_payments = get_payments()
    for com in all_companies["companies"]:
        has_payment = False
        for pay in all_payments["payments"]:
            if pay["company"] == com["name"]:
                has_payment = True
                break
        if has_payment:
            continue
        com_obj = Company(com["name"])
        output.append(com_obj)
    return output
Esempio n. 5
0
    def __init__(self,
                 parent: tkinter.Toplevel,
                 x_pos: int,
                 y_pos: int,
                 companies: List[Company] = None):
        self._combo_val = []

        if companies is None:
            all_companies = Company.get_companies()
            for cmp in all_companies["companies"]:
                self._combo_val.append(cmp["name"])
        else:
            for cmp in companies:
                self._combo_val.append(cmp.name)

        self._combo = tkinter.Listbox(parent,
                                      selectmode=tkinter.EXTENDED,
                                      font=default_font())

        for value in self._combo_val:
            self._combo.insert(tkinter.END, value)

        self._combo.place(x=x_pos, y=y_pos)