mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
fix blan-split handling
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@734 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
ccd1537fd7
commit
ddb9495572
48
src/Ledger.c
48
src/Ledger.c
@ -36,6 +36,10 @@
|
|||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024
|
||||||
|
|
||||||
/* ======================================================== */
|
/* ======================================================== */
|
||||||
|
/* this callback gets called when the user clicks on the gui
|
||||||
|
* in such a way as to leave the current transaction, and to
|
||||||
|
* go to a new one. So, sve the current transaction.
|
||||||
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LedgerMoveCursor (Table *table, void * client_data)
|
LedgerMoveCursor (Table *table, void * client_data)
|
||||||
@ -252,6 +256,7 @@ xaccLoadRegister (BasicRegister *reg, Split **slist,
|
|||||||
int num_phys_cols;
|
int num_phys_cols;
|
||||||
int num_virt_rows;
|
int num_virt_rows;
|
||||||
int phys_row;
|
int phys_row;
|
||||||
|
int vrow;
|
||||||
|
|
||||||
table = reg->table;
|
table = reg->table;
|
||||||
|
|
||||||
@ -292,41 +297,50 @@ xaccLoadRegister (BasicRegister *reg, Split **slist,
|
|||||||
printf ("load reg of %d entries --------------------------- \n",i);
|
printf ("load reg of %d entries --------------------------- \n",i);
|
||||||
/* populate the table */
|
/* populate the table */
|
||||||
i=0;
|
i=0;
|
||||||
|
vrow = 0;
|
||||||
split = slist[0];
|
split = slist[0];
|
||||||
while (split) {
|
while (split) {
|
||||||
phys_row = reg->header->numRows;
|
|
||||||
phys_row += i * (reg->cursor->numRows);
|
|
||||||
|
|
||||||
/* i+1 because header is virt row zero */
|
/* don't load the "blank split" inline; instead, we put
|
||||||
xaccSetCursor (table, reg->cursor, phys_row, 0, i+1, 0);
|
* it at the end. */
|
||||||
xaccMoveCursor (table, phys_row, 0);
|
if (split != ((Split *) (reg->user_hook))) {
|
||||||
xaccLoadRegEntry (reg, split);
|
phys_row = reg->header->numRows;
|
||||||
|
phys_row += vrow * (reg->cursor->numRows);
|
||||||
|
|
||||||
|
/* vrow+1 because header is virt row zero */
|
||||||
|
vrow ++;
|
||||||
|
xaccSetCursor (table, reg->cursor, phys_row, 0, vrow, 0);
|
||||||
|
xaccMoveCursor (table, phys_row, 0);
|
||||||
|
xaccLoadRegEntry (reg, split);
|
||||||
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
split = slist[i];
|
split = slist[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the "blank split" at the end */
|
/* add the "blank split" at the end */
|
||||||
if (!(reg->user_hook)) {
|
if (reg->user_hook) {
|
||||||
|
split = (Split *) reg->user_hook;
|
||||||
|
} else {
|
||||||
trans = xaccMallocTransaction ();
|
trans = xaccMallocTransaction ();
|
||||||
xaccTransSetDateToday (trans);
|
xaccTransSetDateToday (trans);
|
||||||
split = xaccTransGetSourceSplit (trans);
|
split = xaccTransGetSourceSplit (trans);
|
||||||
xaccAccountInsertSplit (default_source_acc, split);
|
xaccAccountInsertSplit (default_source_acc, split);
|
||||||
reg->user_hook = (void *) split;
|
reg->user_hook = (void *) split;
|
||||||
reg->destroy = LedgerDestroy;
|
reg->destroy = LedgerDestroy;
|
||||||
|
|
||||||
phys_row = reg->header->numRows;
|
|
||||||
phys_row += i * (reg->cursor->numRows);
|
|
||||||
xaccSetCursor (table, reg->cursor, phys_row, 0, i+1, 0);
|
|
||||||
xaccMoveCursor (table, phys_row, 0);
|
|
||||||
|
|
||||||
xaccLoadRegEntry (reg, split);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
phys_row = reg->header->numRows;
|
||||||
|
phys_row += vrow * (reg->cursor->numRows);
|
||||||
|
vrow ++;
|
||||||
|
xaccSetCursor (table, reg->cursor, phys_row, 0, vrow, 0);
|
||||||
|
xaccMoveCursor (table, phys_row, 0);
|
||||||
|
|
||||||
|
xaccLoadRegEntry (reg, split);
|
||||||
|
|
||||||
/* restore the cursor to its original location */
|
/* restore the cursor to its original location */
|
||||||
phys_row = reg->header->numRows;
|
phys_row = reg->header->numRows;
|
||||||
phys_row += i * (reg->cursor->numRows);
|
phys_row += vrow * (reg->cursor->numRows);
|
||||||
|
|
||||||
if (phys_row <= save_cursor_phys_row) {
|
if (phys_row <= save_cursor_phys_row) {
|
||||||
save_cursor_phys_row = phys_row - reg->cursor->numRows;
|
save_cursor_phys_row = phys_row - reg->cursor->numRows;
|
||||||
|
Loading…
Reference in New Issue
Block a user