fix sign of balance amounts for income, expense windows

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@812 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-04-16 07:05:11 +00:00
parent efbf0854d3
commit b560bb6d01
3 changed files with 24 additions and 5 deletions

View File

@ -203,6 +203,7 @@ xaccLoadRegEntry (BasicRegister *reg, Split *split)
char *accname;
char buff[2];
time_t secs;
double baln;
if (!split) return;
trans = xaccSplitGetParent (split);
@ -226,7 +227,17 @@ xaccLoadRegEntry (BasicRegister *reg, Split *split)
xaccSetDebCredCellValue (reg->debitCell,
reg->creditCell, xaccSplitGetValue (split));
xaccSetAmountCellValue (reg->balanceCell, xaccSplitGetBalance (split));
/* For income and expense acounts, we have to reverse
* the meaning of balance, since, in a dual entry
* system, income will show up as a credit to a
* bank account, and a debit to the income account.
* Thus, positive and negative are interchanged */
baln = xaccSplitGetBalance (split);
if ((INCOME_REGISTER == reg->type) ||
(EXPENSE_REGISTER == reg->type)) {
baln = -baln;
}
xaccSetAmountCellValue (reg->balanceCell, baln);
xaccSetAmountCellValue (reg->priceCell, xaccSplitGetSharePrice (split));
xaccSetPriceCellValue (reg->shrsCell, xaccSplitGetShareBalance (split));

View File

@ -123,8 +123,10 @@
/* ============================================== */
static void
configLayout (BasicRegister *reg, int type)
configLayout (BasicRegister *reg)
{
int type = reg->type;
/* perform a bsic layout that's valid for most
* of the ledgers; then customize with case
* statements. */
@ -224,8 +226,9 @@ configLayout (BasicRegister *reg, int type)
/* negative cells mean "traverse out of table" */
static void
configTraverse (BasicRegister *reg, int type)
configTraverse (BasicRegister *reg)
{
int type = reg->type;
CellBlock *curs = reg->cursor;
switch (type) {
@ -315,9 +318,10 @@ void xaccInitBasicRegister (BasicRegister *reg, int type)
reg->user_hook = NULL;
reg->destroy = NULL;
reg->type = type;
/* --------------------------- */
configLayout (reg, type);
configLayout (reg);
/* --------------------------- */
/* define the header */
@ -360,7 +364,7 @@ void xaccInitBasicRegister (BasicRegister *reg, int type)
/* -------------------------------- */
/* define how traversal works */
configTraverse (reg, type);
configTraverse (reg);
/* -------------------------------- */
/* add menu items for the action cell */

View File

@ -107,6 +107,10 @@ struct _BasicRegister {
ComboCell * xtoCell;
PriceCell * balanceCell;
/* the type of the register, must be one of the enumerated types
* above *_REGISTER, *_LEDGER, above */
int type;
/* some private data; outsiders should not access this */
short num_cols;
short num_header_rows;