Add Transaction Notes field.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3204 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-11-28 08:08:56 +00:00
parent 17cd046e33
commit a46cc74491
7 changed files with 151 additions and 141 deletions

View File

@ -2307,6 +2307,9 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm,
if (MOD_DESC & changed) if (MOD_DESC & changed)
gnc_trans_scm_set_description(trans_scm, reg->descCell->cell.value); gnc_trans_scm_set_description(trans_scm, reg->descCell->cell.value);
if (MOD_NOTES & changed)
gnc_trans_scm_set_notes(trans_scm, reg->notesCell->cell.value);
if (MOD_RECN & changed) if (MOD_RECN & changed)
gnc_split_scm_set_reconcile_state(split_scm, gnc_split_scm_set_reconcile_state(split_scm,
xaccRecnCellGetFlag(reg->recnCell)); xaccRecnCellGetFlag(reg->recnCell));
@ -2338,24 +2341,11 @@ xaccSRSaveRegEntryToSCM (SplitRegister *reg, SCM trans_scm, SCM split_scm,
if (other_split_scm == SCM_UNDEFINED) { if (other_split_scm == SCM_UNDEFINED) {
if (gnc_trans_scm_get_num_splits(trans_scm) == 1) { if (gnc_trans_scm_get_num_splits(trans_scm) == 1) {
Split *temp_split; Split *temp_split;
char *temp_string;
temp_split = xaccMallocSplit (); temp_split = xaccMallocSplit ();
other_split_scm = gnc_copy_split(temp_split, use_cut_semantics); other_split_scm = gnc_copy_split(temp_split, use_cut_semantics);
xaccSplitDestroy(temp_split); xaccSplitDestroy(temp_split);
temp_string = gnc_split_scm_get_memo(split_scm);
if (temp_string != NULL) {
gnc_split_scm_set_memo(other_split_scm, temp_string);
free(temp_string);
}
temp_string = gnc_split_scm_get_action(split_scm);
if (temp_string != NULL) {
gnc_split_scm_set_action(other_split_scm, temp_string);
free(temp_string);
}
gnc_trans_scm_append_split_scm(trans_scm, other_split_scm); gnc_trans_scm_append_split_scm(trans_scm, other_split_scm);
} }
} }
@ -2595,25 +2585,27 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
} }
if (MOD_DESC & changed) { if (MOD_DESC & changed) {
DEBUG ("MOD_DESC: %s\n", DEBUG ("MOD_DESC: %s", reg->descCell->cell.value);
reg->descCell->cell.value);
xaccTransSetDescription (trans, reg->descCell->cell.value); xaccTransSetDescription (trans, reg->descCell->cell.value);
} }
if (MOD_NOTES & changed) {
DEBUG ("MOD_NOTES: %s", reg->notesCell->cell.value);
xaccTransSetNotes (trans, reg->notesCell->cell.value);
}
if (MOD_RECN & changed) { if (MOD_RECN & changed) {
DEBUG ("MOD_RECN: %c\n", xaccRecnCellGetFlag(reg->recnCell)); DEBUG ("MOD_RECN: %c", xaccRecnCellGetFlag(reg->recnCell));
xaccSplitSetReconcile (split, xaccRecnCellGetFlag(reg->recnCell)); xaccSplitSetReconcile (split, xaccRecnCellGetFlag(reg->recnCell));
} }
if (MOD_ACTN & changed) { if (MOD_ACTN & changed) {
DEBUG ("MOD_ACTN: %s\n", DEBUG ("MOD_ACTN: %s", reg->actionCell->cell.value);
reg->actionCell->cell.value);
xaccSplitSetAction (split, reg->actionCell->cell.value); xaccSplitSetAction (split, reg->actionCell->cell.value);
} }
if (MOD_MEMO & changed) { if (MOD_MEMO & changed) {
DEBUG ("MOD_MEMO: %s\n", DEBUG ("MOD_MEMO: %s", reg->memoCell->cell.value);
reg->memoCell->cell.value);
xaccSplitSetMemo (split, reg->memoCell->cell.value); xaccSplitSetMemo (split, reg->memoCell->cell.value);
} }
@ -2627,18 +2619,17 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
* XFRM or XTO should be in a given cursor. */ * XFRM or XTO should be in a given cursor. */
if ((MOD_XFRM | MOD_XTO) & changed) if ((MOD_XFRM | MOD_XTO) & changed)
{ {
Account *old_acc=NULL, *new_acc=NULL; Account *old_acc;
Account *new_acc;
char *new_name; char *new_name;
if (MOD_XFRM & changed) if (MOD_XFRM & changed)
{ {
DEBUG ("MOD_XFRM: %s\n", DEBUG ("MOD_XFRM: %s", reg->xfrmCell->cell.value);
reg->xfrmCell->cell.value);
} }
else else
{ {
DEBUG ("MOD_XTO: %s\n", DEBUG ("MOD_XTO: %s", reg->xtoCell->cell.value);
reg->xtoCell->cell.value);
} }
/* do some reparenting. Insertion into new account will automatically /* do some reparenting. Insertion into new account will automatically
@ -2693,8 +2684,7 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
if (MOD_MXFRM & changed) if (MOD_MXFRM & changed)
{ {
DEBUG ("MOD_MXFRM: %s\n", DEBUG ("MOD_MXFRM: %s", reg->mxfrmCell->cell.value);
reg->mxfrmCell->cell.value);
other_split = xaccGetOtherSplit(split); other_split = xaccGetOtherSplit(split);
@ -3106,6 +3096,10 @@ xaccSRGetEntryHandler (VirtualLocation virt_loc, short _cell_type,
return xaccTransGetDescription (trans); return xaccTransGetDescription (trans);
break; break;
case NOTES_CELL:
return xaccTransGetNotes (trans);
break;
case RECN_CELL: case RECN_CELL:
{ {
static char s[2]; static char s[2];
@ -3733,16 +3727,17 @@ xaccSRLoadRegister (SplitRegister *reg, Split **slist,
* fill up the quickfill cells. */ * fill up the quickfill cells. */
if (info->first_pass) if (info->first_pass)
{ {
int j, num_splits; GList *node;
Split *s;
xaccQuickFillAddCompletion (reg->descCell, xaccQuickFillAddCompletion (reg->descCell,
xaccTransGetDescription (trans)); xaccTransGetDescription (trans));
num_splits = xaccTransCountSplits (trans); xaccQuickFillAddCompletion (reg->notesCell,
for (j = 0; j < num_splits; j++) xaccTransGetNotes (trans));
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{ {
s = xaccTransGetSplit (trans, j); Split *s = node->data;
xaccQuickFillAddCompletion (reg->memoCell, xaccSplitGetMemo (s)); xaccQuickFillAddCompletion (reg->memoCell, xaccSplitGetMemo (s));
} }
} }

View File

@ -1933,9 +1933,10 @@ xaccTransSetNotes (Transaction *trans, const char *notes)
kvp_value *new_value; kvp_value *new_value;
if (!trans || !notes) return; if (!trans || !notes) return;
CHECK_OPEN (trans); CHECK_OPEN (trans);
new_value = kvp_value_new_string(notes); new_value = kvp_value_new_string (notes);
if (new_value) if (new_value)
{ {

View File

@ -1107,6 +1107,7 @@ readTransaction( int fd, Account *acc, int token )
} else { /* else, read version 5 and above files */ } else { /* else, read version 5 and above files */
Split *split; Split *split;
int offset = 0; int offset = 0;
const char *notes = NULL;
if (5 == token) if (5 == token)
{ {
@ -1145,6 +1146,12 @@ readTransaction( int fd, Account *acc, int token )
} else { } else {
xaccTransAppendSplit(trans, split); xaccTransAppendSplit(trans, split);
} }
if (!notes) {
notes = xaccSplitGetMemo (split);
if (notes)
xaccTransSetNotes (trans, notes);
}
} }
} }
xaccTransCommitEdit (trans); xaccTransCommitEdit (trans);

