*** empty log message ***

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2160 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-04-05 09:41:32 +00:00
parent 52a68d663e
commit 60a90316d0
5 changed files with 175 additions and 110 deletions

View File

@ -1,3 +1,14 @@
2000-04-05 Dave Peticolas <peticola@cs.ucdavis.edu>
* src/register/table-allgui.c: more error checking
* src/SplitLedger.c: more cleanup. Fix a bug in refreshing a register
in auto-mode where the current transaction has been deleted.
* src/scm/report/balance-and-pnl.scm: put sub-accouts below their
parent accounts and indent their names. Align the columns better.
Print fully-qualified names.
2000-04-04 Dave Peticolas <peticola@cs.ucdavis.edu>
* src/register/gnome/gnucash-style.c: update the styles

View File

@ -175,6 +175,7 @@ static char account_separator = ':';
static SRReverseBalanceCallback reverse_balance = NULL;
/* static prototypes */
static void xaccSRLoadRegEntry (SplitRegister *reg, Split *split);
static Transaction * xaccSRGetTrans (SplitRegister *reg,
int phys_row, int phys_col);
@ -1681,7 +1682,7 @@ xaccSRSaveRegEntry (SplitRegister *reg, Transaction *new_trans)
/* ======================================================== */
static void
xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
{
SRInfo *info = xaccSRGetInfo(reg);
int typo = reg->type & REG_TYPE_MASK;
@ -1691,7 +1692,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
/* don't even bother doing a load if there is no current cursor */
if (!(reg->table->current_cursor)) return;
ENTER ("SRLoadTransEntry(): s=%p commit=%d\n", split, do_commit);
ENTER ("SRLoadTransEntry(): s=%p\n", split);
if (!split) {
/* we interpret a NULL split as a blank split */
@ -1740,7 +1741,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
account = xaccSplitGetAccount(split);
if (account == NULL)
account = info->default_source_account;
if (reverse_balance(account))
baln = -baln;
}
@ -1829,26 +1830,18 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit)
reg->table->current_cursor->user_data = (void *) split;
/* copy cursor contents into the table */
if (do_commit) {
xaccCommitCursor (reg->table);
}
xaccCommitCursor (reg->table);
LEAVE("SRLoadTransEntry()\n");
}
/* ======================================================== */
void
xaccSRLoadRegEntry (SplitRegister *reg, Split *split)
{
xaccSRLoadTransEntry (reg, split, GNC_T);
}
/* ======================================================== */
static gncBoolean
static void
xaccSRCountRows (SplitRegister *reg, Split **slist,
Transaction *find_trans, Split *find_split)
Transaction *find_trans, Split *find_split,
gncBoolean *ext_found_trans,
gncBoolean *ext_found_split)
{
SRInfo *info = xaccSRGetInfo(reg);
CellBlock *lead_cursor;
@ -1857,6 +1850,7 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
Table *table;
gncBoolean found_split = GNC_F;
gncBoolean found_trans = GNC_F;
gncBoolean multi_line;
gncBoolean dynamic;
@ -1915,7 +1909,7 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
/* do not count the blank split */
if (split != info->blank_split) {
Transaction *trans;
int do_expand = 0;
gncBoolean do_expand;
/* lets determine where to locate the cursor ... */
if (!found_split) {
@ -1924,12 +1918,14 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
save_cursor_phys_row = num_phys_rows;
save_cursor_virt_row = num_virt_rows;
found_split = GNC_T;
found_trans = GNC_T;
}
/* Otherwise, check for a close match. This could happen
* if we are collapsing from multi-line to single, e.g. */
else if (xaccSplitGetParent(split) == find_trans) {
save_cursor_phys_row = num_phys_rows;
save_cursor_virt_row = num_virt_rows;
found_trans = GNC_T;
}
}
@ -1970,14 +1966,14 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
/* lets determine where to locate the cursor ... */
if (!found_split) {
/* Check to see if we find a perfect match. We have to
* check the transaction in case the split is NULL (blank).
*/
/* Check if we find a perfect match. We have to check
* the transaction in case the split is NULL (blank). */
if ((secondary == find_split) &&
(trans == find_trans)) {
save_cursor_phys_row = num_phys_rows;
save_cursor_virt_row = num_virt_rows;
found_split = GNC_T;
found_trans = GNC_T;
}
}
@ -2009,6 +2005,13 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
save_cursor_phys_row = num_phys_rows;
save_cursor_virt_row = num_virt_rows;
found_split = GNC_T;
found_trans = GNC_T;
}
else if (!found_split &&
(xaccSplitGetParent(info->blank_split) == find_trans)) {
save_cursor_phys_row = num_phys_rows;
save_cursor_virt_row = num_virt_rows;
found_trans = GNC_T;
}
}
@ -2018,6 +2021,7 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
save_cursor_phys_row = num_phys_rows + 1;
save_cursor_virt_row = num_virt_rows + 1;
found_split = GNC_T;
found_trans = GNC_T;
}
num_virt_rows += 2;
num_phys_rows += reg->trans_cursor->numRows;
@ -2046,7 +2050,10 @@ xaccSRCountRows (SplitRegister *reg, Split **slist,
reg->cursor_phys_row = save_cursor_phys_row;
reg->cursor_virt_row = save_cursor_virt_row;
return found_split;
if (ext_found_split != NULL)
*ext_found_split = found_split;
if (ext_found_trans != NULL)
*ext_found_trans = found_trans;
}
/* ======================================================== */
@ -2065,7 +2072,8 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
Table *table;
gncBoolean found_pending = GNC_F;
gncBoolean found_split;
gncBoolean found_split = GNC_F;
gncBoolean found_trans = GNC_F;
gncBoolean multi_line;
gncBoolean dynamic;
@ -2111,7 +2119,9 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
save_phys_col = table->num_phys_cols - 1;
/* count the number of rows, looking for the place we want to go. */
found_split = xaccSRCountRows (reg, slist, find_trans, find_split);
xaccSRCountRows (reg, slist,
find_trans, find_split,
&found_trans, &found_split);
/* If the current cursor has changed, and the 'current split'
* is still among the living, we save the values for later
@ -2125,7 +2135,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
else
reg_buffer = NULL;
/* disable move callback -- we con't want the cascade of
/* disable move callback -- we don't want the cascade of
* callbacks while we are fiddling with loading the register */
table->move_cursor = NULL;
xaccMoveCursorGUI (table, -1, -1);
@ -2158,7 +2168,7 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
/* do not load the blank split */
if (split != info->blank_split) {
Transaction *trans;
int do_expand;
gncBoolean do_expand;
PINFO ("xaccSRLoadRegister(): "
"load trans %d at phys row %d \n", i, phys_row);
@ -2172,6 +2182,10 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
trans = xaccSplitGetParent (split);
do_expand = do_expand || (trans == find_trans);
}
if (dynamic && !found_trans && (vrow == reg->cursor_virt_row)) {
reg->cursor_phys_row = phys_row;
do_expand = GNC_T;
}
if (do_expand)
{

View File

@ -14,8 +14,11 @@
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License*
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
* along with this program; if not, contact: *
* *
* Free Software Foundation Voice: +1-617-542-5942 *
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
* Boston, MA 02111-1307, USA gnu@gnu.org *
* *
* Author: Rob Clark *
* Internet: rclark@cs.hmc.edu *
@ -681,122 +684,124 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar)
GtkWidget *menubar;
GtkAccelGroup *accel_group;
GnomeUIInfo reconcile_menu[] =
static GnomeUIInfo reconcile_menu[] =
{
{
GNOME_APP_UI_ITEM,
END_BALN_MENU_E_STR, TOOLTIP_ADJUST_END,
gnc_ui_reconcile_window_change_cb, recnData, NULL,
END_BALN_MENU_E_STR_N, TOOLTIP_ADJUST_END_N,
gnc_ui_reconcile_window_change_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_SEPARATOR,
{
GNOME_APP_UI_ITEM,
FINISH_MENU_STR, TOOLTIP_RECN_FINISH,
recnFinishCB, recnData, NULL,
FINISH_MENU_STR_N, TOOLTIP_RECN_FINISH_N,
recnFinishCB, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'f', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
CANCEL_MENU_STR, TOOLTIP_RECN_CANCEL,
recnCancelCB, recnData, NULL,
CANCEL_MENU_STR_N, TOOLTIP_RECN_CANCEL_N,
recnCancelCB, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_END
};
GnomeUIInfo account_menu[] =
static GnomeUIInfo account_menu[] =
{
{
GNOME_APP_UI_ITEM,
OPEN_ACC_MENU_STR, TOOLTIP_OPEN_ACC,
gnc_recn_open_cb, recnData, NULL,
OPEN_ACC_MENU_STR_N, TOOLTIP_OPEN_ACC_N,
gnc_recn_open_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
{
GNOME_APP_UI_ITEM,
EDIT_ACC_MENU_STR, TOOLTIP_EDIT_REG,
gnc_recn_edit_account_cb, recnData, NULL,
EDIT_ACC_MENU_STR_N, TOOLTIP_EDIT_REG_N,
gnc_recn_edit_account_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_SEPARATOR,
{
GNOME_APP_UI_ITEM,
TRANSFER_MENU_E_STR, TOOLTIP_TRANSFER,
gnc_recn_xfer_cb, recnData, NULL,
TRANSFER_MENU_E_STR_N, TOOLTIP_TRANSFER_N,
gnc_recn_xfer_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
{
GNOME_APP_UI_ITEM,
ADJ_BALN_MENU_E_STR, TOOLTIP_ADJUST,
gnc_recn_adjust_cb, recnData, NULL,
ADJ_BALN_MENU_E_STR_N, TOOLTIP_ADJUST_N,
gnc_recn_adjust_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_SEPARATOR,
{
GNOME_APP_UI_ITEM,
SCRUB_MENU_STR, TOOLTIP_SCRUB_ACCT,
gnc_recn_scrub_cb, recnData, NULL,
SCRUB_MENU_STR_N, TOOLTIP_SCRUB_ACCT_N,
gnc_recn_scrub_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_END
};
GnomeUIInfo transaction_menu[] =
static GnomeUIInfo transaction_menu[] =
{
{
GNOME_APP_UI_ITEM,
NEW_MENU_STR, TOOLTIP_NEW_TRANS,
gnc_ui_reconcile_window_new_cb, recnData, NULL,
NEW_MENU_STR_N, TOOLTIP_NEW_TRANS_N,
gnc_ui_reconcile_window_new_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'n', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
EDIT_MENU_STR, TOOLTIP_EDIT_TRANS,
gnc_ui_reconcile_window_edit_cb, recnData, NULL,
EDIT_MENU_STR_N, TOOLTIP_EDIT_TRANS_N,
gnc_ui_reconcile_window_edit_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'e', GDK_CONTROL_MASK, NULL
},
{
GNOME_APP_UI_ITEM,
DELETE_MENU_STR, TOOLTIP_DEL_TRANS,
gnc_ui_reconcile_window_delete_cb, recnData, NULL,
DELETE_MENU_STR_N, TOOLTIP_DEL_TRANS_N,
gnc_ui_reconcile_window_delete_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
'd', GDK_CONTROL_MASK, NULL
},
GNOMEUIINFO_END
};
GnomeUIInfo help_menu[] =
static GnomeUIInfo help_menu[] =
{
{
GNOME_APP_UI_ITEM,
HELP_MENU_STR, TOOLTIP_HELP,
gnc_ui_reconcile_window_help_cb, recnData, NULL,
HELP_MENU_STR_N, TOOLTIP_HELP_N,
gnc_ui_reconcile_window_help_cb, NULL, NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, 0, NULL
},
GNOMEUIINFO_END
};
GnomeUIInfo reconcile_window_menu[] =
static GnomeUIInfo reconcile_window_menu[] =
{
GNOMEUIINFO_SUBTREE(RECONCILE_MENU_STR, reconcile_menu),
GNOMEUIINFO_SUBTREE(ACCOUNT_MENU_STR, account_menu),
GNOMEUIINFO_SUBTREE(TRANSACTION_MENU_STR, transaction_menu),
GNOMEUIINFO_SUBTREE(RECONCILE_MENU_STR_N, reconcile_menu),
GNOMEUIINFO_SUBTREE(ACCOUNT_MENU_STR_N, account_menu),
GNOMEUIINFO_SUBTREE(TRANSACTION_MENU_STR_N, transaction_menu),
GNOMEUIINFO_MENU_HELP_TREE(help_menu),
GNOMEUIINFO_END
};
gnc_fill_menu_with_data(reconcile_window_menu, recnData);
menubar = gtk_menu_bar_new();
accel_group = gtk_accel_group_new();

View File

@ -1,14 +1,3 @@
/*
* FILE:
* table-allgui.c
*
* FUNCTION:
* Implements the gui-independent parts of the table infrastructure.
*
* HISTORY:
* Copyright (c) 1998,1999,2000 Linas Vepstas
*/
/********************************************************************\
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
@ -25,6 +14,17 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
\********************************************************************/
/*
* FILE:
* table-allgui.c
*
* FUNCTION:
* Implements the gui-independent parts of the table infrastructure.
*
* HISTORY:
* Copyright (c) 1998,1999,2000 Linas Vepstas
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -461,7 +461,7 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col,
* passive again. */
makePassive (table);
if (do_move_gui)
xaccRefreshCursorGUI(table, FALSE);
xaccRefreshCursorGUI(table, GNC_F);
}
/* check for out-of-bounds conditions (which may be deliberate) */
@ -583,13 +583,17 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col,
void xaccMoveCursor (Table *table, int new_phys_row, int new_phys_col)
{
doMoveCursor (table, new_phys_row, new_phys_col, 0);
if (!table) return;
doMoveCursor (table, new_phys_row, new_phys_col, 0);
}
/* same as above, but be sure to deal with GUI elements as well */
void xaccMoveCursorGUI (Table *table, int new_phys_row, int new_phys_col)
{
doMoveCursor (table, new_phys_row, new_phys_col, 1);
if (!table) return;
doMoveCursor (table, new_phys_row, new_phys_col, 1);
}
/* ==================================================== */
@ -602,6 +606,8 @@ void xaccCommitCursor (Table *table)
int phys_row, phys_col;
int phys_row_origin, phys_col_origin;
if (!table) return;
curs = table->current_cursor;
if (!curs) return;
@ -661,6 +667,7 @@ xaccRefreshHeader (Table *table)
int i,j;
CellBlock *arr;
if (!table) return;
if (!(table->entries)) return;
/* copy header data into entries cache */
@ -699,7 +706,7 @@ xaccVerifyCursorPosition (Table *table, int phys_row, int phys_col)
gncBoolean do_commit = GNC_F;
gncBoolean moved_cursor = GNC_F;
if (!table) return FALSE;
if (!table) return GNC_F;
/* Someone may be trying to intentionally invalidate the cursor,
* in which case the physical addresses could be out of bounds.
@ -759,6 +766,8 @@ xaccGetUserData (Table *table, int phys_row, int phys_col)
{
int virt_row, virt_col;
if (!table) return NULL;
/* check for out-of-bounds conditions */
if ((0 > phys_row) || (0 > phys_col) ||
(phys_row >= table->num_phys_rows) ||
@ -813,6 +822,8 @@ wrapVerifyCursorPosition (Table *table, int row, int col)
const int save_phys_col = table->current_cursor_phys_col;
gncBoolean moved_cursor;
if (!table) return;
ENTER("wrapVerifyCursorPosition(): (%d %d) val=%s\n",
row,col, table->entries[row][col]);
@ -835,10 +846,12 @@ wrapVerifyCursorPosition (Table *table, int row, int col)
void
xaccRefreshCursorGUI (Table * table, gncBoolean do_scroll)
{
doRefreshCursorGUI (table, table->current_cursor,
table->current_cursor_phys_row,
table->current_cursor_phys_col,
do_scroll);
if (!table) return;
doRefreshCursorGUI (table, table->current_cursor,
table->current_cursor_phys_row,
table->current_cursor_phys_col,
do_scroll);
}
/* ==================================================== */
@ -852,6 +865,8 @@ gnc_register_cell_valid(Table *table, int row, int col, gncBoolean exact_cell)
int virt_row, virt_col;
CellBlock *arr, *header;
if (!table) return GNC_F;
/* can't edit outside of the physical space */
invalid = (0 > row) || (0 > col) ;
invalid = invalid || (row >= table->num_phys_rows);
@ -860,7 +875,7 @@ gnc_register_cell_valid(Table *table, int row, int col, gncBoolean exact_cell)
/* In case we're called after table has been destroyed. */
invalid = invalid || (table->handlers == NULL);
if(invalid) return GNC_F;
if (invalid) return GNC_F;
/* header rows cannot be modified */
/* hack alert -- assumes that header is first cell */

View File

@ -70,31 +70,38 @@
gnc:*pnl-report-options*)
(define (render-level-2-account level-2-account l2-value)
(let ((account-name (gnc:account-get-name level-2-account))
(let ((account-name (string-append "&nbsp;&nbsp;"
(gnc:account-get-full-name
level-2-account)))
(type-name (gnc:account-get-type-string
(gnc:account-get-type level-2-account))))
(html-table-row
(html-table-row-align
(list
account-name type-name (gnc:amount->formatted-string l2-value #f)))))
; (list "left" "center" "right"))))
account-name type-name (gnc:amount->formatted-string l2-value #f))
(list "left" "center" "right"))))
(define (render-level-1-account account l1-value l2-value)
(let ((name (gnc:account-get-name account))
(let ((name (gnc:account-get-full-name account))
(type (gnc:account-get-type-string (gnc:account-get-type account))))
(html-table-row
(html-table-row-align
(list name type
(gnc:amount->formatted-string l2-value #f)
(if l2-value
(gnc:amount->formatted-string l2-value #f)
"&nbsp;")
(gnc:amount->formatted-string l1-value #f)
"&nbsp;" "&nbsp;"))))
; (list "left" "center" "right" "right" "right" "right"))))
"&nbsp;" "&nbsp;")
(list "left" "center" "right" "right" "right" "right"))))
(define (render-total l0-value)
(html-table-row
(html-table-row-align
(list "&nbsp;" "&nbsp;" "&nbsp;"
(html-strong (string-db 'lookup 'net))
"&nbsp;"
(gnc:amount->formatted-string l0-value #f))))
; (list "left" "center" "right" "right" "right" "right")))
(gnc:amount->formatted-string l0-value #f))
(list "left" "center" "right" "right" "right" "right")))
(define blank-line
(html-table-row '()))
(define (is-it-on-balance-sheet? type balance?)
(eq?
@ -116,20 +123,22 @@
(if (is-it-on-balance-sheet? type balance-sheet?)
;; Ignore
'()
(let
((childrens-output (gnc:group-map-accounts
(lambda (x)
(handle-level-2-account x options))
(gnc:account-get-children account)))
(let* ((children (gnc:account-get-children account))
(num-children (gnc:group-get-num-accounts children))
(account-balance (if balance-sheet?
(gnc:account-get-balance-at-date
account
to-value #f)
(gnc:account-get-balance-interval
account
from-value
to-value #f))))
(childrens-output (gnc:group-map-accounts
(lambda (x)
(handle-level-2-account x options))
children))
(account-balance (if balance-sheet?
(gnc:account-get-balance-at-date
account
to-value #f)
(gnc:account-get-balance-interval
account
from-value
to-value #f))))
(if (not balance-sheet?)
(set! account-balance (- account-balance)))
@ -139,10 +148,17 @@
(let ((level-1-output
(render-level-1-account account
(l1-collector 'total #f)
(l2-collector 'total #f))))
(if (> num-children 0)
(l2-collector 'total #f)
#f))))
(l1-collector 'reset #f)
(l2-collector 'reset #f)
(list childrens-output level-1-output))))))
(if (null? childrens-output)
level-1-output
(list blank-line
level-1-output
childrens-output
blank-line)))))))
(define (handle-level-2-account account options)
(let
@ -204,11 +220,14 @@
report-description
"<p>"
"<table cellpadding=1>"
"<table cellpadding=2>"
"<caption><b>" report-name "</b></caption>"
"<tr><th>" (string-db 'lookup 'account-name)
"<th align=center>" (string-db 'lookup 'type)
"<th> <th align=center>" (string-db 'lookup 'balance)
"<tr>"
"<th>" (string-db 'lookup 'account-name) "</th>"
"<th align=center>" (string-db 'lookup 'type) "</th>"
"<th align=right>" (string-db 'lookup 'subaccounts) "</th>"
"<th align=right>" (string-db 'lookup 'balance) "</th>"
"</tr>"
output
@ -219,6 +238,7 @@
(string-db 'store 'net "Net")
(string-db 'store 'type "Type")
(string-db 'store 'account-name "Account Name")
(string-db 'store 'subaccounts "(subaccounts)")
(string-db 'store 'balance "Balance")
(string-db 'store 'bal-title "Balance Sheet")
(string-db 'store 'bal-desc "This page shows your net worth.")