Custom data import on sales invoice

i want to create new doctype which it can importing sales invoice data from external document, and when i make checkbox called “create customer” and check it,
if the customer name doesn’t listed in master customer it would auto create new customer. I already make the new doctype can u help me with the rest like function in client-server script?

I think this is a bad idea for data integrity. You can end up with many duplicate customers with similar spellings. If you rarely have repeat customers this may not be a big deal.

It could also work in reverse… new customer Charles having same name as Charles will have sales invoice to wrong customer.

Humans should be diligent in confirming if a customer exists prior to creating a new record.

A unique identifier like email or telephone may be accurate enough to avoid duplicates. This can still lead to issues with multiple email and phone numbers per person.

but my boss still want to make it like that. can u help me with that?