[grisbi-cvs] grisbi/src gsb_data_transaction.c, 1.54, 1.55 gsb_data_transaction.h, 1.26, 1.27 gsb_file_save.c, 1.110, 1.111 gsb_form.c, 1.109, 1.110 gsb_transactions_list.c, 1.152, 1.153 transaction_list.c, 1.27, 1.28

Pierre Biava pbiava at users.sourceforge.net
Sun Feb 15 21:01:28 CET 2009


Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16981/src

Modified Files:
	gsb_data_transaction.c gsb_data_transaction.h gsb_file_save.c 
	gsb_form.c gsb_transactions_list.c transaction_list.c 
Log Message:
Fix bug 417

Index: gsb_data_transaction.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- gsb_data_transaction.c	25 Oct 2008 13:57:29 -0000	1.54
+++ gsb_data_transaction.c	15 Feb 2009 20:01:26 -0000	1.55
@@ -58,6 +58,7 @@
     gchar *transaction_id;				/**< filled by ofx */
     gint account_number;
     gsb_real transaction_amount;
+    gint transaction_sign;              /*< GSB_PAYMENT_DEBIT 1, GSB_PAYMENT_CREDIT 2 pbiava 02/14/2009 */
     gint party_number;
     gchar *notes;
     gint marked_transaction;				/**<  OPERATION_NORMALE=nothing, OPERATION_POINTEE=P, OPERATION_TELERAPPROCHEE=T, OPERATION_RAPPROCHEE=R */
@@ -2533,4 +2534,44 @@
 }
 
 
+/**
+ * get the  transaction_sign
+ * 
+ * \param transaction_number the number of the transaction
+ * 
+ * \return the sign of the transaction
+ * */
+gint gsb_data_transaction_get_sign ( gint transaction_number )
+{
+    struct_transaction *transaction;
 
+    transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
+
+    if ( !transaction )
+        return -1;
+
+    return transaction -> transaction_sign;
+}
+
+
+/**
+ * set the  transaction_sign
+ * 
+ * \param transaction_number the number of the transaction
+ * \param sign of the transaction = GSB_PAYMENT_DEBIT 1, GSB_PAYMENT_CREDIT 2
+ * 
+ * \return \return TRUE if ok
+ * */
+gint gsb_data_transaction_set_sign ( gint transaction_number, gint sign )
+{
+    struct_transaction *transaction;
+
+    transaction = gsb_data_transaction_get_transaction_by_no ( transaction_number);
+
+    if ( !transaction )
+        return -1;
+
+    transaction -> transaction_sign = sign;
+
+    return TRUE;
+}

Index: gsb_transactions_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_transactions_list.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- gsb_transactions_list.c	12 Feb 2009 20:51:37 -0000	1.152
+++ gsb_transactions_list.c	15 Feb 2009 20:01:26 -0000	1.153
@@ -721,19 +721,22 @@
 							   NULL )));
 
 	case ELEMENT_DEBIT:
+        /* give the amount of the transaction on the transaction currency */
+        if ( gsb_data_transaction_get_sign ( transaction_number ) == GSB_PAYMENT_DEBIT )
+		return gsb_real_get_string_with_currency ( gsb_real_abs (
+                        gsb_data_transaction_get_amount ( transaction_number )),
+                        gsb_data_transaction_get_currency_number (transaction_number), TRUE);
+	    else
+            return NULL;
+	    break;
 	case ELEMENT_CREDIT:
 	    /* give the amount of the transaction on the transaction currency */
-	    if ( (cell_content_number == ELEMENT_DEBIT
-		  &&
-		  gsb_data_transaction_get_amount ( transaction_number).mantissa < 0 )
-		 ||
-		 (cell_content_number == ELEMENT_CREDIT
-		  &&
-		  gsb_data_transaction_get_amount ( transaction_number).mantissa >= 0 ))
-		return gsb_real_get_string_with_currency ( gsb_real_abs (gsb_data_transaction_get_amount ( transaction_number )),
-							   gsb_data_transaction_get_currency_number (transaction_number), TRUE);
+        if ( gsb_data_transaction_get_sign ( transaction_number ) == GSB_PAYMENT_CREDIT )
+		return gsb_real_get_string_with_currency ( gsb_real_abs (
+                        gsb_data_transaction_get_amount ( transaction_number )),
+                        gsb_data_transaction_get_currency_number (transaction_number), TRUE);
 	    else
-		return NULL;
+            return NULL;
 	    break;
 
 	case ELEMENT_BALANCE:

Index: gsb_form.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_form.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
--- gsb_form.c	13 Feb 2009 21:31:37 -0000	1.109
+++ gsb_form.c	15 Feb 2009 20:01:26 -0000	1.110
@@ -704,12 +704,12 @@
 	    break;
 
 	case TRANSACTION_FORM_DEBIT:
