mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Rob Browning's patch to add a 'type' api for Splits.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3381 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -3,6 +3,7 @@ COPYING
|
|||||||
INSTALL
|
INSTALL
|
||||||
Makefile
|
Makefile
|
||||||
Makefile.in
|
Makefile.in
|
||||||
|
TAGS
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
configure
|
configure
|
||||||
config.cache
|
config.cache
|
||||||
|
|||||||
@@ -1,3 +1,21 @@
|
|||||||
|
2001-01-03 Rob Browning <rlb@cs.utexas.edu>
|
||||||
|
|
||||||
|
* src/engine/Transaction.h :start documenting reserved split slots.
|
||||||
|
add prototypes for new functions below.
|
||||||
|
|
||||||
|
* src/engine/Transaction.c
|
||||||
|
(xaccSplitGetType): new function.
|
||||||
|
(xaccSplitMakeStockSplit): new function.
|
||||||
|
|
||||||
|
* src/doc/design/engine.texinfo
|
||||||
|
(Engine Introduction): add docs for split types, including the new
|
||||||
|
stock-split split.
|
||||||
|
(General Split API): remove Slot Get/Set function docs.
|
||||||
|
(General Split API): add xaccSplitMakeStockSplit docs.
|
||||||
|
(Split Getters): add xaccSplitGetType docs.
|
||||||
|
|
||||||
|
* .cvsignore: add TAGS.
|
||||||
|
|
||||||
2000-12-20 Bill Gribble <grib@billgribble.com>
|
2000-12-20 Bill Gribble <grib@billgribble.com>
|
||||||
|
|
||||||
* src/scm/report.scm: minor changes to allow report URLs
|
* src/scm/report.scm: minor changes to allow report URLs
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@node Engine, Register, Top Level, Top
|
@node Engine
|
||||||
@chapter Engine
|
@chapter Engine
|
||||||
@cindex The Engine
|
@cindex The Engine
|
||||||
|
|
||||||
@@ -49,13 +49,13 @@ accounting. A Transaction consists of a date, a description, a number, a
|
|||||||
list of one or more Splits, and a key-value frame. When double-entry
|
list of one or more Splits, and a key-value frame. When double-entry
|
||||||
rules are enforced, the total value of the splits is zero. Note that if
|
rules are enforced, the total value of the splits is zero. Note that if
|
||||||
there is just one split, its value must be zero for double-entry
|
there is just one split, its value must be zero for double-entry
|
||||||
accounting; this is useful because a zero-valued split can store a price
|
accounting; this used to be used for storing prices, but with the advent
|
||||||
(useful for e.g. tracking stocks). If there are two splits, then the
|
of the pricedb, zero-valued splits are probably best avoided. If there
|
||||||
value of one must be positive, the other negative: this denotes that one
|
are two splits, then the value of one must be positive, the other
|
||||||
account is credited, and another is debited by an equal amount. Positive
|
negative: this denotes that one account is credited, and another is
|
||||||
Split values are 'debits' and negative Split values are 'credits'.
|
debited by an equal amount. Positive Split values are 'debits' and
|
||||||
Ensuring the Splits to 'add up' to zero causes a double-entry accounting
|
negative Split values are 'credits'. Ensuring the Splits to 'add up' to
|
||||||
system to always balance.
|
zero causes a double-entry accounting system to always balance.
|
||||||
|
|
||||||
The engine does not enforce double-entry accounting, but provides an API
|
The engine does not enforce double-entry accounting, but provides an API
|
||||||
to enable user-code to find unbalanced transactions and 'repair' them so
|
to enable user-code to find unbalanced transactions and 'repair' them so
|
||||||
@@ -1070,6 +1070,17 @@ reconciliation states for a Split are:
|
|||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@item A set of slots
|
||||||
|
This is a kvp_frame specific to a given split. Reserved key names
|
||||||
|
include:
|
||||||
|
|
||||||
|
@table @code
|
||||||
|
@item "gnc:stock-split"
|
||||||
|
This slot stores a string indicating the type of the split if the
|
||||||
|
split is not a ``normal'' split. See @code{xaccSplitGetType}
|
||||||
|
for more details.
|
||||||
|
@end table
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
In addition to the above, Splits contain a Memo field, an Action field,
|
In addition to the above, Splits contain a Memo field, an Action field,
|
||||||
@@ -1111,13 +1122,9 @@ Return the split associated with @var{GUID}, or @code{NULL} if there is
|
|||||||
no such split.
|
no such split.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
@deftypefun {kvp_value *} xaccSplitGetSlot(Split * @var{split}, const char * @var{key})
|
@deftypefun void xaccSplitMakeStockSplit (Split * @var{split})
|
||||||
Return the @code{kvp_value} associated with @var{key} in @var{split}.
|
Modify @var{split} to be an ``official'' stock-split split. Among other
|
||||||
If there is none, @code{NULL} is returned.
|
things, this involves clearing the value of the split to 0.
|
||||||
@end deftypefun
|
|
||||||
|
|
||||||
@deftypefun void xaccSplitSetSlot(Split * @var{split}, const char * @var{key}, const kvp_value * @var{value})
|
|
||||||
Associate a copy of @var{value} with @var{key} in @var{split}.
|
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
|
|
||||||
@@ -1216,6 +1223,21 @@ Return the share reconciled balance of @var{split}'s parent Account up
|
|||||||
to and including @var{split}. See @ref{Accounts} for details.
|
to and including @var{split}. See @ref{Accounts} for details.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
|
@deftypefun {const char*} xaccSplitGetType (Split * @var{split})
|
||||||
|
Return @var{split}'s type as a string. Currently, the possibilities are
|
||||||
|
|
||||||
|
@table @code
|
||||||
|
@item normal
|
||||||
|
a normal split -- the default.
|
||||||
|
|
||||||
|
@item stock-split
|
||||||
|
a split representing a stock split. The value should be 0 and the
|
||||||
|
share amount should represent the number of shares added/subtracted from
|
||||||
|
the account as a result of the forward/reverse stock split.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
|
|
||||||
@node Split Setters, , Split Getters, Splits
|
@node Split Setters, , Split Getters, Splits
|
||||||
@subsection Split Setters
|
@subsection Split Setters
|
||||||
|
|||||||
@@ -467,7 +467,7 @@ void
|
|||||||
xaccSplitSetValue (Split *s, gnc_numeric amt) {
|
xaccSplitSetValue (Split *s, gnc_numeric amt) {
|
||||||
if(!s) return;
|
if(!s) return;
|
||||||
|
|
||||||
s->value = gnc_numeric_convert(amt, get_currency_denom(s), GNC_RND_ROUND);;
|
s->value = gnc_numeric_convert(amt, get_currency_denom(s), GNC_RND_ROUND);
|
||||||
|
|
||||||
mark_split (s);
|
mark_split (s);
|
||||||
}
|
}
|
||||||
@@ -2055,6 +2055,39 @@ xaccSplitGetSharePrice (Split * split) {
|
|||||||
PRICE_DENOM, GNC_RND_ROUND);
|
PRICE_DENOM, GNC_RND_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************************************\
|
||||||
|
\********************************************************************/
|
||||||
|
|
||||||
|
const char *
|
||||||
|
xaccSplitGetType(const Split *s)
|
||||||
|
{
|
||||||
|
kvp_frame *frame;
|
||||||
|
kvp_value *split_type;
|
||||||
|
|
||||||
|
if(!s) return NULL;
|
||||||
|
frame = xaccSplitGetSlots((Split *) s);
|
||||||
|
if(!frame) return NULL;
|
||||||
|
split_type = kvp_frame_get_slot(frame, "gnc:split-type");
|
||||||
|
if(!split_type) return "normal";
|
||||||
|
if(kvp_value_get_type(split_type) != KVP_TYPE_STRING) return NULL;
|
||||||
|
return(kvp_value_get_string(split_type));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reconfgure a split to be a stock split - after this, you shouldn't
|
||||||
|
mess with the value, just the damount. */
|
||||||
|
void
|
||||||
|
xaccSplitMakeStockSplit(Split *s)
|
||||||
|
{
|
||||||
|
kvp_frame *frame = xaccSplitGetSlots(s);
|
||||||
|
|
||||||
|
xaccSplitSetValue(s, gnc_numeric_zero());
|
||||||
|
kvp_frame_set_slot(frame,
|
||||||
|
"gnc:split-type",
|
||||||
|
kvp_value_new_string("stock-split"));
|
||||||
|
mark_split(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
|
|||||||
@@ -299,8 +299,13 @@ gboolean xaccSplitEqual(const Split *sa, const Split *sb,
|
|||||||
gboolean check_txn_splits);
|
gboolean check_txn_splits);
|
||||||
|
|
||||||
/* Split slots are used to store arbitrary strings, numbers, and
|
/* Split slots are used to store arbitrary strings, numbers, and
|
||||||
* structures which aren't members of the transaction struct. */
|
* structures which aren't members of the transaction struct.
|
||||||
|
*
|
||||||
|
* Reserved slot names:
|
||||||
|
*
|
||||||
|
* gnc:split-type -- a string representing the type of split, if not normal.
|
||||||
|
*
|
||||||
|
*/
|
||||||
kvp_frame *xaccSplitGetSlots(Split *trans);
|
kvp_frame *xaccSplitGetSlots(Split *trans);
|
||||||
|
|
||||||
/* The xaccSplitGetGUID() subroutine will return the
|
/* The xaccSplitGetGUID() subroutine will return the
|
||||||
@@ -426,6 +431,13 @@ gnc_numeric xaccSplitGetValue (Split * split);
|
|||||||
|
|
||||||
Account * xaccSplitGetAccount (Split *split);
|
Account * xaccSplitGetAccount (Split *split);
|
||||||
|
|
||||||
|
/* split types: normal stock-split */
|
||||||
|
const char *xaccSplitGetType(const Split *s);
|
||||||
|
|
||||||
|
/* reconfgure a split to be a stock split - after this, you shouldn't
|
||||||
|
mess with the value, just the damount. */
|
||||||
|
void xaccSplitMakeStockSplit(Split *s);
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
* sorting comparison function
|
* sorting comparison function
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user