diff --git a/application/receipts/__pycache__/receipts_api.cpython-313.pyc b/application/receipts/__pycache__/receipts_api.cpython-313.pyc index e8bc1ce..d989544 100644 Binary files a/application/receipts/__pycache__/receipts_api.cpython-313.pyc and b/application/receipts/__pycache__/receipts_api.cpython-313.pyc differ diff --git a/application/receipts/receipts_api.py b/application/receipts/receipts_api.py index 401e326..c7336c0 100644 --- a/application/receipts/receipts_api.py +++ b/application/receipts/receipts_api.py @@ -126,7 +126,6 @@ def addSKULine(): site_name = session['selected_site'] item = receipts_database.getItemAllByID(site_name, (item_id, )) - #pprint.pprint(item) data = { 'cost': item['item_info']['cost'], 'expires': item['food_info']['expires'] @@ -145,6 +144,33 @@ def addSKULine(): return jsonify({'error': False, "message": "Line added Succesfully"}) return jsonify({'error': True, "message": "Something went wrong while add SKU line!"}) +@receipt_api.route('/api/addCustomLine', methods=["POST"]) +@access_api.login_required +def addCustomLine(): + if request.method == "POST": + receipt_id = int(request.get_json()['receipt_id']) + site_name = session['selected_site'] + print(receipt_id) + data = { + 'cost': request.get_json()['line_cost'], + 'expires': False + } + + receipt_item = database_payloads.ReceiptItemPayload( + type="custom", + receipt_id=receipt_id, + barcode=None, + item_uuid=None, + name=request.get_json()['line_name'], + qty=request.get_json()['line_qty'], + uom=request.get_json()['line_UOM'], + data=data + ) + receipts_database.insertReceiptItemsTuple(site_name, receipt_item.payload()) + return jsonify({'error': False, "message": "Line added Succesfully"}) + return jsonify({'error': True, "message": "Something went wrong while add SKU line!"}) + + @receipt_api.route('/api/deleteLine', methods=["POST"]) @access_api.login_required def deleteLine(): diff --git a/application/receipts/static/js/receiptHandler.js b/application/receipts/static/js/receiptHandler.js index 91d4ded..610f146 100644 --- a/application/receipts/static/js/receiptHandler.js +++ b/application/receipts/static/js/receiptHandler.js @@ -195,11 +195,6 @@ async function viewFile(source) { } -async function openCustomModal() { - console.log("custom") - -} - async function openLineEditModal(line_data) { console.log(line_data) document.getElementById('lineName').value = line_data.name @@ -287,6 +282,7 @@ async function uploadFile() { .then(response => response.json()) .then(data => console.log('File uploaded!', data)) .catch(error => console.error('Error:', error)); + await refreshReceipt() } async function saveLine(line_id){ @@ -364,6 +360,46 @@ async function getReceipt(id) { return receipt; } +// Custom Line Modal Functions +async function openAddCustomLineModal() { + console.log("custom") + document.getElementById('CustomlineName').value = "" + document.getElementById('CustomlineQty').value = 0 + document.getElementById('CustomlineUOM').value = 1 + document.getElementById('CustomlineCost').value = 0.00 + document.getElementById('saveCustomLineButton').innerHTML = "Add" + document.getElementById('saveCustomLineButton').onclick = async function() { + await addCustomLine() + } + + UIkit.modal(document.getElementById("CustomLineModal")).show(); +} + +async function addCustomLine(){ + let LineName = document.getElementById('CustomlineName').value + let LineQty = document.getElementById('CustomlineQty').value + let LineUOM = document.getElementById('CustomlineUOM').value + let LineCost = document.getElementById('CustomlineCost').value + console.log(LineName) + UIkit.modal(document.getElementById("CustomLineModal")).hide(); + + const response = await fetch(`/receipts/api/addCustomLine`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + line_name: LineName, + line_qty: LineQty, + line_UOM: LineUOM, + line_cost: LineCost, + receipt_id: receipt_id + }), + }); + await refreshReceipt() +} + + // SKU Modal functions let items_limit = 50; var ItemsModal_search_string = "" diff --git a/application/receipts/templates/receipt.html b/application/receipts/templates/receipt.html index 471d05b..845c4c6 100644 --- a/application/receipts/templates/receipt.html +++ b/application/receipts/templates/receipt.html @@ -184,7 +184,7 @@
@@ -336,6 +336,52 @@ + +
+
+

Add a Custom Line...

+

Custom lines are items where you would like to solely track them through receipts and nothing more. That means + that beyond saving the line on the receipt, nothing else will be saved, transacted, or handled by the over + all system. Keep that in mind as you choose to add a custom line.

+

Edit any fields here for the Custom Line and all the data will be saved.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
Name
QTY
UOM + +
COST
+

+ + +

+
+
diff --git a/logs/database.log b/logs/database.log index 1c5561c..821babb 100644 --- a/logs/database.log +++ b/logs/database.log @@ -58,4 +58,7 @@ sql='INSERT INTO test_receipt_items(type, receipt_id, barcode, name, qty, uom, data, status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) RETURNING *;') 2025-08-09 14:53:40.869005 --- ERROR --- DatabaseError(message='not all arguments converted during string formatting', payload=('sku', 36, '%078742015101%', '3405b49b-843a-4bca-a235-686e4a9f2e73', '100% grated parmesan cheese', 1, 1, '{"cost": 0, "expires": false}', 'Unresolved'), - sql='INSERT INTO test_receipt_items(type, receipt_id, barcode, name, qty, uom, data, status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) RETURNING *;') \ No newline at end of file + sql='INSERT INTO test_receipt_items(type, receipt_id, barcode, name, qty, uom, data, status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) RETURNING *;') +2025-08-09 15:57:58.332708 --- ERROR --- DatabaseError(message='invalid input syntax for type uuid: ""LINE 3: VALUES ('custom', 36, '', '', 'test1', '1', '2', '{"cost": "... ^', + payload=('custom', 36, '', '', 'test1', '1', '2', '{"cost": "0.99", "expires": false}', 'Unresolved'), + sql='INSERT INTO test_receipt_items(type, receipt_id, barcode, item_uuid, name, qty, uom, data, status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) RETURNING *;') \ No newline at end of file