mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@23497 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
80b51ad5dd
commit
0d3d2c33b8
@ -381,31 +381,29 @@ gchar *
|
|||||||
get_check_splits_amount(PrintCheckDialog *pcd)
|
get_check_splits_amount(PrintCheckDialog *pcd)
|
||||||
{
|
{
|
||||||
gchar* amount = NULL;
|
gchar* amount = NULL;
|
||||||
gchar* amt_temp;
|
|
||||||
int cnt;
|
|
||||||
const gchar* split_amount;
|
|
||||||
int nSplits;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
|
||||||
GList *node;
|
GList *node;
|
||||||
SplitList* s_list;
|
SplitList* s_list;
|
||||||
|
|
||||||
trans = xaccSplitGetParent(pcd->split);
|
trans = xaccSplitGetParent(pcd->split);
|
||||||
nSplits = xaccTransCountSplits(trans);
|
|
||||||
s_list = xaccTransGetSplitList(trans);
|
s_list = xaccTransGetSplitList(trans);
|
||||||
if ( !s_list ) return NULL;
|
if ( !s_list ) return NULL;
|
||||||
|
|
||||||
amount = g_strconcat("", NULL);
|
amount = g_strconcat("", NULL);
|
||||||
node = s_list;
|
node = s_list;
|
||||||
cnt = 1;
|
while ( node )
|
||||||
while ( cnt < nSplits )
|
|
||||||
{
|
{
|
||||||
cnt++;
|
Split *split = node->data;
|
||||||
split = node->data;
|
/* Include all splits except the main split for the check */
|
||||||
split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
|
if (split != pcd->split)
|
||||||
amt_temp = amount;
|
{
|
||||||
amount = g_strconcat(amt_temp, "\n", split_amount, NULL);
|
const gchar* split_amount;
|
||||||
g_free(amt_temp);
|
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;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
@ -418,31 +416,29 @@ gchar *
|
|||||||
get_check_splits_memo(PrintCheckDialog *pcd)
|
get_check_splits_memo(PrintCheckDialog *pcd)
|
||||||
{
|
{
|
||||||
gchar* memo = NULL;
|
gchar* memo = NULL;
|
||||||
gchar* memo_temp;
|
|
||||||
int cnt;
|
|
||||||
const gchar* split_memo;
|
const gchar* split_memo;
|
||||||
int nSplits;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
|
||||||
GList *node;
|
GList *node;
|
||||||
SplitList* s_list;
|
SplitList* s_list;
|
||||||
|
|
||||||
trans = xaccSplitGetParent(pcd->split);
|
trans = xaccSplitGetParent(pcd->split);
|
||||||
nSplits = xaccTransCountSplits(trans);
|
|
||||||
s_list = xaccTransGetSplitList(trans);
|
s_list = xaccTransGetSplitList(trans);
|
||||||
if ( !s_list ) return NULL;
|
if ( !s_list ) return NULL;
|
||||||
|
|
||||||
memo = g_strconcat("", NULL);
|
memo = g_strconcat("", NULL);
|
||||||
node = s_list;
|
node = s_list;
|
||||||
cnt = 1;
|
while ( node )
|
||||||
while ( cnt < nSplits )
|
|
||||||
{
|
{
|
||||||
cnt++;
|
Split *split = node->data;
|
||||||
split = node->data;
|
/* Include all splits except the main split for the check */
|
||||||
split_memo = xaccSplitGetMemo(split);
|
if (split != pcd->split)
|
||||||
memo_temp = memo;
|
{
|
||||||
memo = g_strconcat(memo_temp, "\n", split_memo, NULL);
|
gchar* memo_temp;
|
||||||
g_free(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;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return memo;
|
return memo;
|
||||||
@ -455,33 +451,31 @@ gchar *
|
|||||||
get_check_splits_account(PrintCheckDialog *pcd)
|
get_check_splits_account(PrintCheckDialog *pcd)
|
||||||
{
|
{
|
||||||
gchar* account = NULL;
|
gchar* account = NULL;
|
||||||
gchar* account_temp;
|
|
||||||
int cnt;
|
|
||||||
const gchar* aName = NULL;
|
|
||||||
int nSplits;
|
|
||||||
Account *pAccount;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
|
||||||
GList *node;
|
GList *node;
|
||||||
SplitList* s_list;
|
SplitList* s_list;
|
||||||
|
|
||||||
trans = xaccSplitGetParent(pcd->split);
|
trans = xaccSplitGetParent(pcd->split);
|
||||||
nSplits = xaccTransCountSplits(trans);
|
|
||||||
s_list = xaccTransGetSplitList(trans);
|
s_list = xaccTransGetSplitList(trans);
|
||||||
if ( !s_list ) return NULL;
|
if ( !s_list ) return NULL;
|
||||||
|
|
||||||
account = g_strconcat("", NULL);
|
account = g_strconcat("", NULL);
|
||||||
node = s_list;
|
node = s_list;
|
||||||
cnt = 1;
|
while ( node )
|
||||||
while ( cnt < nSplits )
|
|
||||||
{
|
{
|
||||||
cnt++;
|
Split *split = node->data;
|
||||||
split = node->data;
|
/* Include all splits except the main split for the check */
|
||||||
pAccount = xaccSplitGetAccount(split);
|
if (split != pcd->split)
|
||||||
aName = gnc_get_account_name_for_register(pAccount);
|
{
|
||||||
account_temp = account;
|
gchar* account_temp;
|
||||||
account = g_strconcat(account_temp, "\n", aName, NULL);
|
const gchar* aName = NULL;
|
||||||
g_free(account_temp);
|
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;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return account;
|
return account;
|
||||||
|
@ -381,31 +381,29 @@ gchar *
|
|||||||
get_check_splits_amount2(PrintCheckDialog *pcd)
|
get_check_splits_amount2(PrintCheckDialog *pcd)
|
||||||
{
|
{
|
||||||
gchar* amount = NULL;
|
gchar* amount = NULL;
|
||||||
gchar* amt_temp;
|
|
||||||
int cnt;
|
|
||||||
const gchar* split_amount;
|
|
||||||
int nSplits;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
|
||||||
GList *node;
|
GList *node;
|
||||||
SplitList* s_list;
|
SplitList* s_list;
|
||||||
|
|
||||||
trans = xaccSplitGetParent(pcd->split);
|
trans = xaccSplitGetParent(pcd->split);
|
||||||
nSplits = xaccTransCountSplits(trans);
|
|
||||||
s_list = xaccTransGetSplitList(trans);
|
s_list = xaccTransGetSplitList(trans);
|
||||||
if ( !s_list ) return NULL;
|
if ( !s_list ) return NULL;
|
||||||
|
|
||||||
amount = g_strconcat("", NULL);
|
amount = g_strconcat("", NULL);
|
||||||
node = s_list;
|
node = s_list;
|
||||||
cnt = 1;
|
while ( node )
|
||||||
while ( cnt < nSplits )
|
|
||||||
{
|
{
|
||||||
cnt++;
|
Split *split = node->data;
|
||||||
split = node->data;
|
/* Include all splits except the main split for the check */
|
||||||
split_amount = xaccPrintAmount(xaccSplitGetAmount(split), gnc_split_amount_print_info(split, TRUE));
|
if (split != pcd->split)
|
||||||
amt_temp = amount;
|
{
|
||||||
amount = g_strconcat(amt_temp, "\n", split_amount, NULL);
|
const gchar* split_amount;
|
||||||
g_free(amt_temp);
|
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;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return amount;
|
return amount;
|
||||||
@ -418,31 +416,29 @@ gchar *
|
|||||||
get_check_splits_memo2(PrintCheckDialog *pcd)
|
get_check_splits_memo2(PrintCheckDialog *pcd)
|
||||||
{
|
{
|
||||||
gchar* memo = NULL;
|
gchar* memo = NULL;
|
||||||
gchar* memo_temp;
|
|
||||||
int cnt;
|
|
||||||
const gchar* split_memo;
|
const gchar* split_memo;
|
||||||
int nSplits;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
|
||||||
GList *node;
|
GList *node;
|
||||||
SplitList* s_list;
|
SplitList* s_list;
|
||||||
|
|
||||||
trans = xaccSplitGetParent(pcd->split);
|
trans = xaccSplitGetParent(pcd->split);
|
||||||
nSplits = xaccTransCountSplits(trans);
|
|
||||||
s_list = xaccTransGetSplitList(trans);
|
s_list = xaccTransGetSplitList(trans);
|
||||||
if ( !s_list ) return NULL;
|
if ( !s_list ) return NULL;
|
||||||
|
|
||||||
memo = g_strconcat("", NULL);
|
memo = g_strconcat("", NULL);
|
||||||
node = s_list;
|
node = s_list;
|
||||||
cnt = 1;
|
while ( node )
|
||||||
while ( cnt < nSplits )
|
|
||||||
{
|
{
|
||||||
cnt++;
|
Split *split = node->data;
|
||||||
split = node->data;
|
/* Include all splits except the main split for the check */
|
||||||
split_memo = xaccSplitGetMemo(split);
|
if (split != pcd->split)
|
||||||
memo_temp = memo;
|
{
|
||||||
memo = g_strconcat(memo_temp, "\n", split_memo, NULL);
|
gchar* memo_temp;
|
||||||
g_free(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;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return memo;
|
return memo;
|
||||||
@ -455,33 +451,31 @@ gchar *
|
|||||||
get_check_splits_account2(PrintCheckDialog *pcd)
|
get_check_splits_account2(PrintCheckDialog *pcd)
|
||||||
{
|
{
|
||||||
gchar* account = NULL;
|
gchar* account = NULL;
|
||||||
gchar* account_temp;
|
|
||||||
int cnt;
|
|
||||||
const gchar* aName = NULL;
|
|
||||||
int nSplits;
|
|
||||||
Account *pAccount;
|
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
|
||||||
GList *node;
|
GList *node;
|
||||||
SplitList* s_list;
|
SplitList* s_list;
|
||||||
|
|
||||||
trans = xaccSplitGetParent(pcd->split);
|
trans = xaccSplitGetParent(pcd->split);
|
||||||
nSplits = xaccTransCountSplits(trans);
|
|
||||||
s_list = xaccTransGetSplitList(trans);
|
s_list = xaccTransGetSplitList(trans);
|
||||||
if ( !s_list ) return NULL;
|
if ( !s_list ) return NULL;
|
||||||
|
|
||||||
account = g_strconcat("", NULL);
|
account = g_strconcat("", NULL);
|
||||||
node = s_list;
|
node = s_list;
|
||||||
cnt = 1;
|
while ( node )
|
||||||
while ( cnt < nSplits )
|
|
||||||
{
|
{
|
||||||
cnt++;
|
Split *split = node->data;
|
||||||
split = node->data;
|
/* Include all splits except the main split for the check */
|
||||||
pAccount = xaccSplitGetAccount(split);
|
if (split != pcd->split)
|
||||||
aName = gnc_get_account_name_for_register(pAccount);
|
{
|
||||||
account_temp = account;
|
gchar* account_temp;
|
||||||
account = g_strconcat(account_temp, "\n", aName, NULL);
|
const gchar* aName = NULL;
|
||||||
g_free(account_temp);
|
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;
|
node = node->next;
|
||||||
}
|
}
|
||||||
return account;
|
return account;
|
||||||
|
@ -2696,6 +2696,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
|
|||||||
Transaction * trans;
|
Transaction * trans;
|
||||||
GList * splits = NULL, *item;
|
GList * splits = NULL, *item;
|
||||||
GNCLedgerDisplayType ledger_type;
|
GNCLedgerDisplayType ledger_type;
|
||||||
|
Account * account;
|
||||||
|
|
||||||
ENTER("(action %p, plugin_page %p)", action, plugin_page);
|
ENTER("(action %p, plugin_page %p)", action, plugin_page);
|
||||||
|
|
||||||
@ -2706,14 +2707,30 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
|
|||||||
ledger_type = gnc_ledger_display_type(priv->ledger);
|
ledger_type = gnc_ledger_display_type(priv->ledger);
|
||||||
if (ledger_type == LD_SINGLE || ledger_type == LD_SUBACCOUNT)
|
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);
|
split = gnc_split_register_get_current_split(reg);
|
||||||
trans = xaccSplitGetParent(split);
|
trans = xaccSplitGetParent(split);
|
||||||
|
|
||||||
if (split && trans)
|
if (split && trans)
|
||||||
{
|
{
|
||||||
splits = g_list_append(splits, split);
|
if (xaccSplitGetAccount(split) == account)
|
||||||
gnc_ui_print_check_dialog_create(plugin_page, splits);
|
{
|
||||||
g_list_free(splits);
|
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)
|
else if (ledger_type == LD_GL && reg->type == SEARCH_LEDGER)
|
||||||
|
@ -2543,6 +2543,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
|
|||||||
Transaction * trans;
|
Transaction * trans;
|
||||||
GList * splits = NULL, *item;
|
GList * splits = NULL, *item;
|
||||||
GNCLedgerDisplay2Type ledger_type;
|
GNCLedgerDisplay2Type ledger_type;
|
||||||
|
Account * account;
|
||||||
|
|
||||||
ENTER("(action %p, plugin_page %p)", action, plugin_page);
|
ENTER("(action %p, plugin_page %p)", action, plugin_page);
|
||||||
|
|
||||||
@ -2555,6 +2556,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
|
|||||||
|
|
||||||
if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT)
|
if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT)
|
||||||
{
|
{
|
||||||
|
account = gnc_plugin_page_register2_get_account (plugin_page);
|
||||||
split = gnc_tree_view_split_reg_get_current_split (view);
|
split = gnc_tree_view_split_reg_get_current_split (view);
|
||||||
trans = xaccSplitGetParent (split);
|
trans = xaccSplitGetParent (split);
|
||||||
|
|
||||||
@ -2587,9 +2589,24 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
|
|||||||
|
|
||||||
if (split && trans)
|
if (split && trans)
|
||||||
{
|
{
|
||||||
splits = g_list_append (splits, split);
|
if (xaccSplitGetAccount(split) == account)
|
||||||
gnc_ui_print_check_dialog_create2 (plugin_page, splits);
|
{
|
||||||
g_list_free (splits);
|
splits = g_list_append(splits, split);
|
||||||
|
gnc_ui_print_check_dialog_create2 (plugin_page, splits);
|
||||||
|
g_list_free(splits);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This split is not for the account shown in this register. Get the
|
||||||
|
split for that account and use it. */
|
||||||
|
split = gnc_tree_model_split_reg_trans_get_split_equal_to_ancestor(trans, account);
|
||||||
|
if (split)
|
||||||
|
{
|
||||||
|
splits = g_list_append(splits, split);
|
||||||
|
gnc_ui_print_check_dialog_create2 (plugin_page, splits);
|
||||||
|
g_list_free(splits);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ledger_type == LD2_GL && model->type == SEARCH_LEDGER2)
|
else if (ledger_type == LD2_GL && model->type == SEARCH_LEDGER2)
|
||||||
|
Loading…
Reference in New Issue
Block a user