View File

@ -41,12 +41,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <glib.h> #include <glib.h>
#include "gnc-engine-util.h"
#include "messages.h"
#include "recncell.h" #include "recncell.h"
#include "splitreg.h" #include "splitreg.h"
#include "table-allgui.h" #include "table-allgui.h"
#include "textcell.h" #include "textcell.h"
#include "messages.h"
#include "gnc-engine-util.h"
/* This static indicates the debugging module that this .o belongs to. */ /* This static indicates the debugging module that this .o belongs to. */
@ -80,29 +80,31 @@ struct _SplitRegisterBuffer
CellBuffer priceCell; CellBuffer priceCell;
CellBuffer sharesCell; CellBuffer sharesCell;
CellBuffer mxfrmCell; CellBuffer mxfrmCell;
CellBuffer notesCell;
}; };
static char *cell_sample_strings[] = static char *cell_sample_strings[] =
{ {
N_("sample:12/12/2000"+7), /* date cell */ N_("sample:12/12/2000"+7), /* date cell */
N_("sample:99999"+7), /* num cell */ N_("sample:99999"+7), /* num cell */
N_("sample:Description of a transaction"+7), /* desc cell */ N_("sample:Description of a transaction"+7), /* desc cell */
N_("Reconciled:R"+11), /* recn cell */ N_("Reconciled:R"+11), /* recn cell */
N_("sample:999,999.000"+7), /* share balance cell */ N_("sample:999,999.000"+7), /* share balance cell */
N_("sample:999,999.000"+7), /* balance cell */ N_("sample:999,999.000"+7), /* balance cell */
N_("Transfer"), /* action cell */ N_("Transfer"), /* action cell */
N_("sample:Expenses:Automobile:Gasoline"+7), /* xfrm cell */ N_("sample:Expenses:Automobile:Gasoline"+7), /* xfrm cell */
N_("sample:Expenses:Automobile:Gasoline"+7), /* xto cell */ N_("sample:Expenses:Automobile:Gasoline"+7), /* xto cell */
N_("sample:Memo field sample text string"+7), /* memo cell */ N_("sample:Memo field sample text string"+7), /* memo cell */
N_("sample:999,999.000"+7), /* credit cell */ N_("sample:999,999.000"+7), /* credit cell */
N_("sample:999,999.000"+7), /* debit cell */ N_("sample:999,999.000"+7), /* debit cell */
N_("sample:999,999.000"+7), /* price cell */ N_("sample:999,999.000"+7), /* price cell */
N_("sample:999,999.000"+7), /* shares cell */ N_("sample:999,999.000"+7), /* shares cell */
N_("sample:Expenses:Automobile:Gasoline"+7), /* mxfrm cell */ N_("sample:Expenses:Automobile:Gasoline"+7), /* mxfrm cell */
N_("sample:999,999.000"+7), /* tcredit cell */ N_("sample:999,999.000"+7), /* tcredit cell */
N_("sample:999,999.000"+7), /* tdebit cell */ N_("sample:999,999.000"+7), /* tdebit cell */
N_("sample:999,999.000"+7), /* tshrbaln cell */ N_("sample:999,999.000"+7), /* tshrbaln cell */
N_("sample:999,999.000"+7), /* tbalance cell */ N_("sample:999,999.000"+7), /* tbalance cell */
N_("sample:Notes field sample text string"+7), /* notes cell */
}; };
static CellAlignment cell_alignments[] = static CellAlignment cell_alignments[] =
@ -126,6 +128,7 @@ static CellAlignment cell_alignments[] =
CELL_ALIGN_RIGHT, /* tdebit cell */ CELL_ALIGN_RIGHT, /* tdebit cell */
CELL_ALIGN_RIGHT, /* tshrbaln cell */ CELL_ALIGN_RIGHT, /* tshrbaln cell */
CELL_ALIGN_RIGHT, /* tbalance cell */ CELL_ALIGN_RIGHT, /* tbalance cell */
CELL_ALIGN_LEFT, /* notes cell */
}; };
@ -196,6 +199,7 @@ configLabels (SplitRegister *reg)
LABEL (TDEBT, _("Total")); LABEL (TDEBT, _("Total"));
LABEL (TSHRBALN, _("Total Shares")); LABEL (TSHRBALN, _("Total Shares"));
LABEL (TBALN, _("Balance")); LABEL (TBALN, _("Balance"));
LABEL (NOTES, _("Notes"));
if (debit_getter != NULL) if (debit_getter != NULL)
{ {
@ -433,8 +437,8 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_ledger_double; curs = reg->cursor_ledger_double;
copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0); copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0);
set_cell (reg, curs, ACTN_CELL, 1, 1); set_cell (reg, curs, ACTN_CELL, 1, 1);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_journal_single; curs = reg->cursor_journal_single;
set_cell (reg, curs, DATE_CELL, 0, 0); set_cell (reg, curs, DATE_CELL, 0, 0);
@ -448,7 +452,7 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_journal_double; curs = reg->cursor_journal_double;
copy_cursor_row (reg, curs, reg->cursor_journal_single, 0); copy_cursor_row (reg, curs, reg->cursor_journal_single, 0);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_split; curs = reg->cursor_split;
set_cell (reg, curs, ACTN_CELL, 0, 1); set_cell (reg, curs, ACTN_CELL, 0, 1);
@ -478,8 +482,8 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_ledger_double; curs = reg->cursor_ledger_double;
copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0); copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0);
set_cell (reg, curs, ACTN_CELL, 1, 1); set_cell (reg, curs, ACTN_CELL, 1, 1);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_journal_single; curs = reg->cursor_journal_single;
set_cell (reg, curs, DATE_CELL, 0, 0); set_cell (reg, curs, DATE_CELL, 0, 0);
@ -493,7 +497,7 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_journal_double; curs = reg->cursor_journal_double;
copy_cursor_row (reg, curs, reg->cursor_journal_single, 0); copy_cursor_row (reg, curs, reg->cursor_journal_single, 0);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_split; curs = reg->cursor_split;
set_cell (reg, curs, ACTN_CELL, 0, 1); set_cell (reg, curs, ACTN_CELL, 0, 1);
@ -525,8 +529,8 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_ledger_double; curs = reg->cursor_ledger_double;
copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0); copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0);
set_cell (reg, curs, ACTN_CELL, 1, 1); set_cell (reg, curs, ACTN_CELL, 1, 1);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_journal_single; curs = reg->cursor_journal_single;
set_cell (reg, curs, DATE_CELL, 0, 0); set_cell (reg, curs, DATE_CELL, 0, 0);
@ -543,7 +547,7 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_journal_double; curs = reg->cursor_journal_double;
copy_cursor_row (reg, curs, reg->cursor_journal_single, 0); copy_cursor_row (reg, curs, reg->cursor_journal_single, 0);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_split; curs = reg->cursor_split;
set_cell (reg, curs, ACTN_CELL, 0, 1); set_cell (reg, curs, ACTN_CELL, 0, 1);
@ -573,8 +577,8 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_ledger_double; curs = reg->cursor_ledger_double;
copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0); copy_cursor_row (reg, curs, reg->cursor_ledger_single, 0);
set_cell (reg, curs, ACTN_CELL, 1, 1); set_cell (reg, curs, ACTN_CELL, 1, 1);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_journal_single; curs = reg->cursor_journal_single;
set_cell (reg, curs, DATE_CELL, 0, 0); set_cell (reg, curs, DATE_CELL, 0, 0);
@ -590,7 +594,7 @@ configLayout (SplitRegister *reg)
curs = reg->cursor_journal_double; curs = reg->cursor_journal_double;
copy_cursor_row (reg, curs, reg->cursor_journal_single, 0); copy_cursor_row (reg, curs, reg->cursor_journal_single, 0);
set_cell (reg, curs, MEMO_CELL, 1, 2); set_cell (reg, curs, NOTES_CELL, 1, 2);
curs = reg->cursor_split; curs = reg->cursor_split;
set_cell (reg, curs, ACTN_CELL, 0, 1); set_cell (reg, curs, ACTN_CELL, 0, 1);
@ -790,6 +794,7 @@ xaccInitSplitRegister (SplitRegister *reg,
NEW (TDEBT, tdebit, Price); NEW (TDEBT, tdebit, Price);
NEW (TSHRBALN, tshrbaln, Price); NEW (TSHRBALN, tshrbaln, Price);
NEW (TBALN, tbalance, Price); NEW (TBALN, tbalance, Price);
NEW (NOTES, notes, QuickFill);
/* --------------------------- */ /* --------------------------- */
@ -845,6 +850,10 @@ xaccInitSplitRegister (SplitRegister *reg,
xaccSetBasicCellBlankHelp (&reg->descCell->cell, xaccSetBasicCellBlankHelp (&reg->descCell->cell,
_("Enter a description of the transaction")); _("Enter a description of the transaction"));
/* the notes cell */
xaccSetBasicCellBlankHelp (&reg->notesCell->cell,
_("Enter notes for the transaction"));
/* The balance and total cells are just placeholders */ /* The balance and total cells are just placeholders */
reg->balanceCell->cell.input_output = XACC_CELL_ALLOW_NONE; reg->balanceCell->cell.input_output = XACC_CELL_ALLOW_NONE;
reg->shrbalnCell->cell.input_output = XACC_CELL_ALLOW_NONE; reg->shrbalnCell->cell.input_output = XACC_CELL_ALLOW_NONE;
@ -1011,6 +1020,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
xaccDestroyPriceCell (reg->tdebitCell); xaccDestroyPriceCell (reg->tdebitCell);
xaccDestroyPriceCell (reg->tshrbalnCell); xaccDestroyPriceCell (reg->tshrbalnCell);
xaccDestroyPriceCell (reg->tbalanceCell); xaccDestroyPriceCell (reg->tbalanceCell);
xaccDestroyQuickFillCell (reg->notesCell);
reg->dateCell = NULL; reg->dateCell = NULL;
reg->numCell = NULL; reg->numCell = NULL;
@ -1031,6 +1041,7 @@ xaccDestroySplitRegister (SplitRegister *reg)
reg->tdebitCell = NULL; reg->tdebitCell = NULL;
reg->tshrbalnCell = NULL; reg->tshrbalnCell = NULL;
reg->tbalanceCell = NULL; reg->tbalanceCell = NULL;
reg->notesCell = NULL;
for (i = 0; i < CELL_TYPE_COUNT; i++) for (i = 0; i < CELL_TYPE_COUNT; i++)
{ {
@ -1058,16 +1069,16 @@ xaccSplitRegisterGetChangeFlag (SplitRegister *reg)
changed |= MOD_NUM & reg->numCell->cell.changed; changed |= MOD_NUM & reg->numCell->cell.changed;
changed |= MOD_DESC & reg->descCell->cell.changed; changed |= MOD_DESC & reg->descCell->cell.changed;
changed |= MOD_RECN & reg->recnCell->cell.changed; changed |= MOD_RECN & reg->recnCell->cell.changed;
changed |= MOD_ACTN & reg->actionCell->cell.changed; changed |= MOD_ACTN & reg->actionCell->cell.changed;
changed |= MOD_XFRM & reg->xfrmCell->cell.changed; changed |= MOD_XFRM & reg->xfrmCell->cell.changed;
changed |= MOD_MXFRM & reg->mxfrmCell->cell.changed;
changed |= MOD_XTO & reg->xtoCell->cell.changed; changed |= MOD_XTO & reg->xtoCell->cell.changed;
changed |= MOD_MEMO & reg->memoCell->cell.changed; changed |= MOD_MEMO & reg->memoCell->cell.changed;
changed |= MOD_AMNT & reg->creditCell->cell.changed; changed |= MOD_AMNT & reg->creditCell->cell.changed;
changed |= MOD_AMNT & reg->debitCell->cell.changed; changed |= MOD_AMNT & reg->debitCell->cell.changed;
changed |= MOD_PRIC & reg->priceCell->cell.changed; changed |= MOD_PRIC & reg->priceCell->cell.changed;
changed |= MOD_SHRS & reg->sharesCell->cell.changed; changed |= MOD_SHRS & reg->sharesCell->cell.changed;
changed |= MOD_MXFRM & reg->mxfrmCell->cell.changed;
changed |= MOD_NOTES & reg->notesCell->cell.changed;
return changed; return changed;
} }
@ -1082,16 +1093,16 @@ xaccSplitRegisterGetConditionalChangeFlag (SplitRegister *reg)
changed |= MOD_NUM & reg->numCell->cell.conditionally_changed; changed |= MOD_NUM & reg->numCell->cell.conditionally_changed;
changed |= MOD_DESC & reg->descCell->cell.conditionally_changed; changed |= MOD_DESC & reg->descCell->cell.conditionally_changed;
changed |= MOD_RECN & reg->recnCell->cell.conditionally_changed; changed |= MOD_RECN & reg->recnCell->cell.conditionally_changed;
changed |= MOD_ACTN & reg->actionCell->cell.conditionally_changed; changed |= MOD_ACTN & reg->actionCell->cell.conditionally_changed;
changed |= MOD_XFRM & reg->xfrmCell->cell.conditionally_changed; changed |= MOD_XFRM & reg->xfrmCell->cell.conditionally_changed;
changed |= MOD_MXFRM & reg->mxfrmCell->cell.conditionally_changed;
changed |= MOD_XTO & reg->xtoCell->cell.conditionally_changed; changed |= MOD_XTO & reg->xtoCell->cell.conditionally_changed;
changed |= MOD_MEMO & reg->memoCell->cell.conditionally_changed; changed |= MOD_MEMO & reg->memoCell->cell.conditionally_changed;
changed |= MOD_AMNT & reg->creditCell->cell.conditionally_changed; changed |= MOD_AMNT & reg->creditCell->cell.conditionally_changed;
changed |= MOD_AMNT & reg->debitCell->cell.conditionally_changed; changed |= MOD_AMNT & reg->debitCell->cell.conditionally_changed;
changed |= MOD_PRIC & reg->priceCell->cell.conditionally_changed; changed |= MOD_PRIC & reg->priceCell->cell.conditionally_changed;
changed |= MOD_SHRS & reg->sharesCell->cell.conditionally_changed; changed |= MOD_SHRS & reg->sharesCell->cell.conditionally_changed;
changed |= MOD_MXFRM & reg->mxfrmCell->cell.conditionally_changed;
changed |= MOD_NOTES & reg->notesCell->cell.conditionally_changed;
return changed; return changed;
} }
@ -1105,16 +1116,16 @@ xaccSplitRegisterClearChangeFlag (SplitRegister *reg)
reg->numCell->cell.changed = 0; reg->numCell->cell.changed = 0;
reg->descCell->cell.changed = 0; reg->descCell->cell.changed = 0;
reg->recnCell->cell.changed = 0; reg->recnCell->cell.changed = 0;
reg->actionCell->cell.changed = 0; reg->actionCell->cell.changed = 0;
reg->xfrmCell->cell.changed = 0; reg->xfrmCell->cell.changed = 0;
reg->mxfrmCell->cell.changed = 0;
reg->xtoCell->cell.changed = 0; reg->xtoCell->cell.changed = 0;
reg->memoCell->cell.changed = 0; reg->memoCell->cell.changed = 0;
reg->creditCell->cell.changed = 0; reg->creditCell->cell.changed = 0;
reg->debitCell->cell.changed = 0; reg->debitCell->cell.changed = 0;
reg->priceCell->cell.changed = 0; reg->priceCell->cell.changed = 0;
reg->sharesCell->cell.changed = 0; reg->sharesCell->cell.changed = 0;
reg->mxfrmCell->cell.changed = 0;
reg->notesCell->cell.changed = 0;
} }
/* ============================================== */ /* ============================================== */
@ -1182,50 +1193,14 @@ xaccSplitRegisterGetCursorClass (SplitRegister *reg,
static CellType static CellType
sr_cell_type (SplitRegister *reg, void * cell) sr_cell_type (SplitRegister *reg, void * cell)
{ {
if (cell == reg->dateCell) int i;
return DATE_CELL;
if (cell == reg->numCell) if (reg == NULL)
return NUM_CELL; return NO_CELL;
if (cell == reg->descCell) for (i = 0; i < CELL_TYPE_COUNT; i++)
return DESC_CELL; if (cell == reg->cells[i])
return i;
if (cell == reg->recnCell)
return RECN_CELL;
if (cell == reg->shrbalnCell)
return SHRBALN_CELL;
if (cell == reg->balanceCell)
return BALN_CELL;
if (cell == reg->actionCell)
return ACTN_CELL;
if (cell == reg->xfrmCell)
return XFRM_CELL;
if (cell == reg->mxfrmCell)
return MXFRM_CELL;
if (cell == reg->xtoCell)
return XTO_CELL;
if (cell == reg->memoCell)
return MEMO_CELL;
if (cell == reg->creditCell)
return CRED_CELL;
if (cell == reg->debitCell)
return DEBT_CELL;
if (cell == reg->priceCell)
return PRIC_CELL;
if (cell == reg->sharesCell)
return SHRS_CELL;
return NO_CELL; return NO_CELL;
} }
@ -1244,8 +1219,7 @@ xaccSplitRegisterGetCurrentCellType (SplitRegister *reg)
if (table == NULL) if (table == NULL)
return NO_CELL; return NO_CELL;
return return xaccSplitRegisterGetCellType(reg, table->current_cursor_loc);
xaccSplitRegisterGetCellType(reg, table->current_cursor_loc);
} }
/* ============================================== */ /* ============================================== */
@ -1402,13 +1376,14 @@ xaccDestroySplitRegisterBuffer (SplitRegisterBuffer *srb)
destroyCellBuffer(&srb->balanceCell); destroyCellBuffer(&srb->balanceCell);
destroyCellBuffer(&srb->actionCell); destroyCellBuffer(&srb->actionCell);
destroyCellBuffer(&srb->xfrmCell); destroyCellBuffer(&srb->xfrmCell);
destroyCellBuffer(&srb->mxfrmCell);
destroyCellBuffer(&srb->xtoCell); destroyCellBuffer(&srb->xtoCell);
destroyCellBuffer(&srb->memoCell); destroyCellBuffer(&srb->memoCell);
destroyCellBuffer(&srb->creditCell); destroyCellBuffer(&srb->creditCell);
destroyCellBuffer(&srb->debitCell); destroyCellBuffer(&srb->debitCell);
destroyCellBuffer(&srb->priceCell); destroyCellBuffer(&srb->priceCell);
destroyCellBuffer(&srb->sharesCell); destroyCellBuffer(&srb->sharesCell);
destroyCellBuffer(&srb->mxfrmCell);
destroyCellBuffer(&srb->notesCell);
g_free(srb); g_free(srb);
} }
@ -1442,13 +1417,14 @@ xaccSplitRegisterSaveCursor(SplitRegister *sr, SplitRegisterBuffer *srb)
saveCell(&sr->balanceCell->cell, &srb->balanceCell); saveCell(&sr->balanceCell->cell, &srb->balanceCell);
saveCell(&sr->actionCell->cell, &srb->actionCell); saveCell(&sr->actionCell->cell, &srb->actionCell);
saveCell(&sr->xfrmCell->cell, &srb->xfrmCell); saveCell(&sr->xfrmCell->cell, &srb->xfrmCell);
saveCell(&sr->mxfrmCell->cell, &srb->mxfrmCell);
saveCell(&sr->xtoCell->cell, &srb->xtoCell); saveCell(&sr->xtoCell->cell, &srb->xtoCell);
saveCell(&sr->memoCell->cell, &srb->memoCell); saveCell(&sr->memoCell->cell, &srb->memoCell);
saveCell(&sr->creditCell->cell, &srb->creditCell); saveCell(&sr->creditCell->cell, &srb->creditCell);
saveCell(&sr->debitCell->cell, &srb->debitCell); saveCell(&sr->debitCell->cell, &srb->debitCell);
saveCell(&sr->priceCell->cell, &srb->priceCell); saveCell(&sr->priceCell->cell, &srb->priceCell);
saveCell(&sr->sharesCell->cell, &srb->sharesCell); saveCell(&sr->sharesCell->cell, &srb->sharesCell);
saveCell(&sr->mxfrmCell->cell, &srb->mxfrmCell);
saveCell(&sr->notesCell->cell, &srb->notesCell);
} }
/* ============================================== */ /* ============================================== */
@ -1505,13 +1481,14 @@ xaccSplitRegisterRestoreCursorChanged(SplitRegister *sr,
restoreCellChanged(&sr->balanceCell->cell, &srb->balanceCell, cursor); restoreCellChanged(&sr->balanceCell->cell, &srb->balanceCell, cursor);
restoreCellChanged(&sr->actionCell->cell, &srb->actionCell, cursor); restoreCellChanged(&sr->actionCell->cell, &srb->actionCell, cursor);
restoreCellChanged(&sr->xfrmCell->cell, &srb->xfrmCell, cursor); restoreCellChanged(&sr->xfrmCell->cell, &srb->xfrmCell, cursor);
restoreCellChanged(&sr->mxfrmCell->cell, &srb->mxfrmCell, cursor);
restoreCellChanged(&sr->xtoCell->cell, &srb->xtoCell, cursor); restoreCellChanged(&sr->xtoCell->cell, &srb->xtoCell, cursor);
restoreCellChanged(&sr->memoCell->cell, &srb->memoCell, cursor); restoreCellChanged(&sr->memoCell->cell, &srb->memoCell, cursor);
restoreCellChanged(&sr->creditCell->cell, &srb->creditCell, cursor); restoreCellChanged(&sr->creditCell->cell, &srb->creditCell, cursor);
restoreCellChanged(&sr->debitCell->cell, &srb->debitCell, cursor); restoreCellChanged(&sr->debitCell->cell, &srb->debitCell, cursor);
restoreCellChanged(&sr->priceCell->cell, &srb->priceCell, cursor); restoreCellChanged(&sr->priceCell->cell, &srb->priceCell, cursor);
restoreCellChanged(&sr->sharesCell->cell, &srb->sharesCell, cursor); restoreCellChanged(&sr->sharesCell->cell, &srb->sharesCell, cursor);
restoreCellChanged(&sr->mxfrmCell->cell, &srb->mxfrmCell, cursor);
restoreCellChanged(&sr->notesCell->cell, &srb->notesCell, cursor);
} }
/* keep in sync with CellType enum */ /* keep in sync with CellType enum */
@ -1531,7 +1508,12 @@ static const char *cell_names[] =
"debit", "debit",
"price", "price",
"shares", "shares",
"transfer" "transfer",
"trans-credit",
"trans-debit",
"trans-share-balance",
"trans-balance",
"notes"
}; };
const char * const char *

