[Gnucash-changes] r13575 - gnucash/trunk/src/register/ledger-core - More register line wraps, clean-ups, etc., plus some minor re-ordering

Chris Shoemaker chris at cvs.gnucash.org
Thu Mar 9 21:28:28 EST 2006


Author: chris
Date: 2006-03-09 21:28:28 -0500 (Thu, 09 Mar 2006)
New Revision: 13575
Trac: http://svn.gnucash.org/trac/changeset/13575

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-control.c
   gnucash/trunk/src/register/ledger-core/split-register-p.h
   gnucash/trunk/src/register/ledger-core/split-register.c
Log:
   More register line wraps, clean-ups, etc., plus some minor re-ordering
   to prepare for some factoring.


Modified: gnucash/trunk/src/register/ledger-core/split-register-control.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-control.c	2006-03-09 22:58:36 UTC (rev 13574)
+++ gnucash/trunk/src/register/ledger-core/split-register-control.c	2006-03-10 02:28:28 UTC (rev 13575)
@@ -959,7 +959,7 @@
 
   /* If 'name' is "-- Split Transaction --" then return NULL or the
      register acct */
-  if (!safe_strcmp (name, _("-- Split Transaction --"))) {
+  if (!safe_strcmp (name, SPLIT_TRANS_STR)) {
     return NULL;
   }
 
@@ -1044,7 +1044,7 @@
     _("You need to expand the transaction in order to modify its exchange rates.");
 
   /* If this is an un-expanded, multi-split transaction, then warn the user */
-  if (force_dialog && !expanded && ! xfer_acc) {
+  if (force_dialog && !expanded && !xfer_acc) {
     gnc_error_dialog (gnc_split_register_get_parent (reg), message);
     return TRUE;
   }
@@ -1098,6 +1098,20 @@
     return TRUE;
   }
 
+  /* Strangely, if we're in a two-split, non-expanded txn, we need
+   * to do something really special with the exchange rate!  In
+   * particular, we have to pick it up from the _other_ split --
+   * right?
+   * XXX: perhaps I should pop up an error here?  Or maybe require the
+   * user to go into expanded-mode?
+   */
+  if (!expanded && osplit && !gnc_commodity_equal(reg_com, txn_cur) && 
+      !gnc_commodity_equal(reg_com, xfer_com)) {
+      gnc_numeric amt = xaccSplitGetAmount (osplit);
+      gnc_numeric val = xaccSplitGetValue (osplit);
+      exch_rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
+  }
+
   /* Ok, we need to grab the exchange rate */
   amount = gnc_split_register_debcred_cell_value (reg);
 
@@ -1116,11 +1130,25 @@
       split != gnc_split_register_get_blank_split (reg))
     return FALSE;
 
+  /* create the exchange-rate dialog */
+  xfer = gnc_xfer_dialog (NULL, NULL); /* XXX */
+  gnc_xfer_dialog_is_exchange_dialog (xfer, &exch_rate);
 
+  /* fill in the dialog entries */
+  gnc_xfer_dialog_set_description(
+      xfer, gnc_split_register_get_cell_string (reg, DESC_CELL));
+  gnc_xfer_dialog_set_memo(
+      xfer, gnc_split_register_get_cell_string (reg, MEMO_CELL));
+  gnc_xfer_dialog_set_num(
+      xfer, gnc_split_register_get_cell_string (reg, NUM_CELL));
+  gnc_xfer_dialog_set_date(
+      xfer, timespecToTime_t(
+          gnc_split_register_get_cell_date(reg, DATE_CELL)));
+
   /* We know that "amount" is always in the reg_com currency.
    * Unfortunately it is possible that neither xfer_com or txn_cur are
    * the same as reg_com, in which case we need to convert to the txn
-   * currency...  Or, if the local currency is the xfer_com, then we
+   * currency...  Or, if the register commodity is the xfer_com, then we
    * need to flip-flop the commodities and the exchange rates.
    */
 
@@ -1143,25 +1171,8 @@
     /* XXX: should we tell the user we've done the conversion? */
     amount = gnc_numeric_div(
         amount, rate, gnc_commodity_get_fraction (txn_cur), GNC_DENOM_REDUCE);
