James LewisMoss's patch with:

1) More meta data updates (.cvsignore updates, debian/* updates,
   gnucash.lsm)
2) Changes to make-gnucash-patch.in.  I like the changes, but I don't
   know whether they would be universally liked, so pay attention to
   this one.  Changes include:
   a) check out compared source from cvs
   b) use .cvsignore files to get a large part of the --exclude list.
   c) Keep track of past patches by not automatically overwriting old
      patches and put the patches in a directory to keep things neat.
3) Refactoring in src/engine/Transaction.c to remove the redundant
   code setting dates in transactions.
4) remove all the #if 0 blocks in src/engine/io-gnc{bin,xml}* (helped
   my see things more clearly when looking at the code.  Again ignore
   it if this is inappropriate.)
5) append emacs local variable settings stuff to save file so it's
   known as an xml file.
6) Patch to cleanup startup some more.
   a) src/gnome/top-level.c: don't run load-account-file, split up
      startup into a couple of functions.
   b) src/gnome/window-main.h; src/gulie/gnc.gwp: add the new functions
   c) src/scm/main.scm: do the new startup sequence.
   d) All this so in a batch environment you can start up the gui
      system without bringing up the default window.
7) src/scm/report/budget-report.scm: some refactoring/cleanup done
   while looking at the code.  Nothing functional different (at least
   there shouldn't be.)


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3320 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-12-19 07:59:44 +00:00
parent ee3c0b4864
commit 6290fdae4a
16 changed files with 427 additions and 622 deletions

4
debian/.cvsignore vendored
View File

@ -1,2 +1,6 @@
Makefile Makefile
Makefile.in Makefile.in
tmp
*.debhelper
files
substvars

4
debian/changelog vendored
View File

@ -1,8 +1,8 @@
gnucash (1.5.2.cvs20001210-0.1) unstable; urgency=low gnucash (1.5.2.cvs20001218-0.1) unstable; urgency=low
* local compile * local compile
-- James LewisMoss <dres@debian.org> Thu, 30 Nov 2000 13:29:17 -0500 -- James LewisMoss <dres@debian.org> Mon, 18 Dec 2000 19:33:43 -0500
gnucash (1.5.2.cvs20001105-0.1) unstable; urgency=low gnucash (1.5.2.cvs20001105-0.1) unstable; urgency=low

2
debian/control vendored
View File

@ -6,7 +6,7 @@ Standards-Version: 3.1.0.0
Package: gnucash Package: gnucash
Architecture: any Architecture: any
Depends: ${shlibs:Depends}, libwww-perl, slib, scm, guile1.3, libguile6-slib, perl-5.005, eperl Depends: ${shlibs:Depends}, libwww-perl, guile1.4-slib
Suggests: gnuplot Suggests: gnuplot
Description: A personal finance tracking program. Description: A personal finance tracking program.
Gnucash can track finances in multiple accounts, keeping running Gnucash can track finances in multiple accounts, keeping running

5
debian/postinst vendored Normal file
View File

@ -0,0 +1,5 @@
#!/bin/sh
ldconfig
#DEBHELPER#

4
debian/rules vendored
View File

@ -69,8 +69,8 @@ binary-arch: build install
dh_installmanpages dh_installmanpages
# dh_undocumented gnc-prices.1 gnucash.1x gnucash.motif.1x # dh_undocumented gnc-prices.1 gnucash.1x gnucash.motif.1x
dh_installchangelogs ChangeLog dh_installchangelogs ChangeLog
dh_strip # dh_strip
cp src/.libs/gnucash $(id)/usr/bin/gnucash.debug # cp src/.libs/gnucash $(id)/usr/bin/gnucash.debug
dh_compress dh_compress
dh_fixperms dh_fixperms
dh_suidregister dh_suidregister

View File

@ -1,6 +1,6 @@
Begin3 Begin3
Title: gnucash -- simple single-user accounting program Title: gnucash -- simple single-user accounting program
Version: 1.5.0 Version: 1.4.9
Entered-date: 18JUN99 Entered-date: 18JUN99
Description: GnuCash is a personal finance manager. A check-book like Description: GnuCash is a personal finance manager. A check-book like
register GUI allows you to enter and track bank accounts, register GUI allows you to enter and track bank accounts,
@ -60,13 +60,9 @@ Description: GnuCash is a personal finance manager. A check-book like
Keywords: X11 Accounting Finance double entry Keywords: X11 Accounting Finance double entry
Author: rclark@cs.hmc.edu (Robin Clark) Author: rclark@cs.hmc.edu (Robin Clark)
Maintained-by: linas@linas.org (Linas Vepstas) Maintained-by: linas@linas.org (Linas Vepstas)
Primary-site: http://gnucash.org/ Primary-site: ftp://ftp.gnucash.org/pub/gnucash/sources/stable/
Alternate-site: http://linas.org/linux/xacc 3463kB gnucash-1.4.9.tar.gz
885KB gnucash-1.1.22.tar.gz Platforms: Linux/Unix/X Windows/Gnome/Gtk/Sparc/Intel/PowerPC
Alternate-site: sunsite.unc.edu /pub/Linux/apps/financial/accounting/
885KB gnucash-1.1.22.tar.gz
Alternate-site: ftp.x.org /contrib/applications
Platforms: Linux/Unix/X Windows/Lesstif/Motif/Mootif/Sparc/Intel/PowerPC
Copying-policy: GPL Copying-policy: GPL
End End

View File

@ -1,4 +1,5 @@
#!@-PERL-@ -w #!@-PERL-@ -w
# -*- perl -*-
# #
# This perl script is used to make a patch for your GnuCash # This perl script is used to make a patch for your GnuCash
# development work. All patches should be submitted to the # development work. All patches should be submitted to the
@ -12,18 +13,18 @@
use strict; use strict;
use File::Basename;
########################################################### ###########################################################
# This section must be configured for your own setup. # # This section must be configured for your own setup. #
########################################################### ###########################################################
# The directory with the original gnucash sources # The directory with the original gnucash sources
my $old = 'gnucash.pristine'; my $old = undef;
# The directory where you do your development chomp(my $cwd = `pwd`);
my $new = 'gnucash';
# The directory where the above two directories reside my ($new, $gnc_home) = fileparse($cwd);
my $gnc_home = '/usr/src/misc/gnc';
########################################################### ###########################################################
# This section should not need to be modified. # # This section should not need to be modified. #
@ -43,40 +44,90 @@ if($ENV{'GNC_MAKEPATCH_HOME_DIR'}) {
$gnc_home = $ENV{'GNC_MAKEPATCH_HOME_DIR'}; $gnc_home = $ENV{'GNC_MAKEPATCH_HOME_DIR'};
} }
# Switch to the home directory # Switch to the home directory
print "Changing directory to $gnc_home\n";
chdir $gnc_home or die "Can't cd!\n";
if (not defined($old)) {
if (not -f "$new/CVS/Root") {
print "Source not checked out of CVS and no \$old set. Quitting...\n";
exit(1);
}
if (not -d "tmp") {
mkdir "tmp";
}
chdir "tmp";
system("cvs -d `cat ../$new/CVS/Root` co gnucash");
chdir "..";
$old = "tmp/gnucash";
}
chdir $gnc_home . "/" . $new or die "Can't cd!\n";
# Start out with our basic makepatch arguments
my @args = ('-verbose', '-diff', 'diff -u', '-exclude-vc');
# Add in the exclude patterns from the __DATA__ section
push_exclusions(\@args);
sub push_exclusions {
my $args = shift;
foreach my $pat (<DATA>) {
chomp($pat);
push(@{$args}, '-exclude', $pat) if $pat;
}
my @cvsignores = `find . -name '.cvsignore'`;
foreach my $one_ignore (@cvsignores) {
my ($name, $path) = fileparse($one_ignore);
open (IG, $one_ignore);
foreach my $fl (<IG>) {
chomp $fl;
$path =~ s/^\.\///;
push(@{$args}, '-exclude', $path . $fl) if $fl;
}
close (IG);
}
}
# Add the from and to directories for makepatch
push(@args, $old, $new);
print "Arguments are: " . join("; ", @args) . "\n";
chdir $gnc_home or die "Can't cd!\n"; chdir $gnc_home or die "Can't cd!\n";
# Erase the old files # Erase the old files
unlink('gnc.diff', 'gnucash.diff.gz', 'gnucash.diff.gz.uue'); #unlink('gnc.diff', 'gnucash.diff.gz', 'gnucash.diff.gz.uue');
# Start out with our basic makepatch arguments if (not -d "diffs") {
my @args = ('-diff', 'diff -u', '-exclude-vc'); mkdir "diffs";
# Add in the exclude patterns from the __DATA__ section
foreach my $pat (<DATA>) {
chomp($pat);
push(@args, '-exclude', $pat) if $pat;
} }
# Add the from and to directories for makepatch my $date = `date '+%s'`;
push(@args, $old, $new); chomp($date);
my $who = `whoami`;
chomp($who);
my $outfilename = "gnucash-$date-$who.diff";
# Invoke makepatch with standard out redirected to 'gnucash.diff' # Invoke makepatch with standard out redirected to 'gnucash.diff'
open(OLDOUT, ">&STDOUT"); open(OLDOUT, ">&STDOUT");
open(STDOUT, "> gnucash.diff") || die "Can't redirect stdout"; open(STDOUT, "> diffs/$outfilename") || die "Can't redirect stdout";
system('makepatch', @args); system('makepatch', @args);
close(STDOUT); close(STDOUT);
open(STDOUT, ">&OLDOUT"); open(STDOUT, ">&OLDOUT");
print "makepatch done\n";
# Make a copy of the ascii diff in 'gnc.diff'
system('cp gnucash.diff gnc.diff');
# Compress the patch # Compress the patch
system('gzip -9vf gnucash.diff'); if (-f "diffs/$outfilename") {
system("gzip", "-9vf", "diffs/$outfilename");
}
# UU encode the compressed patch # UU encode the compressed patch
# 'gnucash.diff.gz.uue' is the file you send. # 'gnucash.diff.gz.uue' is the file you send.
system('uuencode gnucash.diff.gz gnucash.diff.gz > gnucash.diff.gz.uue'); if (-f "diffs/$outfilename.gz") {
system("uuencode diffs/$outfilename.gz $outfilename.gz > diffs/$outfilename.gz.uue");
}
print "diffs/$outfilename.gz.uue\n";
exit(0); exit(0);
@ -100,72 +151,5 @@ __DATA__
*.tar.gz *.tar.gz
*.wrap *.wrap
*.xac.*.xac *.xac.*.xac
*~
.#* .#*
.deps
.libs
ABOUT-NLS
INSTALL
COPYING
Makefile
Makefile.in
Makefile.init
POTFILES
TAGS
aclocal.m4
cat-id-tbl.c
conf.h
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
doc/sgml/C/gnucash/*
doc/sgml/C/gnucash.junk
doc/sgml/C/gnucash.tex
errs*
g-wrap-guile
g-wrap.info
gnc-autogen.h
gnucash-design.html
gnucash-engine-perl5_wrap.c
gnucash-engine-perl5_wrap_int.c
gnucash.engine.i
gnucash.pm
install-sh
intl
lib/finance-quote/blib
lib/finance-quote/pm_to_blib
libgncengine.la
libgwrapguile.la
libgwraprs.la
libtool
ltconfig
ltmain.sh
make-gnucash-patch
po/gnucash.pot
po/Makefile.in.in
stamp-h.in
rpm/gnucash.spec
src/doc/design/texinfo.tex
src/doc/design/gnucash-design.info*
src/doc/design/stamp-vti
src/doc/design/version.texi
src/gnome/glade-cb-gnc-dialogs.c
src/gnome/glade-support-gnc-dialogs.c
src/gnucash
src/gnome/gnucash.keys
src/guile/gnc.c
src/guile/gnc.h
src/guile/gnc.html
src/guile/gnucash.c
src/guile/i18n.h
src/optional/swig/gnucash.engine_wrap.doc
src/optional/swig/libgncswig.la
src/quotes/gnc-prices
src/scm/bootstrap.scm
doc/sgml/C/gnucash
stamp-cat-id
stamp-h

View File

@ -2,7 +2,6 @@ Makefile
Makefile.in Makefile.in
version.texi version.texi
stamp-vti stamp-vti
gnucash-design.tps gnucash-design.tps
gnucash-design.fns gnucash-design.fns
gnucash-design.cps gnucash-design.cps
@ -13,7 +12,7 @@ gnucash-design.tp
gnucash-design.vr gnucash-design.vr
gnucash-design.fn gnucash-design.fn
gnucash-design.cp gnucash-design.cp
*.info *.info
*.info-* *.info-*
*.html *.html
texinfo.tex

View File

@ -1828,19 +1828,26 @@ xaccTransOrder (Transaction *ta, Transaction *tb)
/********************************************************************\ /********************************************************************\
\********************************************************************/ \********************************************************************/
void enum { TDATE_POSTED, TDATE_ENTERED };
xaccTransSetDateSecs (Transaction *trans, time_t secs)
static void
xaccTransSetDateInternal(Transaction *trans, int which, time_t secs,
long int nsecs)
{ {
if (!trans) return; Timespec *dadate = 0;
check_open (trans); if(!trans) return;
PINFO ("addr=%p set date to %lu %s \n", check_open(trans);
trans, secs, ctime (&secs));
trans->date_posted.tv_sec = secs; PINFO ("addr=%p set %d date to %lu %li %s \n",
trans->date_posted.tv_nsec = 0; trans, which, secs, nsecs, ctime (&secs));
mark_trans (trans); dadate = ((which == TDATE_POSTED)
? &trans->date_posted
: &trans->date_entered);
dadate->tv_sec = secs;
dadate->tv_nsec = nsecs;
mark_trans(trans);
/* Because the date has changed, we need to make sure that each of the /* Because the date has changed, we need to make sure that each of the
* splits is properly ordered in each of their accounts. We could do that * splits is properly ordered in each of their accounts. We could do that
* here, simply by reinserting each split into its account. However, in * here, simply by reinserting each split into its account. However, in
@ -1850,70 +1857,45 @@ xaccTransSetDateSecs (Transaction *trans, time_t secs)
*/ */
} }
void
xaccTransSetDateSecs (Transaction *trans, time_t secs)
{
xaccTransSetDateInternal(trans, TDATE_POSTED, secs, 0);
}
void void
xaccTransSetDateEnteredSecs (Transaction *trans, time_t secs) xaccTransSetDateEnteredSecs (Transaction *trans, time_t secs)
{ {
if (!trans) return; xaccTransSetDateInternal(trans, TDATE_ENTERED, secs, 0);
check_open (trans);
trans->date_entered.tv_sec = secs;
trans->date_entered.tv_nsec = 0;
mark_trans (trans);
} }
void void
xaccTransSetDateTS (Transaction *trans, const Timespec *ts) xaccTransSetDateTS (Transaction *trans, const Timespec *ts)
{ {
if (!trans || !ts) return; if (!ts) return;
check_open (trans); xaccTransSetDateInternal(trans, TDATE_POSTED, ts->tv_sec, ts->tv_nsec);
DEBUGCMD ({
time_t sicko = ts->tv_sec;
PINFO ("addr=%p set date to %Lu %s \n",
trans, ts->tv_sec, ctime (&sicko));
})
trans->date_posted.tv_sec = ts->tv_sec;
trans->date_posted.tv_nsec = ts->tv_nsec;
mark_trans (trans);
} }
void void
xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts) xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
{ {
if (!trans || !ts) return; if (!ts) return;
check_open (trans); xaccTransSetDateInternal(trans, TDATE_ENTERED, ts->tv_sec, ts->tv_nsec);
trans->date_entered.tv_sec = ts->tv_sec;
trans->date_entered.tv_nsec = ts->tv_nsec;
mark_trans (trans);
} }
void void
xaccTransSetDate (Transaction *trans, int day, int mon, int year) xaccTransSetDate (Transaction *trans, int day, int mon, int year)
{ {
Timespec ts = gnc_dmy2timespec(day, mon, year); Timespec ts = gnc_dmy2timespec(day, mon, year);
xaccTransSetDateTS (trans, &ts); xaccTransSetDateInternal(trans, TDATE_POSTED, ts.tv_sec, ts.tv_nsec);
} }
void void
xaccTransSetDateToday (Transaction *trans) xaccTransSetDateToday (Transaction *trans)
{ {
struct timeval tv; struct timeval tv;
if (!trans) return;
check_open (trans);
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);
trans->date_posted.tv_sec = tv.tv_sec; xaccTransSetDateInternal(trans, TDATE_POSTED, tv.tv_sec, tv.tv_usec);
trans->date_posted.tv_nsec = 1000 * tv.tv_usec;
mark_trans (trans);
PINFO ("addr=%p set date to %lu %s \n",
trans, tv.tv_sec, ctime ((time_t *)&tv.tv_sec));
} }

