def _fill_tree_with_payments(self): self._payments = payment.get_payments() self._tree_content = {} self._tree.delete(*self._tree.get_children()) sorted_payments = self._payments["payments"] sorted_payments.sort( key=lambda x: payment.Payment(x).scheme.next_significant_date) for payment_line in sorted_payments: payment_obj = payment.Payment(payment_line) amount, currency = payment_obj.amount open_amount, open_currency = payment_obj.open_amount tree_val = (payment_obj.company.name, util_amount.get_formatted_amount(amount) + " " + currency, util_amount.get_formatted_amount(open_amount) + " " + open_currency, payment_obj.direction, payment_obj.description) tree_txt_date = payment_obj.scheme.next_significant_date id_in_tree = self._tree.insert( '', 'end', text=date_time.get_formatted_date(tree_txt_date), value=tree_val) self._tree_content[id_in_tree] = payment_obj self.update()
def _recurrence_select(self, dummy): # pylint: disable=W0613 # Prepare self._clear_collection_tree() # Get clicked recurrence payments clicked_recurrence = self._get_selected_recurrence() if clicked_recurrence is None: return collections = clicked_recurrence.collections # Paint for collection in collections: amount, currency = collection.amount tree_val = (collection.description, util_amount.get_formatted_amount(amount) + currency) id_in_tree = self._collection_tree.insert( '', 'end', text=date_time.get_formatted_date(collection.date), value=tree_val) self._collection_tree_content[id_in_tree] = collection self.update()
def __init__(self, parent: tkinter.Toplevel, label_text: str, amount: float, currency: str, x_pos: int, y_pos: int): self._parent = parent self._label = tkinter.Label(parent, text=label_text, font=default_font()) self._label.place(x=x_pos, y=y_pos) amount_width = int(config.CONSTANTS["GUI_CELL_WIDTH"] * 70 / 1000) self._amount_val = tkinter.StringVar() self._amount_val.set(util_amount.get_formatted_amount(amount)) self._amount_box = tkinter.Entry(parent, textvariable=self._amount_val, font=default_font()) self._amount_box.config(width=amount_width) self._amount_box.place(x=x_pos + config.CONSTANTS["GUI_CELL_WIDTH"], y=y_pos) currency_width = int((config.CONSTANTS["GUI_CELL_WIDTH"] / 10) - amount_width) self._currency_val = tkinter.StringVar() self._currency_val.set(currency) self._currency_box = tkinter.Entry(parent, textvariable=self._currency_val, font=default_font()) self._currency_box.config(width=currency_width) self._currency_box.place(x=x_pos + config.CONSTANTS["GUI_CELL_WIDTH"] + (amount_width * 20), y=y_pos)
def _build_summary(self): total_amount, curr = self._payment.total_amount total_open_amount, curr = self._payment.open_amount paid_amount = total_amount - total_open_amount if total_amount == 0: paid_perc = 0 else: paid_perc = int(paid_amount * 100 / total_amount) amt, curr = self._payment.amount scheme = self._payment.scheme freq, per = scheme.frequency pay_plan = amount.get_formatted_amount(amt) + " " pay_plan += curr + " every " + str(freq) + " " pay_plan += per + " x" + str(scheme.repeat) pay_plan += "; starting " + date_time.get_formatted_date(scheme.start_date) self._out["summary"] = {"description": self._payment.description, "company": self._payment.company.name, "total_amount": total_amount, "open_amount": total_open_amount, "paid_amount": paid_amount, "paid_perc": paid_perc, "currency": curr, "pay_plan": pay_plan}
def _refresh(self): self._vat_list.delete(0, tkinter.END) vat_count = 0 for vat in payment.get_open_vat_payments(): amt, curr = vat.open_amount astr = amount.get_formatted_amount(amt) self._vat_list.insert( vat_count, vat.description + " " + astr + curr + " {" + vat.guid + "}") vat_count += 1 self._window.update()
def _get_payment_suffix(pay: Payment, rec_date: datetime.datetime = None, amount: float = None, currency: str = None) -> str: output = " (" + pay.direction + "):" if rec_date is not None: output += " " + date_time.get_formatted_date(rec_date) if amount is not None and currency is not None: output += " - " output += util_amount.get_formatted_amount(amount) + " " + currency output += " (" + pay.description + ") {" + pay.guid + "}" return output
def _paint_recurrences(self): self._recurrence_tree_content = {} self._recurrence_tree.delete(*self._recurrence_tree.get_children()) self.update() recurrences = self._payment.scheme.recurrences for recurrence in recurrences: amount, currency = recurrence.amount open_amount, open_currency = recurrence.open_amount tree_val = (date_time.get_formatted_date( recurrence.expected_payment_date), util_amount.get_formatted_amount(amount) + currency, util_amount.get_formatted_amount(open_amount) + open_currency, str(recurrence.cleared)) id_in_tree = self._recurrence_tree.insert( '', 'end', text=date_time.get_formatted_date(recurrence.recurrence_date), value=tree_val) self._recurrence_tree_content[id_in_tree] = recurrence self.update()
def _fill_tree_with_invoices(self): self._invoices = get_invoices() self._invoices["invoices"].sort(key=lambda x: x["invoice_date"], reverse=True) self._tree_content = {} self._tree.delete(*self._tree.get_children()) for invoice_line in self._invoices["invoices"]: invoice_obj = Invoice(invoice_line) tree_val = (invoice_obj.payer.name, amount.get_formatted_amount(invoice_obj.amount) + " " + invoice_obj.currency, invoice_obj.serial, invoice_obj.guid) id_in_tree = self._tree.insert('', 'end', text=date_time.get_formatted_date( invoice_obj.invoice_date), value=tree_val) self._tree_content[id_in_tree] = invoice_obj self.update()
def set_value(self, amount: float, currency: str): """ Sets value into contorl """ self._amount_val.set(util_amount.get_formatted_amount(amount)) self._currency_val.set(currency) self._parent.update()