[grisbi-cvs] grisbi/src gsb_currency.c, 1.54, 1.55 gsb_currency.h, 1.10, 1.11 gsb_data_transaction.c, 1.77, 1.78 gsb_form_transaction.c, 1.53, 1.54 gsb_form_widget.c, 1.41, 1.42 gsb_payment_method.c, 1.19, 1.20 utils_str.c, 1.75, 1.76

Pierre Biava pbiava at users.sourceforge.net
Wed Jan 13 20:30:18 CET 2010


Update of /cvsroot/grisbi/grisbi/src
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24599/src

Modified Files:
	gsb_currency.c gsb_currency.h gsb_data_transaction.c 
	gsb_form_transaction.c gsb_form_widget.c gsb_payment_method.c 
	utils_str.c 
Log Message:
fixed bug 850

Index: gsb_data_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- gsb_data_transaction.c	10 Dec 2009 22:02:32 -0000	1.77
+++ gsb_data_transaction.c	13 Jan 2010 19:30:14 -0000	1.78
@@ -37,6 +37,7 @@
 #include "./gsb_data_budget.h"
 #include "./gsb_data_category.h"
 #include "./gsb_data_currency.h"
+#include "./gsb_currency.h"
 #include "./gsb_data_currency_link.h"
 #include "./gsb_data_payee.h"
 #include "./gsb_data_payment.h"
@@ -765,8 +766,21 @@
 					   return_exponent );
 
     /* now we can adjust the amount */
-    if ( (link_number = gsb_data_currency_link_search ( transaction -> currency_number,
-							return_currency_number )))
+	/* the exchange is saved in the transaction itself */
+    if ( transaction -> exchange_rate.mantissa )
+    {
+        if ( transaction -> change_between_account_and_transaction )
+            amount = gsb_real_div ( transaction -> transaction_amount,
+                        transaction -> exchange_rate );
+        else
+            amount = gsb_real_mul ( transaction -> transaction_amount,
+                        transaction -> exchange_rate );
+
+        /* The costs are still deducted from the transaction. In case of internal transfer there is no charge. */
+        amount = gsb_real_sub (amount, transaction -> exchange_fees);
+    }
+    else if ( (link_number = gsb_data_currency_link_search ( transaction -> currency_number,
+							return_currency_number ) ) )
     {
 	/* there is a hard link between the transaction currency and the return currency */
         if ( gsb_data_currency_link_get_first_currency (link_number) == transaction -> currency_number)
@@ -781,20 +795,33 @@
     }
     else
     {
-	    /* no hard link between the 2 currencies, the exchange must have been saved in the transaction itself */
-        if ( transaction -> exchange_rate.mantissa )
-        {
-            if ( transaction -> change_between_account_and_transaction )
-            amount = gsb_real_div ( transaction -> transaction_amount,
-                        transaction -> exchange_rate );
-            else
-            amount = gsb_real_mul ( transaction -> transaction_amount,
-                        transaction -> exchange_rate );
+        gsb_real current_exchange;
+        gsb_real current_exchange_fees;
 
-            /* The costs are still deducted from the transaction. In case of internal transfer there is no charge. */
-            amount = gsb_real_sub (amount, transaction -> exchange_fees);
-        }
+        gsb_currency_exchange_dialog ( return_currency_number,
+                        transaction -> currency_number,
+                        0,
+                        null_real,
+                        null_real,
+                        TRUE );
+
+        current_exchange = gsb_currency_get_current_exchange ( );
+        current_exchange_fees = gsb_currency_get_current_exchange_fees ( );
+
+        gsb_data_transaction_set_exchange_rate ( transaction_number,
+                        gsb_real_abs ( current_exchange ) );
+        gsb_data_transaction_set_change_between (transaction_number, 0 );
+        amount = gsb_real_div ( transaction -> transaction_amount,
+                        current_exchange );
+
+        if ( transaction -> exchange_fees.mantissa == 0
+         && current_exchange_fees.mantissa != 0 )
+            amount = gsb_real_sub ( amount, current_exchange_fees );
+        else
+            amount = gsb_real_sub ( amount, transaction -> exchange_fees );
+            
     }
+
     return gsb_real_adjust_exponent  ( amount, return_exponent );
 }
 

Index: gsb_form_widget.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_widget.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- gsb_form_widget.c	15 Dec 2009 21:08:27 -0000	1.41
+++ gsb_form_widget.c	13 Jan 2010 19:30:15 -0000	1.42
@@ -798,6 +798,12 @@
                  * to hide the cheque element too */
                 if ( ! GTK_WIDGET_VISIBLE (widget) )
                     gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+                //~ else if ( gsb_data_payment_get_show_entry ( 0 ) )
+                //~ {
+                    //~ gtk_widget_show (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+                //~ }
+                //~ else
+                    //~ gsb_payment_method_changed_callback ( widget, NULL );
 
                 widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA );
                 if ( widget && GTK_WIDGET_VISIBLE ( widget ) )
