Skip to content

Commit

Permalink
Further register rewrite work.
Browse files Browse the repository at this point in the history
This patch is an updated patch which I have been fighting with the sort
model on. It allows you to add, delete and modify basic transactions
and splits with the toolbar buttons. Jump and move to blank are
also working.

Visual indication of read only and future transactions are
also implemented.

As before, do not open same account in old and new register.

Tab key works manually but needs more work, cell editable value does not
seem to be reliable which was the way I was going to auto step over
uneditable cells.

There is another problem if you enter the debit/credit value before the
account, you will get an error in the trace file but entries
are recorded, not sure of answer.

New transactions are not added in date order at the moment, this was
going to be done by the sort model or the existing method of reload
register via the commented out watchers in ledger-display.

All the numeric functions are the existing ones from the rewrite and as
such I have not proved they are correct but a basic transaction seems to
work.

Author: Robert Fewell <14ubobit@gmail.com>

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22448 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
gjanssens committed Oct 18, 2012
1 parent f6da044 commit 3f5eae6
Show file tree
Hide file tree
Showing 22 changed files with 9,380 additions and 1,449 deletions.
3 changes: 3 additions & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ src/gnome/gnc-plugin-page-sx-list.c
src/gnome/gnc-plugin-register2.c
src/gnome/gnc-plugin-register.c
src/gnome/gnc-split-reg.c
src/gnome/gnc-split-reg2.c
src/gnome/gtkbuilder/assistant-acct-period.glade
src/gnome/gtkbuilder/assistant-hierarchy.glade
src/gnome/gtkbuilder/assistant-loan.glade
Expand All @@ -220,6 +221,7 @@ src/gnome/gtkbuilder/dialog-sx.glade
src/gnome/gtkbuilder/dialog-tax-info.glade
src/gnome/gtkbuilder/gnc-plugin-page-budget.glade
src/gnome/gtkbuilder/gnc-plugin-page-register.glade
src/gnome/gtkbuilder/gnc-plugin-page-register2.glade
src/gnome/gtkbuilder/window-autoclear.glade
src/gnome/gtkbuilder/window-reconcile.glade
src/gnome/reconcile-view.c
Expand Down Expand Up @@ -456,6 +458,7 @@ src/plugins/customer_import/gtkbuilder/dialog-customer-import-gui.glade
src/plugins/customer_import/libgncmod-customer_import.c
src/python/gncmod-python.c
src/register/ledger-core/gnc-ledger-display.c
src/register/ledger-core/gnc-ledger-display2.c
src/register/ledger-core/gncmod-ledger-core.c
src/register/ledger-core/split-register.c
src/register/ledger-core/split-register-control.c
Expand Down
23 changes: 10 additions & 13 deletions src/engine/Split.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,30 +660,27 @@ xaccSplitEqual(const Split *sa, const Split *sb,
}


/*################## Added for Reg2 #################*/
/********************************************************************
* xaccSplitListGetUniqueTransactions
********************************************************************/
static void
add_keys_to_list(gpointer key, gpointer val, gpointer list)
{
*(GList **)list = g_list_prepend(*(GList **)list, key);
}

