[patch] FIx loan druid when auto_decimal is enabled

Jerry Quinn jlquinn at optonline.net
Sun Mar 18 17:52:57 EDT 2007


Hi, folks.

This patch fixes #343795 for me.

This patch makes the loan druid generate correct loan amortization numbers 
when auto_decimal is turned on.  The problem is that the formulas use "12" as 
the number of periods inside the text string, rather than "12.0".  The text 
parser turns it into a number, applies auto_decimal, and creates 12/100, which 
then screws up the remaining computations.

This bug has been around and biting me for a long time, since version 1.8 when 
I started using gnucash.

Can this be ported back to 2.0.5 as well?

Thanks,
Jerry Quinn


Index: src/gnome/druid-loan.c
===================================================================
--- src/gnome/druid-loan.c	(revision 15707)
+++ src/gnome/druid-loan.c	(working copy)
@@ -927,7 +927,7 @@
  {
          g_assert( ldd != NULL );
          g_assert( gstr != NULL );
-        g_string_append_printf( gstr, "pmt( %.5f / 12 : %0.2f : %0.2f : 0 : 0 )",
+        g_string_append_printf( gstr, "pmt( %.5f / 12.0 : %0.2f : %0.2f : 0 : 
0 )",
                                  (ldd->ld.interestRate / 100),
                                  ( ldd->ld.numPer
                                    * ( ldd->ld.perSize == GNC_MONTHS ? 1 : 12 
) ) * 1.,
@@ -940,7 +940,7 @@
  {
          g_assert( ldd != NULL );
          g_assert( gstr != NULL );
-        g_string_printf( gstr, "ppmt( %.5f / 12 : i : %0.2f : %0.2f : 0 : 0 )",
+        g_string_printf( gstr, "ppmt( %.5f / 12.0 : i : %0.2f : %0.2f : 0 : 0 )",
                           (ldd->ld.interestRate / 100),
                           ( ldd->ld.numPer
                             * ( ldd->ld.perSize == GNC_MONTHS ? 1 : 12 ) ) * 1.,
@@ -953,7 +953,7 @@
  {
          g_assert( ldd != NULL );
          g_assert( gstr != NULL );
-        g_string_printf( gstr, "ipmt( %.5f / 12 : i : %0.2f : %0.2f : 0 : 0 )",
+        g_string_printf( gstr, "ipmt( %.5f / 12.0 : i : %0.2f : %0.2f : 0 : 0 )",
                           (ldd->ld.interestRate / 100),
                           ( ldd->ld.numPer
                             * ( ldd->ld.perSize == GNC_MONTHS ? 1 : 12 ) ) * 1.,


More information about the gnucash-devel mailing list