assorted changes for commiting edits to transaction list

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@472 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-01-31 19:04:44 +00:00
parent 1eb7c9df08
commit af64219849
6 changed files with 96 additions and 52 deletions

View File

@ -14,22 +14,76 @@
/* ======================================================== */
void
xaccCommitEdits (BasicRegister *reg)
Split * xaccGetCurrentSplit (BasicRegister *reg)
{
CellBlock *cursor;
Split *split;
/* get the handle to the current split and transaction */
cursor = reg->table->cursor;
split = (Split *) cursor->user_data;
return split;
}
/* ======================================================== */
void
xaccSaveRegEntry (BasicRegister *reg)
{
Split *split;
Transaction *trans;
cursor = reg->table->cursor;
split = (Split *) cursor->user_data;
/* get the handle to the current split and transaction */
split = xaccGetCurrentSplit (reg);
if (!split) return;
trans = (Transaction *) (split->parent);
if (trans->num) free (trans->num);
trans->num = strdup (reg->numCell->value);
/* copy the contents from the cursor to the split */
xaccTransSetDate (trans, reg->dateCell->date.tm_mday,
reg->dateCell->date.tm_mon+1,
reg->dateCell->date.tm_year+1900);
xaccTransSetNum (trans, reg->numCell->value);
xaccTransSetDescription (trans, reg->descCell->cell.value);
xaccSplitSetMemo (split, reg->memoCell->value);
xaccSplitSetAction (split, reg->actionCell->cell.value);
xaccSplitSetReconcile (split, reg->recnCell->value[0]);
}
/* ======================================================== */
void
xaccLoadRegEntry (BasicRegister *reg, Split *split)
{
Transaction *trans;
char buff[2];
if (!split) return;
trans = (Transaction *) (split->parent);
xaccSetDateCellValue (reg->dateCell, trans->date.day,
trans->date.month,
trans->date.year);
xaccSetBasicCellValue (reg->numCell, trans->num);
xaccSetBasicCellValue (&(reg->actionCell->cell), split->action);
xaccSetQuickFillCellValue (reg->descCell, trans->description);
xaccSetBasicCellValue (reg->memoCell, split->memo);
buff[0] = split->reconciled;
buff[1] = 0x0;
xaccSetBasicCellValue (reg->recnCell, buff);
xaccSetDebCredCellValue (reg->debitCell,
reg->creditCell, split->damount);
xaccSetAmountCellValue (reg->balanceCell, split->balance);
reg->table->cursor->user_data = (void *) split;
/* copy cursor contents into the table */
xaccCommitCursor (reg->table);
}
/* ======================================================== */
@ -55,34 +109,8 @@ xaccLoadRegister (BasicRegister *reg, Split **slist)
split = slist[0];
while (split) {
trans = (Transaction *) (split->parent);
xaccMoveCursor (table, i, 0);
sprintf (buff, "%2d/%2d/%4d", trans->date.day,
trans->date.month,
trans->date.year);
xaccSetBasicCellValue (reg->dateCell, buff);
xaccSetBasicCellValue (reg->numCell, trans->num);
xaccSetBasicCellValue (&(reg->actionCell->cell), split->action);
xaccSetQuickFillCellValue (reg->descCell, trans->description);
xaccSetBasicCellValue (reg->memoCell, split->memo);
buff[0] = split->reconciled;
buff[1] = 0x0;
xaccSetBasicCellValue (reg->recnCell, buff);
xaccSetDebCredCellValue (reg->debitCell,
reg->creditCell, split->damount);
xaccSetAmountCellValue (reg->balanceCell, split->balance);
table->cursor->user_data = (void *) split;
/* copy cursor contents into the table */
xaccCommitCursor (table);
xaccLoadRegEntry (reg, split);
i++;
split = slist[i];

View File

@ -595,8 +595,7 @@ closeRegWindow( Widget mw, XtPointer cd, XtPointer cb )
RegWindow *regData = (RegWindow *)cd;
/* Save any unsaved changes */
/* hack alert */
/* regSaveTransaction( regData, regData->currEntry ); */
xaccSaveRegEntry (regData->ledger);
regData->blackacc[0]->regData = NULL;
regData->blackacc[0]->regLedger = NULL;
@ -669,13 +668,11 @@ startRecnCB( Widget mw, XtPointer cd, XtPointer cb )
\********************************************************************/
static void
recordCB( Widget mw, XtPointer cd, XtPointer cb )
{
{
RegWindow *regData = (RegWindow *)cd;
/* hack alert */
/* regSaveTransaction( regData, regData->currEntry ); */
regData->changed = MOD_NONE;
}
xaccSaveRegEntry (regData->ledger);
}
/********************************************************************\
* deleteCB *
@ -731,8 +728,13 @@ deleteCB( Widget mw, XtPointer cd, XtPointer cb )
\********************************************************************/
static void
cancelCB( Widget mw, XtPointer cd, XtPointer cb )
{
{
RegWindow *regData = (RegWindow *)cd;
}
Split * split;
/* when cancelling edits, reload the cursor from the transaction */
split = xaccGetCurrentSplit (regData->ledger);
xaccLoadRegEntry (regData->ledger, split);
}
/************************** END OF FILE *************************/

View File

@ -460,6 +460,21 @@ xaccCountTransactions (Transaction **tarray)
/********************************************************************\
\********************************************************************/
void
xaccTransSetDate (Transaction *trans, int day, int mon, int year)
{
trans->date.year = year;
trans->date.month = mon;
trans->date.day = day;
}
void
xaccTransSetNum (Transaction *trans, char *xnum)
{
if (trans->num) free (trans->num);
trans->num = strdup (xnum);
}
void
xaccTransSetDescription (Transaction *trans, char *desc)
{

View File

@ -34,7 +34,7 @@ PriceMV (struct _BasicCell *_cell,
}
/* hack alert - should parse the float pt value */
xaccSetBaicCellValue (cell, newval);
xaccSetBasicCellValue (cell, newval);
return newval;
}

View File

@ -109,10 +109,9 @@ void xaccInitBasicRegister (BasicRegister *reg)
curs = xaccMallocCellBlock (2, MAX_COLS);
reg->cursor = curs;
cell = (BasicCell *) xaccMallocDateCell();
cell->width = 9;
xaccAddCell (curs, cell, DATE_CELL_R, DATE_CELL_C);
reg->dateCell = cell;
reg->dateCell = xaccMallocDateCell();
reg->dateCell->cell.width = 9;
xaccAddCell (curs, &(reg->dateCell->cell), DATE_CELL_R, DATE_CELL_C);
cell = xaccMallocTextCell();
cell->width = 7;

View File

@ -19,7 +19,7 @@ typedef struct _BasicRegister {
Table * table;
CellBlock * cursor;
CellBlock * header;
BasicCell * dateCell;
DateCell * dateCell;
BasicCell * numCell;
ComboCell * actionCell;
ComboCell * xfrmCell;