View File

@ -98,6 +98,7 @@ typedef enum
TDEBT_CELL, TDEBT_CELL,
TSHRBALN_CELL, TSHRBALN_CELL,
TBALN_CELL, TBALN_CELL,
NOTES_CELL,
CELL_TYPE_COUNT CELL_TYPE_COUNT
} CellType; } CellType;
@ -119,20 +120,24 @@ typedef enum
} SplitRegisterStyle; } SplitRegisterStyle;
/* modified flags -- indicate which cell values have been modified by user */ /* modified flags -- indicate which cell values have been modified by user */
#define MOD_NONE 0x0000 typedef enum
#define MOD_DATE 0x0001 {
#define MOD_NUM 0x0002 MOD_NONE = 0,
#define MOD_DESC 0x0004 MOD_DATE = 1 << 0,
#define MOD_RECN 0x0008 MOD_NUM = 1 << 1,
#define MOD_ACTN 0x0010 MOD_DESC = 1 << 2,
#define MOD_XFRM 0x0020 MOD_RECN = 1 << 3,
#define MOD_MXFRM 0x0040 MOD_ACTN = 1 << 4,
#define MOD_XTO 0x0080 MOD_XFRM = 1 << 5,
#define MOD_MEMO 0x0100 MOD_MXFRM = 1 << 6,
#define MOD_AMNT 0x0200 MOD_XTO = 1 << 7,
#define MOD_PRIC 0x0400 MOD_MEMO = 1 << 8,
#define MOD_SHRS 0x0800 MOD_AMNT = 1 << 9,
#define MOD_ALL 0xffff MOD_PRIC = 1 << 10,
MOD_SHRS = 1 << 11,
MOD_NOTES = 1 << 12,
MOD_ALL = 0xffff
} CellModifiedFlags;
/* Types of cursors */ /* Types of cursors */
typedef enum typedef enum
@ -194,6 +199,7 @@ struct _SplitRegister
PriceCell * tdebitCell; PriceCell * tdebitCell;
PriceCell * tshrbalnCell; PriceCell * tshrbalnCell;
PriceCell * tbalanceCell; PriceCell * tbalanceCell;
QuickFillCell * notesCell;
SplitRegisterType type; SplitRegisterType type;
SplitRegisterStyle style; SplitRegisterStyle style;

