What is the proper way to foster generosity and gratitude? I can see how generosity and gratitude are important as means to foster right resolve. But what if someone do good things sometimes due a sense of obligation, but also cause much harm to you? For example, this mother. Given that our resources and gains are limited, it is not much better to support the virtuous one rather than the unvirtuous?

And in the case of supporting the unvirtuous and unwise, how this would not contradict others teachings like "do not associate with fools" and "give a gift in a proper time"? (a unwise person would surely use a material gift unwisely causing harm for himself/herself and others).
&quot;Monks, these two people are hard to find in the world. Which two? The one who is first to do a kindness, and the one who is grateful for a kindness done and feels obligated to repay it. These two people are hard to find in the world.&quot; ...and more on lessons of gratitude

Danilo, your observations are totally right in regard one has already a broader view and the question is a good and useful one to understand things better. But &amp; Because: Yet most people are not even able to fullfil their duties (break silas and do not take what is not give, or pay the price, hold to promises) and stay to contracts (virtue) in relation of sensuallity (material things and reverence). The next higher stage then is toward more selfless giving of material things. So even if most made in this way, it's useless to build a tower on a muddy baseless place and one needs to start where the mud is places, do the hard and &quot;dirty&quot;, painful job, first.
Above the first gods (those giving birth, parents), if those are recognised, one can walk on to the higher goods, , those introducing, nurishing this the four needs (food, shelter, cloth, medicine), those teaching, leading to heaven and then even to liberation.
If the base is not done, e.g. not even obligation as reward of sensuality is recognices and duties payed off, if even parents are not put on the right scale, there is no way to ever develope that much freedom to be able to interact and receive on a higher scale. One makes nothing but more and more debts on this way, in all directions, even if feeling released by certain thought constructs.
It's maybe importand to understand that parents can aside of being the first gods be also the higherst. Some are that gifted, some even recognice it.
The issue of giving and the issue of duties (sila) which also may include giving is not that easy understood. Sometimes giving is a deal for expected gain, sometimes a required obligation for a relation (deal), sometime a payment for release seldom really generosity and it is gain and again worthy to note that the treasure of real generosity is only gained by a person of integrity, e.g. comes after perfection of silas.
Most not even managed in regard of giving at large plays all in the section of sila, starting from proper veneration to service and assistance.
What the proper places for generosity are, for all being, regardless of relation, nice or bad, is mentioned in timely giving and is of course always excelled by Noble Ones and those train for it.
It's very difficult to make western or better modern people basics (at least right view) understandable because they are not at all used to generosity, feelings of obligation, gratitude... but raised in a society, if good, where all has a to be payed marked price, and no, really no, neither at home, nor at school, good basic conducts are trained.
For defilements even a pleasure to here that giving to immoral people is not conductive, yet they would not include the own person when making their greedy excuses to deny even obligations.
May person once had a longer discussion with a typical western Buddhist and it might be of use, even the place itself there is not one to advice for a good. The topics discussion and links may explain certain basics and misunderstandings: Dana (Generosity, Charity)  &quot;Abhidhamma in daily life &quot; 
To understand guṇā (best transated as &quot;giver&quot; or &quot;benefactor&quot;) here are also some explaining. Usually translated as goodness or &quot;people of goodness&quot;, it's meaning starts by the sense organs and is then used for goodness making real sense and beyound: guṇā គុណ - Gönner, Verbindubg/Band | benefactor, string/bound (just in German, if one like to translate, feel given)
It's impossible to walk a spiritual way if not having placed all benefactors on the right place in the heart at a matter that even most modern or western monks are not able to get fixed. At least it's underlying right view and becoming a person of integrity, either on faith, Dhamma or by entering the stream to get really ride of macchariya which only Noble ones, but right from the beginning are free from. If that and gratitude is still a problem, don't even think on Jhanas or any attainments: impossible.
Since those basic topics are merelt tabu and not welcome at all, leading even most to anger and aversion, the so called buddhist community in the west and modern world is merely just a wellness and trade branch and not really a source of real attainments at all, does not even have any basic positiv effects in normal live and sociaty which can be easy observed everywhere.
But back to a many helpful &quot;classification&quot; of worthyness in regard of people or relations, of course not really possible to distinguished in a very firm way, but merely an orientation and a source to think and reflect more about it:

A raw ranking based on it, in regard of worthy (general, can differ in cases aside of Noble Ones):

Ordinary beings

Ordinary people

Ordinary beings hungry, lacking existencial needs

Normal friends and wordily fellows

Normal elders


People of goodness:

Wordily teachers

Ones family and relatives

Ones first goods, parents

People keeping 5 precepts

