mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
1eb7c9df08
commit
af64219849
98
src/Ledger.c
98
src/Ledger.c
@ -14,22 +14,76 @@
|
|||||||
|
|
||||||
/* ======================================================== */
|
/* ======================================================== */
|
||||||
|
|
||||||
void
|
Split * xaccGetCurrentSplit (BasicRegister *reg)
|
||||||
xaccCommitEdits (BasicRegister *reg)
|
|
||||||
{
|
{
|
||||||
CellBlock *cursor;
|
CellBlock *cursor;
|
||||||
Split *split;
|
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;
|
Transaction *trans;
|
||||||
|
|
||||||
cursor = reg->table->cursor;
|
/* get the handle to the current split and transaction */
|
||||||
|
split = xaccGetCurrentSplit (reg);
|
||||||
split = (Split *) cursor->user_data;
|
|
||||||
if (!split) return;
|
if (!split) return;
|
||||||
|
|
||||||
trans = (Transaction *) (split->parent);
|
trans = (Transaction *) (split->parent);
|
||||||
|
|
||||||
if (trans->num) free (trans->num);
|
/* copy the contents from the cursor to the split */
|
||||||
trans->num = strdup (reg->numCell->value);
|
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];
|
split = slist[0];
|
||||||
while (split) {
|
while (split) {
|
||||||
|
|
||||||
trans = (Transaction *) (split->parent);
|
|
||||||
|
|
||||||
xaccMoveCursor (table, i, 0);
|
xaccMoveCursor (table, i, 0);
|
||||||
|
xaccLoadRegEntry (reg, split);
|
||||||
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);
|
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
split = slist[i];
|
split = slist[i];
|
||||||
|
@ -595,8 +595,7 @@ closeRegWindow( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
RegWindow *regData = (RegWindow *)cd;
|
RegWindow *regData = (RegWindow *)cd;
|
||||||
|
|
||||||
/* Save any unsaved changes */
|
/* Save any unsaved changes */
|
||||||
/* hack alert */
|
xaccSaveRegEntry (regData->ledger);
|
||||||
/* regSaveTransaction( regData, regData->currEntry ); */
|
|
||||||
|
|
||||||
regData->blackacc[0]->regData = NULL;
|
regData->blackacc[0]->regData = NULL;
|
||||||
regData->blackacc[0]->regLedger = NULL;
|
regData->blackacc[0]->regLedger = NULL;
|
||||||
@ -669,13 +668,11 @@ startRecnCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
static void
|
static void
|
||||||
recordCB( Widget mw, XtPointer cd, XtPointer cb )
|
recordCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||||
{
|
{
|
||||||
RegWindow *regData = (RegWindow *)cd;
|
RegWindow *regData = (RegWindow *)cd;
|
||||||
|
|
||||||
/* hack alert */
|
xaccSaveRegEntry (regData->ledger);
|
||||||
/* regSaveTransaction( regData, regData->currEntry ); */
|
}
|
||||||
regData->changed = MOD_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* deleteCB *
|
* deleteCB *
|
||||||
@ -731,8 +728,13 @@ deleteCB( Widget mw, XtPointer cd, XtPointer cb )
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
static void
|
static void
|
||||||
cancelCB( Widget mw, XtPointer cd, XtPointer cb )
|
cancelCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||||
{
|
{
|
||||||
RegWindow *regData = (RegWindow *)cd;
|
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 *************************/
|
/************************** END OF FILE *************************/
|
||||||
|
@ -461,7 +461,22 @@ xaccCountTransactions (Transaction **tarray)
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccTransSetDescription (Transaction *trans, char *desc)
|
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)
|
||||||
{
|
{
|
||||||
if (trans->description) free (trans->description);
|
if (trans->description) free (trans->description);
|
||||||
trans->description = strdup (desc);
|
trans->description = strdup (desc);
|
||||||
|
@ -34,7 +34,7 @@ PriceMV (struct _BasicCell *_cell,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* hack alert - should parse the float pt value */
|
/* hack alert - should parse the float pt value */
|
||||||
xaccSetBaicCellValue (cell, newval);
|
xaccSetBasicCellValue (cell, newval);
|
||||||
return newval;
|
return newval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,10 +109,9 @@ void xaccInitBasicRegister (BasicRegister *reg)
|
|||||||
curs = xaccMallocCellBlock (2, MAX_COLS);
|
curs = xaccMallocCellBlock (2, MAX_COLS);
|
||||||
reg->cursor = curs;
|
reg->cursor = curs;
|
||||||
|
|
||||||
cell = (BasicCell *) xaccMallocDateCell();
|
reg->dateCell = xaccMallocDateCell();
|
||||||
cell->width = 9;
|
reg->dateCell->cell.width = 9;
|
||||||
xaccAddCell (curs, cell, DATE_CELL_R, DATE_CELL_C);
|
xaccAddCell (curs, &(reg->dateCell->cell), DATE_CELL_R, DATE_CELL_C);
|
||||||
reg->dateCell = cell;
|
|
||||||
|
|
||||||
cell = xaccMallocTextCell();
|
cell = xaccMallocTextCell();
|
||||||
cell->width = 7;
|
cell->width = 7;
|
||||||
|
@ -19,7 +19,7 @@ typedef struct _BasicRegister {
|
|||||||
Table * table;
|
Table * table;
|
||||||
CellBlock * cursor;
|
CellBlock * cursor;
|
||||||
CellBlock * header;
|
CellBlock * header;
|
||||||
BasicCell * dateCell;
|
DateCell * dateCell;
|
||||||
BasicCell * numCell;
|
BasicCell * numCell;
|
||||||
ComboCell * actionCell;
|
ComboCell * actionCell;
|
||||||
ComboCell * xfrmCell;
|
ComboCell * xfrmCell;
|
||||||
|
Loading…
Reference in New Issue
Block a user