The present perfect expresses the idea of “an action that was finished at some unspecified point in the past”. Saying “I have done it yesterday” is basically the same as saying “I finished doing it yesterday at some unspecified point in the past”. It doesn’t really work, does it; it’s either “at some point” or “yesterday”, not both. If you want to include the time when the action took place, you must use the simple past tense (the “-ed” form), e.g.
However, the simple past is ambiguous. “I did it yesterday” can be used to express that you finished it yesterday as well as that you left the work unfinished and will continue doing it later, as in “I did it yesterday, and I am also going to do it tomorrow”. If you want to express that the action is already completed, you can use verbs like “finish” or “complete” in the simple past:
A strong indicator that you shouldn’t use the present perfect is the presence of “when” in the sentence, since “when” always refers to a specific point in time:
Note that there is one case where “when + present perfect” can be used: to express surprise or mistrust. Say, a friend of yours told you how he enjoyed the view from the Eiffel Tower, and you weren’t aware of the fact that he had ever been to Paris. You could ask
It is an expression of surprise. You aren’t really asking when he visited Paris; you express that the fact he did surprised you.
There is another common situation in which the rule can be (seemingly) broken. For example, it is perfectly fine to say:
The present perfect can be used with any period that includes the present. This includes the common adverbs students learn to use with the present perfect, e.g. “ever” (“from the beginning of the universe until now”), “never” (“not ever”), “already”/“yet” (“from some implied point in the past until now”), for example:
I have never been there.