From 056d50fff208168e4a103a9091fd96efb3a88065 Mon Sep 17 00:00:00 2001 From: Jadowyne Ulve Date: Sat, 9 Aug 2025 16:01:54 -0500 Subject: [PATCH] Implemented Custom Lines in Receipts Module --- .../__pycache__/receipts_api.cpython-313.pyc | Bin 20084 -> 21235 bytes application/receipts/receipts_api.py | 28 +++++++++- .../receipts/static/js/receiptHandler.js | 46 +++++++++++++++-- application/receipts/templates/receipt.html | 48 +++++++++++++++++- logs/database.log | 5 +- 5 files changed, 119 insertions(+), 8 deletions(-) diff --git a/application/receipts/__pycache__/receipts_api.cpython-313.pyc b/application/receipts/__pycache__/receipts_api.cpython-313.pyc index e8bc1ce77aae65cf2495f77e26f45881abc8ee2d..d9895446d0b0de140dc296365d2eb859ffe73b1a 100644 GIT binary patch delta 1786 zcmZ`(du&r>6u;l?W9{ua+pb$5bgtdIW9vG$vB7u`H)J3}osUeM4J}aJqx*UX4osFQ zL6WI}M}zZ`%qZxBf#EfP1SLKajKR1KW1B+aBSil*BO^ZeN6)!s@`^XPzk9y(y65|y z^L^LeVzY-?&aBxi3Hb1nhqjL|Ihf-Vy;&zJ40@Q<6v77mAO!V=@S8plyc!2<7Mz#l=c3>hwz(#GysZ?tPmUqWu>TS=kcqHgAfL1oFH`XE*5 zjMTAVJ@273oS+loA)Y|=XLBuSs2O}AflQ!BNbBM}_C&ADvq`gqActTl!AgQG1iv;@ z*)me}6AU6GD5)18UVuW{{2$@#uyp<$>VUkifUm+1`NeD`ImGimirTYVR;#bfPL z*5GA}BWdwYTf7%7MPrMnEP=ZeDQn(UtI;X#%f4n8jP9hNc3R0UJHwa^=gR|Z5ByQ? z)4hQ89aB6N`xz=e^goZrU}Y8C3!5w5x|h*-T6wl|saUuN#S9y2ZwxqIT{M>&E=C|# zwHZSfR#$soBF`I?-HcLs8-$^1kM1>e_(B=0{!CnY2*q>`_VDRwq^moYkh@|LK8ng# zevr~+8u$u|e&byYgg1j_Cd$BHCm4kb!8++}6esabD8#u^P|L)kJ5w2M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QvxidN(MWdVy@qoAaqTEcbm7bTW&Xbp;~YB7&y7$T z$c!w;aa`T7SUyA3v_-$&FvBKJ;g{J9GI>*;oWbOa7;4-*>o_kr>**S7PA(E$Vq9ii zU|b^@u0%>xQ(9P!Xl-zX-DcHKVZod#`99fSE&9?qFN8Rc{-!+nI>lc5$6zO$`g|rMgH*$y zB-KPbsQ`ZnQrH`uV(+7AA@&E~3LoBU4&>b6&@E1p)xn 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