How to get if the customer name has specific type?

Hello there!

How can I reach the customer.type which is in Customer doctype from the Customer_name which is in Sales Invoice?

If the customer.name ==“John” has a customer.type == company :
do a thing

I have the field(customer name) in “Sales Invoice doctype” only but I want to check if this customer has (customer.type == company) in Customer doctype