Compare commits
4 Commits
18a5bc6603
...
f0d66d9503
| Author | SHA1 | Date | |
|---|---|---|---|
| f0d66d9503 | |||
| 5453f87603 | |||
| 77b86851a0 | |||
| 047fcc49b0 |
@@ -0,0 +1,2 @@
|
||||
|
||||
from westech_r2.api import sales
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,68 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_qa_ready_serials(limit=50):
|
||||
"""Get Serial Nos ready for QA."""
|
||||
return frappe.get_all('Serial No',
|
||||
filters={'r2_status': 'Needs QA'},
|
||||
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)
|
||||
|
||||
existing = frappe.db.get_value('R2 Device Inspection',
|
||||
{'serial_no': serial_no, 'docstatus': ['!=', 2]}, 'name')
|
||||
if existing:
|
||||
return {'error': f'Inspection {existing} already exists'}
|
||||
|
||||
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}
|
||||
|
||||
@frappe.whitelist()
|
||||
def auto_grade(serial_no, grade='C5'):
|
||||
"""Auto-grade a device and move to Priced state."""
|
||||
serial = frappe.get_doc('Serial No', serial_no)
|
||||
serial.cosmetic_grade = grade
|
||||
serial.r2_status = 'Processed'
|
||||
serial.save(ignore_permissions=True)
|
||||
|
||||
# Apply flat pricing
|
||||
item = frappe.db.get_value('Item', serial.item_code, 'item_group')
|
||||
flat_prices = {
|
||||
'Laptops': {'c3': 250, 'c4': 200, 'c5': 150, 'c6': 100, 'c7': 60, 'c8': 30, 'c9': 15},
|
||||
'Desktops': {'c3': 180, 'c4': 150, 'c5': 120, 'c6': 80, 'c7': 50, 'c8': 25, 'c9': 10},
|
||||
'Tablets': {'c3': 120, 'c4': 100, 'c5': 80, 'c6': 50, 'c7': 30, 'c8': 15, 'c9': 8},
|
||||
'Phones': {'c3': 100, 'c4': 80, 'c5': 60, 'c6': 40, 'c7': 25, 'c8': 12, 'c9': 5}
|
||||
}
|
||||
prices = flat_prices.get(item, flat_prices['Laptops'])
|
||||
price = prices.get(grade.lower(), 100)
|
||||
|
||||
serial.suggested_price = price
|
||||
serial.assigned_price = price
|
||||
serial.pricing_status = 'Priced'
|
||||
serial.price_point = grade
|
||||
serial.r2_status = 'Priced'
|
||||
serial.save(ignore_permissions=True)
|
||||
|
||||
return {'success': True, 'price': price}
|
||||
@@ -0,0 +1,92 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
|
||||
@frappe.whitelist()
|
||||
def quick_sell(serial_no, customer=None, payment_method='Cash'):
|
||||
"""Create Sales Invoice for quick cash sale."""
|
||||
try:
|
||||
serial = frappe.get_doc('Serial No', serial_no)
|
||||
|
||||
if serial.r2_status != 'Ready for Sale':
|
||||
return {'error': 'Device must be Ready for Sale'}
|
||||
|
||||
# Use default customer if none provided
|
||||
if not customer:
|
||||
customer = frappe.db.get_value('Customer', {}, 'name', order_by='creation asc')
|
||||
if not customer:
|
||||
# Create walk-in customer
|
||||
customer = frappe.get_doc({
|
||||
'doctype': 'Customer',
|
||||
'customer_name': 'Walk-in Customer',
|
||||
'customer_type': 'Individual'
|
||||
}).insert(ignore_permissions=True).name
|
||||
|
||||
# Create Sales Invoice
|
||||
price = serial.assigned_price or serial.suggested_price or 0
|
||||
|
||||
invoice = frappe.get_doc({
|
||||
'doctype': 'Sales Invoice',
|
||||
'customer': customer,
|
||||
'serial_no': serial_no,
|
||||
'device_condition': f"Cosmetic: {serial.cosmetic_grade or 'N/A'}",
|
||||
'posting_date': frappe.utils.today(),
|
||||
'due_date': frappe.utils.today(),
|
||||
'items': [{
|
||||
'item_code': serial.item_code,
|
||||
'qty': 1,
|
||||
'rate': price,
|
||||
'amount': price,
|
||||
'serial_no': serial_no
|
||||
}],
|
||||
'payments': [{
|
||||
'mode_of_payment': payment_method,
|
||||
'amount': price
|
||||
}]
|
||||
})
|
||||
invoice.insert(ignore_permissions=True)
|
||||
invoice.submit()
|
||||
|
||||
# Update Serial No
|
||||
serial.r2_status = 'Sold'
|
||||
serial.status = 'Delivered'
|
||||
serial.customer = customer
|
||||
serial.save(ignore_permissions=True)
|
||||
|
||||
return {
|
||||
'success': True,
|
||||
'invoice': invoice.name,
|
||||
'customer': customer,
|
||||
'amount': price
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
frappe.log_error(f"Quick sell failed: {str(e)}", "Sales")
|
||||
return {'error': str(e)}
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_sales_order(quotation_name):
|
||||
"""Create Sales Order from Quotation."""
|
||||
try:
|
||||
from erpnext.selling.doctype.quotation.quotation import make_sales_order
|
||||
|
||||
so = make_sales_order(quotation_name)
|
||||
so.insert(ignore_permissions=True)
|
||||
so.submit()
|
||||
|
||||
return {'success': True, 'sales_order': so.name}
|
||||
except Exception as e:
|
||||
return {'error': str(e)}
|
||||
|
||||
@frappe.whitelist()
|
||||
def create_delivery_note(sales_order_name):
|
||||
"""Create Delivery Note from Sales Order."""
|
||||
try:
|
||||
from erpnext.selling.doctype.sales_order.sales_order import make_delivery_note
|
||||
|
||||
dn = make_delivery_note(sales_order_name)
|
||||
dn.insert(ignore_permissions=True)
|
||||
dn.submit()
|
||||
|
||||
return {'success': True, 'delivery_note': dn.name}
|
||||
except Exception as e:
|
||||
return {'error': str(e)}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"charts": [],
|
||||
"content": "[{\"type\": \"header\", \"data\": {\"text\": \"<span class=\\\"h4\\\"><b>Westech Recyclers</b></span>\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"New Intake\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Pallets\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Pallet List\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Scheduled Pickups\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Route Planner\"}}, {\"type\": \"spacer\", \"data\": {}}, {\"type\": \"header\", \"data\": {\"text\": \"<span class=\\\"h4\\\"><b>Tools</b></span>\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"EIM Device Portal\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"R2 Data Tracking\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Wes AI Assistant\"}}, {\"type\": \"spacer\", \"data\": {}}, {\"type\": \"header\", \"data\": {\"text\": \"<span class=\\\"h4\\\"><b>Records</b></span>\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Customers\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Suppliers\"}}]",
|
||||
"content": "[{\"type\": \"header\", \"data\": {\"text\": \"<span class=\\\"h4\\\"><b>Westech Recyclers</b></span>\"}}, {\"type\": \"spacer\", \"data\": {}}, {\"type\": \"header\", \"data\": {\"text\": \"<span class=\\\"h4\\\"><b>Operations</b></span>\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"New Intake\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Pallets\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Pallet List\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Scheduled Pickups\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Route Planner\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"EIM Device Portal\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"R2 Data Tracking\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Wes AI Assistant\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Customers\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Suppliers\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"Serial No\"}}, {\"type\": \"shortcut\", \"data\": {\"shortcut_name\": \"R2 Device Inspection\"}}]",
|
||||
"creation": "2026-05-17 05:39:20.222818",
|
||||
"custom_blocks": [],
|
||||
"docstatus": 0,
|
||||
@@ -13,51 +13,25 @@
|
||||
"label": "Westech",
|
||||
"links": [
|
||||
{
|
||||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Stock",
|
||||
"label": "Tools",
|
||||
"link_count": 0,
|
||||
"link_to": "",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Card Break"
|
||||
},
|
||||
{
|
||||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Warehouses",
|
||||
"label": "New Intake",
|
||||
"link_count": 0,
|
||||
"link_to": "Warehouse",
|
||||
"link_type": "DocType",
|
||||
"link_to": "intake",
|
||||
"link_type": "Page",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Serial Nos",
|
||||
"link_count": 0,
|
||||
"link_to": "Serial No",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Stock Entry",
|
||||
"link_count": 0,
|
||||
"link_to": "Stock Entry",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Pallets",
|
||||
@@ -68,7 +42,124 @@
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"dependencies": "",
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Pallet List",
|
||||
"link_count": 0,
|
||||
"link_to": "pallet-list",
|
||||
"link_type": "Page",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Scheduled Pickups",
|
||||
"link_count": 0,
|
||||
"link_to": "Scheduled Pickup",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Route Planner",
|
||||
"link_count": 0,
|
||||
"link_to": "route-planner",
|
||||
"link_type": "Page",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "EIM Device Portal",
|
||||
"link_count": 0,
|
||||
"link_to": "eim-portal",
|
||||
"link_type": "Page",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "R2 Data Tracking",
|
||||
"link_count": 0,
|
||||
"link_to": "r2-tracking",
|
||||
"link_type": "Page",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Records",
|
||||
"link_count": 0,
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Card Break"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Customers",
|
||||
"link_count": 0,
|
||||
"link_to": "Customer",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Suppliers",
|
||||
"link_count": 0,
|
||||
"link_to": "Supplier",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Stock",
|
||||
"link_count": 0,
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Card Break"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Warehouses",
|
||||
"link_count": 0,
|
||||
"link_to": "Warehouse",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Serial Nos",
|
||||
"link_count": 0,
|
||||
"link_to": "Serial No",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Stock Entry",
|
||||
"link_count": 0,
|
||||
"link_to": "Stock Entry",
|
||||
"link_type": "DocType",
|
||||
"onboard": 0,
|
||||
"type": "Link"
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"is_query_report": 0,
|
||||
"label": "Stock Balance",
|
||||
@@ -81,7 +172,6 @@
|
||||
},
|
||||
{
|
||||
"hidden": 0,
|
||||
"icon": "octicon octicon-shield-check",
|
||||
"is_query_report": 0,
|
||||
"label": "R2 Tracking",
|
||||
"link_count": 0,
|
||||
@@ -100,7 +190,7 @@
|
||||
"type": "Link"
|
||||
}
|
||||
],
|
||||
"modified": "2026-05-17 08:50:07.192685",
|
||||
"modified": "2026-05-17 17:46:55.663737",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Westech R2",
|
||||
"name": "Westech",
|
||||
@@ -108,84 +198,120 @@
|
||||
"owner": "Administrator",
|
||||
"public": 1,
|
||||
"quick_lists": [],
|
||||
"roles": [],
|
||||
"roles": [
|
||||
{
|
||||
"role": "System Manager"
|
||||
},
|
||||
{
|
||||
"role": "Westech User"
|
||||
},
|
||||
{
|
||||
"role": "All"
|
||||
}
|
||||
],
|
||||
"sequence_id": 0.0,
|
||||
"shortcuts": [
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "add",
|
||||
"label": "New Intake",
|
||||
"link_to": "intake",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "scan",
|
||||
"label": "EIM Device Portal",
|
||||
"link_to": "eim-portal",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "table",
|
||||
"label": "R2 Data Tracking",
|
||||
"link_to": "r2-tracking",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "stock",
|
||||
"label": "Pallets",
|
||||
"link_to": "Pallet",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "customer",
|
||||
"label": "Customers",
|
||||
"link_to": "Customer",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "users",
|
||||
"label": "Suppliers",
|
||||
"link_to": "Supplier",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "list",
|
||||
"label": "Pallet List",
|
||||
"link_to": "pallet-list",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "map",
|
||||
"label": "Route Planner",
|
||||
"link_to": "route-planner",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "List",
|
||||
"icon": "calendar",
|
||||
"label": "Scheduled Pickups",
|
||||
"link_to": "Scheduled Pickup",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"icon": "fa fa-tags",
|
||||
"label": "eBay Pricing",
|
||||
"link_to": "ebay-pricing",
|
||||
"label": "Route Planner",
|
||||
"link_to": "route-planner",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "Sales Manager",
|
||||
"link_to": "sales-manager",
|
||||
"label": "EIM Device Portal",
|
||||
"link_to": "eim-portal",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Data Tracking",
|
||||
"link_to": "r2-tracking",
|
||||
"type": "Page"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "Customers",
|
||||
"link_to": "Customer",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "Suppliers",
|
||||
"link_to": "Supplier",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "Serial No",
|
||||
"link_to": "Serial No",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Device Inspection",
|
||||
"link_to": "R2 Device Inspection",
|
||||
"type": "DocType"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Pipeline",
|
||||
"link_to": "R2 Pipeline",
|
||||
"type": "Dashboard"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Sort",
|
||||
"link_to": "R2 Sort",
|
||||
"type": "Dashboard"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 HDR",
|
||||
"link_to": "R2 HDR",
|
||||
"type": "Dashboard"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Testing",
|
||||
"link_to": "R2 Testing",
|
||||
"type": "Dashboard"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Wipe",
|
||||
"link_to": "R2 Wipe",
|
||||
"type": "Dashboard"
|
||||
},
|
||||
{
|
||||
"doc_view": "",
|
||||
"label": "R2 Warehouse",
|
||||
"link_to": "R2 Warehouse",
|
||||
"type": "Dashboard"
|
||||
}
|
||||
],
|
||||
"title": "Westech"
|
||||
|
||||
Reference in New Issue
Block a user