Ejemplo n.º 1
0
 def _del_idle_companies():
     IncubusFactory.get_instance().user_event()
     idle_companies = get_companies_without_payment()
     if len(idle_companies) <= 0:
         return
     company_list.CompanyList(Prime._del_idle_companies__selected,
                              companies=idle_companies).mainloop()
Ejemplo n.º 2
0
    def _split_latest_activity():
        IncubusFactory.get_instance().user_event()
        last_activity = Activity(Activity.get_last_activity())

        as_window = activity_split.ActivitySplit()
        as_window.fill_with_activity(last_activity)
        as_window.mainloop()
Ejemplo n.º 3
0
 def refresh(self):
     """ Refreshes notifications """
     IncubusFactory.get_instance().user_event()
     self._notif_list.delete(0, tkinter.END)
     notif_count = 0
     for ntf in notification.get_notifications():
         self._notif_list.insert(notif_count, ntf)
         notif_count += 1
     self._root.update()
Ejemplo n.º 4
0
    def _reconciliation__company_selected(companies: List):
        IncubusFactory.get_instance().user_event()
        names = ""
        for selco in companies:
            if names != "":
                names += ","
            names += selco.name

        startup_url("reconciliation",
                    query_string="names=" + urllib.parse.quote(names, safe=''))
Ejemplo n.º 5
0
 def _notif_double_click(self, dummy):  # pylint: disable=W0613
     IncubusFactory.get_instance().user_event()
     selection = self._notif_list.get(self._notif_list.curselection())
     if selection.__contains__("Payment"):
         payment_guid = selection[selection.find("{") +
                                  1:selection.find("}")]
         payment_obj = payment_model.get_payment_with_guid(payment_guid)
         if payment_obj is None:
             return
         payment_win = payment.PaymentWindow()
         payment_win.fill_with_payment(payment_obj)
         payment_win.mainloop()
Ejemplo n.º 6
0
    def __init__(self, state: WidgetState, system_selected_handler, login_handler):

        super().__init__(state,
                         system_selected_handler,
                         self._system_select,
                         self._system_add,
                         self._system_del,
                         self._system_change,
                         "System")

        self._repainting = False
        self._locate_text = QLineEdit()
        self._locate_text.setPlaceholderText("locate...")
        self._locate_text.textChanged.connect(self._locate)

        connection_label = QLabel("Connection")
        self._connection = QPlainTextEdit()
        connection_login = QPushButton("SAP Login")
        connection_login.clicked.connect(login_handler)
        connection_save = QPushButton("Save")
        connection_save.clicked.connect(self._connection_save_clicked)
        connection_layout = QVBoxLayout()
        connection_layout.addWidget(self._locate_text)
        connection_layout.addWidget(connection_label)
        connection_layout.addWidget(self._connection)
        connection_layout.addWidget(connection_save)
        connection_layout.addWidget(connection_login)
        self.crud_layout.addLayout(connection_layout)

        self.flush_layout()
        self._selected_system = System()
        self._repaint_systems()

        self._incubus = IncubusFactory.get_instance()
Ejemplo n.º 7
0
    def __init__(self, state: WidgetState):
        self._state = state
        self._credential = QPlainTextEdit(self._state.main_widget)
        self._selected_account = Account()
        self._selected_system = System()
        self._internal_value = ""
        self._displayed_value = ""
        self._masked = True

        toggle_mask = QPushButton("Toggle")
        toggle_mask.clicked.connect(self._toggle_clicked)
        copy_pwd = QPushButton("Copy")
        copy_pwd.clicked.connect(self._copy_clicked)
        credential_save = QPushButton("Save")
        credential_save.clicked.connect(self._credential_save_clicked)
        button_layout = QHBoxLayout()
        button_layout.addWidget(toggle_mask)
        button_layout.addWidget(copy_pwd)
        button_layout.addWidget(credential_save)

        credential_layout = QVBoxLayout()
        credential_layout.addWidget(self._credential)
        credential_layout.addLayout(button_layout)

        self._state.main_layout.addLayout(credential_layout)
        self._incubus = IncubusFactory.get_instance()
