mercredi 9 août 2017

Linq from where selection inaccurate

I need your help again.

I have an excelsheet with some credits and have to check the trust of a loan user and the return

I have created some sampledata which I check for loans with a imagined return of 14% annually. The thing is. Im getting shown a loan with under 14% return. HOW can that be?

this is my code snippet

var applicable = from b in discounts.ToList() where
                    (b["Interest Rate"].Cast<double>() + (-b["Discount/Premium"].Cast<double>()) + ((-b["Discount/Premium"].Cast<double>()) / (b["Term"].Cast<int>() / 12))) >= GlobalVar.minRealReturn select b;

            //some test here
            MessageBox.Show(applicable.First().ElementAt(15).Cast<double>() + " discount \n " +
                            applicable.First().ElementAt(8).Cast<double>() + " interestrate \n " +
                            applicable.First().ElementAt(9).Cast<double>() + " term \n " +
                            "interest rate "+ applicable.First().ElementAt(8).Cast<double>() + " + (-discount "+ applicable.First().ElementAt(15).Cast<double>() + ") + ((-discount "+ applicable.First().ElementAt(15).Cast<double>() + ")/(term "+ applicable.First().ElementAt(9).Cast<double>() + " /12)) = " +
                            (applicable.First().ElementAt(8).Cast<double>() + (-applicable.First().ElementAt(15).Cast<double>()) + ((-applicable.First().ElementAt(15).Cast<double>())/(applicable.First().ElementAt(9).Cast<double>()/12)))
                            );

and this is the result (a loan with 13.975% returneventhough it should check for 14% and above. not that it is much of a difference but you basically don´t want inconsistent data in a financial application!

enter image description here

Aucun commentaire:

Enregistrer un commentaire