Show totals in transaction debit/credit field in expanded mode.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3184 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-11-21 02:11:23 +00:00
parent 2b99156495
commit 4699cd4699
4 changed files with 141 additions and 58 deletions

View File

@ -2593,24 +2593,25 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
}
/* -------------------------------------------------------------- */
/* OK, the handling of transfers gets complicated because it
* depends on what was displayed to the user. For a multi-line
* display, we just reparent the indicated split, its it,
* and that's that. For a two-line display, we want to reparent
* the "other" split, but only if there is one ...
* XFRM is the straight split, MXFRM is the mirrored split.
* XTO is the straight split, too :) Only one of XFRM or XTO
* should be in a given cursor.
*/
if ((MOD_XFRM | MOD_XTO) & changed) {
/* OK, the handling of transfers gets complicated because it depends
* on what was displayed to the user. For a multi-line display, we
* just reparent the indicated split, its it, and that's that. For
* a two-line display, we want to reparent the "other" split, but
* only if there is one. XFRM is the straight split, MXFRM is the
* mirrored split. XTO is the straight split, too :) Only one of
* XFRM or XTO should be in a given cursor. */
if ((MOD_XFRM | MOD_XTO) & changed)
{
Account *old_acc=NULL, *new_acc=NULL;
char *new_name;
if (MOD_XFRM & changed) {
if (MOD_XFRM & changed)
{
DEBUG ("MOD_XFRM: %s\n",
reg->xfrmCell->cell.value);
}
else {
else
{
DEBUG ("MOD_XTO: %s\n",
reg->xtoCell->cell.value);
}
@ -2634,18 +2635,21 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
currency = xaccAccountGetCurrency(new_acc);
currency = xaccTransIsCommonExclSCurrency(trans, currency, split);
if (currency == NULL) {
if (currency == NULL)
{
security = xaccAccountGetSecurity(new_acc);
security = xaccTransIsCommonExclSCurrency(trans, security, split);
}
if ((currency != NULL) || (security != NULL)) {
if ((currency != NULL) || (security != NULL))
{
xaccAccountInsertSplit (new_acc, split);
refresh_accounts = g_list_prepend(refresh_accounts, old_acc);
refresh_accounts = g_list_prepend(refresh_accounts, new_acc);
}
else {
else
{
const char *format = _("You cannot transfer funds from the %s "
"account.\nIt does not have a matching "
"currency.\nTo transfer funds between "
@ -2680,9 +2684,11 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
* the user's request to transfer actually works out.
*/
if (!other_split) {
if (!other_split)
{
other_split = xaccTransGetSplit (trans, 1);
if (!other_split) {
if (!other_split)
{
gnc_numeric amount = xaccSplitGetShareAmount (split);
gnc_numeric price = xaccSplitGetSharePrice (split);
@ -2696,7 +2702,8 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
}
}
if (other_split) {
if (other_split)
{
Account *old_acc=NULL, *new_acc=NULL;
/* do some reparenting. Insertion into new account will automatically
@ -2714,19 +2721,22 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
currency = xaccTransIsCommonExclSCurrency(trans,
currency, other_split);
if (currency == NULL) {
if (currency == NULL)
{
security = xaccAccountGetSecurity(new_acc);
security = xaccTransIsCommonExclSCurrency(trans,
security, other_split);
}
if ((currency != NULL) || (security != NULL)) {
if ((currency != NULL) || (security != NULL))
{
xaccAccountInsertSplit (new_acc, other_split);
refresh_accounts = g_list_prepend(refresh_accounts, old_acc);
refresh_accounts = g_list_prepend(refresh_accounts, new_acc);
}
else {
else
{
const char *format = _("You cannot transfer funds from the %s "
"account.\nIt does not have a matching "
"currency.\nTo transfer funds between "
@ -2867,7 +2877,8 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
}
}
if (MOD_SHRS & changed) {
if (MOD_SHRS & changed)
{
gnc_numeric amount = xaccGetPriceCellValue(reg->sharesCell);
gnc_numeric price = xaccGetPriceCellValue(reg->priceCell);
@ -2877,7 +2888,8 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
xaccSplitSetSharePrice (split, price);
}
if (MOD_PRIC & changed) {
if (MOD_PRIC & changed)
{
gnc_numeric price;
price = xaccGetPriceCellValue(reg->priceCell);
@ -2891,7 +2903,8 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
* the split cursors show minus the quants that the single,
* double and transaction cursors show, and so when updates
* happen, the extra minus sign must also be handled. */
if (MOD_AMNT & changed) {
if (MOD_AMNT & changed)
{
gnc_numeric new_amount;
gnc_numeric credit;
gnc_numeric debit;
@ -2911,6 +2924,37 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
/* ======================================================== */
static gnc_numeric
get_trans_total (SplitRegister *reg, Transaction *trans)
{
GList *node;
Account *account;
gnc_numeric total = gnc_numeric_zero ();
SRInfo *info = xaccSRGetInfo(reg);
account = info->default_source_account;
if (!account)
return total;
total = gnc_numeric_convert (total, xaccAccountGetCurrencySCU (account),
GNC_RND_ROUND);
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
Split *split = node->data;
if (xaccSplitGetAccount (split) != account)
continue;
total = gnc_numeric_add_fixed (total, xaccSplitGetValue (split));
}
return total;
}
/* ======================================================== */
const char *
xaccSRGetEntryHandler (gpointer vcell_data, short _cell_type,
gpointer user_data)
@ -3096,6 +3140,27 @@ xaccSRGetEntryHandler (gpointer vcell_data, short _cell_type,
return name;
}
case TCRED_CELL:
case TDEBT_CELL:
{
gnc_numeric total;
total = get_trans_total (reg, trans);
if (gnc_numeric_zero_p (total))
return "";
if (gnc_numeric_negative_p (total) && (cell_type == TDEBT_CELL))
return "";
if (gnc_numeric_positive_p (total) && (cell_type == TCRED_CELL))
return "";
total = gnc_numeric_abs (total);
return xaccPrintAmount (total,
gnc_split_value_print_info (split, FALSE));
}
default:
return "";
break;
@ -3172,9 +3237,9 @@ xaccSRGetFGColorHandler (VirtualLocation virt_loc, gpointer user_data)
{
Account *account;
account = xaccSplitGetAccount(split);
account = xaccSplitGetAccount (split);
if (reverse_balance(account))
if (reverse_balance (account))
balance = gnc_numeric_neg (balance);
}
else if ((INCOME_REGISTER == reg->type) ||

View File

@ -1097,14 +1097,14 @@ gnc_register_create_menu_bar(RegWindow *regData, GtkWidget *statusbar)
static GnomeUIInfo style_list[] =
{
GNOMEUIINFO_RADIOITEM_DATA(N_("Ledger"),
GNOMEUIINFO_RADIOITEM_DATA(N_("Basic Ledger"),
N_("Show transactions on one or two lines"),
gnc_register_style_ledger_cb, NULL, NULL),
GNOMEUIINFO_RADIOITEM_DATA(N_("Auto Ledger"),
GNOMEUIINFO_RADIOITEM_DATA(N_("Auto-Split Ledger"),
N_("Show transactions on one or two lines and "
"expand the current transaction"),
gnc_register_style_auto_ledger_cb, NULL, NULL),
GNOMEUIINFO_RADIOITEM_DATA(N_("Journal"),
GNOMEUIINFO_RADIOITEM_DATA(N_("Transaction Journal"),
N_("Show expanded transactions with all "
"splits"),
gnc_register_style_journal_cb, NULL, NULL),

View File

@ -72,13 +72,13 @@ struct _SplitRegisterBuffer
CellBuffer balanceCell;
CellBuffer actionCell;
CellBuffer xfrmCell;
CellBuffer mxfrmCell;
CellBuffer xtoCell;
CellBuffer memoCell;
CellBuffer creditCell;
CellBuffer debitCell;
CellBuffer priceCell;
CellBuffer sharesCell;
CellBuffer mxfrmCell;
};
static char *cell_sample_strings[] =
@ -98,6 +98,8 @@ static char *cell_sample_strings[] =
N_("sample:999,999.000"+7), /* price cell */
N_("sample:999,999.000"+7), /* shares cell */
N_("sample:Expenses:Automobile:Gasoline"+7), /* mxfrm cell */
N_("sample:999,999.000"+7), /* tcredit cell */
N_("sample:999,999.000"+7), /* tdebit cell */
};
static CellAlignment cell_alignments[] =
@ -117,6 +119,8 @@ static CellAlignment cell_alignments[] =
CELL_ALIGN_RIGHT, /* price cell */
CELL_ALIGN_RIGHT, /* shares cell */
CELL_ALIGN_RIGHT, /* mxfrm cell */
CELL_ALIGN_RIGHT, /* tcredit cell */
CELL_ALIGN_RIGHT, /* tdebit cell */
};
@ -176,13 +180,15 @@ configLabels (SplitRegister *reg)
LABEL (BALN, _("Balance"));
LABEL (ACTN, _("Action"));
LABEL (XFRM, _("Account"));
LABEL (MXFRM, _("Transfer"));
LABEL (XTO, _("Account"));
LABEL (MEMO, _("Memo"));
LABEL (CRED, _("Credit"));
LABEL (DEBT, _("Debit"));
LABEL (PRIC, _("Price"));
LABEL (SHRS, _("Shares"));
LABEL (MXFRM, _("Transfer"));
LABEL (TCRED, _("Total"));
LABEL (TDEBT, _("Total"));
if (debit_getter != NULL)
{
@ -424,13 +430,13 @@ configLayout (SplitRegister *reg)
set_cell (reg, curs, MEMO_CELL, 1, 2);
curs = reg->cursor_journal_single;
set_cell (reg, curs, DATE_CELL, 0, 0);
set_cell (reg, curs, NUM_CELL, 0, 1);
set_cell (reg, curs, DESC_CELL, 0, 2);
set_cell (reg, curs, RECN_CELL, 0, 4);
set_cell (reg, curs, DEBT_CELL, 0, 5);
set_cell (reg, curs, CRED_CELL, 0, 6);
set_cell (reg, curs, BALN_CELL, 0, 7);
set_cell (reg, curs, DATE_CELL, 0, 0);
set_cell (reg, curs, NUM_CELL, 0, 1);
set_cell (reg, curs, DESC_CELL, 0, 2);
set_cell (reg, curs, RECN_CELL, 0, 4);
set_cell (reg, curs, TDEBT_CELL, 0, 5);
set_cell (reg, curs, TCRED_CELL, 0, 6);
set_cell (reg, curs, BALN_CELL, 0, 7);
curs = reg->cursor_journal_double;
copy_cursor_row (reg, curs, reg->cursor_journal_single, 0);
@ -469,13 +475,13 @@ configLayout (SplitRegister *reg)
set_cell (reg, curs, MEMO_CELL, 1, 2);
curs = reg->cursor_journal_single;
set_cell (reg, curs, DATE_CELL, 0, 0);
set_cell (reg, curs, NUM_CELL, 0, 1);
set_cell (reg, curs, DESC_CELL, 0, 2);
set_cell (reg, curs, XTO_CELL, 0, 3);
set_cell (reg, curs, RECN_CELL, 0, 5);
set_cell (reg, curs, DEBT_CELL, 0, 6);
set_cell (reg, curs, CRED_CELL, 0, 7);
set_cell (reg, curs, DATE_CELL, 0, 0);
set_cell (reg, curs, NUM_CELL, 0, 1);
set_cell (reg, curs, DESC_CELL, 0, 2);
set_cell (reg, curs, XTO_CELL, 0, 3);
set_cell (reg, curs, RECN_CELL, 0, 5);
set_cell (reg, curs, TDEBT_CELL, 0, 6);
set_cell (reg, curs, TCRED_CELL, 0, 7);
curs = reg->cursor_journal_double;
copy_cursor_row (reg, curs, reg->cursor_journal_single, 0);
@ -522,8 +528,8 @@ configLayout (SplitRegister *reg)
set_cell (reg, curs, RECN_CELL, 0, 4);
set_cell (reg, curs, SHRS_CELL, 0, 5);
set_cell (reg, curs, PRIC_CELL, 0, 6);
set_cell (reg, curs, DEBT_CELL, 0, 7);
set_cell (reg, curs, CRED_CELL, 0, 8);
set_cell (reg, curs, TDEBT_CELL, 0, 7);
set_cell (reg, curs, TCRED_CELL, 0, 8);
set_cell (reg, curs, SHRBALN_CELL, 0, 9);
set_cell (reg, curs, BALN_CELL, 0, 10);
@ -572,8 +578,8 @@ configLayout (SplitRegister *reg)
set_cell (reg, curs, RECN_CELL, 0, 5);
set_cell (reg, curs, SHRS_CELL, 0, 6);
set_cell (reg, curs, PRIC_CELL, 0, 7);
set_cell (reg, curs, DEBT_CELL, 0, 8);
set_cell (reg, curs, CRED_CELL, 0, 9);
set_cell (reg, curs, TDEBT_CELL, 0, 8);
set_cell (reg, curs, TCRED_CELL, 0, 9);
set_cell (reg, curs, SHRBALN_CELL, 0, 10);
curs = reg->cursor_journal_double;
@ -758,7 +764,6 @@ xaccInitSplitRegister (SplitRegister *reg,
NEW (SHRBALN, shrbaln, Price);
NEW (BALN, balance, Price);
NEW (XFRM, xfrm, Combo);
NEW (MXFRM, mxfrm, Combo);
NEW (XTO, xto, Combo);
NEW (ACTN, action, Combo);
NEW (MEMO, memo, QuickFill);
@ -766,10 +771,14 @@ xaccInitSplitRegister (SplitRegister *reg,
NEW (DEBT, debit, Price);
NEW (PRIC, price, Price);
NEW (SHRS, shares, Price);
NEW (MXFRM, mxfrm, Combo);
NEW (TCRED, tcredit, Price);
NEW (TDEBT, tdebit, Price);
/* --------------------------- */
/* configLabels merely puts strings into the label cells
* it does *not* copy them to the header cursor */
/* configLabels merely puts strings into the label cells. It does
* *not* copy them to the header cursor */
configLabels (reg);
/* config the layout of the cells in the cursors */
@ -806,7 +815,8 @@ xaccInitSplitRegister (SplitRegister *reg,
{
const char *help = _("This transaction has multiple splits; "
"switch to multi-line mode to see them all");
"switch to auto-split or transaction "
"mode to see them all");
xaccComboCellSetIgnoreHelp (reg->mxfrmCell, help);
xaccComboCellSetIgnoreHelp (reg->xtoCell, help);
}
@ -819,9 +829,11 @@ xaccInitSplitRegister (SplitRegister *reg,
xaccSetBasicCellBlankHelp (&reg->descCell->cell,
_("Enter a description of the transaction"));
/* The balance cells are just placeholders */
/* The balance and total cells are just placeholders */
reg->balanceCell->cell.input_output = XACC_CELL_ALLOW_NONE;
reg->shrbalnCell->cell.input_output = XACC_CELL_ALLOW_NONE;
reg->tcreditCell->cell.input_output = XACC_CELL_ALLOW_NONE;
reg->tdebitCell->cell.input_output = XACC_CELL_ALLOW_NONE;
/* by default, don't blank zeros on the price cells. */
xaccSetPriceCellBlankZero(reg->priceCell, FALSE);
@ -964,16 +976,17 @@ xaccDestroySplitRegister (SplitRegister *reg)
xaccDestroyRecnCell (reg->recnCell);
xaccDestroyPriceCell (reg->shrbalnCell);
xaccDestroyPriceCell (reg->balanceCell);
xaccDestroyComboCell (reg->actionCell);
xaccDestroyComboCell (reg->xfrmCell);
xaccDestroyComboCell (reg->mxfrmCell);
xaccDestroyComboCell (reg->xtoCell);
xaccDestroyQuickFillCell (reg->memoCell);
xaccDestroyPriceCell (reg->creditCell);
xaccDestroyPriceCell (reg->debitCell);
xaccDestroyPriceCell (reg->priceCell);
xaccDestroyPriceCell (reg->sharesCell);
xaccDestroyComboCell (reg->mxfrmCell);
xaccDestroyPriceCell (reg->tcreditCell);
xaccDestroyPriceCell (reg->tdebitCell);
reg->dateCell = NULL;
reg->numCell = NULL;
@ -981,16 +994,17 @@ xaccDestroySplitRegister (SplitRegister *reg)
reg->recnCell = NULL;
reg->shrbalnCell = NULL;
reg->balanceCell = NULL;
reg->actionCell = NULL;
reg->xfrmCell = NULL;
reg->mxfrmCell = NULL;
reg->xtoCell = NULL;
reg->memoCell = NULL;
reg->creditCell = NULL;
reg->debitCell = NULL;
reg->priceCell = NULL;
reg->sharesCell = NULL;
reg->mxfrmCell = NULL;
reg->tcreditCell = NULL;
reg->tdebitCell = NULL;
for (i = 0; i < CELL_TYPE_COUNT; i++)
{

View File

@ -94,6 +94,8 @@ typedef enum
PRIC_CELL,
SHRS_CELL,
MXFRM_CELL, /* MXFRM is the "mirrored" transfer-from account */
TCRED_CELL,
TDEBT_CELL,
CELL_TYPE_COUNT
} CellType;
@ -186,6 +188,8 @@ struct _SplitRegister
PriceCell * priceCell;
PriceCell * sharesCell;
ComboCell * mxfrmCell;
PriceCell * tcreditCell;
PriceCell * tdebitCell;
SplitRegisterType type;
SplitRegisterStyle style;