-	    if (gsb_data_mix_get_amount (transaction_number, is_transaction).mantissa < 0)
+        /* changed by pbiava on the 02/14//2009 fix bug 417 */
+	    if ( gsb_data_transaction_get_sign ( transaction_number ) == GSB_PAYMENT_DEBIT )
 	    {
 		char_tmp = gsb_real_get_string_with_currency (gsb_real_abs (gsb_data_mix_get_amount (transaction_number, is_transaction)),
 							      gsb_data_mix_get_currency_number (transaction_number, is_transaction),
 							      FALSE );
-
 		gsb_form_entry_get_focus (widget);
 		gtk_entry_set_text ( GTK_ENTRY ( widget ),
 				     char_tmp );
@@ -718,7 +718,8 @@
 	    break;
 
 	case TRANSACTION_FORM_CREDIT:
-	    if (gsb_data_mix_get_amount (transaction_number, is_transaction).mantissa >= 0)
+        /* changed by pbiava on the 02/14//2009 fix bug 417 */
+	    if ( gsb_data_transaction_get_sign ( transaction_number ) == GSB_PAYMENT_CREDIT )
 	    {
 		char_tmp = gsb_real_get_string_with_currency (gsb_data_mix_get_amount (transaction_number, is_transaction),
 							      gsb_data_mix_get_currency_number (transaction_number, is_transaction),
@@ -2672,13 +2673,25 @@
 		break;
 
 	    case TRANSACTION_FORM_DEBIT:
-		if (!gsb_form_widget_check_empty (element -> element_widget)) 
-		    gsb_data_mix_set_amount ( transaction_number, gsb_real_opposite (gsb_utils_edit_calculate_entry ( element -> element_widget )), is_transaction);
-		break;
+		if (!gsb_form_widget_check_empty (element -> element_widget))
+        {
+		    gsb_data_mix_set_amount ( transaction_number, gsb_real_opposite 
+                        (gsb_utils_edit_calculate_entry ( 
+                        element -> element_widget )), is_transaction);
+            gsb_data_transaction_set_sign ( transaction_number, 
+                        GSB_PAYMENT_DEBIT );
+        }
+        break;
 
 	    case TRANSACTION_FORM_CREDIT:
-		if (!gsb_form_widget_check_empty (element -> element_widget)) 
-		    gsb_data_mix_set_amount ( transaction_number, gsb_utils_edit_calculate_entry ( element -> element_widget ), is_transaction);
+		if (!gsb_form_widget_check_empty (element -> element_widget))
+        {
+		    gsb_data_mix_set_amount ( transaction_number, gsb_real_opposite 
+                        (gsb_utils_edit_calculate_entry ( 
+                        element -> element_widget )), is_transaction);
+            gsb_data_transaction_set_sign ( transaction_number, 
+                        GSB_PAYMENT_CREDIT );
+        }
 		break;
 
 	    case TRANSACTION_FORM_BUDGET:

Index: gsb_file_save.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_file_save.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- gsb_file_save.c	24 Jan 2009 17:56:58 -0000	1.110
+++ gsb_file_save.c	15 Feb 2009 20:01:26 -0000	1.111
@@ -1102,6 +1102,10 @@
 
 	/* set the reals */
 	amount = gsb_real_get_string (gsb_data_transaction_get_amount ( transaction_number ));
+    /* added by pbiava on the 02/14//2009 fix bug 417 */
+    if ( strcmp (amount, "0") == 0 && 
+                        gsb_data_transaction_get_sign ( transaction_number ) == GSB_PAYMENT_DEBIT )
+        amount = g_strconcat ( "-", amount, NULL );
 	exchange_rate = gsb_real_get_string (gsb_data_transaction_get_exchange_rate (transaction_number ));
 	exchange_fees = gsb_real_get_string (gsb_data_transaction_get_exchange_fees ( transaction_number));
 	
@@ -1111,34 +1115,34 @@
 
 	/* now we can fill the file content */
 	new_string = g_markup_printf_escaped ( "\t<Transaction Ac=\"%d\" Nb=\"%d\" Id=\"%s\" Dt=\"%s\" Dv=\"%s\" Cu=\"%d\" Am=\"%s\" Exb=\"%d\" Exr=\"%s\" Exf=\"%s\" Pa=\"%d\" Ca=\"%d\" Sca=\"%d\" Br=\"%d\" No=\"%s\" Pn=\"%d\" Pc=\"%s\" Ma=\"%d\" Ar=\"%d\" Au=\"%d\" Re=\"%d\" Fi=\"%d\" Bu=\"%d\" Sbu=\"%d\" Vo=\"%s\" Ba=\"%s\" Trt=\"%d\" Mo=\"%d\" />\n",
-					       gsb_data_transaction_get_account_number ( transaction_number ),
-					       transaction_number,
-					       gsb_data_transaction_get_transaction_id ( transaction_number),
-					       date,
-					       value_date,
-					       gsb_data_transaction_get_currency_number (transaction_number ),
-					       amount,
-					       gsb_data_transaction_get_change_between (transaction_number ),
-					       exchange_rate,
-					       exchange_fees,
-					       gsb_data_transaction_get_party_number ( transaction_number),
-					       gsb_data_transaction_get_category_number ( transaction_number),
-					       gsb_data_transaction_get_sub_category_number (transaction_number),
-					       gsb_data_transaction_get_split_of_transaction (transaction_number),
-					       gsb_data_transaction_get_notes (transaction_number),
-					       gsb_data_transaction_get_method_of_payment_number (transaction_number),
-					       gsb_data_transaction_get_method_of_payment_content (transaction_number),
-					       gsb_data_transaction_get_marked_transaction (transaction_number),
-					       transaction_archive_number,
-					       gsb_data_transaction_get_automatic_transaction (transaction_number),
-					       gsb_data_transaction_get_reconcile_number (transaction_number),
-					       gsb_data_transaction_get_financial_year_number (transaction_number),
-					       gsb_data_transaction_get_budgetary_number (transaction_number),
-					       gsb_data_transaction_get_sub_budgetary_number (transaction_number),
-					       gsb_data_transaction_get_voucher (transaction_number),
-					       gsb_data_transaction_get_bank_references (transaction_number),
-					       gsb_data_transaction_get_contra_transaction_number (transaction_number),
-					       gsb_data_transaction_get_mother_transaction_number (transaction_number));
+                        gsb_data_transaction_get_account_number ( transaction_number ),
+                        transaction_number,
+                        gsb_data_transaction_get_transaction_id ( transaction_number),
+					    date,
+					    value_date,
+                        gsb_data_transaction_get_currency_number (transaction_number ),
+                        amount,
+                        gsb_data_transaction_get_change_between (transaction_number ),
+                        exchange_rate,
+                        exchange_fees,
+                        gsb_data_transaction_get_party_number ( transaction_number),
+                        gsb_data_transaction_get_category_number ( transaction_number),
+                        gsb_data_transaction_get_sub_category_number (transaction_number),
+                        gsb_data_transaction_get_split_of_transaction (transaction_number),
+                        gsb_data_transaction_get_notes (transaction_number),
+                        gsb_data_transaction_get_method_of_payment_number (transaction_number),
+                        gsb_data_transaction_get_method_of_payment_content (transaction_number),
+                        gsb_data_transaction_get_marked_transaction (transaction_number),
+                        transaction_archive_number,
+                        gsb_data_transaction_get_automatic_transaction (transaction_number),
+                        gsb_data_transaction_get_reconcile_number (transaction_number),
+                        gsb_data_transaction_get_financial_year_number (transaction_number),
+                        gsb_data_transaction_get_budgetary_number (transaction_number),
+                        gsb_data_transaction_get_sub_budgetary_number (transaction_number),
+                        gsb_data_transaction_get_voucher (transaction_number),
+                        gsb_data_transaction_get_bank_references (transaction_number),
+                        gsb_data_transaction_get_contra_transaction_number (transaction_number),
+                        gsb_data_transaction_get_mother_transaction_number (transaction_number));
 
 	g_free (amount);
 	g_free (exchange_rate);

Index: transaction_list.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/transaction_list.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- transaction_list.c	7 Dec 2008 08:52:28 -0000	1.27
+++ transaction_list.c	15 Feb 2009 20:01:26 -0000	1.28
@@ -934,6 +934,7 @@
     custom_list = transaction_model_get_model ();
 
     g_return_val_if_fail ( custom_list != NULL, FALSE);
+    devel_debug_int (transaction_number);
 
     /* we can update a transaction wich is not visible, so need to find the iter into
      * all the transactions */
@@ -1075,7 +1076,7 @@
     gint line_element;
 
     /* for now, this is the same position for all accounts, so no problem */
-
+    devel_debug_int (element_number);
     /* get the position of the element */
     column_element = find_element_col (element_number);		/*  0 to CUSTOM_MODEL_N_VISIBLES_COLUMN */
     line_element = find_element_line (element_number);		/*  0 to TRANSACTION_LIST_ROWS_NB */

Index: gsb_data_transaction.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/gsb_data_transaction.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- gsb_data_transaction.h	25 Oct 2008 13:07:53 -0000	1.26
+++ gsb_data_transaction.h	15 Feb 2009 20:01:26 -0000	1.27
@@ -127,6 +127,8 @@
 					       const GDate *date );
 gboolean gsb_data_transaction_set_voucher ( gint transaction_number,
 					    const gchar *voucher );
+gint gsb_data_transaction_get_sign ( gint transaction_number );
+gboolean gsb_data_transaction_set_sign ( gint transaction_number, gint sign );
 /* END_DECLARATION */
 
 



More information about the cvs mailing list