View File

@ -172,6 +172,7 @@ gnc_table_get_entry_internal (Table *table, VirtualLocation virt_loc,
{ {
VirtualCell *vcell; VirtualCell *vcell;
CellBlockCell *cb_cell; CellBlockCell *cb_cell;
const char *entry;
vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc); vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc);
if (vcell == NULL) if (vcell == NULL)
@ -185,9 +186,13 @@ gnc_table_get_entry_internal (Table *table, VirtualLocation virt_loc,
if (cb_cell->cell_type < 0) if (cb_cell->cell_type < 0)
return ""; return "";
return table->entry_handler (virt_loc, cb_cell->cell_type, entry = table->entry_handler (virt_loc, cb_cell->cell_type,
conditionally_changed, conditionally_changed,
table->handler_user_data); table->handler_user_data);
if (!entry)
entry = "";
return entry;
} }
const char * const char *
@ -195,6 +200,7 @@ gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
{ {
VirtualCell *vcell; VirtualCell *vcell;
CellBlockCell *cb_cell; CellBlockCell *cb_cell;
const char *entry;
vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc); vcell = gnc_table_get_virtual_cell (table, virt_loc.vcell_loc);
if (vcell == NULL) if (vcell == NULL)
@ -218,8 +224,12 @@ gnc_table_get_entry (Table *table, VirtualLocation virt_loc)
return cb_cell->cell->value; return cb_cell->cell->value;
} }
return table->entry_handler (virt_loc, cb_cell->cell_type, NULL, entry = table->entry_handler (virt_loc, cb_cell->cell_type, NULL,
table->handler_user_data); table->handler_user_data);
if (!entry)
entry = "";
return entry;
} }
/* ==================================================== */ /* ==================================================== */