GList *
xaccSplitListGetUniqueTransactions(const GList *splits)
{
const GList *node;
const GList *snode;
GList *transList = NULL;
GHashTable *transHash = g_hash_table_new(g_direct_hash, g_direct_equal);

for(node = splits; node; node = node->next) {
Transaction *trans = xaccSplitGetParent((Split *)(node->data));
g_hash_table_insert(transHash, trans, trans);
for(snode = splits; snode; snode = snode->next)
{
Transaction *trans = xaccSplitGetParent((Split *)(snode->data));

GList *item = g_list_find (transList, trans);
if (item == NULL)
transList = g_list_append (transList, trans);
}
g_hash_table_foreach(transHash, add_keys_to_list, &transList);
g_hash_table_destroy(transHash);
return transList;
}
/*################## Added for Reg2 #################*/


/********************************************************************
Expand Down
3 changes: 2 additions & 1 deletion src/engine/Split.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,10 @@ gboolean xaccSplitEqual(const Split *sa, const Split *sb,
Split * xaccSplitLookup (const GncGUID *guid, QofBook *book);
#define xaccSplitLookupDirect(g,b) xaccSplitLookup(&(g),b)


/*################## Added for Reg2 #################*/
/* Get a GList of unique transactions containing the given list of Splits. */
GList *xaccSplitListGetUniqueTransactions(const GList *splits);
/*################## Added for Reg2 #################*/

/**
* The xaccSplitGetOtherSplit() is a convenience routine that returns
Expand Down
24 changes: 24 additions & 0 deletions src/engine/Transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ xaccTransGetAccountAmount (const Transaction *trans, const Account *acc)
return total;
}

/*################## Added for Reg2 #################*/
gboolean
xaccTransGetRateForCommodity(const Transaction *trans,
const gnc_commodity *split_com,
Expand Down Expand Up @@ -1028,6 +1029,7 @@ xaccTransGetRateForCommodity(const Transaction *trans,
}
return FALSE;
}
/*################## Added for Reg2 #################*/

gnc_numeric
xaccTransGetAccountConvRate(const Transaction *txn, const Account *acc)
Expand Down Expand Up @@ -2068,6 +2070,28 @@ gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans)
return result;
}

/*################## Added for Reg2 #################*/

gboolean xaccTransInFutureByPostedDate (const Transaction *trans)
{
GDate date_now;
GDate trans_date;
gboolean result;
g_assert(trans);

trans_date = xaccTransGetDatePostedGDate (trans);

g_date_set_time_t (&date_now, time(NULL));

if (g_date_compare (&trans_date, &date_now) > 0)
result = TRUE;
else
result = FALSE;

return result;
}

/*################## Added for Reg2 #################*/

gboolean
xaccTransHasReconciledSplitsByAccount (const Transaction *trans,
Expand Down
9 changes: 9 additions & 0 deletions src/engine/Transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ const char * xaccTransGetReadOnly (const Transaction *trans);
* qof_book_uses_autofreeze() and qof_book_get_autofreeze_gdate(). */
gboolean xaccTransIsReadonlyByPostedDate(const Transaction *trans);

/*################## Added for Reg2 #################*/

/** Returns TRUE if this Transaction's posted-date is in the future */
gboolean xaccTransInFutureByPostedDate (const Transaction *trans);

/*################## Added for Reg2 #################*/

/** Returns the number of splits in this transaction. */
int xaccTransCountSplits (const Transaction *trans);

Expand Down Expand Up @@ -410,12 +417,14 @@ gnc_numeric xaccTransGetAccountValue (const Transaction *trans,
gnc_numeric xaccTransGetAccountAmount (const Transaction *trans,
const Account *account);

/*################## Added for Reg2 #################*/
/* Gets the amt/val rate, i.e. rate from the transaction currency to
the 'split_com' */
gboolean
xaccTransGetRateForCommodity(const Transaction *trans,
const gnc_commodity *split_com,
const Split *split_to_exclude, gnc_numeric *rate);
/*################## Added for Reg2 #################*/

/* Compute the conversion rate for the transaction to this account.
* Any "split value" (which is in the transaction currency),
Expand Down
2 changes: 1 addition & 1 deletion src/gnome-utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ libgncmod_gnome_utils_la_SOURCES = \
gnc-tree-model-budget.c \
gnc-tree-model-owner.c \
gnc-tree-model-commodity.c \
gnc-tree-model-split-reg.c \
gnc-tree-model-price.c \
gnc-tree-model-split-reg.c \
gnc-tree-view-account.c \
gnc-tree-view-commodity.c \
gnc-tree-view-owner.c \
Expand Down
Loading

0 comments on commit 3f5eae6

Please sign in to comment.