View File

@ -157,12 +157,6 @@ static AccountGroup *maingrp; /* temporary holder for file
static GHashTable *ids_to_finished_accounts; static GHashTable *ids_to_finished_accounts;
static GHashTable *ids_to_unfinished_accounts; static GHashTable *ids_to_unfinished_accounts;
#if 0
/* used while writing */
static GHashTable *accounts_to_ids;
static gint32 next_write_account_id;
#endif
/** PROTOTYPES ******************************************************/ /** PROTOTYPES ******************************************************/
static Account *locateAccount (int acc_id); static Account *locateAccount (int acc_id);
@ -175,16 +169,6 @@ static char *readString( int fd, int token );
static time_t readDMYDate( int fd, int token ); static time_t readDMYDate( int fd, int token );
static int readTSDate( int fd, Timespec *, int token ); static int readTSDate( int fd, Timespec *, int token );
#if 0
static int writeGroup( int fd, AccountGroup *grp );
static int writeAccount( int fd, Account *account );
static int writeAccInfo(int fd, Account *account);
static int writeTransaction( int fd, Transaction *trans );
static int writeSplit( int fd, Split *split);
static int writeString( int fd, const char *str );
static int writeTSDate( int fd, Timespec *);
#endif
/*******************************************************/ /*******************************************************/
/* backwards compatibility definitions for numeric value /* backwards compatibility definitions for numeric value
* of account type. These numbers are used (are to be * of account type. These numbers are used (are to be
@ -236,17 +220,6 @@ xaccFlipInt (int val)
return (int) flip; return (int) flip;
} }
#if 0
static short
xaccFlipShort (short val)
{
unsigned short flip;
flip = (val & 0xff00) >> 8;
flip |= (val & 0xff) << 8;
return (short) flip;
}
#endif
static double static double
xaccFlipDouble (double val) xaccFlipDouble (double val)
{ {

View File

@ -73,47 +73,6 @@
*/ */
#if 0
static xmlDocPtr
xml_sax_parse_file_r(xmlSAXHandlerPtr sax,
const char *filename,
int recovery,
void *user_data) {
xmlDocPtr ret;
xmlParserCtxtPtr ctxt;
char *directory = NULL;
ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL) return(NULL);
if (sax != NULL) {
if (ctxt->sax != NULL) xmlFree(ctxt->sax);
ctxt->sax = sax;
ctxt->userData = user_data;
}
if ((ctxt->directory == NULL) && (directory == NULL))
directory = xmlParserGetDirectory(filename);
if ((ctxt->directory == NULL) && (directory != NULL))
ctxt->directory = (char *) xmlStrdup((xmlChar *) directory); /* !!!!!!! */
xmlParseDocument(ctxt);
if ((ctxt->wellFormed) || recovery) ret = ctxt->myDoc;
else {
ret = NULL;
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;
}
if (sax != NULL)
ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
return(ret);
}
#endif
/* result for a characters handler is shared across all character /* result for a characters handler is shared across all character
handlers for a given node. result for start/end pair is shared as handlers for a given node. result for start/end pair is shared as
@ -335,20 +294,6 @@ sixtp_print_frame_stack(GSList *stack, FILE *f) {
indent += 2; indent += 2;
} }
#if 0
for(lp = printcopy; lp; lp = lp->next) {
if(lp != printcopy) fprintf(f, " -> ");
if(lp == printcopy) {
/* top level node */
fprintf(f, "[top-level]");
} else {
sixtp_stack_frame *frame = (sixtp_stack_frame *) lp->data;
fprintf(f, "<%s>", (gchar *) frame->tag);
}
}
fprintf(f, ")\n");
#endif
} }
static xmlEntityPtr static xmlEntityPtr
@ -370,10 +315,6 @@ sixtp_sax_start_handler(void *user_data,
if(!pdata->parsing_ok) return; if(!pdata->parsing_ok) return;
#if 0
fprintf(stderr, "Hit start tag <%s>\n", name);
#endif
current_frame = (sixtp_stack_frame *) pdata->stack->data; current_frame = (sixtp_stack_frame *) pdata->stack->data;
current_parser = current_frame->parser; current_parser = current_frame->parser;
@ -492,10 +433,6 @@ sixtp_sax_end_handler(void *user_data, const xmlChar *name) {
if(!pdata->parsing_ok) return; if(!pdata->parsing_ok) return;
#if 0
fprintf(stderr, "Hit end tag </%s>\n", name);
#endif
current_frame = (sixtp_stack_frame *) pdata->stack->data; current_frame = (sixtp_stack_frame *) pdata->stack->data;
parent_frame = (sixtp_stack_frame *) pdata->stack->next->data; parent_frame = (sixtp_stack_frame *) pdata->stack->next->data;
@ -534,10 +471,6 @@ sixtp_sax_end_handler(void *user_data, const xmlChar *name) {
g_slist_prepend(parent_frame->data_from_children, child_result_data); g_slist_prepend(parent_frame->data_from_children, child_result_data);
} }
#if 0
printf("POPPING FRAME for <%s> parser.\n", current_frame->tag);
#endif
/* grab it before it goes away - we shouldn't need to g_strdup /* grab it before it goes away - we shouldn't need to g_strdup
because this string is held by the parent parser's hash table. */ because this string is held by the parent parser's hash table. */
end_tag = current_frame->tag; end_tag = current_frame->tag;
@ -548,11 +481,6 @@ sixtp_sax_end_handler(void *user_data, const xmlChar *name) {
pdata->stack = sixtp_pop_and_destroy_frame(pdata->stack); pdata->stack = sixtp_pop_and_destroy_frame(pdata->stack);
#if 0
printf("REMAINING STACK:\n");
sixtp_print_frame_stack(pdata->stack, stderr);
#endif
/* reset pointer after stack pop */ /* reset pointer after stack pop */
current_frame = (sixtp_stack_frame *) pdata->stack->data; current_frame = (sixtp_stack_frame *) pdata->stack->data;
/* reset the parent, checking to see if we're at the top level node */ /* reset the parent, checking to see if we're at the top level node */
@ -647,67 +575,6 @@ sixtp_destroy(sixtp *sp) {
g_hash_table_destroy(corpses); g_hash_table_destroy(corpses);
} }
#if 0
/* Not tested yet - not needed... */
static sixtp *sixtp_copy(sixtp *s);
typedef struct {
gboolean ok;
GHashTable *hash;
} sixtp_copy_data;
static void
sixtp_copy_children_helper(gpointer key, gpointer value, gpointer user_data) {
sixtp_copy_data *cd = (sixtp_copy_data *) user_data;
const gchar *newkey = g_strdup(key);
sixtp *newparser;
if(!newkey) {
cd->ok = FALSE;
return;
}
newparser = sixtp_copy((sixtp *) value);
if(!newparser) {
cd->ok = FALSE;
g_free(newkey);
return;
}
g_hash_table_insert(cd->hash, newkey, newparser);
}
static sixtp *
sixtp_copy(sixtp *s) {
sixtp_copy_data copy_data;
sixtp *copy = gnew0(sixtp, 1);
if(!copy) return(NULL);
*copy = *s;
/* now the bits that shouldn't be shared */
copy_data.ok = TRUE;
copy_data.hash = g_hash_table_new(g_str_hash, g_str_equal);
if(!copy_data.hash) {
g_free(copy);
return(NULL);
}
copy->children = copy_data.hash;
g_hash_table_foreach(s->children, sixtp_copy_children_helper, copy->children);
if(!copy_data.ok) {
sixtp_destroy(copy);
return(NULL);
}
return(copy);
}
#endif
static void static void
sixtp_set_start(sixtp *parser, sixtp_start_handler start_handler) { sixtp_set_start(sixtp *parser, sixtp_start_handler start_handler) {
parser->start_handler = start_handler; parser->start_handler = start_handler;
@ -960,18 +827,6 @@ allow_and_ignore_only_whitespace(GSList *sibling_data,
return(is_space); return(is_space);
} }
#if 0
static gboolean
generic_pass_data_to_children_start_handler(GSList* sibling_data,
gpointer parent_data,
gpointer global_data,
gpointer *result,
const gchar *tag) {
data_for_children = parent_data;
return(TRUE);
}
#endif
static gboolean static gboolean
generic_accumulate_chars(GSList *sibling_data, generic_accumulate_chars(GSList *sibling_data,
gpointer parent_data, gpointer parent_data,
@ -4664,67 +4519,3 @@ is_gncxml_file(const gchar *filename) {
if(f) fclose(f); if(f) fclose(f);
return(result); return(result);
} }
/****************************************************************************/
#if 0
void
real_main(int argc, char *argv[]) {
gboolean parse_ok;
gpointer parse_result;
sixtp *top_level_pr;
sixtp *gnc_pr;
sixtp *gnc_version_pr;
GNCParseStatus global_parse_status;
/* top-level: This is just a dummy node. It doesn't do anything.
For now, the result is communicated through the global_data
parser. */
top_level_pr = sixtp_new();
if(!top_level_pr) return;
sixtp_set_chars(top_level_pr, allow_and_ignore_only_whitespace);
/* <gnc> */
gnc_pr = gnc_parser_new();
if(!gnc_pr) {
sixtp_destroy(top_level_pr);
return;
}
sixtp_add_sub_parser(top_level_pr, "gnc", gnc_pr);
/* <version> */
gnc_version_pr = gnc_version_parser_new();
if(!gnc_version_pr) {
sixtp_destroy(top_level_pr);
return;
}
sixtp_add_sub_parser(gnc_pr, "version", gnc_version_pr);
global_parse_status.seen_version = FALSE;
global_parse_status.gnc_parser = gnc_pr;
global_parse_status.account_group = NULL;
global_parse_status.error = GNC_PARSE_ERR_NONE;
parse_result = NULL;
parse_ok = sixtp_parse_file(top_level_pr,
"test-data.xml",
NULL,
&global_parse_status,
&parse_result);
sixtp_destroy(top_level_pr);
printf("Result:\n");
printf(" seen_version: %d\n", global_parse_status.seen_version);
printf(" version: %lld\n", global_parse_status.version);
printf(" AccountGroup: %p\n", global_parse_status.account_group);
printf(" error: %d\n", global_parse_status.error);
}
int
main(int argc, char *argv[]) {
gh_enter(argc, argv, real_main);
return(0);
}
#endif

View File

@ -6,6 +6,7 @@
#include <glib.h> #include <glib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <tree.h> #include <tree.h>
#include <parser.h> #include <parser.h>
@ -38,6 +39,10 @@
#define xmlRootNode root #define xmlRootNode root
#endif #endif
static const gchar *gncxml_emacs_trailer =
"<!-- Local variables: -->\n"
"<!-- mode: xml -->\n"
"<!-- End: -->\n";
static gboolean static gboolean
xml_add_str(xmlNodePtr p, const char *tag, const char *str, xml_add_str(xmlNodePtr p, const char *tag, const char *str,
@ -583,32 +588,6 @@ xml_add_transaction_split(xmlNodePtr p, Split* s) {
} }
} }
#if 0
{
gchar data[] = "DEADBEEF";
GList *lst = NULL;
kvp_frame *f = kvp_frame_new();
kvp_value *val1 = kvp_value_new_binary(data, sizeof(data) - 1);
kvp_value *val2 = kvp_value_new_gint64(666);
kvp_value *val3 = kvp_value_new_string("foo");
kvp_frame_set_slot(f, "slot-1", val1);
kvp_frame_set_slot(f, "slot-2", val2);
kvp_frame_set_slot(f, "slot-3", val3);
lst = g_list_append(lst, val1);
lst = g_list_append(lst, val2);
lst = g_list_append(lst, val3);
xaccSplitSetSlot(s, "one", val1);
xaccSplitSetSlot(s, "two", val2);
xaccSplitSetSlot(s, "three", val3);
xaccSplitSetSlot(s, "listness", kvp_value_new_glist(lst));
xaccSplitSetSlot(s, "subbyslot", kvp_value_new_frame(f));
}
#endif
if(s->kvp_data) { if(s->kvp_data) {
if(!xml_add_kvp_frame(split_xml, "slots", s->kvp_data, FALSE)) if(!xml_add_kvp_frame(split_xml, "slots", s->kvp_data, FALSE))
return(FALSE); return(FALSE);
@ -766,6 +745,24 @@ xml_add_account_restorers(xmlNodePtr p, AccountGroup *g) {
return(TRUE); return(TRUE);
} }
static gboolean
gncxml_append_emacs_trailer(const gchar *filename)
{
FILE *toappend;
toappend = fopen(filename, "a+");
if(!toappend)
{
fprintf(stderr, "Unable to append emacs trailer: %s\n",
strerror(errno));
return 0;
}
fprintf(toappend, gncxml_emacs_trailer);
return fclose(toappend);
}
gboolean gboolean
gncxml_write(AccountGroup *group, const gchar *filename) { gncxml_write(AccountGroup *group, const gchar *filename) {
/* fixme: this should be broken up into sub-functions later. */ /* fixme: this should be broken up into sub-functions later. */
@ -810,6 +807,8 @@ gncxml_write(AccountGroup *group, const gchar *filename) {
status = xmlSaveFile(filename, doc); status = xmlSaveFile(filename, doc);
xmlFreeDoc(doc); xmlFreeDoc(doc);
gncxml_append_emacs_trailer(filename);
/* FIXME: This gives me a non-zero result, even when everything's fine ??? /* FIXME: This gives me a non-zero result, even when everything's fine ???
status = xmlDocDump(outfile, doc); status = xmlDocDump(outfile, doc);

View File

@ -195,7 +195,6 @@ gnucash_ui_init(void)
restargv2 = (char**)poptGetArgs(returnedPoptContext); restargv2 = (char**)poptGetArgs(returnedPoptContext);
gnc_set_remaining_argv(argv_length(restargv2), (const char**)restargv2); gnc_set_remaining_argv(argv_length(restargv2), (const char**)restargv2);
gh_eval_str("(gnc:load-account-file)");
/* this must come after using the poptGetArgs return value */ /* this must come after using the poptGetArgs return value */
poptFreeContext (returnedPoptContext); poptFreeContext (returnedPoptContext);
@ -274,7 +273,7 @@ gnucash_ui_init(void)
xaccRecnCellSetStringGetter(gnc_get_reconcile_str); xaccRecnCellSetStringGetter(gnc_get_reconcile_str);
mainWindow(); /* gnc_default_ui_start */
gnucash_style_init(); gnucash_style_init();
gnucash_color_init(); gnucash_color_init();
@ -285,6 +284,16 @@ gnucash_ui_init(void)
return 0; return 0;
} }
static int hasstarted = 0;
void gnc_default_ui_start(void)
{
if(!hasstarted)
{
mainWindow();
hasstarted = 1;
}
}
/* ============================================================== */ /* ============================================================== */
void void
@ -348,7 +357,8 @@ gnc_ui_main(void)
{ {
/* Initialize gnome */ /* Initialize gnome */
gnucash_ui_init(); gnucash_ui_init();
gnc_default_ui_start();
gnc_refresh_main_window(); gnc_refresh_main_window();
gtk_widget_show(app); gtk_widget_show(app);

View File

@ -32,5 +32,7 @@ void mainWindow(void);
GNCMainWinAccountTree * gnc_get_current_account_tree(void); GNCMainWinAccountTree * gnc_get_current_account_tree(void);
void gnc_ui_mainWindow_save_size(void); void gnc_ui_mainWindow_save_size(void);
void gnc_default_ui_start(void);
int gnucash_ui_init(void);
#endif #endif

View File

@ -146,6 +146,9 @@
(begin (begin
;; (gnc:load-account-file) ;; (gnc:load-account-file)
(gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:ui-finish) (gnc:hook-add-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)
(gnc:ui-init)
(gnc:load-account-file)
(gnc:default-ui-start)
(gnc:ui-main) (gnc:ui-main)
(gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish)) (gnc:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish))

View File

@ -25,6 +25,8 @@
(gnc:depend "date-utilities.scm") (gnc:depend "date-utilities.scm")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Budget Entry
(define budget-entry-structure (define budget-entry-structure
(make-record-type (make-record-type
"budget-entry-structure" "budget-entry-structure"
@ -73,6 +75,44 @@
(define make-nominal-mechanism (define make-nominal-mechanism
(record-constructor budget-nominal-mechanism-structure)) (record-constructor budget-nominal-mechanism-structure))
(define budget-entry-get-description
(record-accessor budget-entry-structure 'description))
(define budget-subentry-get-description
(record-accessor budget-subentry-structure 'description))
(define budget-entry-get-accounts
(record-accessor budget-entry-structure 'accounts))
(define budget-entry-get-subentries
(record-accessor budget-entry-structure 'subentries))
(define budget-entry-get-action
(record-accessor budget-entry-structure 'action))
(define budget-entry-get-filter-pred
(record-accessor budget-entry-structure 'filter-pred))
(define budget-subentry-get-amount
(record-accessor budget-subentry-structure 'amount))
(define budget-subentry-get-period
(record-accessor budget-subentry-structure 'period))
(define budget-subentry-get-period-type
(record-accessor budget-subentry-structure 'period-type))
(define budget-bill-get-window-start-day
(record-accessor budget-bill-mechanism-structure 'window-start-day))
(define budget-bill-get-window-end-day
(record-accessor budget-bill-mechanism-structure 'window-end-day))
(define budget-subentry-get-mechanism
(record-accessor budget-subentry-structure 'mechanism))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; useful filter-pred's for a budget entry ;;; useful filter-pred's for a budget entry
(define (budget-filter-pred-debit split budget-line) (define (budget-filter-pred-debit split budget-line)
@ -130,58 +170,69 @@
"gross" '("Income:Gross Employment Income") #f "gross" '("Income:Gross Employment Income") #f
(list (list
(make-budget-subentry #f -99999.99 1 'gnc:budget-month (make-budget-subentry #f -99999.99 1 'gnc:budget-month
(make-bill-mechanism -1 2))) #t) (make-bill-mechanism -1 2)))
#t)
(make-budget-entry (make-budget-entry
"bank interest" '("Expense:Bank Charges:Interest") #f "bank interest" '("Expense:Bank Charges:Interest") #f
(list (list
(make-budget-subentry #f 40 1 'gnc:budget-month (make-budget-subentry #f 40 1 'gnc:budget-month
(make-bill-mechanism -4 0))) #t) (make-bill-mechanism -4 0)))
#t)
(make-budget-entry (make-budget-entry
"bank feed" '("Expense:Bank Charges:Fees") #f "bank feed" '("Expense:Bank Charges:Fees") #f
(list (list
(make-budget-subentry #f 50 1 'gnc:budget-year (make-budget-subentry #f 50 1 'gnc:budget-year
(make-bill-mechanism 27 27))) #t) (make-bill-mechanism 27 27)))
#t)
(make-budget-entry (make-budget-entry
"cell phone" '("Expense:Bills:Cell phone") #f "cell phone" '("Expense:Bills:Cell phone") #f
(list (list
(make-budget-subentry #f 60 1 'gnc:budget-month (make-budget-subentry #f 60 1 'gnc:budget-month
(make-bill-mechanism -4 -1))) #t) (make-bill-mechanism -4 -1)))
#t)
(make-budget-entry (make-budget-entry
"hydro" '("Expense:Bills:Hydro") #f "hydro" '("Expense:Bills:Hydro") #f
(list (list
(make-budget-subentry #f 20 1 'gnc:budget-month (make-budget-subentry #f 20 1 'gnc:budget-month
(make-bill-mechanism 15 19))) #t) (make-bill-mechanism 15 19)))
#t)
(make-budget-entry (make-budget-entry
"life insurance" '("Expense:Bills:Life Insurance") #f "life insurance" '("Expense:Bills:Life Insurance") #f
(list (list
(make-budget-subentry #f 15 1 'gnc:budget-month (make-budget-subentry #f 15 1 'gnc:budget-month
(make-bill-mechanism 1 3))) #t) (make-bill-mechanism 1 3)))
#t)
(make-budget-entry (make-budget-entry
"diesel" '("Expense:Car:Diesel") #f "diesel" '("Expense:Car:Diesel") #f
(list (list
(make-budget-subentry #f 30 4 'gnc:budget-week (make-budget-subentry #f 30 4 'gnc:budget-week
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"licenses" '("Expense:Car:Licenses") #f "licenses" '("Expense:Car:Licenses") #f
(list (list
(make-budget-subentry #f 1000 1 'gnc:budget-year (make-budget-subentry #f 1000 1 'gnc:budget-year
(make-bill-mechanism -122 -108))) #t) (make-bill-mechanism -122 -108)))
#t)
(make-budget-entry (make-budget-entry
"car maintenance" '("Expense:Car:Maintenance") #f "car maintenance" '("Expense:Car:Maintenance") #f
(list (list
(make-budget-subentry #f 100 6 'gnc:budget-month (make-budget-subentry #f 100 6 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"car misc" '("Expense:Car:Miscellaneous") #f "car misc" '("Expense:Car:Miscellaneous") #f
(list (list
(make-budget-subentry #f 5 1 'gnc:budget-week (make-budget-subentry #f 5 1 'gnc:budget-week
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"charitable" '("Expense:Charitable:Non-taxable" "charitable" '("Expense:Charitable:Non-taxable"
"Expense:Charitable:Taxable") #f "Expense:Charitable:Taxable") #f
(list (list
(make-budget-subentry #f 200 1 'gnc:budget-year (make-budget-subentry #f 200 1 'gnc:budget-year
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"entertainment" '("Expense:Entertainment:Beer (out)" "entertainment" '("Expense:Entertainment:Beer (out)"
"Expense:Entertainment:Cover" "Expense:Entertainment:Cover"
@ -192,61 +243,72 @@
"Expense:Entertainment:Liquor (home)") #f "Expense:Entertainment:Liquor (home)") #f
(list (list
(make-budget-subentry #f 50 1 'gnc:budget-week (make-budget-subentry #f 50 1 'gnc:budget-week
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"groceries" '("Expense:Food:Groceries") #f "groceries" '("Expense:Food:Groceries") #f
(list (list
(make-budget-subentry #f 125 1 'gnc:budget-month (make-budget-subentry #f 125 1 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"junk food" '("Expense:Food:Junk") #f "junk food" '("Expense:Food:Junk") #f
(list (list
(make-budget-subentry #f 0.5 1 'gnc:budget-day (make-budget-subentry #f 0.5 1 'gnc:budget-day
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"lunch" '("Expense:Food:Lunch") #f "lunch" '("Expense:Food:Lunch") #f
(list (list
(make-budget-subentry #f 8 1 'gnc:budget-day (make-budget-subentry #f 8 1 'gnc:budget-day
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"gifts" '("Expense:Gifts") #f "gifts" '("Expense:Gifts") #f
(list (list
(make-budget-subentry #f 400 1 'gnc:budget-year (make-budget-subentry #f 400 1 'gnc:budget-year
(make-recurring-mechanism)) (make-recurring-mechanism))
(make-budget-subentry "xmas" 400 1 'gnc:budget-year (make-budget-subentry "xmas" 400 1 'gnc:budget-year
(make-bill-mechanism -30 -5))) #t) (make-bill-mechanism -30 -5)))
#t)
(make-budget-entry (make-budget-entry
"rent" '("Expense:Household:Rent") #f "rent" '("Expense:Household:Rent") #f
(list (list
(make-budget-subentry #f 312.50 1 'gnc:budget-month (make-budget-subentry #f 312.50 1 'gnc:budget-month
(make-bill-mechanism 1 2))) #t) (make-bill-mechanism 1 2)))
#t)
(make-budget-entry (make-budget-entry
"house junk" '("Expense:Household:Stuff") #f "house junk" '("Expense:Household:Stuff") #f
(list (list
(make-budget-subentry #f 25 1 'gnc:budget-month (make-budget-subentry #f 25 1 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"medical" '("Expense:Medical:Dental" "medical" '("Expense:Medical:Dental"
"Expense:Medical:Optical" "Expense:Medical:Optical"
"Expense:Medical:Other") #f "Expense:Medical:Other") #f
(list (list
(make-budget-subentry #f 1000 1 'gnc:budget-year (make-budget-subentry #f 1000 1 'gnc:budget-year
(make-contingency-mechanism))) #t) (make-contingency-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"clothes" '("Expense:Personal:Clothes") #f "clothes" '("Expense:Personal:Clothes") #f
(list (list
(make-budget-subentry #f 150 3 'gnc:budget-month (make-budget-subentry #f 150 3 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"hygeine" '("Expense:Personal:Personal maintenance") #f "hygeine" '("Expense:Personal:Personal maintenance") #f
(list (list
(make-budget-subentry #f 30 1 'gnc:budget-month (make-budget-subentry #f 30 1 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"newspapers" '("Expense:Stuff:Newspapers") #f "newspapers" '("Expense:Stuff:Newspapers") #f
(list (list
(make-budget-subentry #f 20.52 1 'gnc:budget-month (make-budget-subentry #f 20.52 1 'gnc:budget-month
(make-bill-mechanism 14 14))) #t) (make-bill-mechanism 14 14)))
#t)
(make-budget-entry "stuff" '("Expense:Stuff:CD's" (make-budget-entry "stuff" '("Expense:Stuff:CD's"
"Expense:Stuff:Electronic entertainment" "Expense:Stuff:Electronic entertainment"
"Expense:Stuff:Fiction" "Expense:Stuff:Fiction"
@ -258,37 +320,43 @@
"Expense:Stuff:Videos") #f "Expense:Stuff:Videos") #f
(list (list
(make-budget-subentry #f 250 1 'gnc:budget-month (make-budget-subentry #f 250 1 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"student loan" '("Expense:Bills:Student Loan Interest" "student loan" '("Expense:Bills:Student Loan Interest"
"Loans:student loan") #f "Loans:student loan") #f
(list (list
(make-budget-subentry #f 94.54 1 'gnc:budget-month (make-budget-subentry #f 94.54 1 'gnc:budget-month
(make-bill-mechanism -1 -1))) #t) (make-bill-mechanism -1 -1)))
#t)
(make-budget-entry (make-budget-entry
"car loan" '("Expense:Car:Loan Interest" "car loan" '("Expense:Car:Loan Interest"
"Loans:Car Loan") #f "Loans:Car Loan") #f
(list (list
(make-budget-subentry #f 374.18 1 'gnc:budget-month (make-budget-subentry #f 374.18 1 'gnc:budget-month
(make-bill-mechanism 15 17))) #t) (make-bill-mechanism 15 17)))
#t)
(make-budget-entry (make-budget-entry
"RRSP loan" '("Expense:Investment Expenses:RRSP LOC Interest" "RRSP loan" '("Expense:Investment Expenses:RRSP LOC Interest"
"Loans:Scotia Bank RRSP Line of Credit") "Loans:Scotia Bank RRSP Line of Credit")
budget-filter-pred-debit budget-filter-pred-debit
(list (list
(make-budget-subentry #f 100 1 'gnc:budget-month (make-budget-subentry #f 100 1 'gnc:budget-month
(make-bill-mechanism 5 8))) #t) (make-bill-mechanism 5 8)))
#t)
(make-budget-entry (make-budget-entry
"cash write off" '("Expense:Cash write-off") #f "cash write off" '("Expense:Cash write-off") #f
(list (list
(make-budget-subentry #f 60 1 'gnc:budget-month (make-budget-subentry #f 60 1 'gnc:budget-month
(make-recurring-mechanism))) #t) (make-recurring-mechanism)))
#t)
(make-budget-entry (make-budget-entry
"taxes" '("Expense:Taxes:CPP" "Expense:Taxes:EI" "taxes" '("Expense:Taxes:CPP" "Expense:Taxes:EI"
"Expense:Taxes:Federal Income Tax") #f "Expense:Taxes:Federal Income Tax") #f
(list (list
(make-budget-subentry #f 1034.38 1 'gnc:budget-month (make-budget-subentry #f 1034.38 1 'gnc:budget-month
(make-bill-mechanism -1 -2))) #t))) (make-bill-mechanism -1 -2)))
#t)))
;; these are the "other collectors". This is where all transactions ;; these are the "other collectors". This is where all transactions
@ -296,76 +364,64 @@
;; by account-type, which is an integer. ;; by account-type, which is an integer.
(define gnc:budget-others (define gnc:budget-others
(list (list
(make-budget-entry "other bank" '() #f (list (make-budget-entry "other bank" '() #f
(make-budget-subentry #f 0 1 'gnc:budget-month (list
(make-nominal-mechanism))) #f) (make-budget-subentry #f 0 1 'gnc:budget-month
(make-budget-entry "other cash" '() #f (list (make-nominal-mechanism)))
(make-budget-subentry #f 0 1 'gnc:budget-month #f)
(make-nominal-mechanism))) #f) (make-budget-entry "other cash" '() #f
(make-budget-entry "other asset" '() #f (list (list
(make-budget-subentry #f 0 1 'gnc:budget-month (make-budget-subentry #f 0 1 'gnc:budget-month
(make-nominal-mechanism))) #f) (make-nominal-mechanism)))
(make-budget-entry "other credit" '() #f (list #f)
(make-budget-subentry #f 0 1 'gnc:budget-month (make-budget-entry "other asset" '() #f
(make-nominal-mechanism))) #f) (list
(make-budget-entry "other liability" '() #f (list (make-budget-subentry #f 0 1 'gnc:budget-month
(make-budget-subentry #f 0 1 'gnc:budget-month (make-nominal-mechanism)))
(make-nominal-mechanism))) #f) #f)
(make-budget-entry "other stock" '() #f (list (make-budget-entry "other credit" '() #f
(make-budget-subentry #f 0 1 'gnc:budget-month (list
(make-nominal-mechanism))) #f) (make-budget-subentry #f 0 1 'gnc:budget-month
(make-budget-entry "other mutual" '() #f (list (make-nominal-mechanism)))
(make-budget-subentry #f 0 1 'gnc:budget-month #f)
(make-nominal-mechanism))) #f) (make-budget-entry "other liability" '() #f
(make-budget-entry "other currency" '() #f (list (list
(make-budget-subentry #f 0 1 'gnc:budget-month (make-budget-subentry #f 0 1 'gnc:budget-month
(make-nominal-mechanism))) #f) (make-nominal-mechanism)))
(make-budget-entry "other income" '() #f (list #f)
(make-budget-subentry #f -10000 5 'gnc:budget-year (make-budget-entry "other stock" '() #f
(make-contingency-mechanism))) 'gnc:budget-comment) (list
(make-budget-entry "other expense" '() #f (list (make-budget-subentry #f 0 1 'gnc:budget-month
(make-budget-subentry #f 10000 5 'gnc:budget-year (make-nominal-mechanism)))
(make-contingency-mechanism))) 'gnc:budget-comment) #f)
(make-budget-entry "other equity" '() #f (list (make-budget-entry "other mutual" '() #f
(make-budget-subentry #f 10000 5 'gnc:budget-year (list
(make-contingency-mechanism))) #f))) (make-budget-subentry #f 0 1 'gnc:budget-month
(make-nominal-mechanism)))
(define budget-entry-get-description #f)
(record-accessor budget-entry-structure 'description)) (make-budget-entry "other currency" '() #f
(list
(define budget-subentry-get-description (make-budget-subentry #f 0 1 'gnc:budget-month
(record-accessor budget-subentry-structure 'description)) (make-nominal-mechanism)))
#f)
(define budget-entry-get-accounts (make-budget-entry "other income" '() #f
(record-accessor budget-entry-structure 'accounts)) (list
(make-budget-subentry #f -10000 5 'gnc:budget-year
(define budget-entry-get-subentries (make-contingency-mechanism)))
(record-accessor budget-entry-structure 'subentries)) 'gnc:budget-comment)
(make-budget-entry "other expense" '() #f
(define budget-entry-get-action (list
(record-accessor budget-entry-structure 'action)) (make-budget-subentry #f 10000 5 'gnc:budget-year
(make-contingency-mechanism)))
(define budget-entry-get-filter-pred 'gnc:budget-comment)
(record-accessor budget-entry-structure 'filter-pred)) (make-budget-entry "other equity" '() #f
(list
(define budget-subentry-get-amount (make-budget-subentry #f 10000 5 'gnc:budget-year
(record-accessor budget-subentry-structure 'amount)) (make-contingency-mechanism)))
#f)))
(define budget-subentry-get-period
(record-accessor budget-subentry-structure 'period))
(define budget-subentry-get-period-type
(record-accessor budget-subentry-structure 'period-type))
(define budget-bill-get-window-start-day
(record-accessor budget-bill-mechanism-structure 'window-start-day))
(define budget-bill-get-window-end-day
(record-accessor budget-bill-mechanism-structure 'window-end-day))
(define budget-subentry-get-mechanism
(record-accessor budget-subentry-structure 'mechanism))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Budget Report
(define budget-report-structure (define budget-report-structure
(make-record-type (make-record-type
"budget-report-structure" "budget-report-structure"
@ -424,6 +480,37 @@
(define budget-subreport-get-maximum-expected (define budget-subreport-get-maximum-expected
(record-accessor budget-subreport-structure 'maximum-expected)) (record-accessor budget-subreport-structure 'maximum-expected))
(define budget-report-set-actual!
(record-modifier budget-report-structure 'actual))
(define (budget-report-accumulate-actual! value budget-line)
(budget-report-set-actual!
(budget-line-get-report budget-line)
(+ value (budget-report-get-actual
(budget-line-get-report budget-line)))))
(define budget-subreport-set-min-expected!
(record-modifier budget-subreport-structure 'minimum-expected))
(define budget-subreport-set-max-expected!
(record-modifier budget-subreport-structure 'maximum-expected))
(define budget-report-set-min-expected!
(record-modifier budget-report-structure 'minimum-expected))
(define budget-report-set-max-expected!
(record-modifier budget-report-structure 'maximum-expected))
(define (budget-report-accumulate-min-expected! report min-expected)
(budget-report-set-min-expected! report
(+ min-expected (budget-report-get-minimum-expected report))))
(define (budget-report-accumulate-max-expected! report max-expected)
(budget-report-set-max-expected! report
(+ max-expected (budget-report-get-maximum-expected report))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Budget Line
(define budget-line-structure (define budget-line-structure
(make-record-type "budget-line-structure" (make-record-type "budget-line-structure"
'(entry report))) '(entry report)))
@ -463,34 +550,7 @@
(length (length
(budget-entry-get-subentries (budget-line-get-entry line)))) (budget-entry-get-subentries (budget-line-get-entry line))))
(define budget-report-set-actual! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(record-modifier budget-report-structure 'actual))
(define (budget-report-accumulate-actual! value budget-line)
(budget-report-set-actual!
(budget-line-get-report budget-line)
(+ value (budget-report-get-actual
(budget-line-get-report budget-line)))))
(define budget-subreport-set-min-expected!
(record-modifier budget-subreport-structure 'minimum-expected))
(define budget-subreport-set-max-expected!
(record-modifier budget-subreport-structure 'maximum-expected))
(define budget-report-set-min-expected!
(record-modifier budget-report-structure 'minimum-expected))
(define budget-report-set-max-expected!
(record-modifier budget-report-structure 'maximum-expected))
(define (budget-report-accumulate-min-expected! report min-expected)
(budget-report-set-min-expected! report
(+ min-expected (budget-report-get-minimum-expected report))))
(define (budget-report-accumulate-max-expected! report max-expected)
(budget-report-set-max-expected! report
(+ max-expected (budget-report-get-maximum-expected report))))
;; return the # of budget periods over the report period ;; return the # of budget periods over the report period
(define (budget-num-periods subentry begin-date end-date) (define (budget-num-periods subentry begin-date end-date)
@ -510,9 +570,10 @@
(define budget-nominal-pred (define budget-nominal-pred
(record-predicate budget-nominal-mechanism-structure)) (record-predicate budget-nominal-mechanism-structure))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (budget-calculate-expected! budget-line begin-date end-date) (define (budget-calculate-expected! budget-line begin-date end-date)
(let ((entry (budget-line-get-entry budget-line)) (let ((report (budget-line-get-report budget-line)))
(report (budget-line-get-report budget-line)))
(for-each (for-each
(lambda (subentry subreport) (lambda (subentry subreport)
(let ((mechanism (budget-subentry-get-mechanism subentry))) (let ((mechanism (budget-subentry-get-mechanism subentry)))
@ -533,7 +594,8 @@
report (budget-subreport-get-minimum-expected subreport)) report (budget-subreport-get-minimum-expected subreport))
(budget-report-accumulate-max-expected! (budget-report-accumulate-max-expected!
report (budget-subreport-get-maximum-expected subreport)))) report (budget-subreport-get-maximum-expected subreport))))
(budget-entry-get-subentries entry)
(budget-entry-get-subentries (budget-line-get-entry budget-line))
(budget-report-get-subreports report)))) (budget-report-get-subreports report))))
;; calculate the nominal value. ;; calculate the nominal value.
@ -577,83 +639,78 @@
(budget-subreport-set-max-expected! subreport (+ min amount))))) (budget-subreport-set-max-expected! subreport (+ min amount)))))
(define (budget-calculate-bill! subentry subreport mechanism begin-date end-date) (define (budget-calculate-bill! subentry subreport mechanism begin-date end-date)
(let ((N-type (budget-subentry-get-period-type subentry)) (letrec ((N-type (budget-subentry-get-period-type subentry))
(window-start (budget-bill-get-window-start-day mechanism)) (window-start (budget-bill-get-window-start-day mechanism))
(window-end (budget-bill-get-window-end-day mechanism)) (window-end (budget-bill-get-window-end-day mechanism))
(psize (budget-subentry-get-period subentry)) (psize (budget-subentry-get-period subentry))
(amount (budget-subentry-get-amount subentry))) (amount (budget-subentry-get-amount subentry))
; convert negative numbers to positive numbers (date-positiverter
(let ((trig-start-A (if (> window-start 0) (lambda (num date)
window-start (if (> num 0)
(+ window-start num
(gnc:days-in-period (+ num (gnc:days-in-period num date N-type psize))))))
begin-date N-type psize)))) ;; convert negative numbers to positive numbers
(trig-start-B (if (> window-start 0) (let ((trig-start-A (date-positiverter window-start begin-date))
window-start (trig-start-B (date-positiverter window-start end-date))
(+ window-start (trig-end-A (date-positiverter window-end begin-date))
(gnc:days-in-period (trig-end-B (date-positiverter window-end end-date))
end-date N-type psize)))) (possible 0)
(trig-end-A (if (> window-end 0) (sure 0)
window-end (report-start (gnc:date-to-N-remainder begin-date N-type psize))
(+ window-end (report-end (gnc:date-to-N-remainder end-date N-type psize))
(gnc:days-in-period (date-diff (inexact->exact
begin-date N-type psize)))) (- (floor (/ (gnc:date-to-N-fraction
(trig-end-B (if (> window-end 0) end-date N-type) psize))
window-end (floor (/ (gnc:date-to-N-fraction
(+ window-end begin-date N-type) psize))))))
(gnc:days-in-period ;; special case if report start and end are in same period
end-date N-type psize)))) (if (= 0 date-diff)
(possible 0) (cond ((<= trig-start-A trig-end-A)
(sure 0) (cond ((or (> report-start trig-end-A)
(report-start (gnc:date-to-N-remainder begin-date N-type psize)) (< report-end trig-start-A))
(report-end (gnc:date-to-N-remainder end-date N-type psize))) #f)
; special case if report start and end are in same period ((or (> report-start trig-start-A)
(cond ((= (floor (/ (gnc:date-to-N-fraction end-date N-type) psize)) (< report-end trig-end-A))
(floor (/ (gnc:date-to-N-fraction begin-date N-type) psize))) (set! possible 1))
(cond ((<= trig-start-A trig-end-A) (else
(cond ((> report-start trig-end-A) #f) (set! sure 1))))
((< report-end trig-start-A) #f) (else
((or (> report-start trig-start-A) (if (<= report-start trig-end-A)
(< report-end trig-end-A)) (set! possible 1))
(set! possible 1)) (if (>= report-end trig-start-A)
(else (set! sure 1)))) (set! possible (+ possible 1)))))
(else ;; not in same period.
(if (<= report-start trig-end-A) ;; first calculate terminal periods
(set! possible 1)) (begin
(if (>= report-end trig-start-A) (cond ((<= trig-start-A trig-end-A)
(set! possible (+ possible 1)))))) (cond ((> report-start trig-end-A)
; not in same period. #f)
(else ((<= report-start trig-start-A)
; first calculate terminal periods (set! sure 1))
(cond ((<= trig-start-A trig-end-A) (else
(cond ((> report-start trig-end-A) #f) (set! possible 1)))
((<= report-start trig-start-A) (cond ((< report-end trig-start-B)
(set! sure (+ sure 1))) #f)
(else (set! possible (+ possible 1)))) ((>= report-end trig-end-B)
(cond ((< report-end trig-start-B) #f) (set! sure 1))
((>= report-end trig-end-B) (set! sure (+ sure 1))) (else
(else (set! possible (+ possible 1))))) (set! possible 1))))
(else (else
(if (<= report-start trig-end-A) (if (<= report-start trig-end-A)
(set! possible (+ possible 1))) (set! possible (+ possible 1)))
(if (>= report-end trig-start-B) (if (>= report-end trig-start-B)
(set! possible (+ possible 1))) (set! possible (+ possible 1)))
(if (or (> report-start trig-start-A) (if (or (> report-start trig-start-A)
(< report-end trig-end-B)) (< report-end trig-end-B))
(set! possible (+ possible 1)) (set! possible (+ possible 1))
(set! sure (+ sure 1))))) (set! sure (+ sure 1)))))
; then add intermediate periods ;; then add intermediate periods
(set! sure (+ -1 sure (set! sure (+ -1 sure date-diff))))
(inexact->exact ;; now save 'em into the record
(- (floor (/ (gnc:date-to-N-fraction (budget-subreport-set-min-expected! subreport
end-date N-type) psize)) (* amount sure))
(floor (/ (gnc:date-to-N-fraction (budget-subreport-set-max-expected! subreport
begin-date N-type) psize)))))))) (* amount (+ sure possible))))))
; now save 'em into the record
(budget-subreport-set-min-expected! subreport
(* amount sure))
(budget-subreport-set-max-expected! subreport
(* amount (+ sure possible))))))
(define (budget-calculate-actual! budget-hash others begin-date-secs end-date-secs) (define (budget-calculate-actual! budget-hash others begin-date-secs end-date-secs)
(let loop ((group (gnc:get-current-group))) (let loop ((group (gnc:get-current-group)))