Closed vladimir-puzic closed 5 months ago
Issue fixed in commit db2e39b
Transaction Management > Create Transaction > Create Custom Transaction
The error occurred when executing the db_itemize_transaction function. With in the CreateTransactionCustom class the item name was used as for lookup after input. The input was used to obtain the PLU for that particular item and was supposed to be forwarded to the db_itemize_transaction function in the following format: db_itemize_transaction(transaction_id: str, plu, item_to_add: str, amount) db_itemize_transaction(20241706-123456, 644455, 'Milk', 5)
Due to a bug with the db_fetch_item_data function, the returned item info was not in the expected format: (644455, 'Milk', 'Dairy', 1.0, 2.5) but was instead returned as a list containing a single tuple: [(644455, 'Milk', 'Dairy', 1.0, 2.5)]
This caused the SQL insert statement to fail.
The issue was fixed by using .fetchone() instead .fetchall() in this case as there is only a single expected result. .fetchone() >> (644455, 'Milk', 'Dairy', 1.0, 2.5) .fetchall() >> [(644455, 'Milk', 'Dairy', 1.0, 2.5)]
Terminal output and error message:
Transaction ID: 20240524-123456 Customer ID: 123456 Employee ID: vp123456 Total: 5.0 Transaction 20240524-123456 created Select item: Milk Amount: 3 20240524-123456 (123456, 'Milk', 'Dairy', 1.0, 2.0) Milk 3 Traceback (most recent call last): File "e:\PROJECTS\pos_software\database_session.py", line 944, in
option.execute()
File "e:\PROJECTS\pos_software\database_session.py", line 332, in execute
session.db_itemize_transaction(transaction_id, item_data[0], item_to_add, amount_to_add)
File "e:\PROJECTS\pos_software\database_session.py", line 132, in db_itemize_transaction
self.cursor.execute(f"INSERT INTO Itemizer VALUES ('{transaction_id}', '{plu}', '{item_to_add}', '{amount}')")
sqlite3.OperationalError: near "Milk": syntax error