-
-    /* Strangely, if we're in a two-split, non-expanded txn, we need
-     * to do something really special with the exchange rate!  In
-     * particular, we have to pick it up from the _other_ split --
-     * right?
-     * XXX: perhaps I should pop up an error here?  Or maybe require the
-     * user to go into expanded-mode?
-     */
-    if (osplit && !expanded) {
-      gnc_numeric amt = xaccSplitGetAmount (osplit);
-      gnc_numeric val = xaccSplitGetValue (osplit);
-      exch_rate = gnc_numeric_div (amt, val, GNC_DENOM_AUTO, GNC_DENOM_REDUCE);
-    }
   }
 
-  /* create the exchange-rate dialog */
-  xfer = gnc_xfer_dialog (NULL, NULL); /* XXX */
-  gnc_xfer_dialog_is_exchange_dialog (xfer, &exch_rate);
-
   /* enter the accounts */
   if (swap_amounts) {
     gnc_xfer_dialog_select_to_currency (xfer, txn_cur);
@@ -1176,17 +1187,7 @@
   gnc_xfer_dialog_hide_to_account_tree (xfer);
   gnc_xfer_dialog_hide_from_account_tree (xfer);
 
-  /* fill in the dialog entries */
   gnc_xfer_dialog_set_amount (xfer, amount);
-  gnc_xfer_dialog_set_description(
-      xfer, gnc_split_register_get_cell_string (reg, DESC_CELL));
-  gnc_xfer_dialog_set_memo(
-      xfer, gnc_split_register_get_cell_string (reg, MEMO_CELL));
-  gnc_xfer_dialog_set_num(
-      xfer, gnc_split_register_get_cell_string (reg, NUM_CELL));
-  gnc_xfer_dialog_set_date(
-      xfer, timespecToTime_t(
-          gnc_split_register_get_cell_date(reg, DATE_CELL)));
 
   /*
    * When we flip, we should tell the dialog so it can deal with the

Modified: gnucash/trunk/src/register/ledger-core/split-register-p.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-p.h	2006-03-09 22:58:36 UTC (rev 13574)
+++ gnucash/trunk/src/register/ledger-core/split-register-p.h	2006-03-10 02:28:28 UTC (rev 13575)
@@ -149,8 +149,8 @@
 
 void gnc_split_register_set_last_num (SplitRegister *reg, const char *num);
 
-Account * gnc_split_register_get_account_by_name (SplitRegister *reg, BasicCell * cell,
-						  const char *name, gboolean *new);
+Account * gnc_split_register_get_account_by_name(
+    SplitRegister *reg, BasicCell * cell, const char *name, gboolean *new);
 Account * gnc_split_register_get_account (SplitRegister *reg,
                                           const char *cell_name);
 
@@ -164,7 +164,9 @@
  * transaction, and if so, what conversion we need
  */
 gboolean gnc_split_reg_has_rate_cell (SplitRegisterType type);
-gboolean gnc_split_register_split_needs_amount (SplitRegister *reg, Split *split);
-gboolean gnc_split_register_needs_conv_rate (SplitRegister *reg, Transaction *txn, Account *acc);
+gboolean gnc_split_register_split_needs_amount(
+    SplitRegister *reg, Split *split);
+gboolean gnc_split_register_needs_conv_rate(
+    SplitRegister *reg, Transaction *txn, Account *acc);
 
 #endif

Modified: gnucash/trunk/src/register/ledger-core/split-register.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register.c	2006-03-09 22:58:36 UTC (rev 13574)
+++ gnucash/trunk/src/register/ledger-core/split-register.c	2006-03-10 02:28:28 UTC (rev 13575)
@@ -2102,12 +2102,12 @@
   gnc_combo_cell_add_ignore_string
     ((ComboCell *)
      gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL),
-     _("-- Split Transaction --"));
+     SPLIT_TRANS_STR);
 
   gnc_combo_cell_add_ignore_string
     ((ComboCell *)
      gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL),
-     _("-- Stock Split --"));
+     STOCK_SPLIT_STR);
 
   /* the action cell */
   gnc_combo_cell_set_autosize



More information about the gnucash-changes mailing list