mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Move shares & price to split row in journal mode.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3218 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
9415ee13b5
commit
88bdc41cd8
@ -3103,6 +3103,35 @@ get_trans_total_value (SplitRegister *reg, Transaction *trans)
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gnc_numeric
|
||||||
|
get_trans_total_shares (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, xaccAccountGetSecuritySCU (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, xaccSplitGetShareAmount (split));
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
static Split *
|
static Split *
|
||||||
get_trans_last_split (SplitRegister *reg, Transaction *trans)
|
get_trans_last_split (SplitRegister *reg, Transaction *trans)
|
||||||
{
|
{
|
||||||
@ -3408,6 +3437,16 @@ xaccSRGetEntryHandler (VirtualLocation virt_loc, short _cell_type,
|
|||||||
gnc_split_value_print_info (split, FALSE));
|
gnc_split_value_print_info (split, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case TSHRS_CELL:
|
||||||
|
{
|
||||||
|
gnc_numeric total;
|
||||||
|
|
||||||
|
total = get_trans_total_shares (reg, trans);
|
||||||
|
|
||||||
|
return xaccPrintAmount (total,
|
||||||
|
gnc_split_quantity_print_info (split, FALSE));
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
break;
|
break;
|
||||||
@ -3420,6 +3459,7 @@ xaccSRGetFGColorHandler (VirtualLocation virt_loc, gpointer user_data)
|
|||||||
SplitRegister *reg = user_data;
|
SplitRegister *reg = user_data;
|
||||||
const guint32 black = 0x000000;
|
const guint32 black = 0x000000;
|
||||||
const guint32 red = 0xff0000;
|
const guint32 red = 0xff0000;
|
||||||
|
Transaction *trans;
|
||||||
VirtualCell *vcell;
|
VirtualCell *vcell;
|
||||||
gboolean is_current;
|
gboolean is_current;
|
||||||
CellType cell_type;
|
CellType cell_type;
|
||||||
@ -3436,6 +3476,8 @@ xaccSRGetFGColorHandler (VirtualLocation virt_loc, gpointer user_data)
|
|||||||
if (split == NULL)
|
if (split == NULL)
|
||||||
return black;
|
return black;
|
||||||
|
|
||||||
|
trans = xaccSplitGetParent (split);
|
||||||
|
|
||||||
cell_type = xaccSplitRegisterGetCellType (reg, virt_loc);
|
cell_type = xaccSplitRegisterGetCellType (reg, virt_loc);
|
||||||
|
|
||||||
is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
|
is_current = virt_cell_loc_equal (reg->table->current_cursor_loc.vcell_loc,
|
||||||
@ -3444,10 +3486,13 @@ xaccSRGetFGColorHandler (VirtualLocation virt_loc, gpointer user_data)
|
|||||||
switch (cell_type)
|
switch (cell_type)
|
||||||
{
|
{
|
||||||
case SHRS_CELL:
|
case SHRS_CELL:
|
||||||
|
case TSHRS_CELL:
|
||||||
{
|
{
|
||||||
gnc_numeric shares;
|
gnc_numeric shares;
|
||||||
|
|
||||||
if (is_current)
|
if (cell_type == TSHRS_CELL)
|
||||||
|
shares = get_trans_total_shares (reg, trans);
|
||||||
|
else if (is_current)
|
||||||
shares = xaccGetPriceCellValue (reg->sharesCell);
|
shares = xaccGetPriceCellValue (reg->sharesCell);
|
||||||
else
|
else
|
||||||
shares = xaccSplitGetShareAmount (split);
|
shares = xaccSplitGetShareAmount (split);
|
||||||
@ -3460,10 +3505,14 @@ xaccSRGetFGColorHandler (VirtualLocation virt_loc, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SHRBALN_CELL:
|
case SHRBALN_CELL:
|
||||||
|
case TSHRBALN_CELL:
|
||||||
{
|
{
|
||||||
gnc_numeric balance;
|
gnc_numeric balance;
|
||||||
|
|
||||||
|
if (cell_type == SHRBALN_CELL)
|
||||||
balance = xaccSplitGetShareBalance (split);
|
balance = xaccSplitGetShareBalance (split);
|
||||||
|
else
|
||||||
|
balance = get_trans_total_share_balance (reg, trans);
|
||||||
|
|
||||||
if (gnc_numeric_negative_p (balance))
|
if (gnc_numeric_negative_p (balance))
|
||||||
return red;
|
return red;
|
||||||
@ -3473,12 +3522,16 @@ xaccSRGetFGColorHandler (VirtualLocation virt_loc, gpointer user_data)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BALN_CELL:
|
case BALN_CELL:
|
||||||
|
case TBALN_CELL:
|
||||||
{
|
{
|
||||||
gnc_numeric balance;
|
gnc_numeric balance;
|
||||||
|
|
||||||
/* If the reverse_balance callback is present use that.
|
/* If the reverse_balance callback is present use that.
|
||||||
* Otherwise, reverse income and expense by default. */
|
* Otherwise, reverse income and expense by default. */
|
||||||
|
if (cell_type == BALN_CELL)
|
||||||
balance = xaccSplitGetBalance (split);
|
balance = xaccSplitGetBalance (split);
|
||||||
|
else
|
||||||
|
balance = get_trans_total_balance (reg, trans);
|
||||||
|
|
||||||
if (reverse_balance != NULL)
|
if (reverse_balance != NULL)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,7 @@ static char *cell_sample_strings[] =
|
|||||||
N_("sample:Expenses:Automobile:Gasoline"+7), /* mxfrm cell */
|
N_("sample:Expenses:Automobile:Gasoline"+7), /* mxfrm cell */
|
||||||
N_("sample:999,999.000"+7), /* tcredit cell */
|
N_("sample:999,999.000"+7), /* tcredit cell */
|
||||||
N_("sample:999,999.000"+7), /* tdebit cell */
|
N_("sample:999,999.000"+7), /* tdebit cell */
|
||||||
|
N_("sample:999,999.000"+7), /* tshares cell */
|
||||||
N_("sample:999,999.000"+7), /* tshrbaln cell */
|
N_("sample:999,999.000"+7), /* tshrbaln cell */
|
||||||
N_("sample:999,999.000"+7), /* tbalance cell */
|
N_("sample:999,999.000"+7), /* tbalance cell */
|
||||||
N_("sample:Notes field sample text string"+7), /* notes cell */
|
N_("sample:Notes field sample text string"+7), /* notes cell */
|
||||||
@ -126,6 +127,7 @@ static CellAlignment cell_alignments[] =
|
|||||||
CELL_ALIGN_RIGHT, /* mxfrm cell */
|
CELL_ALIGN_RIGHT, /* mxfrm cell */
|
||||||
CELL_ALIGN_RIGHT, /* tcredit cell */
|
CELL_ALIGN_RIGHT, /* tcredit cell */
|
||||||
CELL_ALIGN_RIGHT, /* tdebit cell */
|
CELL_ALIGN_RIGHT, /* tdebit cell */
|
||||||
|
CELL_ALIGN_RIGHT, /* tshares cell */
|
||||||
CELL_ALIGN_RIGHT, /* tshrbaln cell */
|
CELL_ALIGN_RIGHT, /* tshrbaln cell */
|
||||||
CELL_ALIGN_RIGHT, /* tbalance cell */
|
CELL_ALIGN_RIGHT, /* tbalance cell */
|
||||||
CELL_ALIGN_LEFT, /* notes cell */
|
CELL_ALIGN_LEFT, /* notes cell */
|
||||||
@ -197,6 +199,7 @@ configLabels (SplitRegister *reg)
|
|||||||
LABEL (MXFRM, _("Transfer"));
|
LABEL (MXFRM, _("Transfer"));
|
||||||
LABEL (TCRED, _("Total"));
|
LABEL (TCRED, _("Total"));
|
||||||
LABEL (TDEBT, _("Total"));
|
LABEL (TDEBT, _("Total"));
|
||||||
|
LABEL (TSHRS, _("Total"));
|
||||||
LABEL (TSHRBALN, _("Total Shares"));
|
LABEL (TSHRBALN, _("Total Shares"));
|
||||||
LABEL (TBALN, _("Balance"));
|
LABEL (TBALN, _("Balance"));
|
||||||
LABEL (NOTES, _("Notes"));
|
LABEL (NOTES, _("Notes"));
|
||||||
@ -537,8 +540,7 @@ configLayout (SplitRegister *reg)
|
|||||||
set_cell (reg, curs, NUM_CELL, 0, 1);
|
set_cell (reg, curs, NUM_CELL, 0, 1);
|
||||||
set_cell (reg, curs, DESC_CELL, 0, 2);
|
set_cell (reg, curs, DESC_CELL, 0, 2);
|
||||||
set_cell (reg, curs, RECN_CELL, 0, 4);
|
set_cell (reg, curs, RECN_CELL, 0, 4);
|
||||||
set_cell (reg, curs, SHRS_CELL, 0, 5);
|
set_cell (reg, curs, TSHRS_CELL, 0, 5);
|
||||||
set_cell (reg, curs, PRIC_CELL, 0, 6);
|
|
||||||
set_cell (reg, curs, TDEBT_CELL, 0, 7);
|
set_cell (reg, curs, TDEBT_CELL, 0, 7);
|
||||||
set_cell (reg, curs, TCRED_CELL, 0, 8);
|
set_cell (reg, curs, TCRED_CELL, 0, 8);
|
||||||
set_cell (reg, curs, TSHRBALN_CELL, 0, 9);
|
set_cell (reg, curs, TSHRBALN_CELL, 0, 9);
|
||||||
@ -553,6 +555,8 @@ configLayout (SplitRegister *reg)
|
|||||||
set_cell (reg, curs, ACTN_CELL, 0, 1);
|
set_cell (reg, curs, ACTN_CELL, 0, 1);
|
||||||
set_cell (reg, curs, MEMO_CELL, 0, 2);
|
set_cell (reg, curs, MEMO_CELL, 0, 2);
|
||||||
set_cell (reg, curs, XFRM_CELL, 0, 3);
|
set_cell (reg, curs, XFRM_CELL, 0, 3);
|
||||||
|
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, DEBT_CELL, 0, 7);
|
||||||
set_cell (reg, curs, CRED_CELL, 0, 8);
|
set_cell (reg, curs, CRED_CELL, 0, 8);
|
||||||
|
|
||||||
@ -586,8 +590,7 @@ configLayout (SplitRegister *reg)
|
|||||||
set_cell (reg, curs, DESC_CELL, 0, 2);
|
set_cell (reg, curs, DESC_CELL, 0, 2);
|
||||||
set_cell (reg, curs, XTO_CELL, 0, 3);
|
set_cell (reg, curs, XTO_CELL, 0, 3);
|
||||||
set_cell (reg, curs, RECN_CELL, 0, 5);
|
set_cell (reg, curs, RECN_CELL, 0, 5);
|
||||||
set_cell (reg, curs, SHRS_CELL, 0, 6);
|
set_cell (reg, curs, TSHRS_CELL, 0, 6);
|
||||||
set_cell (reg, curs, PRIC_CELL, 0, 7);
|
|
||||||
set_cell (reg, curs, TDEBT_CELL, 0, 8);
|
set_cell (reg, curs, TDEBT_CELL, 0, 8);
|
||||||
set_cell (reg, curs, TCRED_CELL, 0, 9);
|
set_cell (reg, curs, TCRED_CELL, 0, 9);
|
||||||
|
|
||||||
@ -600,6 +603,8 @@ configLayout (SplitRegister *reg)
|
|||||||
set_cell (reg, curs, ACTN_CELL, 0, 1);
|
set_cell (reg, curs, ACTN_CELL, 0, 1);
|
||||||
set_cell (reg, curs, MEMO_CELL, 0, 2);
|
set_cell (reg, curs, MEMO_CELL, 0, 2);
|
||||||
set_cell (reg, curs, XFRM_CELL, 0, 4);
|
set_cell (reg, curs, XFRM_CELL, 0, 4);
|
||||||
|
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, DEBT_CELL, 0, 8);
|
||||||
set_cell (reg, curs, CRED_CELL, 0, 9);
|
set_cell (reg, curs, CRED_CELL, 0, 9);
|
||||||
|
|
||||||
@ -628,7 +633,7 @@ xaccMallocSplitRegister (SplitRegisterType type,
|
|||||||
{
|
{
|
||||||
SplitRegister * reg;
|
SplitRegister * reg;
|
||||||
|
|
||||||
reg = g_new0(SplitRegister, 1);
|
reg = g_new0 (SplitRegister, 1);
|
||||||
|
|
||||||
xaccInitSplitRegister (reg, type, style, use_double_line,
|
xaccInitSplitRegister (reg, type, style, use_double_line,
|
||||||
entry_handler, fg_color_handler, bg_color_handler,
|
entry_handler, fg_color_handler, bg_color_handler,
|
||||||
@ -792,6 +797,7 @@ xaccInitSplitRegister (SplitRegister *reg,
|
|||||||
NEW (MXFRM, mxfrm, Combo);
|
NEW (MXFRM, mxfrm, Combo);
|
||||||
NEW (TCRED, tcredit, Price);
|
NEW (TCRED, tcredit, Price);
|
||||||
NEW (TDEBT, tdebit, Price);
|
NEW (TDEBT, tdebit, Price);
|
||||||
|
NEW (TSHRS, tshares, Price);
|
||||||
NEW (TSHRBALN, tshrbaln, Price);
|
NEW (TSHRBALN, tshrbaln, Price);
|
||||||
NEW (TBALN, tbalance, Price);
|
NEW (TBALN, tbalance, Price);
|
||||||
NEW (NOTES, notes, QuickFill);
|
NEW (NOTES, notes, QuickFill);
|
||||||
@ -859,6 +865,7 @@ xaccInitSplitRegister (SplitRegister *reg,
|
|||||||
reg->shrbalnCell->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->tcreditCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||||
reg->tdebitCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
reg->tdebitCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||||
|
reg->tsharesCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||||
reg->tbalanceCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
reg->tbalanceCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||||
reg->tshrbalnCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
reg->tshrbalnCell->cell.input_output = XACC_CELL_ALLOW_NONE;
|
||||||
|
|
||||||
@ -880,6 +887,8 @@ xaccInitSplitRegister (SplitRegister *reg,
|
|||||||
/* Initialize shares and share balance cells */
|
/* Initialize shares and share balance cells */
|
||||||
xaccSetPriceCellPrintInfo
|
xaccSetPriceCellPrintInfo
|
||||||
(reg->sharesCell, gnc_default_share_print_info ());
|
(reg->sharesCell, gnc_default_share_print_info ());
|
||||||
|
xaccSetPriceCellPrintInfo
|
||||||
|
(reg->tsharesCell, gnc_default_share_print_info ());
|
||||||
xaccSetPriceCellPrintInfo
|
xaccSetPriceCellPrintInfo
|
||||||
(reg->shrbalnCell, gnc_default_share_print_info ());
|
(reg->shrbalnCell, gnc_default_share_print_info ());
|
||||||
xaccSetPriceCellPrintInfo
|
xaccSetPriceCellPrintInfo
|
||||||
@ -1018,6 +1027,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
|
|||||||
xaccDestroyComboCell (reg->mxfrmCell);
|
xaccDestroyComboCell (reg->mxfrmCell);
|
||||||
xaccDestroyPriceCell (reg->tcreditCell);
|
xaccDestroyPriceCell (reg->tcreditCell);
|
||||||
xaccDestroyPriceCell (reg->tdebitCell);
|
xaccDestroyPriceCell (reg->tdebitCell);
|
||||||
|
xaccDestroyPriceCell (reg->tsharesCell);
|
||||||
xaccDestroyPriceCell (reg->tshrbalnCell);
|
xaccDestroyPriceCell (reg->tshrbalnCell);
|
||||||
xaccDestroyPriceCell (reg->tbalanceCell);
|
xaccDestroyPriceCell (reg->tbalanceCell);
|
||||||
xaccDestroyQuickFillCell (reg->notesCell);
|
xaccDestroyQuickFillCell (reg->notesCell);
|
||||||
@ -1039,6 +1049,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
|
|||||||
reg->mxfrmCell = NULL;
|
reg->mxfrmCell = NULL;
|
||||||
reg->tcreditCell = NULL;
|
reg->tcreditCell = NULL;
|
||||||
reg->tdebitCell = NULL;
|
reg->tdebitCell = NULL;
|
||||||
|
reg->tsharesCell = NULL;
|
||||||
reg->tshrbalnCell = NULL;
|
reg->tshrbalnCell = NULL;
|
||||||
reg->tbalanceCell = NULL;
|
reg->tbalanceCell = NULL;
|
||||||
reg->notesCell = NULL;
|
reg->notesCell = NULL;
|
||||||
|
@ -96,6 +96,7 @@ typedef enum
|
|||||||
MXFRM_CELL, /* MXFRM is the "mirrored" transfer-from account */
|
MXFRM_CELL, /* MXFRM is the "mirrored" transfer-from account */
|
||||||
TCRED_CELL, /* T* cells are transaction summary cells */
|
TCRED_CELL, /* T* cells are transaction summary cells */
|
||||||
TDEBT_CELL,
|
TDEBT_CELL,
|
||||||
|
TSHRS_CELL,
|
||||||
TSHRBALN_CELL,
|
TSHRBALN_CELL,
|
||||||
TBALN_CELL,
|
TBALN_CELL,
|
||||||
NOTES_CELL,
|
NOTES_CELL,
|
||||||
@ -197,6 +198,7 @@ struct _SplitRegister
|
|||||||
ComboCell * mxfrmCell;
|
ComboCell * mxfrmCell;
|
||||||
PriceCell * tcreditCell;
|
PriceCell * tcreditCell;
|
||||||
PriceCell * tdebitCell;
|
PriceCell * tdebitCell;
|
||||||
|
PriceCell * tsharesCell;
|
||||||
PriceCell * tshrbalnCell;
|
PriceCell * tshrbalnCell;
|
||||||
PriceCell * tbalanceCell;
|
PriceCell * tbalanceCell;
|
||||||
QuickFillCell * notesCell;
|
QuickFillCell * notesCell;
|
||||||
|
Loading…
Reference in New Issue
Block a user