mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-22 17:06:36 -06:00
Print currency prices with 5 digits of precision.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2343 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
846240b7e1
commit
c1fa12bf8b
17
ChangeLog
17
ChangeLog
@ -1,5 +1,22 @@
|
||||
2000-05-16 Dave Peticolas <peticola@cs.ucdavis.edu>
|
||||
|
||||
* src/engine/guid/guid.h: change the GUID struct to a union with
|
||||
an integer to force 32-bit alignment on systems that need it.
|
||||
|
||||
* src/register/splitreg.c (xaccInitSplitRegister): in a currency
|
||||
register, set the is_currency flag on the price cell.
|
||||
|
||||
* src/register/pricecell.c (xaccSetPriceCellIsCurrency): function
|
||||
to set printing of currency prices in price cells.
|
||||
|
||||
* src/engine/util.c (xaccSPrintAmount): added a PRTCUR flag for
|
||||
printing currency prices. Changed flags type from short to unsigned
|
||||
int with a typedef of GNCPrintAmountFlags. Changed other files to
|
||||
reflect this.
|
||||
|
||||
* src/scm/report/balance-and-pnl.scm: fix html error (fix from
|
||||
Martin Schwenke).
|
||||
|
||||
* src/guile/guile-util.c: many bug fixes.
|
||||
|
||||
* src/scm/engine-interface.scm: fix list-ref arg order bug.
|
||||
|
@ -1,86 +1,83 @@
|
||||
|
||||
GnuCash currently consists of six (mostly) independent modules:
|
||||
|
||||
The Engine
|
||||
----------
|
||||
"The Engine" (src/engine) provides an interface for accounts and transactions.
|
||||
An account consists of an account name, a default currency, a stock-ticker symbol
|
||||
(if applicable), notes, some miscellany and a list of "split" transactions.
|
||||
A transaction consists of a list of splits, with each split having a description
|
||||
and memo field, date entered and date reconciled fields, quantity and
|
||||
price fields (price == 1.0 for plain old bank accts), and some misc disposition
|
||||
fields.
|
||||
"The Engine" (src/engine) provides an interface for accounts and
|
||||
transactions. An account consists of an account name, a default
|
||||
currency, a stock-ticker symbol (if applicable), notes, some
|
||||
miscellany and a list of "split" transactions. A transaction consists
|
||||
of a list of splits, with each split having a description and memo
|
||||
field, date entered and date reconciled fields, quantity and price
|
||||
fields (price == 1.0 for plain old bank accts), and some misc
|
||||
disposition fields.
|
||||
|
||||
The current implementation is file-format (not SQL) based. It defines a byte
|
||||
stream, for saving to a file or transmitting via pipes/sockets ("persistence"
|
||||
and "data migration" -- the byte stream allows the engine objects to be
|
||||
moved/copied/dynamically recreated on any host. ). The API also
|
||||
provides simple concurrency controls, including a session object, and
|
||||
primitives for beginning/committing/rejecting edits. This should be enough to
|
||||
allow SQL-based transactional back ends to be implemented. The GUI uses
|
||||
and respects these primitives, so GnuCash as a whole should "just work" with
|
||||
an SQL back end.
|
||||
The current implementation is file-format (not SQL) based. It defines
|
||||
a byte stream, for saving to a file or transmitting via pipes/sockets
|
||||
("persistence" and "data migration" -- the byte stream allows the
|
||||
engine objects to be moved/copied/dynamically recreated on any
|
||||
host. ). The API also provides simple concurrency controls, including
|
||||
a session object, and primitives for beginning/committing/rejecting
|
||||
edits. This should be enough to allow SQL-based transactional back
|
||||
ends to be implemented. The GUI uses and respects these primitives,
|
||||
so GnuCash as a whole should "just work" with an SQL back end.
|
||||
|
||||
The engine code contains no GUI code whatsoever, and is essentially OS-neutral.
|
||||
(It might even compile & run under DOS!)
|
||||
The engine code contains no GUI code whatsoever, and is essentially
|
||||
OS-neutral. (It might even compile & run under DOS!)
|
||||
|
||||
|
||||
The Register
|
||||
------------
|
||||
"The Register" (src/register) implements a ledger-like GUI that allows the user
|
||||
to dynamically enter dates, prices, memos descriptions, etc. in a natural,
|
||||
intuitive fashion that should be obvious to anyone who's used a checkbook
|
||||
register. The code is highly configurable, allowing the ledger columns and
|
||||
rows to be laid out in any way, with no restrictions on the function, type
|
||||
and number of columns/rows. For example, one can define a ledger with
|
||||
three date fields, one price field, and four memo fields in a straightforward
|
||||
fashion. Cell handling objects support and automatically validate date
|
||||
entry, memo entry (w/auto-completion), prices, combo-boxes (pull-down menus),
|
||||
multi-state check-boxes. Cells can be marked read-write, or output-only.
|
||||
Cells can be assigned unique colors. The currently active ledger row-block
|
||||
can be highlighted with a unique color.
|
||||
"The Register" (src/register) implements a ledger-like GUI that allows
|
||||
the user to dynamically enter dates, prices, memos descriptions,
|
||||
etc. in a natural, intuitive fashion that should be obvious to anyone
|
||||
who's used a checkbook register. The code is highly configurable,
|
||||
allowing the ledger columns and rows to be laid out in any way, with
|
||||
no restrictions on the function, type and number of columns/rows. For
|
||||
example, one can define a ledger with three date fields, one price
|
||||
field, and four memo fields in a straightforward fashion. Cell
|
||||
handling objects support and automatically validate date entry, memo
|
||||
entry (w/auto-completion), prices, combo-boxes (pull-down menus),
|
||||
multi-state check-boxes. Cells can be marked read-write, or
|
||||
output-only. Cells can be assigned unique colors. The currently
|
||||
active ledger row-block can be highlighted with a unique color.
|
||||
|
||||
The register code is mostly GUI-independent; i.e. the motif/gtk/qt code is
|
||||
confined to two files and a small number of lines of code. The Motif version
|
||||
is the best one currently, the gtk code works, but the underlying gtk table
|
||||
widget is not really powerful enough to provide an elegant interface.
|
||||
|
||||
The register code is completely independent of the engine code, knows nothing
|
||||
about accounting or any of the other GnuCash subsystems. It can be used
|
||||
in independent projects that have nothing to do with accounting.
|
||||
The register code is completely independent of the engine code, knows
|
||||
nothing about accounting or any of the other GnuCash subsystems. It
|
||||
can be used in independent projects that have nothing to do with
|
||||
accounting.
|
||||
|
||||
Reports
|
||||
-------
|
||||
"Reports" (src/reports) is a perl/html based system to create balance sheets,
|
||||
profit & loss statements, etc. by using the engine API's to fetch and display
|
||||
data. Very alpha code, under development.
|
||||
"Reports" (src/reports) are a scheme (guile) based system to create
|
||||
balance sheets, profit & loss statements, etc. by using the engine
|
||||
API's to fetch and display data. Alpha code, under development.
|
||||
|
||||
Quotes
|
||||
------
|
||||
"Quotes" (src/quotes) is a perl system to fetch stock price data off the net
|
||||
and jam it into the GnuCash engine API. Very alpha, under development.
|
||||
and jam it into the GnuCash engine API. This is now a separate project called
|
||||
Finance::Quote available at SourceForge.
|
||||
|
||||
Scheme
|
||||
------
|
||||
"The Scheme" (src/scm, src/guile, src/prefs) is a scheme based infrastructure
|
||||
meant to provide general extensibility, as well as command-line/resource file
|
||||
processing, user-preferences state management, & other functions. Very alpha,
|
||||
under development.
|
||||
"The Scheme" (src/scm, src/guile, src/prefs) is a scheme based
|
||||
infrastructure meant to provide general extensibility, as well
|
||||
as command-line/resource file processing, user-preferences state
|
||||
management, & other functions. Under development.
|
||||
|
||||
GnuCash
|
||||
-------
|
||||
"GnuCash" (src/motif, src/gnome, src/qt) is the main GUI application. It
|
||||
consists of a collection of miscellaneous GUI code to glue together all of the
|
||||
pieces above into a coherent, point-and-click whole. It is meant to be
|
||||
easy to use and intuitive to the novice user without sacrificing the power
|
||||
and flexibility that a professional might expect. When people say that
|
||||
GnuCash is trying to be a "Quicken/MSMoney look/work/act-alike", this is
|
||||
the piece that they are referring to. It really is meant to be a personal-finance
|
||||
manager with enough power for the power user and the ease of use for the beginner.
|
||||
|
||||
Currently, the Motif interface is the only operational interface. The gtk
|
||||
code compiles, but most of the functions are not wired in. The Qt code won't
|
||||
compile, most-all functions are missing.
|
||||
|
||||
|
||||
"GnuCash" (src/motif, src/gnome, src/qt) is the main GUI application.
|
||||
It consists of a collection of miscellaneous GUI code to glue together
|
||||
all of the pieces above into a coherent, point-and-click whole. It is
|
||||
meant to be easy to use and intuitive to the novice user without
|
||||
sacrificing the power and flexibility that a professional might
|
||||
expect. When people say that GnuCash is trying to be a "Quicken
|
||||
or MSMoney look/work/act-alike", this is the piece that they are
|
||||
referring to. It really is meant to be a personal-finance manager
|
||||
with enough power for the power user and the ease of use for the
|
||||
beginner.
|
||||
|
||||
Currently, the Gnome interface is the only operational interface. The
|
||||
Motif code no longer compiles and is not being maintained. The Qt code
|
||||
won't compile, most-all functions are missing.
|
||||
|
@ -44,9 +44,10 @@
|
||||
* to update xaccAccountTypeEnumAsString --- used for text file exports
|
||||
*/
|
||||
|
||||
enum
|
||||
typedef enum
|
||||
{
|
||||
BAD_TYPE = -1,
|
||||
NO_TYPE = -1,
|
||||
/* Not a type */
|
||||
|
||||
BANK = 0,
|
||||
@ -101,7 +102,7 @@ enum
|
||||
SAVINGS = 12,
|
||||
MONEYMRKT = 13,
|
||||
CREDITLINE = 14, /* line of credit */
|
||||
};
|
||||
} GNCAccountType;
|
||||
|
||||
char * xaccAccountGetTypeStr (int type); /* GUI names */
|
||||
|
||||
|
@ -451,8 +451,11 @@ PrintAmt(char *buf, double val, int prec,
|
||||
}
|
||||
|
||||
int
|
||||
xaccSPrintAmountGeneral (char * bufp, double val, short shrs, int precision,
|
||||
int min_trailing_zeros, const char *curr_sym)
|
||||
xaccSPrintAmountGeneral (char * bufp, double val,
|
||||
GNCPrintAmountFlags flags,
|
||||
int precision,
|
||||
int min_trailing_zeros,
|
||||
const char *curr_sym)
|
||||
{
|
||||
struct lconv *lc;
|
||||
|
||||
@ -473,13 +476,13 @@ xaccSPrintAmountGeneral (char * bufp, double val, short shrs, int precision,
|
||||
if (DEQ(val, 0.0))
|
||||
val = 0.0;
|
||||
|
||||
if (shrs & PRTSHR)
|
||||
if (flags & PRTSHR)
|
||||
{
|
||||
currency_symbol = "shrs";
|
||||
cs_precedes = 0; /* currency symbol follows amount */
|
||||
sep_by_space = 1; /* they are separated by a space */
|
||||
}
|
||||
else if (shrs & PRTEUR)
|
||||
else if (flags & PRTEUR)
|
||||
{
|
||||
currency_symbol = "EUR";
|
||||
cs_precedes = 1; /* currency symbol precedes amount */
|
||||
@ -533,7 +536,7 @@ xaccSPrintAmountGeneral (char * bufp, double val, short shrs, int precision,
|
||||
if (print_sign && (sign_posn == 3))
|
||||
bufp = stpcpy(bufp, sign);
|
||||
|
||||
if (shrs & PRTSYM)
|
||||
if (flags & PRTSYM)
|
||||
{
|
||||
bufp = stpcpy(bufp, currency_symbol);
|
||||
if (sep_by_space)
|
||||
@ -550,8 +553,8 @@ xaccSPrintAmountGeneral (char * bufp, double val, short shrs, int precision,
|
||||
bufp = stpcpy(bufp, "(");
|
||||
|
||||
/* Now print the value */
|
||||
bufp += PrintAmt(bufp, DABS(val), precision, shrs & PRTSEP,
|
||||
!(shrs & PRTNMN), min_trailing_zeros);
|
||||
bufp += PrintAmt(bufp, DABS(val), precision, flags & PRTSEP,
|
||||
!(flags & PRTNMN), min_trailing_zeros);
|
||||
|
||||
/* Now see if we print parentheses */
|
||||
if (print_sign && (sign_posn == 0))
|
||||
@ -564,7 +567,7 @@ xaccSPrintAmountGeneral (char * bufp, double val, short shrs, int precision,
|
||||
if (print_sign && (sign_posn == 3))
|
||||
bufp = stpcpy(bufp, sign);
|
||||
|
||||
if (shrs & PRTSYM)
|
||||
if (flags & PRTSYM)
|
||||
{
|
||||
if (sep_by_space)
|
||||
bufp = stpcpy(bufp, " ");
|
||||
@ -585,7 +588,8 @@ xaccSPrintAmountGeneral (char * bufp, double val, short shrs, int precision,
|
||||
}
|
||||
|
||||
int
|
||||
xaccSPrintAmount (char * bufp, double val, short shrs, const char *curr_code)
|
||||
xaccSPrintAmount (char * bufp, double val, GNCPrintAmountFlags flags,
|
||||
const char *curr_code)
|
||||
{
|
||||
struct lconv *lc;
|
||||
int precision;
|
||||
@ -605,14 +609,19 @@ xaccSPrintAmount (char * bufp, double val, short shrs, const char *curr_code)
|
||||
}
|
||||
|
||||
if (curr_code && (strncmp(curr_code, "EUR", 3) == 0))
|
||||
shrs |= PRTEUR;
|
||||
flags |= PRTEUR;
|
||||
|
||||
if (shrs & PRTSHR)
|
||||
if (flags & PRTCUR)
|
||||
{
|
||||
precision = 5;
|
||||
min_trailing_zeros = 0;
|
||||
}
|
||||
else if (flags & PRTSHR)
|
||||
{
|
||||
precision = 4;
|
||||
min_trailing_zeros = 0;
|
||||
}
|
||||
else if (shrs & PRTEUR)
|
||||
else if (flags & PRTEUR)
|
||||
{
|
||||
precision = 2;
|
||||
min_trailing_zeros = 2;
|
||||
@ -623,17 +632,17 @@ xaccSPrintAmount (char * bufp, double val, short shrs, const char *curr_code)
|
||||
min_trailing_zeros = lc->frac_digits;
|
||||
}
|
||||
|
||||
return xaccSPrintAmountGeneral(bufp, val, shrs, precision,
|
||||
return xaccSPrintAmountGeneral(bufp, val, flags, precision,
|
||||
min_trailing_zeros, curr_code);
|
||||
}
|
||||
|
||||
char *
|
||||
xaccPrintAmount (double val, short shrs, const char *curr_code)
|
||||
xaccPrintAmount (double val, GNCPrintAmountFlags flags, const char *curr_code)
|
||||
{
|
||||
/* hack alert -- this is not thread safe ... */
|
||||
static char buf[BUFSIZE];
|
||||
|
||||
xaccSPrintAmount (buf, val, shrs, curr_code);
|
||||
xaccSPrintAmount (buf, val, flags, curr_code);
|
||||
|
||||
/* its OK to return buf, since we declared it static */
|
||||
return buf;
|
||||
@ -644,13 +653,13 @@ xaccPrintAmountArgs (double val, gncBoolean print_currency_symbol,
|
||||
gncBoolean print_separators, gncBoolean is_shares_value,
|
||||
const char *curr_code)
|
||||
{
|
||||
short shrs = 0;
|
||||
GNCPrintAmountFlags flags = 0;
|
||||
|
||||
if (print_currency_symbol) shrs |= PRTSYM;
|
||||
if (print_separators) shrs |= PRTSEP;
|
||||
if (is_shares_value) shrs |= PRTSHR;
|
||||
if (print_currency_symbol) flags |= PRTSYM;
|
||||
if (print_separators) flags |= PRTSEP;
|
||||
if (is_shares_value) flags |= PRTSHR;
|
||||
|
||||
return xaccPrintAmount(val, shrs, curr_code);
|
||||
return xaccPrintAmount(val, flags, curr_code);
|
||||
}
|
||||
|
||||
|
||||
|
@ -168,6 +168,7 @@ char * gnc_locale_default_currency();
|
||||
* PRTNMN -- print as non-monetary value
|
||||
* PRTEUR -- print as EURO value (2 decimal places, EUR as currency
|
||||
* symbol if PRTSYM is specified, mutually exclisive with PRTSHR)
|
||||
* PRTCUR -- print as a currency price, with 5 decimals, overides PRTSHR
|
||||
*
|
||||
* If non-NULL, the curr_code argument overrides the default currency
|
||||
* code.
|
||||
@ -192,12 +193,18 @@ char * gnc_locale_default_currency();
|
||||
#define PRTSEP 0x4
|
||||
#define PRTNMN 0x8
|
||||
#define PRTEUR 0x10
|
||||
#define PRTCUR 0x20
|
||||
|
||||
char * xaccPrintAmount (double val, short shrs, const char *curr_code);
|
||||
int xaccSPrintAmount (char *buf, double val, short shrs,
|
||||
typedef unsigned int GNCPrintAmountFlags;
|
||||
|
||||
char * xaccPrintAmount (double val, GNCPrintAmountFlags flags,
|
||||
const char *curr_code);
|
||||
int xaccSPrintAmount (char *buf, double val, GNCPrintAmountFlags flags,
|
||||
const char *curr_code);
|
||||
int xaccSPrintAmountGeneral (char * bufp, double val, short shrs,
|
||||
int precision, int min_trailing_zeros,
|
||||
int xaccSPrintAmountGeneral (char * bufp, double val,
|
||||
GNCPrintAmountFlags flags,
|
||||
int precision,
|
||||
int min_trailing_zeros,
|
||||
const char *curr_sym);
|
||||
char * xaccPrintAmountArgs (double val,
|
||||
gncBoolean print_currency_symbol,
|
||||
|
@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* option-util.c -- GNOME<->guile option interface *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* option-util.h -- GNOME<->guile option interface *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -521,6 +521,7 @@ static void
|
||||
gnc_reconcile_list_fill(GNCReconcileList *list)
|
||||
{
|
||||
gchar *strings[list->num_columns + 1];
|
||||
GNCPrintAmountFlags flags = PRTSEP;
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
gboolean reconciled;
|
||||
@ -529,7 +530,6 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
|
||||
int account_type;
|
||||
double amount;
|
||||
char recn_str[2];
|
||||
short shares = PRTSEP;
|
||||
char recn;
|
||||
int row;
|
||||
int i;
|
||||
@ -542,7 +542,7 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
|
||||
|
||||
if ((account_type == STOCK) || (account_type == MUTUAL) ||
|
||||
(account_type == CURRENCY))
|
||||
shares |= PRTSHR;
|
||||
flags |= PRTSHR;
|
||||
|
||||
for (i = 0; i < num_splits; i++)
|
||||
{
|
||||
@ -567,7 +567,7 @@ gnc_reconcile_list_fill(GNCReconcileList *list)
|
||||
strings[0] = xaccTransGetDateStr(trans);
|
||||
strings[1] = xaccTransGetNum(trans);
|
||||
strings[2] = xaccTransGetDescription(trans);
|
||||
strings[3] = xaccPrintAmount(DABS(amount), shares, currency);
|
||||
strings[3] = xaccPrintAmount(DABS(amount), flags, currency);
|
||||
|
||||
reconciled = g_hash_table_lookup(list->reconciled, split) != NULL;
|
||||
|
||||
|
@ -158,16 +158,18 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
double ending;
|
||||
double reconciled;
|
||||
double diff;
|
||||
short shares = PRTSYM | PRTSEP;
|
||||
GNCPrintAmountFlags flags;
|
||||
gboolean reverse_balance;
|
||||
int account_type;
|
||||
|
||||
flags = PRTSYM | PRTSEP;
|
||||
|
||||
reverse_balance = gnc_reverse_balance(recnData->account);
|
||||
|
||||
account_type = xaccAccountGetType(recnData->account);
|
||||
if ((account_type == STOCK ) || (account_type == MUTUAL) ||
|
||||
(account_type == CURRENCY))
|
||||
shares |= PRTSHR;
|
||||
flags |= PRTSHR;
|
||||
|
||||
currency = xaccAccountGetCurrency(recnData->account);
|
||||
|
||||
@ -175,7 +177,7 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
starting = xaccAccountGetReconciledBalance(recnData->account);
|
||||
if (reverse_balance)
|
||||
starting = -starting;
|
||||
amount = xaccPrintAmount(starting, shares, currency);
|
||||
amount = xaccPrintAmount(starting, flags, currency);
|
||||
gnc_set_label_color(recnData->starting, starting);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->starting), amount);
|
||||
if (reverse_balance)
|
||||
@ -185,7 +187,7 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
ending = recnData->new_ending;
|
||||
if (reverse_balance)
|
||||
ending = -ending;
|
||||
amount = xaccPrintAmount(ending, shares, currency);
|
||||
amount = xaccPrintAmount(ending, flags, currency);
|
||||
gnc_set_label_color(recnData->ending, ending);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->ending), amount);
|
||||
if (reverse_balance)
|
||||
@ -198,17 +200,17 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
(GNC_RECONCILE_LIST(recnData->credit));
|
||||
|
||||
/* Update the total debit and credit fields */
|
||||
amount = xaccPrintAmount(DABS(debit), shares, currency);
|
||||
amount = xaccPrintAmount(DABS(debit), flags, currency);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->total_debit), amount);
|
||||
|
||||
amount = xaccPrintAmount(credit, shares, currency);
|
||||
amount = xaccPrintAmount(credit, flags, currency);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->total_credit), amount);
|
||||
|
||||
/* update the reconciled balance */
|
||||
reconciled = starting + debit - credit;
|
||||
if (reverse_balance)
|
||||
reconciled = -reconciled;
|
||||
amount = xaccPrintAmount(reconciled, shares, currency);
|
||||
amount = xaccPrintAmount(reconciled, flags, currency);
|
||||
gnc_set_label_color(recnData->reconciled, reconciled);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->reconciled), amount);
|
||||
if (reverse_balance)
|
||||
@ -218,7 +220,7 @@ recnRecalculateBalance(RecnWindow *recnData)
|
||||
diff = ending - reconciled;
|
||||
if (reverse_balance)
|
||||
diff = -diff;
|
||||
amount = xaccPrintAmount(diff, shares, currency);
|
||||
amount = xaccPrintAmount(diff, flags, currency);
|
||||
gnc_set_label_color(recnData->difference, diff);
|
||||
gtk_label_set_text(GTK_LABEL(recnData->difference), amount);
|
||||
if (reverse_balance)
|
||||
@ -232,7 +234,7 @@ gnc_start_recn_update_cb(GtkWidget *widget, GdkEventFocus *event,
|
||||
gpointer data)
|
||||
{
|
||||
GtkEntry *entry = GTK_ENTRY(widget);
|
||||
short shares = PRTSYM | PRTSEP;
|
||||
GNCPrintAmountFlags flags;
|
||||
Account *account = data;
|
||||
int account_type;
|
||||
char *currency;
|
||||
@ -240,6 +242,8 @@ gnc_start_recn_update_cb(GtkWidget *widget, GdkEventFocus *event,
|
||||
gchar *string;
|
||||
double value;
|
||||
|
||||
flags = PRTSYM | PRTSEP;
|
||||
|
||||
string = gtk_entry_get_text(entry);
|
||||
|
||||
value = xaccParseAmount(string, GNC_T);
|
||||
@ -247,11 +251,11 @@ gnc_start_recn_update_cb(GtkWidget *widget, GdkEventFocus *event,
|
||||
account_type = xaccAccountGetType(account);
|
||||
if ((account_type == STOCK) || (account_type == MUTUAL) ||
|
||||
(account_type == CURRENCY))
|
||||
shares |= PRTSHR;
|
||||
flags |= PRTSHR;
|
||||
|
||||
currency = xaccAccountGetCurrency(account);
|
||||
|
||||
new_string = xaccPrintAmount(value, shares & ~PRTSYM, currency);
|
||||
new_string = xaccPrintAmount(value, flags & ~PRTSYM, currency);
|
||||
|
||||
if (safe_strcmp(string, new_string) == 0)
|
||||
return FALSE;
|
||||
@ -279,11 +283,13 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending)
|
||||
{
|
||||
GtkWidget *dialog, *end_value;
|
||||
char *amount, *title, *currency;
|
||||
short shares = PRTSYM | PRTSEP;
|
||||
GNCPrintAmountFlags flags;
|
||||
double dendBalance;
|
||||
int account_type;
|
||||
int result;
|
||||
|
||||
flags = PRTSYM | PRTSEP;
|
||||
|
||||
/* Get the previous ending balance. Use the published
|
||||
* account interface for this, since the ending balance
|
||||
* may have to be adjusted for stock price fluctuations.
|
||||
@ -298,11 +304,11 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending)
|
||||
account_type = xaccAccountGetType(account);
|
||||
if ((account_type == STOCK) || (account_type == MUTUAL) ||
|
||||
(account_type == CURRENCY))
|
||||
shares |= PRTSHR;
|
||||
flags |= PRTSHR;
|
||||
|
||||
currency = xaccAccountGetCurrency(account);
|
||||
|
||||
amount = xaccPrintAmount(dendBalance, shares, currency);
|
||||
amount = xaccPrintAmount(dendBalance, flags, currency);
|
||||
|
||||
/* Create the dialog box... */
|
||||
title = gnc_recn_make_window_name(account);
|
||||
@ -329,7 +335,7 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending)
|
||||
GtkWidget *vbox = GNOME_DIALOG(dialog)->vbox;
|
||||
end_value = gtk_entry_new();
|
||||
|
||||
amount = xaccPrintAmount(*new_ending, shares & ~PRTSYM, currency);
|
||||
amount = xaccPrintAmount(*new_ending, flags & ~PRTSYM, currency);
|
||||
gtk_entry_set_text(GTK_ENTRY(end_value), amount);
|
||||
gtk_editable_select_region(GTK_EDITABLE(end_value), 0, -1);
|
||||
|
||||
|
@ -1701,7 +1701,7 @@ static void
|
||||
regRefresh(xaccLedgerDisplay *ledger)
|
||||
{
|
||||
RegWindow *regData = (RegWindow *) (ledger->gui_hook);
|
||||
int print_flags = PRTSYM | PRTSEP;
|
||||
GNCPrintAmountFlags print_flags = PRTSYM | PRTSEP;
|
||||
gboolean euro = gnc_lookup_boolean_option("International",
|
||||
"Enable EURO support",
|
||||
FALSE);
|
||||
|
@ -198,6 +198,7 @@ xaccInitPriceCell (PriceCell *cell)
|
||||
cell->amount = 0.0;
|
||||
cell->blank_zero = GNC_T;
|
||||
cell->monetary = GNC_T;
|
||||
cell->is_currency = GNC_F;
|
||||
cell->shares_value = GNC_F;
|
||||
|
||||
SET (&(cell->cell), "");
|
||||
@ -226,7 +227,7 @@ static char *
|
||||
xaccPriceCellPrintValue (PriceCell *cell)
|
||||
{
|
||||
static char buff[PRTBUF];
|
||||
short flags = PRTSEP;
|
||||
GNCPrintAmountFlags flags = PRTSEP;
|
||||
|
||||
if (cell->blank_zero && DEQ(cell->amount, 0.0)) {
|
||||
strcpy(buff, "");
|
||||
@ -236,6 +237,9 @@ xaccPriceCellPrintValue (PriceCell *cell)
|
||||
if (cell->shares_value)
|
||||
flags |= PRTSHR;
|
||||
|
||||
if (cell->is_currency)
|
||||
flags |= PRTCUR;
|
||||
|
||||
xaccSPrintAmount(buff, cell->amount, flags, NULL);
|
||||
|
||||
return buff;
|
||||
@ -287,7 +291,8 @@ xaccSetPriceCellBlank (PriceCell *cell)
|
||||
void
|
||||
xaccSetPriceCellSharesValue (PriceCell * cell, gncBoolean shares_value)
|
||||
{
|
||||
assert(cell != NULL);
|
||||
if (cell == NULL)
|
||||
return;
|
||||
|
||||
cell->shares_value = shares_value;
|
||||
}
|
||||
@ -297,17 +302,30 @@ xaccSetPriceCellSharesValue (PriceCell * cell, gncBoolean shares_value)
|
||||
void
|
||||
xaccSetPriceCellMonetary (PriceCell * cell, gncBoolean monetary)
|
||||
{
|
||||
assert(cell != NULL);
|
||||
if (cell == NULL)
|
||||
return;
|
||||
|
||||
cell->monetary = monetary;
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
void
|
||||
xaccSetPriceCellIsCurrency (PriceCell *cell, gncBoolean is_currency)
|
||||
{
|
||||
if (cell == NULL)
|
||||
return;
|
||||
|
||||
cell->is_currency = is_currency;
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
void
|
||||
xaccSetPriceCellBlankZero (PriceCell *cell, gncBoolean blank_zero)
|
||||
{
|
||||
assert(cell != NULL);
|
||||
if (cell == NULL)
|
||||
return;
|
||||
|
||||
cell->blank_zero = blank_zero;
|
||||
}
|
||||
|
@ -60,13 +60,14 @@
|
||||
|
||||
typedef struct _PriceCell
|
||||
{
|
||||
BasicCell cell;
|
||||
BasicCell cell;
|
||||
|
||||
double amount; /* the amount associated with this cell */
|
||||
double amount; /* the amount associated with this cell */
|
||||
|
||||
gncBoolean blank_zero; /* controls printing of zero values */
|
||||
gncBoolean monetary; /* controls parsing of values */
|
||||
gncBoolean shares_value; /* true if a shares values */
|
||||
gncBoolean blank_zero; /* controls printing of zero values */
|
||||
gncBoolean monetary; /* controls parsing of values */
|
||||
gncBoolean is_currency; /* controls printint of values */
|
||||
gncBoolean shares_value; /* true if a shares values */
|
||||
} PriceCell;
|
||||
|
||||
/* installs a callback to handle price recording */
|
||||
@ -89,10 +90,13 @@ void xaccSetPriceCellBlankZero (PriceCell *cell, gncBoolean);
|
||||
|
||||
/* The xaccSetPriceCellMonetary() sets a flag which determines
|
||||
* how string amounts are parsed, either as monetary or
|
||||
* non-monetary amounts. The default is monetary.
|
||||
*/
|
||||
* non-monetary amounts. The default is monetary. */
|
||||
void xaccSetPriceCellMonetary (PriceCell *, gncBoolean);
|
||||
|
||||
/* The xaccSetPriceCellCurrency() sets a flag which causes
|
||||
* the amount to be printed as a currency price. */
|
||||
void xaccSetPriceCellIsCurrency (PriceCell *, gncBoolean);
|
||||
|
||||
/* The xaccSetPriceCellSharesValue() sets a flag which determines
|
||||
* whether the quantity is printed as a shares value or not. */
|
||||
void xaccSetPriceCellSharesValue (PriceCell *, gncBoolean);
|
||||
|
@ -1148,9 +1148,11 @@ xaccInitSplitRegister (SplitRegister *reg, int type)
|
||||
|
||||
/* number format for share quantities in stock ledgers */
|
||||
switch (type & REG_TYPE_MASK) {
|
||||
case CURRENCY_REGISTER:
|
||||
xaccSetPriceCellIsCurrency (reg->priceCell, GNC_T);
|
||||
|
||||
case STOCK_REGISTER:
|
||||
case PORTFOLIO_LEDGER:
|
||||
case CURRENCY_REGISTER:
|
||||
xaccSetPriceCellSharesValue (reg->debitCell, GNC_T);
|
||||
xaccSetPriceCellSharesValue (reg->creditCell, GNC_T);
|
||||
xaccSetPriceCellSharesValue (reg->ndebitCell, GNC_T);
|
||||
|
Loading…
Reference in New Issue
Block a user