Finished Quick Entry

This commit is contained in:
Ty Reynolds
2026-02-13 10:59:38 -05:00
parent 4357ce7fcc
commit aefb2d4cc6
2 changed files with 32 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ from frappe import _
@frappe.whitelist() @frappe.whitelist()
def create_customer_full(**data): def create_customer_full(**data):
frappe.only_for("System Manager", "Sales User", "Sales Manager") frappe.only_for(["System Manager", "Sales User", "Sales Manager"])
required = [ required = [
"customer_name", "customer_name",
@@ -26,16 +26,22 @@ def create_customer_full(**data):
try: try:
frappe.db.begin() frappe.db.begin()
if data.get("custom_auto_pay_enabled") and not data.get("custom_auto_pay_id"):
frappe.throw("Auto Pay ID is required when Auto Pay is enabled.")
customer = frappe.get_doc({ customer = frappe.get_doc({
"doctype": "Customer", "doctype": "Customer",
"customer_name": data["customer_name"], "customer_name": data["customer_name"],
"customer_type": data["customer_type"], "customer_type": data["customer_type"],
"customer_group": data["customer_group"], "customer_group": data["customer_group"],
"territory": "United States", "territory": "United States",
"custom_auto_pay_status": "Active" if data.get("custom_auto_pay_enabled") else "Disabled", "custom_auto_pay_status": 1 if data.get("custom_auto_pay_enabled") else 0,
"custom_auto_pay_id": data.get("custom_auto_pay_id") if data.get("custom_auto_pay_enabled") else "",
"custom_send_via": data.get("custom_send_via"), "custom_send_via": data.get("custom_send_via"),
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True)
contact = frappe.get_doc({ contact = frappe.get_doc({
"doctype": "Contact", "doctype": "Contact",
"first_name": data["customer_name"] "first_name": data["customer_name"]

View File

@@ -55,11 +55,16 @@ ns_app.customer.open_quick_entry = function (opts = {}) {
fieldtype: "Check", fieldtype: "Check",
default: 0 default: 0
}, },
{
fieldname: "custom_auto_pay_id",
label: "AutoPay ID",
fieldtype: "Data"
},
{ {
fieldname: "custom_send_via", fieldname: "custom_send_via",
label: "Send Via", label: "Send Via",
fieldtype: "Select", fieldtype: "Select",
options: "Mail\nEmail\nFax" options: "mail\nemail\nfax"
}, },
// ───────── CONTACT ───────── // ───────── CONTACT ─────────
@@ -170,6 +175,24 @@ ns_app.customer.open_quick_entry = function (opts = {}) {
d.show(); d.show();
let autoPayField = d.get_field("custom_auto_pay_enabled");
// Initial state
d.set_df_property(
"custom_auto_pay_id",
"hidden",
!d.get_value("custom_auto_pay_enabled")
);
// When checkbox changes
autoPayField.$input.on("change", () => {
let isChecked = d.get_value("custom_auto_pay_enabled");
d.set_df_property("custom_auto_pay_id", "hidden", !isChecked);
});
// Prevent Enter from submitting unless primary button is focused // Prevent Enter from submitting unless primary button is focused
d.$wrapper.on("keydown", "input, select, textarea", function (e) { d.$wrapper.on("keydown", "input, select, textarea", function (e) {
if (e.key === "Enter") { if (e.key === "Enter") {