The Receiver’s Mitzvos Are Credited to The Giver:
Sefer Me’il Tzedakah (Ois 431) relates the following story:
There once was a sinful man who spent his entire life immersed in bad behavior. One day, when he was very old, his wife asked him, “Why didn’t you eat anything today?”
He said, “If you make me a hardboiled egg, I will eat it.”
Before he started to eat, a poor man came to his door and asked for tzedakah. The old man said, “Give him my egg.”
He handed the egg that had been prepared for him to the pauper. That was the first time in his life that he had ever given anything to tzedakah.
Three days later, the sinful man died. A few days later, he appeared to his son in a dream. His son asked him, “Father, how are things going for you in afterlife?”
He said, “My son, my advice to you is to give a lot of tzedakah so that you can merit a good portion in Olam Haba. I never gave tzedakah besides for one egg that I gave to a beggar. When I died, that egg outweighed all of my sins and I was permitted to enter Gan Eden.”
The Me’il Tzedakah asks how one mitzvah could outweigh a lifetime of aveiros. He answers that the poor man was about to die of hunger and this egg brought him back to life. Therefore, every mitzvah that the poor man did after that and every mitzvah done by his children born after that story, and every mitzvah done by all of their descendants, were all credited to the old man because they would never have been done if not for him. All of those mitzvos outweighed his sins.