View File

@ -145,7 +145,8 @@
(define gnc:transaction-structure (define gnc:transaction-structure
(make-record-type (make-record-type
"gnc:transaction-structure" "gnc:transaction-structure"
'(transaction-guid date-entered date-posted num description split-scms))) '(transaction-guid date-entered date-posted
num description notes split-scms)))
;; constructor ;; constructor
(define gnc:make-transaction-scm (define gnc:make-transaction-scm
@ -171,6 +172,9 @@
(define gnc:transaction-scm-get-description (define gnc:transaction-scm-get-description
(record-accessor gnc:transaction-structure 'description)) (record-accessor gnc:transaction-structure 'description))
(define gnc:transaction-scm-get-notes
(record-accessor gnc:transaction-structure 'notes))
(define gnc:transaction-scm-get-split-scms (define gnc:transaction-scm-get-split-scms
(record-accessor gnc:transaction-structure 'split-scms)) (record-accessor gnc:transaction-structure 'split-scms))
@ -203,6 +207,9 @@
(define gnc:transaction-scm-set-description (define gnc:transaction-scm-set-description
(record-modifier gnc:transaction-structure 'description)) (record-modifier gnc:transaction-structure 'description))
(define gnc:transaction-scm-set-notes
(record-modifier gnc:transaction-structure 'notes))
(define gnc:transaction-scm-set-split-scms (define gnc:transaction-scm-set-split-scms
(record-modifier gnc:transaction-structure 'split-scms)) (record-modifier gnc:transaction-structure 'split-scms))
@ -230,6 +237,7 @@
(gnc:transaction-get-num trans) (gnc:transaction-get-num trans)
#f) #f)
(gnc:transaction-get-description trans) (gnc:transaction-get-description trans)
(gnc:transaction-get-notes trans)
(trans-splits 0))) (trans-splits 0)))
;; Copy a scheme representation of a transaction onto a C transaction. ;; Copy a scheme representation of a transaction onto a C transaction.
@ -240,7 +248,6 @@
(if (pointer-token-null? trans) (if (pointer-token-null? trans)
#f #f
(begin (begin
;; open the transaction for editing ;; open the transaction for editing
(if (not (gnc:transaction-is-open trans)) (if (not (gnc:transaction-is-open trans))
(gnc:transaction-begin-edit trans #t)) (gnc:transaction-begin-edit trans #t))
@ -248,9 +255,11 @@
;; copy in the transaction values ;; copy in the transaction values
(let ((description (gnc:transaction-scm-get-description trans-scm)) (let ((description (gnc:transaction-scm-get-description trans-scm))
(num (gnc:transaction-scm-get-num trans-scm)) (num (gnc:transaction-scm-get-num trans-scm))
(notes (gnc:transaction-scm-get-notes trans-scm))
(date-posted (gnc:transaction-scm-get-date-posted trans-scm))) (date-posted (gnc:transaction-scm-get-date-posted trans-scm)))
(if description (gnc:transaction-set-description trans description)) (if description (gnc:transaction-set-description trans description))
(if num (gnc:transaction-set-xnum trans num)) (if num (gnc:transaction-set-xnum trans num))
(if notes (gnc:transaction-set-notes trans notes))
(if date-posted (gnc:transaction-set-date-time-pair (if date-posted (gnc:transaction-set-date-time-pair
trans date-posted))) trans date-posted)))