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)
|
||||
{
|
||||
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;
|
||||
@ -418,31 +416,29 @@ gchar *
|
||||
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;
|
||||
@ -455,33 +451,31 @@ gchar *
|
||||
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;
|
||||
|
@ -381,31 +381,29 @@ gchar *
|
||||
get_check_splits_amount2(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;
|
||||
@ -418,31 +416,29 @@ gchar *
|
||||
get_check_splits_memo2(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;
|
||||
@ -455,33 +451,31 @@ gchar *
|
||||
get_check_splits_account2(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;
|
||||
|
@ -2696,6 +2696,7 @@ gnc_plugin_page_register_cmd_print_check (GtkAction *action,
|
||||
Transaction * trans;
|
||||
GList * splits = NULL, *item;
|
||||
GNCLedgerDisplayType ledger_type;
|
||||
Account * account;
|
||||
|
||||
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);
|
||||
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)
|
||||
|
@ -2543,6 +2543,7 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
|
||||
Transaction * trans;
|
||||
GList * splits = NULL, *item;
|
||||
GNCLedgerDisplay2Type ledger_type;
|
||||
Account * account;
|
||||
|
||||
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)
|
||||
{
|
||||
account = gnc_plugin_page_register2_get_account (plugin_page);
|
||||
split = gnc_tree_view_split_reg_get_current_split (view);
|
||||
trans = xaccSplitGetParent (split);
|
||||
|
||||
@ -2587,9 +2589,24 @@ gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
|
||||
|
||||
if (split && trans)
|
||||
{
|
||||
splits = g_list_append (splits, split);
|
||||
gnc_ui_print_check_dialog_create2 (plugin_page, splits);
|
||||
g_list_free (splits);
|
||||
if (xaccSplitGetAccount(split) == account)
|
||||
{
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user