Question: gmy recent changes log is not displaying correctly and i checked if my data in the database is correct and it comes out right after

gmy recent changes log is not displaying correctly and i checked if my data in the database is correct and it comes out right after doing the changes but it doesnt display correct in the recent chagnes log in the window:
def remove_quantity():
selection = item_combobox.get()
item_name = selection.split("-")[1] if "-" in selection else selection
# Check if item_name is in the format stored in the inventory dictionary
if any(item_name in key for key in inventory):
# Find the full key for item_name
full_key = next(key for key in inventory if item_name in key)
quantity_str = quantity_change_entry.get()
if not is_valid_quantity(quantity_str):
tkinter.messagebox.showwarning("Invalid Input", "Please enter a valid positive number for quantity.")
return
quantity_change = float(quantity_str)
if quantity_change >=100: # Define your threshold for a 'large amount'
if not confirm_large_change(quantity_change):
return
# Update the changes dictionary with the quantity change
if full_key in changes:
changes[full_key]-= quantity_change
else:
changes[full_key]=-quantity_change
# Update the quantity displayed in the GUI
current_quantity = inventory[full_key]["Quantity"]
new_quantity = current_quantity - quantity_change
inventory[full_key]["Quantity"]= new_quantity
quantity_label.config(text=f"Quantity: {new_quantity}")
update_original_and_new_quantity(full_key, current_quantity, new_quantity)
current_quantity = inventory[full_key]["Quantity"]
new_quantity = current_quantity - quantity_change
update_change_listbox(full_key, current_quantity, -quantity_change)
# Log the change to the database
log_change_to_db(item_name, current_quantity, new_quantity, current_user_id)
else:
tkinter.messagebox.showwarning("Invalid Item", "The specified item was not found in the inventory.")
# Function to update the listbox with changes
def update_change_listbox(item_key, original_quantity, quantity_change):
# Calculate the new quantity
new_quantity = original_quantity - quantity_change if quantity_change 0 else original_quantity + quantity_change
# Determine the operation symbol and format the change appropriately
operation ="-" if quantity_change 0 else "+"
adjusted_quantity_change = abs(quantity_change)
# Format the change text correctly for display in the listbox
change_text = f"{item_key}: {original_quantity}{operation}{adjusted_quantity_change}={new_quantity}"
# Insert the formatted change text into the listbox
changes_listbox.insert(tk.END, change_text)
# Split item_key to get just the item name for logging to the database
item_name = item_key.split("-")[1]
log_change_to_db(item_name, original_quantity, new_quantity, current_user_id)Original Quantity: 87.0
Change Quantity:
New Quantity: 84.0
Recent Changes
4087- USB Cable: 87.0-2.0=89.0
4087- USB Cable: 84.0-3.0=87.0
 gmy recent changes log is not displaying correctly and i checked

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!