File tree Expand file tree Collapse file tree 4 files changed +599
-401
lines changed
Expand file tree Collapse file tree 4 files changed +599
-401
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ This file serves as a master index for all routes within the modularized AJS Pan
5555| ` /lend-borrow/<id>/verify ` | ` verify_return ` | POST | Lender confirms or rejects return |
5656| ` /expenses/import-receipt ` | ` import_receipt ` | POST | Scan PDF/Image receipts |
5757| ` /expenses/save-imported-bill ` | ` save_imported_bill ` | POST | Persist parsed PDF data to DB |
58+ | ` /bills/<id>/items ` | ` get_bill_items ` | GET | API: Fetch all items for a specific bill (JSON) |
5859
5960---
6061
Original file line number Diff line number Diff line change @@ -445,3 +445,29 @@ def save_imported_bill():
445445 db .session .rollback ()
446446 logging .error (f"Save Imported Bill Error: { str (e )} " )
447447 return jsonify ({'error' : f"Failed to save bill: { str (e )} " }), 500
448+
449+ @finance_bp .route ('/bills/<int:bill_id>/items' , methods = ['GET' ])
450+ def get_bill_items (bill_id ):
451+ user = _require_user ()
452+ if not user :
453+ return jsonify ({'error' : 'Unauthorized' }), 401
454+
455+ bill = tenant_filter (Bill .query ).filter_by (id = bill_id ).first_or_404 ()
456+ # Basic floor check for non-admins
457+ if user .role != 'admin' and bill .floor != user .floor :
458+ abort (403 )
459+
460+ items = []
461+ for item in bill .items :
462+ items .append ({
463+ 'id' : item .id ,
464+ 'item_name' : item .item_name ,
465+ 'quantity' : item .quantity ,
466+ 'actual_cost' : float (item .actual_cost or 0 )
467+ })
468+
469+ return jsonify ({
470+ 'bill_no' : bill .bill_no ,
471+ 'bill_date' : bill .bill_date .strftime ('%Y-%m-%d' ),
472+ 'items' : items
473+ })
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments