what are u doin here? go fuck urself lmao
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.title("POS SMK Telkom Jakarta")
root.geometry("400x400")
attempts = 0
def clear_window():
for widget in root.winfo_children():
widget.destroy()
def login():
global attempts
if username_entry.get() == "mahvin" and password_entry.get() == "MERDEKA":
show_pos()
else:
attempts += 1
if attempts == 2:
messagebox.showerror("Login Failed", "Too many attempts.")
root.destroy()
else:
messagebox.showwarning("Login Failed", "Try again. One attempt left.")
def show_login():
global username_entry, password_entry
clear_window()
tk.Label(root, text="Login", font=("Arial", 18)).pack(pady=20)
tk.Label(root, text="Username").pack()
username_entry = tk.Entry(root)
username_entry.pack()
tk.Label(root, text="Password").pack()
password_entry = tk.Entry(root, show="*")
password_entry.pack()
tk.Button(root, text="Login", command=login).pack(pady=20)
def show_pos():
global customer_entry, item_entry, quantity_entry, price_entry, paid_entry
clear_window()
root.title("Pembelian Produk")
labels = [
"Nama Pembeli",
"Nama Barang",
"Jumlah Produk (Angka)",
"Price per Item (Angka)",
"Amount Paid (Angka)",
]
entries = []
for label in labels:
tk.Label(root, text=label).pack()
entry = tk.Entry(root)
entry.pack()
entries.append(entry)
customer_entry, item_entry, quantity_entry, price_entry, paid_entry = entries
tk.Button(root, text="Calculate", command=make_receipt).pack(pady=15)
def make_receipt():
customer = customer_entry.get()
item = item_entry.get()
try:
quantity = int(quantity_entry.get())
price = float(price_entry.get())
paid = float(paid_entry.get())
except ValueError:
messagebox.showerror("Invalid Input", "Enter numbers for quantity and prices.")
return
if not customer or not item or quantity <= 0 or price <= 0 or paid < 0:
messagebox.showerror("Invalid Input", "Check the customer, item, and amounts.")
return
subtotal = quantity * price
discount = subtotal * 0.25 if subtotal > 100000 else 0
total = subtotal - discount
balance = paid - total
if balance >= 0:
payment_result = f"Change: Rp {balance:,.2f}"
else:
payment_result = f"Remaining Balance: Rp {-balance:,.2f}"
receipt = (
f"Nama Pembeli: {customer}\n"
f"Nama Barang: {item}\n"
f"Jumlah Barang: {quantity}\n"
f"Harga: Rp {subtotal:,.2f}\n"
f"Diskon: Rp {discount:,.2f}\n"
f"Total: Rp {total:,.2f}\n"
f"Tunai: Rp {paid:,.2f}\n"
f"{payment_result}"
)
messagebox.showinfo("Invoice", receipt)
show_login()
root.mainloop()
import tkinter as tk
from datetime import datetime
from decimal import Decimal, InvalidOperation
from tkinter import messagebox
class POSTelkom:
def __init__(self, root: tk.Tk) -> None:
self.root = root
self.root.title("SMK Telkom Jakarta POS")
self.root.geometry("460x420")
self.root.resizable(False, False)
self.failed_attempts = 0
self.content = tk.Frame(root, padx=24, pady=24)
self.content.pack(fill="both", expand=True)
self.show_login()
def _clear_content(self) -> None:
for widget in self.content.winfo_children():
widget.destroy()
def show_login(self) -> None:
self._clear_content()
self.root.title("POS Login")
tk.Label(self.content, text="Cashier Login", font=("Arial", 18, "bold")).grid(
row=0, column=0, columnspan=2, pady=(20, 28)
)
tk.Label(self.content, text="Username").grid(row=1, column=0, sticky="w", pady=8)
self.username_entry = tk.Entry(self.content, width=28)
self.username_entry.grid(row=1, column=1, pady=8)
tk.Label(self.content, text="Password").grid(row=2, column=0, sticky="w", pady=8)
self.password_entry = tk.Entry(self.content, width=28, show="*")
self.password_entry.grid(row=2, column=1, pady=8)
self.password_entry.bind("", lambda _event: self.login())
tk.Button(self.content, text="Login", width=18, command=self.login).grid(
row=3, column=0, columnspan=2, pady=24
)
self.username_entry.focus_set()
def login(self) -> None:
if (
self.username_entry.get() == "full_name"
and self.password_entry.get() == "MERDEKA"
):
self.show_pos()
return
self.failed_attempts += 1
remaining_attempts = 2 - self.failed_attempts
self.password_entry.delete(0, tk.END)
if remaining_attempts == 0:
messagebox.showerror(
"Login failed",
"You have used both login attempts. The application will close.",
parent=self.root,
)
self.root.destroy()
else:
messagebox.showwarning(
"Login failed",
f"Incorrect username or password. {remaining_attempts} attempt remaining.",
parent=self.root,
)
def show_pos(self) -> None:
self._clear_content()
self.root.title("Point of Sale")
self.root.geometry("520x440")
tk.Label(self.content, text="Purchase Transaction", font=("Arial", 18, "bold")).grid(
row=0, column=0, columnspan=2, pady=(0, 20)
)
fields = (
("Customer Name", "customer"),
("Item Name", "item"),
("Quantity", "quantity"),
("Price per Item (Rp)", "price"),
("Amount Paid (Rp)", "paid"),
)
self.entries: dict[str, tk.Entry] = {}
for row, (label, key) in enumerate(fields, start=1):
tk.Label(self.content, text=label).grid(row=row, column=0, sticky="w", pady=7)
entry = tk.Entry(self.content, width=34)
entry.grid(row=row, column=1, sticky="ew", pady=7)
self.entries[key] = entry
tk.Button(
self.content, text="Calculate and Generate Receipt", command=self.generate_receipt
).grid(row=len(fields) + 1, column=0, columnspan=2, pady=24)
self.entries["customer"].focus_set()
def generate_receipt(self) -> None:
customer = self.entries["customer"].get().strip()
item = self.entries["item"].get().strip()
if not customer or not item:
messagebox.showerror(
"Missing information",
"Enter both the customer name and item name.",
parent=self.root,
)
return
try:
quantity = int(self.entries["quantity"].get().strip())
price = Decimal(self.entries["price"].get().strip())
amount_paid = Decimal(self.entries["paid"].get().strip())
except (ValueError, InvalidOperation):
messagebox.showerror(
"Invalid amount",
"Quantity must be a whole number. Price and amount paid must be numeric.",
parent=self.root,
)
return
if quantity <= 0 or not price.is_finite() or price <= 0:
messagebox.showerror(
"Invalid purchase",
"Quantity and price per item must be greater than zero.",
parent=self.root,
)
return
if not amount_paid.is_finite() or amount_paid < 0:
messagebox.showerror(
"Invalid payment",
"Amount paid must be a non-negative number.",
parent=self.root,
)
return
subtotal = price * quantity
discount = subtotal * Decimal("0.25") if subtotal > Decimal("100000") else Decimal(0)
total = subtotal - discount
balance = amount_paid - total
receipt_lines = [
"SMK TELKOM JAKARTA - PAYMENT RECEIPT",
f"Date: {datetime.now():%Y-%m-%d %H:%M:%S}",
"",
f"Customer: {customer}",
f"Item: {item}",
f"Quantity: {quantity}",
f"Price per item: Rp {price:,.2f}",
f"Subtotal: Rp {subtotal:,.2f}",
f"Discount (25%): Rp {discount:,.2f}",
f"Total: Rp {total:,.2f}",
f"Amount paid: Rp {amount_paid:,.2f}",
(
f"Change: Rp {balance:,.2f}"
if balance >= 0
else f"Remaining balance: Rp {-balance:,.2f}"
),
"",
"Thank you for your purchase!",
]
messagebox.showinfo("Payment Receipt", "\n".join(receipt_lines), parent=self.root)
if __name__ == "__main__":
root = tk.Tk()
POSTelkom(root)
root.mainloop()