diff --git a/westech_r2/api/__pycache__/__init__.cpython-312.pyc b/westech_r2/api/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000..02f0bc7 Binary files /dev/null and b/westech_r2/api/__pycache__/__init__.cpython-312.pyc differ diff --git a/westech_r2/api/__pycache__/scoring.cpython-312.pyc b/westech_r2/api/__pycache__/scoring.cpython-312.pyc new file mode 100644 index 0000000..277f688 Binary files /dev/null and b/westech_r2/api/__pycache__/scoring.cpython-312.pyc differ diff --git a/westech_r2/api/qa.py b/westech_r2/api/qa.py new file mode 100644 index 0000000..3f1b2d4 --- /dev/null +++ b/westech_r2/api/qa.py @@ -0,0 +1,41 @@ +import frappe +from frappe import _ + +@frappe.whitelist() +def get_qa_ready_serials(limit=50): + """Get Serial Nos ready for QA (Erasure Complete state).""" + return frappe.get_all('Serial No', + filters={'r2_status': 'Erasure Complete'}, + fields=['name', 'item_code', 'item_name', 'pallet', 'cosmetic_grade'], + limit=limit, + order_by='creation asc' + ) + +@frappe.whitelist() +def create_qa_from_serial(serial_no): + """Create QA inspection for a Serial No.""" + if not frappe.db.exists('Serial No', serial_no): + return {'error': 'Serial No not found'} + + serial = frappe.get_doc('Serial No', serial_no) + + # Check if already has active inspection + existing = frappe.db.get_value('R2 Device Inspection', + {'serial_no': serial_no, 'docstatus': ['!=', 2]}, 'name') + if existing: + return {'error': f'Inspection {existing} already exists for this serial'} + + insp = frappe.get_doc({ + 'doctype': 'R2 Device Inspection', + 'serial_no': serial_no, + 'item_code': serial.item_code, + 'inspection_date': frappe.utils.today(), + 'inspector': frappe.session.user, + 'cosmetic_grade': serial.cosmetic_grade, + 'screen_condition': serial.screen_condition, + 'keyboard_condition': serial.keyboard_condition, + 'case_condition': serial.case_condition + }) + insp.insert(ignore_permissions=True) + + return {'success': True, 'inspection': insp.name} diff --git a/westech_r2/westech_r2/page/sales-manager/sales-manager.json b/westech_r2/westech_r2/page/sales-manager/sales-manager.json index 1dc08a6..e1d3477 100644 --- a/westech_r2/westech_r2/page/sales-manager/sales-manager.json +++ b/westech_r2/westech_r2/page/sales-manager/sales-manager.json @@ -3,10 +3,16 @@ "route": "sales-manager", "icon": "fa fa-dollar-sign", "roles": [ - {"role": "System Manager"}, - {"role": "Sales User"} + { + "role": "System Manager" + }, + { + "role": "Sales User" + } ], "standard": "Yes", "type": "page", - "module": "Westech R2" -} + "module": "Westech R2", + "doctype": "Page", + "name": "sales-manager" +} \ No newline at end of file diff --git a/westech_r2/westech_r2/page/sales_manager/sales_manager.json b/westech_r2/westech_r2/page/sales_manager/sales_manager.json index 1dc08a6..e1d3477 100644 --- a/westech_r2/westech_r2/page/sales_manager/sales_manager.json +++ b/westech_r2/westech_r2/page/sales_manager/sales_manager.json @@ -3,10 +3,16 @@ "route": "sales-manager", "icon": "fa fa-dollar-sign", "roles": [ - {"role": "System Manager"}, - {"role": "Sales User"} + { + "role": "System Manager" + }, + { + "role": "Sales User" + } ], "standard": "Yes", "type": "page", - "module": "Westech R2" -} + "module": "Westech R2", + "doctype": "Page", + "name": "sales-manager" +} \ No newline at end of file