What is the exact use of Credit Note?

What is the exact use of Credit Note?

Hi, 

Can anyone please explain what is the exact use of credit note? please explain with example. If I add a credit note and use that to pay a invoice, what is the double entry transaction for that? And how I am going to get paid in real? How I will entry the transaction once the payment is received?

Please let me know.

Regards.
Swapan