Midrash for Shekalim 2:5
מוֹתַר שְׁקָלִים, חֻלִּין. מוֹתַר עֲשִׂירִית הָאֵפָה, מוֹתַר קִנֵּי זָבִין, קִנֵּי זָבוֹת, קִנֵּי יוֹלְדוֹת, וְחַטָאוֹת וַאֲשָׁמוֹת, מוֹתְרֵיהֶן נְדָבָה. זֶה הַכְּלָל, כָּל שֶׁהוּא בָּא לְשֵׁם חַטָאת וּלְשֵׁם אַשְׁמָה, מוֹתָרָן נְדָבָה. מוֹתַר עוֹלָה, לָעוֹלָה. מוֹתַר מִנְחָה, לַמִּנְחָה. מוֹתַר שְׁלָמִים, לַשְּׁלָמִים. מוֹתַר פֶּסַח, לַשְּׁלָמִים. מוֹתַר נְזִירִים, לַנְּזִירִים. מוֹתַר נָזִיר, לַנְּדָבָה. מוֹתַר עֲנִיִּים, לָעֲנִיִּים. מוֹתַר עָנִי, לְאוֹתוֹ עָנִי. מוֹתַר שְׁבוּיִים, לַשְּׁבוּיִים. מוֹתַר שָׁבוּי, לְאוֹתוֹ שָׁבוּי. מוֹתַר הַמֵּתִים, לַמֵּתִים. מוֹתַר הַמֵּת, לְיוֹרְשָׁיו. רַבִּי מֵאִיר אוֹמֵר, מוֹתַר הַמֵּת, יְהֵא מֻנָּח עַד שֶׁיָּבֹא אֵלִיָּהוּ. רַבִּי נָתָן אוֹמֵר, מוֹתַר הַמֵּת בּוֹנִין לוֹ נֶפֶשׁ עַל קִבְרוֹ:
The surplus of shekalim is chullin. [If one puts away money, saying: "This is for my shekel," and then, when he counts it, finds he has a surplus, that surplus is chullin. This anonymous Mishnah is as per Beth Hillel.] The surplus of the tenth of an ephah, the birds of zavin, the birds of zavoth, the birds of yoldoth, sin-offerings and guilt-offerings (the surplus is) a gift (to hekdesh). [("the tenth of an ephah,") which is offered (in a state of) abject poverty. If money was laid aside for this, and there was a surplus, that surplus is a gift. For all surpluses of sin-offerings and guilt-offerings are gifts towards the acquisition of "summer burnt-offerings" for the altar, as per the medrash of Yehoyada Hakohen (6:6); and the tenth of the ephah is in place of a sin-offering.] This is the rule: The surplus of all that comes as a sin-offering or as a guilt-offering is a gift (for burnt-offerings). The surplus of a burnt-offering is a burnt-offering. [If he set aside money with which to buy a burnt-offering and there was a surplus, he purchases another burnt-offering with it.] The surplus of a meal-offering is a meal-offering. The surplus of a peace-offering is a peace-offering. The surplus of a Pesach is a peace-offering, [it being written (Deuteronomy 16:2): "And you shall sacrifice a Pesach to the L rd your G d, sheep and cattle." Now does the Pesach come from cattle? The meaning, then, is that the surplus of the Pesach is for what comes from sheep and cattle, namely, peace-offerings.] The surplus of Nazirites is for Nazirites. [If they collected money for Nazirite offerings and there was a surplus, the moneys are kept for the acquisition of offerings for other Nazirites. The surplus of a Nazirite is a gift. [If an individual Nazirite laid aside money for his offerings and there was a surplus, the surplus is a gift for summer burnt-offerings for the altar.] The surplus of (monies collected for) the poor is for the poor. The surplus of a poor man is for that poor man. [If they collected money to buy him clothing and there was a surplus, that surplus is given him.] The surplus of captives is for captives. The surplus of a captive is for that captive. [If they collected charity for the redemption of captives and there was a surplus, it is kept for the redemption of other captives. But if the monies were expressly given for a particular captive, the surplus goes to that captive.] The surplus of the dead is for the dead. [If they collected for the burial of the dead, in general, the surplus goes towards the burial of others.] The surplus of a (particular) dead man is for his heirs, [the assumption being that one waives his "cheapening" after death in favor of his heirs.] R. Meir says: The surplus of a (particular) dead man is to be put aside until Eliyahu comes. [R. Meir is in doubt as to whether or not he waives his "cheapening" in favor of his heirs, for which reason it is put aside until the advent of Eliyahu.] R. Nathan says: The surplus of a (particular) dead man is used for building a monument over his grave. [It is obvious to R. Nathan that he does not waive his "cheapening," for which reason a monument is built over his grave with the surplus, which had already reverted to him. The halachah is in accordance with the first tanna. In an instance where they collected for the (burial) requirements of a particular dead person, thinking he was without means, and then they discovered that this was not the case, we do not say that the surplus goes to the heirs, since the collection was in error. This is borne out in the Yerushalmi. And it also follows from the Yerushalmi and from our gemara that where there are seven city caretakers or where there is one, in charge of all community affairs, he may allocate the surplus of captives or of the poor or of the dead as he sees dictated by the exigencies of the time and he is not to be interfered with. And this is always the ruling in practice.]