r23512 - gnucash/branches/2.4/src/gnome - [23497] Fix bug 653594 related to check printing.
Mike Alexander
mta at code.gnucash.org
Sat Dec 7 18:30:19 EST 2013
Author: mta
Date: 2013-12-07 18:30:18 -0500 (Sat, 07 Dec 2013)
New Revision: 23512
Trac: http://svn.gnucash.org/trac/changeset/23512
Modified:
gnucash/branches/2.4/src/gnome/dialog-print-check.c
gnucash/branches/2.4/src/gnome/gnc-plugin-page-register.c
Log:
[23497] Fix bug 653594 related to check printing.
This bug has two parts. The original bug was that the wrong split is sometimes
used to print the check. In the comments a second problem was mentioned:
sometimes the wrong split is omitted from the split list in formats that print
all the splits.
Modified: gnucash/branches/2.4/src/gnome/dialog-print-check.c
===================================================================
--- gnucash/branches/2.4/src/gnome/dialog-print-check.c 2013-12-07 23:14:59 UTC (rev 23511)
+++ gnucash/branches/2.4/src/gnome/dialog-print-check.c 2013-12-07 23:30:18 UTC (rev 23512)
@@ -403,31 +403,29 @@
get_check_splits_amount(PrintCheckDialog *pcd)
{
gchar* amount = NULL;
- gchar* amt_temp;
- int cnt;
- const gchar* split_amount;
- int nSplits;
Transaction *trans;
- Split *split;
GList *node;
SplitList* s_list;
trans = xaccSplitGetParent(pcd->split);
- nSplits = xaccTransCountSplits(trans);
s_list = xaccTransGetSplitList(trans);
if ( !s_list ) return NULL;
amount = g_strconcat("", NULL);
node = s_list;
- cnt = 1;
- while ( cnt < nSplits )
+ while ( node )
{
- cnt++;
- split = node->data;
- split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
- amt_temp = amount;
- amount = g_strconcat(amt_temp, "\n", split_amount, NULL);
- g_free(amt_temp);
+ Split *split = node->data;
+ /* Include all splits except the main split for the check */
+ if (split != pcd->split)
+ {
+ const gchar* split_amount;
+ gchar* amt_temp;
+ split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
+ amt_temp = amount;
+ amount = g_strconcat(amt_temp, "\n", split_amount, NULL);
+ g_free(amt_temp);
+ }
node = node->next;
}
return amount;
@@ -438,31 +436,29 @@
get_check_splits_memo(PrintCheckDialog *pcd)
{
gchar* memo = NULL;
- gchar* memo_temp;
- int cnt;
const gchar* split_memo;
- int nSplits;
Transaction *trans;
- Split *split;
GList *node;
SplitList* s_list;
trans = xaccSplitGetParent(pcd->split);
- nSplits = xaccTransCountSplits(trans);
s_list = xaccTransGetSplitList(trans);
if ( !s_list ) return NULL;
memo = g_strconcat("", NULL);
node = s_list;
- cnt = 1;
- while ( cnt < nSplits )
+ while ( node )
{
- cnt++;
- split = node->data;
- split_memo = xaccSplitGetMemo(split);
- memo_temp = memo;
- memo = g_strconcat(memo_temp, "\n", split_memo, NULL);
- g_free(memo_temp);
+ Split *split = node->data;
+ /* Include all splits except the main split for the check */
+ if (split != pcd->split)
+ {
+ gchar* memo_temp;
+ split_memo = xaccSplitGetMemo(split);
+ memo_temp = memo;
+ memo = g_strconcat(memo_temp, "\n", split_memo, NULL);
+ g_free(memo_temp);
+ }
node = node->next;
}
return memo;
@@ -473,33 +469,31 @@
get_check_splits_account(PrintCheckDialog *pcd)
{
gchar* account = NULL;
- gchar* account_temp;
- int cnt;
- const gchar* aName = NULL;
- int nSplits;
- Account *pAccount;
Transaction *trans;
- Split *split;
GList *node;
SplitList* s_list;
trans = xaccSplitGetParent(pcd->split);
- nSplits = xaccTransCountSplits(trans);
s_list = xaccTransGetSplitList(trans);
if ( !s_list ) return NULL;
account = g_strconcat("", NULL);
node = s_list;
- cnt = 1;
- while ( cnt < nSplits )
+ while ( node )
{
- cnt++;
- split = node->data;
- pAccount = xaccSplitGetAccount(split);
- aName = gnc_get_account_name_for_register(pAccount);
- account_temp = account;
- account = g_strconcat(account_temp, "\n", aName, NULL);
- g_free(account_temp);
+ Split *split = node->data;
+ /* Include all splits except the main split for the check */
+ if (split != pcd->split)
+ {
+ gchar* account_temp;
+ const gchar* aName = NULL;
+ Account *pAccount;
+ pAccount = xaccSplitGetAccount(split);
+ aName = gnc_get_account_name_for_register(pAccount);
+ account_temp = account;
+ account = g_strconcat(account_temp, "\n", aName, NULL);
+ g_free(account_temp);
+ }
node = node->next;
}
return account;
Modified: gnucash/branches/2.4/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/branches/2.4/src/gnome/gnc-plugin-page-register.c 2013-12-07 23:14:59 UTC (rev 23511)
+++ gnucash/branches/2.4/src/gnome/gnc-plugin-page-register.c 2013-12-07 23:30:18 UTC (rev 23512)
@@ -2088,6 +2088,7 @@
Transaction * trans;
GList * splits = NULL, *item;
GNCLedgerDisplayType ledger_type;
+ Account * account;
ENTER("(action %p, plugin_page %p)", action, plugin_page);
@@ -2098,14 +2099,30 @@
ledger_type = gnc_ledger_display_type(priv->ledger);
if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
{
+ account = gnc_plugin_page_register_get_account (plugin_page);
split = gnc_split_register_get_current_split(reg);
trans = xaccSplitGetParent(split);
if (split && trans)
{
- splits = g_list_append(splits, split);
- gnc_ui_print_check_dialog_create(plugin_page, splits);
- g_list_free(splits);
+ if (xaccSplitGetAccount(split) == account)
+ {
+ splits = g_list_append(splits, split);
+ gnc_ui_print_check_dialog_create(plugin_page, splits);
+ g_list_free(splits);
+ }
+ else
+ {
+ /* This split is not for the account shown in this register. Get the
+ split that anchors the transaction to the registor */
+ split = gnc_split_register_get_current_trans_split(reg, NULL);
+ if (split)
+ {
+ splits = g_list_append(splits, split);
+ gnc_ui_print_check_dialog_create(plugin_page, splits);
+ g_list_free(splits);
+ }
+ }
}
}
else if (ledger_type == LD_GL && reg->type == SEARCH_LEDGER)
More information about the gnucash-changes
mailing list