68 lines
8.7 KiB
JSON
68 lines
8.7 KiB
JSON
[
|
|
{
|
|
"docstatus": 0,
|
|
"doctype": "Client Script",
|
|
"dt": "Serial No",
|
|
"enabled": 1,
|
|
"modified": "2026-05-17 06:30:57.598334",
|
|
"module": null,
|
|
"name": "Serial No - Price Calculator",
|
|
"script": "frappe.ui.form.on('Serial No', {\n grade: function(frm) {\n calculate_price(frm);\n },\n price_point: function(frm) {\n calculate_price(frm);\n },\n manual_price: function(frm) {\n if (frm.doc.price_point === 'Manual') {\n frm.set_value('assigned_price', frm.doc.manual_price);\n frm.set_value('pricing_status', 'Manual Override');\n }\n }\n});\n\nfunction calculate_price(frm) {\n var grade = frm.doc.grade;\n var price_point = frm.doc.price_point;\n \n if (!grade || !price_point) {\n return;\n }\n \n // C, D, F grades = commodity\n if (['C', 'D', 'F'].includes(grade)) {\n // Will be handled by server side\n frm.set_value('pricing_status', 'Commodity');\n return;\n }\n \n // Need item reference to get market prices\n if (!frm.doc.item_code) {\n return;\n }\n \n frappe.call({\n method: 'frappe.client.get',\n args: {\n doctype: 'Item',\n name: frm.doc.item_code\n },\n callback: function(r) {\n if (!r.message) return;\n var item = r.message;\n var base_price = 0;\n \n switch(price_point) {\n case 'Low':\n base_price = item.market_low || item.base_market_price || 0;\n break;\n case 'Median':\n base_price = item.market_median || item.base_market_price || 0;\n break;\n case 'Average':\n base_price = item.market_average || item.base_market_price || 0;\n break;\n case 'High':\n base_price = item.market_high || item.base_market_price || 0;\n break;\n }\n \n var multiplier = 1.0;\n if (grade === 'A') multiplier = item.grade_a_multiplier || 1.0;\n else if (grade === 'B') multiplier = item.grade_b_multiplier || 0.8;\n \n var final_price = base_price * multiplier;\n frm.set_value('assigned_price', Math.round(final_price * 100) / 100);\n frm.set_value('pricing_status', 'Priced');\n }\n });\n}",
|
|
"view": "Form"
|
|
},
|
|
{
|
|
"docstatus": 0,
|
|
"doctype": "Client Script",
|
|
"dt": "Pallet",
|
|
"enabled": 1,
|
|
"modified": "2026-05-17 05:39:15.497479",
|
|
"module": null,
|
|
"name": "Pallet - View Serials",
|
|
"script": "frappe.ui.form.on('Pallet', {\n refresh: function(frm) {\n frm.add_custom_button(__('View Serials'), function() {\n frappe.set_route('List', 'Serial No', {\n 'pallet': frm.doc.pallet_number || frm.doc.name\n });\n }, __('View'));\n \n frm.add_custom_button(__('Serials Spreadsheet'), function() {\n frappe.set_route('query-report', 'Serial Nos by Pallet', {\n 'pallet': frm.doc.pallet_number || frm.doc.name\n });\n }, __('View'));\n }\n});\n",
|
|
"view": "Form"
|
|
},
|
|
{
|
|
"docstatus": 0,
|
|
"doctype": "Client Script",
|
|
"dt": "Load",
|
|
"enabled": 1,
|
|
"modified": "2026-05-17 05:39:15.577871",
|
|
"module": null,
|
|
"name": "Load - View Pallets Button",
|
|
"script": "frappe.ui.form.on('Load', {\n refresh: function(frm) {\n frm.add_custom_button(__('View Pallets'), function() {\n frappe.set_route('List', 'Pallet', {'load': frm.doc.name});\n }, __('Actions'));\n }\n});\n",
|
|
"view": "Form"
|
|
},
|
|
{
|
|
"docstatus": 0,
|
|
"doctype": "Client Script",
|
|
"dt": "Scheduled Pickup",
|
|
"enabled": 1,
|
|
"modified": "2026-05-17 05:39:15.588395",
|
|
"module": null,
|
|
"name": "Scheduled Pickup - Auto Fill",
|
|
"script": "frappe.ui.form.on('Scheduled Pickup', {\n customer_number: function(frm) {\n var customer = frm.doc.customer_number;\n if (!customer) {\n clear_supplier_fields(frm);\n return;\n }\n frappe.call({\n method: 'frappe.client.get',\n args: {doctype: 'Supplier', name: customer},\n callback: function(r) {\n if (!r.message) return;\n var s = r.message;\n if (!frm.doc.company_name && s.supplier_name) {\n frm.set_value('company_name', s.supplier_name);\n }\n if (s.supplier_primary_contact) {\n frappe.call({\n method: 'frappe.client.get',\n args: {doctype: 'Contact', name: s.supplier_primary_contact},\n callback: function(cr) {\n if (!cr.message) return;\n var ct = cr.message;\n var full_name = [ct.first_name, ct.last_name].filter(Boolean).join(' ');\n if (!frm.doc.contact_name) frm.set_value('contact_name', full_name);\n if (!frm.doc.contact_phone) frm.set_value('contact_phone', ct.phone || '');\n if (!frm.doc.contact_email) frm.set_value('contact_email', ct.email_id || '');\n }\n });\n }\n if (s.supplier_primary_address) {\n frappe.call({\n method: 'frappe.client.get',\n args: {doctype: 'Address', name: s.supplier_primary_address},\n callback: function(ar) {\n if (!ar.message) return;\n var a = ar.message;\n if (!frm.doc.address_line) frm.set_value('address_line', a.address_line1 || '');\n if (!frm.doc.city) frm.set_value('city', a.city || '');\n if (!frm.doc.state) frm.set_value('state', a.state || '');\n if (!frm.doc.zip_code) frm.set_value('zip_code', a.pincode || '');\n }\n });\n }\n if (s.geocoded && s.latitude && s.longitude) {\n frm.set_value('latitude', s.latitude);\n frm.set_value('longitude', s.longitude);\n frm.set_value('geocoded', 1);\n }\n }\n });\n }\n});\n\nfunction clear_supplier_fields(frm) {\n frm.set_value('company_name', '');\n frm.set_value('contact_name', '');\n frm.set_value('contact_phone', '');\n frm.set_value('contact_email', '');\n frm.set_value('address_line', '');\n frm.set_value('city', '');\n frm.set_value('state', '');\n frm.set_value('zip_code', '');\n frm.set_value('latitude', '');\n frm.set_value('longitude', '');\n frm.set_value('geocoded', 0);\n}\n",
|
|
"view": "Form"
|
|
},
|
|
{
|
|
"docstatus": 0,
|
|
"doctype": "Client Script",
|
|
"dt": "System Pricing",
|
|
"enabled": 1,
|
|
"modified": "2026-05-17 05:41:31.790905",
|
|
"module": null,
|
|
"name": "System Pricing - Age Indicators",
|
|
"script": "frappe.listview_settings['System Pricing'] = {\n add_fields: [\"scraped_at\", \"days_since_pricing\", \"pricing_status\"],\n get_indicator: function(doc) {\n if (doc.pricing_status === \"Needs Pricing\" || doc.pricing_status === \"Error\") {\n return [__(\"Needs Pricing\"), \"orange\", \"pricing_status,=,Needs Pricing\"];\n }\n if (!doc.scraped_at) {\n return [__(\"No Date\"), \"gray\", \"scraped_at,is,not set\"];\n }\n var days = doc.days_since_pricing || 0;\n if (days < 90) {\n return [__(\"Fresh\"), \"green\", \"days_since_pricing,<,90\"];\n } else if (days < 120) {\n return [__(\"Aging\"), \"yellow\", \"days_since_pricing,<,120\"];\n } else {\n return [__(\"Expired\"), \"red\", \"days_since_pricing,>=,120\"];\n }\n }\n};",
|
|
"view": "List"
|
|
},
|
|
{
|
|
"docstatus": 0,
|
|
"doctype": "Client Script",
|
|
"dt": "System Pricing",
|
|
"enabled": 1,
|
|
"modified": "2026-05-17 05:41:31.954814",
|
|
"module": null,
|
|
"name": "System Pricing - Auto Calculate Days",
|
|
"script": "frappe.ui.form.on('System Pricing', {\n refresh: function(frm) {\n calculate_days(frm);\n },\n scraped_at: function(frm) {\n calculate_days(frm);\n }\n});\n\nfunction calculate_days(frm) {\n if (frm.doc.scraped_at) {\n var scraped = new Date(frm.doc.scraped_at);\n var now = new Date();\n var diffTime = Math.abs(now - scraped);\n var diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));\n frm.set_value('days_since_pricing', diffDays);\n } else {\n frm.set_value('days_since_pricing', 0);\n }\n}",
|
|
"view": "Form"
|
|
}
|
|
] |