CRM-14951: no of terms should be calculated on contribution id rather than entity id/table
Merge pull request #3679 from yashodha/CRM-14951

Tested, working fine.