@@ -838,6 +844,10 @@
                  * to hide the cheque element too */
                 if ( !GTK_WIDGET_VISIBLE (widget))
                     gtk_widget_hide (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+                //~ else if ( gsb_data_payment_get_show_entry ( 0 ) )
+                //~ {
+                    //~ gtk_widget_show (gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE));
+                //~ }
 
                 widget = gsb_form_widget_get_widget ( TRANSACTION_FORM_CONTRA);
                 if ( widget && GTK_WIDGET_VISIBLE ( widget ) )

Index: gsb_form_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form_transaction.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- gsb_form_transaction.c	3 Jan 2010 11:21:26 -0000	1.53
+++ gsb_form_transaction.c	13 Jan 2010 19:30:15 -0000	1.54
@@ -151,7 +151,9 @@
          &&
          element -> element_number != TRANSACTION_FORM_MODE
          && 
-         element -> element_number != TRANSACTION_FORM_TYPE )
+         element -> element_number != TRANSACTION_FORM_TYPE 
+         &&
+         element -> element_number != TRANSACTION_FORM_DEVISE )
     {
         gsb_form_fill_element ( element -> element_number,
                         account_number,

Index: gsb_currency.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_currency.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- gsb_currency.c	29 Nov 2009 21:53:43 -0000	1.54
+++ gsb_currency.c	13 Jan 2010 19:30:10 -0000	1.55
@@ -1049,6 +1049,17 @@
 }
 
 
+gsb_real gsb_currency_get_current_exchange ( void )
+{
+    return current_exchange;
+}
+
+
+gsb_real gsb_currency_get_current_exchange_fees ( void )
+{
+    return current_exchange_fees;
+}
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */

Index: gsb_payment_method.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_payment_method.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- gsb_payment_method.c	24 Aug 2009 13:56:59 -0000	1.19
+++ gsb_payment_method.c	13 Jan 2010 19:30:15 -0000	1.20
@@ -73,7 +73,7 @@
     GtkListStore *store;
     GSList *tmp_list;
     gint store_filled = 0;
-
+devel_debug_int (sign);
     if (!combo_box)
 	return FALSE;
 
@@ -139,9 +139,57 @@
     /* if nothing in the store, hide it */
     if (store_filled)
     {
-        gsb_payment_method_set_combobox_history ( combo_box,
-                        gsb_data_account_get_default_debit (account_number));
+        GtkWidget *cheque_entry;
+        gint payment_number = 0;
+
+        if ( sign == GSB_PAYMENT_DEBIT )
+            payment_number = gsb_data_account_get_default_debit ( account_number );
+        else if ( sign == GSB_PAYMENT_CREDIT )
+            payment_number = gsb_data_account_get_default_credit ( account_number );
+
+            gsb_payment_method_set_combobox_history ( combo_box, payment_number );
+//~ printf ("payment_number = %d\n", payment_number);            
         gtk_widget_show (combo_box);
+
+        cheque_entry = gsb_form_widget_get_widget ( TRANSACTION_FORM_CHEQUE );
+
+        if ( gsb_data_payment_get_show_entry ( payment_number) )
+        {
+            /* set the next number if needed */
+            printf ("show_entry payment_number = %d\n", payment_number);
+            if ( cheque_entry
+             &&
+             gsb_data_payment_get_automatic_numbering ( payment_number ) )
+            {
+                    gchar* tmpstr;
+
+                    gsb_form_entry_get_focus (cheque_entry);
+                    
+                    tmpstr = utils_str_itoa ( gsb_data_payment_get_last_number (
+                                payment_number ) + 1);
+                    gtk_entry_set_text ( GTK_ENTRY (cheque_entry), tmpstr);
+                    g_free ( tmpstr );
+                    gtk_widget_show (cheque_entry);
+            }
+            else if ( cheque_entry )
+            {
+                gtk_entry_set_text ( GTK_ENTRY (cheque_entry),
+                         "" );
+                gsb_form_entry_lose_focus ( cheque_entry,
+                            FALSE,
+                            GINT_TO_POINTER ( TRANSACTION_FORM_CHEQUE ));
+                gtk_widget_show (cheque_entry);
+            }
+        }
+        else if ( cheque_entry )
+        {
+            gtk_entry_set_text ( GTK_ENTRY (cheque_entry),
+                         "" );
+            gsb_form_entry_lose_focus ( cheque_entry,
+                            FALSE,
+                            GINT_TO_POINTER ( TRANSACTION_FORM_CHEQUE ));
+            gtk_widget_hide ( cheque_entry );
+        }
     }
     else
     {
@@ -346,7 +394,6 @@
     gint payment_number;
     GtkWidget *cheque_entry;
 
-    devel_debug (NULL);
     cheque_entry = gsb_form_widget_get_widget (TRANSACTION_FORM_CHEQUE);
     if ( !cheque_entry )
         return FALSE;
@@ -355,9 +402,12 @@
     if ( !payment_number )
         return FALSE;
 
+    devel_debug_int (payment_number);
+
     if ( gsb_data_payment_get_show_entry ( payment_number) )
     {
         /* set the next number if needed */
+        printf ("show_entry payment_number = %d\n", payment_number);
         if (gsb_data_payment_get_automatic_numbering (payment_number) )
         {
             /* pbiava the 03/15/09 fix the bug 493 */

Index: gsb_currency.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_currency.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- gsb_currency.h	7 Nov 2009 08:09:57 -0000	1.10
+++ gsb_currency.h	13 Jan 2010 19:30:14 -0000	1.11
@@ -22,5 +22,7 @@
 gboolean gsb_currency_set_combobox_history ( GtkWidget *combo_box,
                         gint currency_number );
 gboolean gsb_currency_update_combobox_currency_list ( void );
+gsb_real gsb_currency_get_current_exchange ( void );
+gsb_real gsb_currency_get_current_exchange_fees ( void );
 /* END_DECLARATION */
 #endif

Index: utils_str.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/utils_str.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- utils_str.c	12 Jan 2010 20:10:23 -0000	1.75
+++ utils_str.c	13 Jan 2010 19:30:15 -0000	1.76
@@ -109,7 +109,7 @@
     gchar *return_string;
     gchar *p;
     gchar *mon_decimal_point;
-    gunichar decimal_point = -1;
+    gunichar decimal_point = (gunichar )-2;
     struct lconv *conv = localeconv ( );
 
     if ( !amount_string )



More information about the cvs mailing list