Ejemplo n.º 8
0
    def __init__(
            self,  # pylint: disable=R0913
            state: WidgetState,
            external_selected_handler,
            internal_selected_handler,
            add_handler,
            del_handler,
            change_handler,
            title: str):
        self.state = state
        self.external_selected_handler = external_selected_handler
        self.model = GuiToolkit.create_tree_model(self.state.main_widget,
                                                  title)

        self.tree = GuiToolkit.create_tree_view(self.model,
                                                internal_selected_handler,
                                                change_handler)

        self._del_handler = del_handler

        add_button = QPushButton("+")
        add_button.clicked.connect(add_handler)
        del_button = QPushButton("-")
        del_button.clicked.connect(self._del_clicked)

        button_layout = QHBoxLayout()
        button_layout.addWidget(add_button)
        button_layout.addWidget(del_button)

        self.crud_layout = QVBoxLayout()
        self.crud_layout.addWidget(self.tree)
        self.crud_layout.addLayout(button_layout)

        self._incubus = IncubusFactory.get_instance()
Ejemplo n.º 9
0
 def __init__(self, state: WidgetState, account_selected_handler):
     super().__init__(state, account_selected_handler, self._account_select,
                      self._account_add, self._account_del,
                      self._account_change, "Account")
     self._repainting = False
     self.flush_layout()
     self._selected_system = System()
     self._selected_account = Account()
     self._repaint_accounts()
     self._incubus = IncubusFactory.get_instance()
Ejemplo n.º 10
0
def _execute(asset_guid: str = None):
    """ Stock update """
    backup.execute()

    assets = imp_asset.get_assets()
    random.shuffle(assets["assets"])
    first_asset = True

    for asset in assets["assets"]:
        if asset["type"] != "COMMODITY":
            continue
        if "url_suffix" not in asset:
            continue
        if asset["url_suffix"] == "":
            continue
        if asset_guid is not None and asset["guid"] != asset_guid:
            continue

        if first_asset:
            first_asset = False
        else:
            time.sleep(config.CONSTANTS["COMMODITY_SEARCH_SLEEP"])
            IncubusFactory.get_instance().user_event()

        try:
            url = config.CONSTANTS["COMMODITY_URL"] + asset["url_suffix"]
            search_input = SearchInput(
                url=url, post_sleep=config.CONSTANTS["COMMODITY_PAGE_SLEEP"])
            quick_median = QuickMedian(search_input)

            asset["sales_value"] = \
                conv_last_usd_val_to_home_curr(asset) \
                if quick_median.median == 0 \
                else quick_median.median

        except Exception as update_error:
            print(f"Commodity search error: { str(update_error) } ")

    imp_asset.set_assets(assets)
Ejemplo n.º 11
0
    def __init__(self):
        super().__init__()
        self._widget_state = WidgetState(DatabaseFactory.get_instance(), self, QHBoxLayout())

        self._system_widget = SystemWidget(
            self._widget_state,
            self._system_selected,
            self._login_clicked)

        self._account_widget = AccountWidget(self._widget_state, self._account_selected)
        self._credential_widget = CredentialWidget(self._widget_state)
        self.setLayout(self._widget_state.main_layout)
        self.setWindowTitle("Kutapada")
        self._system_widget.focus_on_locate()

        self._incubus = IncubusFactory.get_instance()
        self._incubus.start(5)

        self.show()
Ejemplo n.º 12
0
 def _del_completed_payments(self):
     IncubusFactory.get_instance().user_event()
     self._set_status("Deleting completed payments")
     delete_completed_payments()
     self._set_status("Deletion complete")
     self.refresh()
