[Create Patient] AttributeError: 'NoneType' object has no attribute 'payment_terms

App Versions

{
	"erpnext": "15.30.0",
	"frappe": "15.17.1",
	"healthcare": "16.0.0-dev"
}

Route

Form/Patient/P01183113883

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1718, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/handler.py", line 327, in run_doc_method
    response = doc.run_method(method)
  File "apps/frappe/frappe/model/document.py", line 959, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1319, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1301, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 956, in fn
    return method_object(*args, **kwargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/healthcare/healthcare/healthcare/doctype/patient/patient.py", line 183, in invoice_patient_registration
    sales_invoice.save(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 335, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 357, in _save
    return self.insert()
  File "apps/frappe/frappe/model/document.py", line 289, in insert
    self.run_before_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1088, in run_before_save_methods
    self.run_method("validate")
  File "apps/frappe/frappe/model/document.py", line 959, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1319, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1301, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 956, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 266, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/selling_controller.py", line 29, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/stock_controller.py", line 52, in validate
    super().validate()
  File "apps/erpnext/erpnext/controllers/accounts_controller.py", line 181, in validate
    self.set_missing_values(for_validate=True)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 673, in set_missing_values
    super().set_missing_values(for_validate)
  File "apps/erpnext/erpnext/controllers/selling_controller.py", line 50, in set_missing_values
    self.set_missing_lead_customer_details(for_validate=for_validate)
  File "apps/erpnext/erpnext/controllers/selling_controller.py", line 77, in set_missing_lead_customer_details
    party_details = _get_party_details(
  File "apps/erpnext/erpnext/accounts/party.py", line 111, in _get_party_details
    set_account_and_due_date(party, account, party_type, company, posting_date, bill_date, doctype)
  File "apps/erpnext/erpnext/accounts/party.py", line 369, in set_account_and_due_date
    "due_date": get_due_date(posting_date, party_type, party, company, bill_date),
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/party.py", line 574, in get_due_date
    template_name = get_payment_terms_template(party, party_type, company)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/party.py", line 718, in get_payment_terms_template
    template = customer.payment_terms
AttributeError: 'NoneType' object has no attribute 'payment_terms'

Request Data

{
	"type": "POST",
	"args": {
		"docs": "{\"name\":\"P01183113883\",\"owner\":\"Administrator\",\"creation\":\"2024-07-24 13:20:18.390089\",\"modified\":\"2024-07-24 13:26:04.014500\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":0,\"naming_series\":\"HLC-PAT-.YYYY.-\",\"first_name\":\"RIKI\",\"middle_name\":\"WYA\",\"last_name\":\"PRIGA\",\"patient_name\":\"RIZKI WIA PRIYAA\",\"sex\":\"Male\",\"blood_group\":\"\",\"status\":\"Disabled\",\"uid\":\"351413171\",\"inpatient_status\":\"\",\"report_preference\":\"\",\"invite_user\":1,\"customer\":\"RIKI WYA PRIGA - 1\",\"customer_group\":\"All Customer Groups\",\"territory\":\"All Territories\",\"default_currency\":\"IDR\",\"default_price_list\":\"Standard Selling\",\"language\":\"en\",\"marital_status\":\"\",\"doctype\":\"Patient\",\"patient_relation\":[],\"__onload\":{\"addr_list\":[],\"contact_list\":[],\"dashboard_info\":[]},\"__last_sync_on\":\"2024-07-24T06:41:06.893Z\"}",
		"method": "invoice_patient_registration"
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/run_doc_method",
	"request_id": null
}

Response Data

{
	"exception": "AttributeError: 'NoneType' object has no attribute 'payment_terms'",
	"exc_type": "AttributeError",
	"_exc_source": "erpnext (app)"
}

@wepe17 customer = frappe.get_cached_value(
“Customer”, party_name, fieldname=[“payment_terms”, “customer_group”], as_dict=1

its getting customer is none

Halo @Jeel

By default is already set in erpnext but still error