People keeping 8 pr.

People keeping 10 precepts

Homeless 10 precepts

Samanera

Young Bhikkhu

Full Bhikkhu

Thera

Maha Thera


Ecxeled by innwardly qualities, case by case:

wordlings

Layperson following the training (still enjoys sensuality)

Recluse/monastic following the training (still enjoying sensual pleasure)

Layperson living the wholly life in full, following the Arahats

Recluse/monastic living the wholly live full, following the Arahats

Noble One 1. Path winner



Fruit Winner..2, 3, 4 Patg winner


Arahat

Buddha


In regard of Noble Ones, Recluse excels Lay person.

At least, not as a demand or just to belittle but as a matter of generosity and compassion, Danilo, so that you may have more ease and more doors to good places open in future, to train youself in good conduct, is actually not respectfull, not praisworthy and possible for the most cases a hard hindrance to ask indirect, without reverence and yes of course in certain equal manner. So for normal and strict holding on secure ways, Danilo might not only get any useful answer but also be known, like many, as someone with less virtues not at all worthy of gifts. But again, that is just for you and others grow, being aware that good conduct and proper behaviour is something unknown an utopistic in the modern and internet realms.
One might feel free to go into the topic even deeper or to train here, on a given and more proper place. At least most might be really wasted giving, as mentioned in the question, yet for those possible to get healed still.
How to foster generosity and gratitude?

Again and formost: association with people of integrity and generosity, gratefull people, people rejocing in deeds of giving and devotion, able to share merits and encourage to such and by avoiding places and people not used to, the usuall &quot;cool&quot; ones, like poison.

Rendering service and assistance in monasteries, for monks, for elders, teacher, virtuous. (e.g. practice Silas and pay obligations proper back or even without hope of reward)

Practice generosity where ever there is a possibility.

Learn to great, address, pay respect and good verbal and bodily conduct and use it everywhere, whether usual or not (it also helps to cut of &quot;enemies&quot; for prosperty)

Get used and train youself in all of the ten kinds of merit-making.

Stick to right view, even it goes against all grains and let it be adviser for your daily action rather to let your defilements make use of transcend right view while still living next a punch of fetters and a refrigerator.



He bears no ill will and is not corrupt in the resolves of his heart. [He thinks,] 'May these beings be free from animosity, free from oppression, free from trouble, and may they look after themselves with ease!' He has right view and is not warped in the way he sees things: 'There is what is given, what is offered, what is sacrificed. There are fruits &amp; results of good &amp; bad actions. There is this world &amp; the next world. There is mother &amp; father. There are spontaneously reborn beings; there are brahmans &amp; contemplatives who, faring rightly &amp; practicing rightly, proclaim this world &amp; the next after having directly known &amp; realized it for themselves.' This is how one is made pure in three ways by mental action.&quot;

Once, again, right view is adopted by faith, certain vision or even clear seen and gained, generosity, after virtue and gratitude proper and right placed is no more a matter at all. At this point, not out of reason, one is incapable to do grave, even deliberated misconduct and behave improper.
May it be for release and ease, who ever might be capable to take, make use and understand.
And be carefull, it's not free and not without strings and one might be already hardly caught, with no chance to fall back any more!


Bahukārasuttaṃ

Has done much

&quot;Bhikkhus, these three persons have done much to a person. Which three? Bhikkhus, the person gone to whom this person takes refuge in the Enlightenment, in the Teaching and the Community of bhikkhus.

&quot;Bhikkhus, the person gone to whom this person knows as it really is, this is unpleasant, this is the arising of unpleasantness, this is the cessation of unpleasantness and this is the path leading to the cessation of unpleasantness.
&quot;Again, bhikkhus, the person gone to whom, this person destroys desires, releases the mind and released through wisdom, here and now abides having realized. Bhikkhus, these three persons have done much to this person.
&quot;Bhikkhus, it is not possible that these three persons could be thoroughly repaid with gratitude, by this person revering him, attending on him, clasping hands towards him and honouring him with robes, morsel food, dwellings and medicinal requisites.&quot;

Of course very useful and in same value Utopia: Opening the Door to the Dhamma: Respect in Buddhist Thought &amp; Practice
The orderline duties » sila » generosity ... from the gross to the fine, can btw. be also traced likewise, as tried to point out at the beginning, in the Mangala Sutta and at each level of fullfilment or able to renounce certain relation and it's benefits, debts are growing void and giving is step by step growing to real generosity and compassion. Once a state around the stanca 6. and 7 is reached, no more falling back will accur for one.
Anumodana!
[Note: This is a gift of Dhamma and not meant for commercial purpose or other low wordily gains by means of trade and exchange.]