Ejemplo n.º 13
0
    def __init__(self, add_activity: bool = False):
        # Initialization
        cell_y = 0

        # Main container
        self._root = tkinter.Tk()
        if config.TEST_MODE:
            self._root.title("Kifu [TEST MODE]")
        else:
            self._root.title("Kifu")
        self._root.geometry(
            str(self._WINDOW_WIDTH) + "x" + str(self._WINDOW_HEIGHT))

        # Status label
        self._status_label = tkinter.Label(master=self._root,
                                           text="Welcome to Kifu",
                                           font=default_font())
        self._status_label.place(x=0,
                                 y=cell_y,
                                 width=self._WINDOW_WIDTH,
                                 height=config.CONSTANTS["GUI_CELL_HEIGHT"])

        cell_y += config.CONSTANTS["GUI_CELL_HEIGHT"]

        # Notifications
        self._notif_list = tkinter.Listbox(self._root, font=default_font())
        self.refresh()
        self._notif_list.place(x=0,
                               y=cell_y,
                               width=self._WINDOW_WIDTH,
                               height=self._NOTIF_HEIGHT)
        self._notif_list.bind('<Double-1>', self._notif_double_click)
        cell_y += self._NOTIF_HEIGHT

        refresh_button = tkinter.Button(self._root,
                                        text="Refresh",
                                        command=self.refresh,
                                        font=default_font())
        refresh_button.place(x=0, y=cell_y)
        cell_y += config.CONSTANTS["GUI_CELL_HEIGHT"]

        # Main menu
        self._menu = tkinter.Menu(self._root, tearoff=0)

        file_menu = tkinter.Menu(self._menu, tearoff=0)
        for data_file in file_system.get_data_file_list():
            file_menu.add_command(
                label=data_file,
                command=lambda df=data_file: Prime._edit_data_file(df))
        file_menu.add_separator()
        file_menu.add_command(label="Show data files",
                              command=Prime._show_data_files)
        file_menu.add_command(label="Backup data files",
                              command=self._backup_data)
        file_menu.add_command(label="Exit", command=self._root.quit)
        self._menu.add_cascade(menu=file_menu, label="File")

        timesheet_menu = tkinter.Menu(self._menu, tearoff=0)
        timesheet_menu.add_command(label="Add", command=Prime._add_activity)
        timesheet_menu.add_command(label="Edit", command=Prime._list_activity)
        timesheet_menu.add_command(label="Split latest",
                                   command=Prime._split_latest_activity)
        timesheet_menu.add_separator()
        timesheet_menu.add_command(label="Activity report",
                                   command=Prime._activity_report)
        timesheet_menu.add_command(label="Workdays without activity",
                                   command=Prime._workdays_wo_activity)
        timesheet_menu.add_command(label="Ecz activity comparison",
                                   command=Prime._ecz_activity)
        self._menu.add_cascade(menu=timesheet_menu, label="Timesheet")
        timesheet_menu.add_command(label="Invoices",
                                   command=Prime._list_invoice)

        payment_menu = tkinter.Menu(self._menu, tearoff=0)
        payment_menu.add_command(label="Add", command=Prime._add_payment)
        payment_menu.add_command(label="Edit", command=Prime._list_payment)
        payment_menu.add_command(label="Delete completed payments",
                                 command=self._del_completed_payments)
        payment_menu.add_separator()
        payment_menu.add_command(label="Book CC statement",
                                 command=Prime._add_cc_statement)
        payment_menu.add_command(label="Book cash movement",
                                 command=Prime._add_cash)
        payment_menu.add_command(label="Invest", command=Prime._invest)
        payment_menu.add_command(label="Pay VAT", command=Prime._pay_vat)
        payment_menu.add_command(label="Pay income tax",
                                 command=Prime._pay_tax)
        payment_menu.add_separator()
        payment_menu.add_command(label="Reconciliation",
                                 command=Prime._reconciliation)
        payment_menu.add_command(label="Income tax rates",
                                 command=Prime._inc_tax_rates)
        payment_menu.add_command(label="IBAN list", command=Prime._iban_list)
        payment_menu.add_command(label="Address book",
                                 command=Prime._address_book)
        payment_menu.add_command(label="Tax info", command=Prime._tax_info)
        self._menu.add_cascade(menu=payment_menu, label="Payment")

        asset_menu = tkinter.Menu(self._menu, tearoff=0)
        asset_menu.add_separator()
        asset_menu.add_command(label="Edit assets", command=Prime._edit_assets)
        asset_menu.add_separator()
        asset_menu.add_command(label="Net worth", command=Prime._net_worth)
        asset_menu.add_command(label="Account balances",
                               command=Prime._bank_account_balance)
        asset_menu.add_command(label="Currency balances",
                               command=Prime._currency_account)
        asset_menu.add_command(label="Asset profit",
                               command=Prime._asset_profit)
        asset_menu.add_separator()
        self._menu.add_cascade(menu=asset_menu, label="Asset")

        budget_menu = tkinter.Menu(self._menu, tearoff=0)
        budget_menu.add_command(label="Akbank statement",
                                command=Prime._akbank_statement)
        budget_menu.add_command(label="Plan", command=Prime._budget_plan)
        budget_menu.add_command(label="Plan vs actual",
                                command=Prime._budget_plan_vs_actual)
        budget_menu.add_command(label="Salary simulation",
                                command=Prime._salary_simulation)
        self._menu.add_cascade(menu=budget_menu, label="Budget")

        util_menu = tkinter.Menu(self._menu, tearoff=0)
        util_menu.add_command(label="Update currencies",
                              command=self._currency_update)
        util_menu.add_command(label="Update commodities",
                              command=self._commodity_update)
        util_menu.add_command(label="Print labels", command=self._print_label)
        util_menu.add_command(label="Delete idle companies",
                              command=Prime._del_idle_companies)

        self._menu.add_cascade(menu=util_menu, label="Util")

        # Flush
        self._root.configure(menu=self._menu)
        configure_treeview_style()
        if add_activity:
            Prime._add_activity()

        IncubusFactory.get_instance().start(15)
