One strong theme running through the narrative of Walter Scott's Ivanhoe is that all the bad guys are shown to be constantly justifying their bad behaviour because of good works they had previously done. On the other hand the two heroes, Ivanhoe and Rebecca, do good deeds without any thought for recompense and yet every good work leads to a favour being returned which serves to advance the story and ultimately results in Rebecca's salvation and vindication at the end of the story. Towards the end of the story Wamba, the saxon jester, exposes the rationale and modus operandi of those who justify themselves in conversation with the black knight:
They make up a balanced account with Heaven, as our old cellarer used to call his ciphering, as fair Isaac the Jew keeps with his debtors, and like him, give out very little, and take very large credit for doing so; reckoning, doubtless, on their own behalf the sevenfold usary which the blessed text hath promised to charitable loans . . . these honest fellows balance a good deed with one not quite so laudable; as a crown given to a begging friar with a hundred byzants taken from a fat abbot, or a wench kissed in the greenwood with the relief of a poor widow . . . The merry men of the forest set off the building of a cottage with the burning of a castle - the thatching of a choir against the robbing of a church - the setting free of a poor prisoner against the murder of a proud sheriff . . . Gentle theives they are, in short, and courteous robbers; but it is ever the luckiest to meet with them when they are at the worst . . . then they have some compunction, and are for making up matters with Heaven. But when they have struck an even balance, Heaven help them with whom they next open the account!
[pp343-4 of the 1995 Wordsworth edition]
The interesting thing is that up to this point the outlaws of the forest have been the good guys and yet Wamba's insight shows that really they just happen to be on the side of "good" when we meet them in the narrative. In reality they are operating on the same principles that the bad guys are. This passage and the way the black knight, revealed later to be Richard the Lion Heart, is portrayed leave the observant reader unsettled. Ivanhoe is not the simple swashbuckling tale of good versus evil, it is more the story of two virtuous people navigating a treacherous world where one side is little better than another. If anything there is something karmic rather than Christian about the way one good deed done selflessly leads inexorably to another. But in the way Scott exposes the human tendency to "trade with Heaven" he is spot on.
In the finale when Ivanhoe takes the part of Rebecca's champion in trial by combat he is wounded and exhausted, barely able to stand, and totally outmatched by his opponent. Yet ultimately the vindication that Rebecca needs does come, and not from Ivanhoe's strength, which is already spent. I think it fair to say that for Scott, those who justify themselves are ultimately found wanting, some coming to very sticky ends, and it is only those who give no thought to such accounts but do the right thing anyway who experience Heaven's reward.