diff --git a/src/MultiLedger.c b/src/MultiLedger.c index c26d56b08e..062076deb0 100644 --- a/src/MultiLedger.c +++ b/src/MultiLedger.c @@ -179,7 +179,8 @@ xaccLedgerDisplaySimple (Account *acc) } /* default to single-line display */ - reg_type |= REG_SHOW_TDETAIL; + reg_type |= REG_SHOW_TAMOUNT; + reg_type |= REG_SHOW_TXFRM; retval = xaccLedgerDisplayGeneral (acc, NULL, reg_type); return retval; @@ -252,7 +253,8 @@ xaccLedgerDisplayAccGroup (Account *acc) } /* default to single-line display */ - ledger_type |= REG_SHOW_TDETAIL; + ledger_type |= REG_SHOW_TAMOUNT; + ledger_type |= REG_SHOW_TXFRM; retval = xaccLedgerDisplayGeneral (acc, list, ledger_type); diff --git a/src/SplitLedger.c b/src/SplitLedger.c index 72b5549657..c763c6ec64 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -207,8 +207,8 @@ printf ("save split is %p \n", split); * and that's that. For a two-line display, we want to reparent * the "other" split, but only if there is one ... */ - if (MOD_XFRM & changed) { - Account *old_acc, *new_acc; + if ((MOD_XFRM | MOD_TXFRM) & changed) { + Account *old_acc=NULL, *new_acc=NULL; Split *split_to_modify = NULL; if (reg->type & REG_MULTI_LINE) { @@ -224,7 +224,11 @@ printf ("save split is %p \n", split); /* do some reparenting. Insertion into new account will automatically * delete from the old account */ old_acc = xaccSplitGetAccount (split_to_modify); - new_acc = xaccGetAccountByName (trans, reg->xfrmCell->cell.value); + if (MOD_XFRM & changed) { + new_acc = xaccGetAccountByName (trans, reg->xfrmCell->cell.value); + } else { + new_acc = xaccGetAccountByName (trans, reg->xfrmTransCell->cell.value); + } xaccAccountInsertSplit (new_acc, split_to_modify); /* make sure any open windows of the old account get redrawn */ @@ -297,6 +301,30 @@ xaccTransGetDescription(trans)); /* ======================================================== */ +#define LOAD_XFRM(cellname) { \ + char * accname=NULL; \ + \ + /* Show the transfer-from account name. */ \ + /* What gets displayed depends on the display format. */ \ + /* For a multi-line display, show the account for each member split. */ \ + /* For a one or two-line display, show the other account, but only */ \ + /* if there are exactly two splits. */ \ + if (reg->type & REG_MULTI_LINE) { \ + accname = xaccAccountGetName (xaccSplitGetAccount (split)); \ + xaccSetComboCellValue (reg->cellname, accname); \ + } else { \ + Split *s = xaccGetOtherSplit (split); \ + if (s) { \ + accname = xaccAccountGetName (xaccSplitGetAccount (s)); \ + } else { \ + accname = SPLIT_STR; \ + } \ + xaccSetComboCellValue (reg->cellname, accname); \ + } \ +} + +/* ======================================================== */ + static void xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) { @@ -308,6 +336,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) /* we interpret a NULL split as a blank split */ xaccSetDateCellValueSecs (reg->dateCell, 0); xaccSetBasicCellValue (reg->numCell, ""); + xaccSetComboCellValue (reg->xfrmTransCell, ""); xaccSetQuickFillCellValue (reg->descCell, ""); xaccSetBasicCellValue (reg->recnCell, ""); xaccSetDebCredCellValue (reg->debitTransCell, @@ -325,6 +354,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) xaccSetDateCellValueSecs (reg->dateCell, secs); xaccSetBasicCellValue (reg->numCell, xaccTransGetNum (trans)); + LOAD_XFRM (xfrmTransCell); xaccSetQuickFillCellValue (reg->descCell, xaccTransGetDescription (trans)); buff[0] = xaccSplitGetReconcile (split); @@ -371,7 +401,6 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) static void xaccSRLoadSplitEntry (SplitRegister *reg, Split *split, int do_commit) { - char *accname; char buff[2]; if (!split) { @@ -388,32 +417,13 @@ xaccSRLoadSplitEntry (SplitRegister *reg, Split *split, int do_commit) double amt; xaccSetComboCellValue (reg->actionCell, xaccSplitGetAction (split)); + LOAD_XFRM (xfrmCell); xaccSetBasicCellValue (reg->memoCell, xaccSplitGetMemo (split)); buff[0] = xaccSplitGetReconcile (split); buff[1] = 0x0; xaccSetBasicCellValue (reg->recsCell, buff); - /* Show the transfer-from account name. - * What gets displayed depends on the display format. - * For a multi-line display, show the account for each member split. - * For a two-line display, show the other account, but only if there - * are exactly two splits. - */ - if (reg->type & REG_DOUBLE_LINE) { - Split *s = xaccGetOtherSplit (split); - if (s) { - accname = xaccAccountGetName (xaccSplitGetAccount (s)); - } else { - accname = SPLIT_STR; - } - xaccSetComboCellValue (reg->xfrmCell, accname); - } - if (reg->type & REG_MULTI_LINE) { - accname = xaccAccountGetName (xaccSplitGetAccount (split)); - xaccSetComboCellValue (reg->xfrmCell, accname); - } - if ((EQUITY_REGISTER == (reg->type & REG_TYPE_MASK)) || (STOCK_REGISTER == (reg->type & REG_TYPE_MASK)) || (PORTFOLIO == (reg->type & REG_TYPE_MASK))) diff --git a/src/register/splitreg.c b/src/register/splitreg.c index 9e6f21168e..014bdc3457 100644 --- a/src/register/splitreg.c +++ b/src/register/splitreg.c @@ -41,24 +41,25 @@ /* utility defines for cell configuration data */ #define DATE_CELL 0 #define NUM_CELL 1 -#define DESC_CELL 2 -#define RECN_CELL 3 /* transaction recn */ -#define TCRED_CELL 4 -#define TDEBT_CELL 5 -#define TPRIC_CELL 6 -#define TVALU_CELL 7 -#define SHRS_CELL 8 -#define BALN_CELL 9 +#define TXFRM_CELL 2 +#define DESC_CELL 3 +#define RECN_CELL 4 /* transaction recn */ +#define TCRED_CELL 5 +#define TDEBT_CELL 6 +#define TPRIC_CELL 7 +#define TVALU_CELL 8 +#define SHRS_CELL 9 +#define BALN_CELL 10 -#define ACTN_CELL 10 -#define XFRM_CELL 11 -#define XTO_CELL 12 -#define MEMO_CELL 13 -#define RECS_CELL 14 /* split recn */ -#define CRED_CELL 15 -#define DEBT_CELL 16 -#define PRIC_CELL 17 -#define VALU_CELL 18 +#define ACTN_CELL 11 +#define XFRM_CELL 12 +#define XTO_CELL 13 +#define MEMO_CELL 14 +#define RECS_CELL 15 /* split recn */ +#define CRED_CELL 16 +#define DEBT_CELL 17 +#define PRIC_CELL 18 +#define VALU_CELL 19 /* utility defines for setting of cell values */ @@ -70,6 +71,10 @@ #define NUM_CELL_R (reg->rows[NUM_CELL]) #define NUM_CELL_W (reg->wids[NUM_CELL]) +#define TXFRM_CELL_C (reg->cols[TXFRM_CELL]) +#define TXFRM_CELL_R (reg->rows[TXFRM_CELL]) +#define TXFRM_CELL_W (reg->wids[TXFRM_CELL]) + #define DESC_CELL_C (reg->cols[DESC_CELL]) #define DESC_CELL_R (reg->rows[DESC_CELL]) #define DESC_CELL_W (reg->wids[DESC_CELL]) @@ -157,18 +162,20 @@ configLayout (SplitRegister *reg) { int type = (reg->type) & REG_TYPE_MASK; int show_recs = (reg->type) & REG_SHOW_RECS; - int show_tdetail = (reg->type) & REG_SHOW_TDETAIL; - int show_sdetail = (reg->type) & REG_SHOW_SDETAIL; + int show_tamount = (reg->type) & REG_SHOW_TAMOUNT; + int show_samount = (reg->type) & REG_SHOW_SAMOUNT; + int show_txfrm = (reg->type) & REG_SHOW_TXFRM; /* perform a bsic layout that's valid for most * of the ledgers; then customize with case * statements. */ reg->num_cols = 8; reg->num_header_rows = 1; - SET (DATE_CELL, 0, 0, 11, DATE_STR); - SET (NUM_CELL, 1, 0, 7, NUM_STR); - SET (DESC_CELL, 3, 0, 29, DESC_STR); - SET (RECN_CELL, 4, 0, 1, "R"); + SET (DATE_CELL, 0, 0, 11, DATE_STR); + SET (NUM_CELL, 1, 0, 7, NUM_STR); + SET (TXFRM_CELL, -1, -1, 14, XFRM_STR); + SET (DESC_CELL, 3, 0, 29, DESC_STR); + SET (RECN_CELL, 4, 0, 1, "R"); SET (TDEBT_CELL, -1, -1, 12, DEBIT_STR); SET (TCRED_CELL, -1, -1, 12, CREDIT_STR); SET (TPRIC_CELL, -1, -1, 9, PRICE_STR); @@ -191,6 +198,11 @@ configLayout (SplitRegister *reg) SET (RECS_CELL, 4, 0, 1, "R"); } + /* show or hide the transaction transfer-from field */ + if (show_txfrm) { + SET (TXFRM_CELL, 2, 0, 14, XFRM_STR); + } + switch (type) { case BANK_REGISTER: case CASH_REGISTER: @@ -207,11 +219,11 @@ configLayout (SplitRegister *reg) SET (VALU_CELL, -1, -1, 10, VALUE_STR); SET (SHRS_CELL, -1, -1, 10, TOT_SHRS_STR); - if (show_sdetail) { + if (show_samount) { SET (DEBT_CELL, 5, 0, 12, DEBIT_STR); SET (CRED_CELL, 6, 0, 12, CREDIT_STR); } - if (show_tdetail) { + if (show_tamount) { SET (TDEBT_CELL, 5, 0, 12, DEBIT_STR); SET (TCRED_CELL, 6, 0, 12, CREDIT_STR); } @@ -220,13 +232,13 @@ configLayout (SplitRegister *reg) case STOCK_REGISTER: reg->num_cols = 11; SET (XTO_CELL, -1, -1, 14, XFTO_STR); - if (show_sdetail) { + if (show_samount) { SET (PRIC_CELL, 7, 0, 9, PRICE_STR); SET (VALU_CELL, 8, 0, 10, VALUE_STR); SET (SHRS_CELL, 9, 0, 10, TOT_SHRS_STR); SET (BALN_CELL, 10, 0, 12, BALN_STR); } - if (show_tdetail) { + if (show_tamount) { SET (TDEBT_CELL, 5, 0, 12, DEBIT_STR); SET (TCRED_CELL, 6, 0, 12, CREDIT_STR); SET (TPRIC_CELL, 7, 0, 9, PRICE_STR); @@ -286,7 +298,8 @@ configLayout (SplitRegister *reg) /* define the traversal order */ /* negative cells mean "traverse out of table" */ /* hack alert -- redesign so that we hop from one row to the next, if desired. */ -/* hack alert -- if tdetail or sdetail is set then don't traverse there */ +/* hack alert -- if show_tamount or show_samount is set then don't traverse there */ +/* hack alert -- fix show_txfrm also ... */ static void configTraverse (SplitRegister *reg) @@ -414,6 +427,7 @@ configCursors (SplitRegister *reg) FANCY (date, Date, DATE); BASIC (num, Text, NUM); + FANCY (xfrmTrans, Combo, TXFRM); FANCY (desc, QuickFill, DESC); BASIC (recn, Recn, RECN); FANCY (creditTrans, Price, TCRED); @@ -434,6 +448,7 @@ configCursors (SplitRegister *reg) */ reg->dateCell -> cell.bg_color = 0xccccff; reg->numCell -> bg_color = 0xccccff; + reg->xfrmTransCell -> cell.bg_color = 0xccccff; reg->descCell -> cell.bg_color = 0xccccff; reg->recnCell -> bg_color = 0xccccff; reg->creditTransCell-> cell.bg_color = 0xccccff; @@ -522,6 +537,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type) reg->nullTransCell = xaccMallocBasicCell(); reg->dateCell = xaccMallocDateCell(); reg->numCell = xaccMallocTextCell(); + reg->xfrmTransCell = xaccMallocComboCell(); reg->descCell = xaccMallocQuickFillCell(); reg->recnCell = xaccMallocRecnCell(); reg->creditTransCell = xaccMallocPriceCell(); @@ -670,6 +686,7 @@ xaccDestroySplitRegister (SplitRegister *reg) xaccDestroyDateCell (reg->dateCell); xaccDestroyBasicCell (reg->numCell); + xaccDestroyComboCell (reg->xfrmTransCell); xaccDestroyQuickFillCell (reg->descCell); xaccDestroyBasicCell (reg->recnCell); xaccDestroyPriceCell (reg->creditTransCell); @@ -690,6 +707,7 @@ xaccDestroySplitRegister (SplitRegister *reg) reg->dateCell = NULL; reg->numCell = NULL; + reg->xfrmTransCell = NULL; reg->descCell = NULL; reg->recnCell = NULL; reg->creditTransCell = NULL; @@ -723,6 +741,7 @@ xaccSplitRegisterGetChangeFlag (SplitRegister *reg) /* be careful to use bitwise ands and ors to assemble bit flag */ changed |= MOD_DATE & reg->dateCell->cell.changed; changed |= MOD_NUM & reg->numCell->changed; + changed |= MOD_TXFRM & reg->xfrmTransCell->cell.changed; changed |= MOD_DESC & reg->descCell->cell.changed; changed |= MOD_RECN & reg->recnCell->changed; changed |= MOD_TAMNT & reg->creditTransCell->cell.changed; diff --git a/src/register/splitreg.h b/src/register/splitreg.h index 1b6d278707..1ded4d61c5 100644 --- a/src/register/splitreg.h +++ b/src/register/splitreg.h @@ -73,31 +73,33 @@ #define PORTFOLIO 11 #define REG_TYPE_MASK 0xff -#define REG_SHOW_TDETAIL 0x0100 -#define REG_SHOW_SDETAIL 0x0200 -#define REG_SHOW_RECS 0x0400 -#define REG_DOUBLE_LINE 0x0800 -#define REG_MULTI_LINE 0x1000 +#define REG_SHOW_TAMOUNT 0x0100 +#define REG_SHOW_SAMOUNT 0x0200 +#define REG_SHOW_TXFRM 0x0400 +#define REG_SHOW_RECS 0x0800 +#define REG_DOUBLE_LINE 0x1000 +#define REG_MULTI_LINE 0x2000 /* modified flags -- indicate how values have been modified */ #define MOD_NONE 0x0000 #define MOD_DATE 0x0001 #define MOD_NUM 0x0002 -#define MOD_DESC 0x0004 -#define MOD_RECN 0x0008 -#define MOD_TAMNT 0x0010 -#define MOD_TPRIC 0x0020 -#define MOD_TVALU 0x0040 +#define MOD_TXFRM 0x0004 +#define MOD_DESC 0x0008 +#define MOD_RECN 0x0010 +#define MOD_TAMNT 0x0020 +#define MOD_TPRIC 0x0040 +#define MOD_TVALU 0x0080 -#define MOD_ACTN 0x0080 -#define MOD_XFRM 0x0100 -#define MOD_XTO 0x0200 -#define MOD_MEMO 0x0400 -#define MOD_AMNT 0x0800 -#define MOD_PRIC 0x1000 -#define MOD_VALU 0x2000 -#define MOD_NEW 0x4000 -#define MOD_ALL 0x7fff +#define MOD_ACTN 0x0100 +#define MOD_XFRM 0x0200 +#define MOD_XTO 0x0400 +#define MOD_MEMO 0x0800 +#define MOD_AMNT 0x1000 +#define MOD_PRIC 0x2000 +#define MOD_VALU 0x4000 +#define MOD_NEW 0x8000 +#define MOD_ALL 0xffff /* The value of NUM_CELLS should be larger than the number of * cells defined in the structure below! @@ -119,6 +121,7 @@ struct _SplitRegister { /* these are handled only by the transaction cursor */ DateCell * dateCell; BasicCell * numCell; + ComboCell * xfrmTransCell; QuickFillCell * descCell; BasicCell * recnCell; /* main transaction line reconcile */ PriceCell * creditTransCell; @@ -130,7 +133,7 @@ struct _SplitRegister { BasicCell * nullTransCell; /* split cells */ - /* these are hndled only by the split cursor */ + /* these are handled only by the split cursor */ ComboCell * actionCell; ComboCell * xfrmCell; ComboCell * xtoCell;