Ejemplo n.º 14
0
 def _reconciliation():
     IncubusFactory.get_instance().user_event()
     company_list.CompanyList(
         Prime._reconciliation__company_selected).mainloop()
Ejemplo n.º 15
0
 def _print_label__company_selected(companies: List):
     IncubusFactory.get_instance().user_event()
     CompanyLabel().generate(companies)
Ejemplo n.º 16
0
 def _print_label():
     IncubusFactory.get_instance().user_event()
     company_list.CompanyList(
         Prime._print_label__company_selected).mainloop()
Ejemplo n.º 17
0
 def _edit_data_file(file_name: str):
     IncubusFactory.get_instance().user_event()
     full_path = os.path.join(config.CONSTANTS["DATA_DIR_PATH"], file_name)
     os.system(f"open {full_path}")
Ejemplo n.º 18
0
 def _edit_assets():
     IncubusFactory.get_instance().user_event()
     asset_window = asset_list.AssetListWindow()
     asset_window.mainloop()
Ejemplo n.º 19
0
 def _set_status(self, status: str):
     IncubusFactory.get_instance().user_event()
     self._status_label["text"] = status
     self._root.update()
Ejemplo n.º 20
0
 def _list_payment():
     IncubusFactory.get_instance().user_event()
     payment_window = payment_list.PaymentListWindow()
     payment_window.mainloop()
Ejemplo n.º 21
0
 def _list_invoice():
     IncubusFactory.get_instance().user_event()
     inv_window = invoice_list.InvoiceListWindow()
     inv_window.mainloop()
Ejemplo n.º 22
0
 def _list_activity():
     IncubusFactory.get_instance().user_event()
     list_window = activity_list.ActivityListWindow()
     list_window.mainloop()
Ejemplo n.º 23
0
 def _iban_list():
     IncubusFactory.get_instance().user_event()
     startup_url("iban_list")
Ejemplo n.º 24
0
 def _inc_tax_rates():
     IncubusFactory.get_instance().user_event()
     startup_url("income_tax_rates")
Ejemplo n.º 25
0
 def _show_data_files():
     IncubusFactory.get_instance().user_event()
     os.system(f"open {config.CONSTANTS['DATA_DIR_PATH']}")
Ejemplo n.º 26
0
 def _del_idle_companies__selected(companies: List):
     IncubusFactory.get_instance().user_event()
     for company in companies:
         company.delete()
Ejemplo n.º 27
0
 def _pay_tax():
     IncubusFactory.get_instance().user_event()
     pay_income_tax.PayIncomeTax()
Ejemplo n.º 28
0
 def _pay_vat():
     IncubusFactory.get_instance().user_event()
     pay_vat.PayVat()
Ejemplo n.º 29
0
 def _net_worth():
     IncubusFactory.get_instance().user_event()
     startup_url("net_worth")
Ejemplo n.º 30
0
 def _ecz_activity():
     IncubusFactory.get_instance().user_event()
     startup_url("ecz_activity_comparison")