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.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
-- 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

2
debian/control vendored
View File

@ -6,7 +6,7 @@ Standards-Version: 3.1.0.0
Package: gnucash
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
Description: A personal finance tracking program.
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_undocumented gnc-prices.1 gnucash.1x gnucash.motif.1x
dh_installchangelogs ChangeLog
dh_strip
cp src/.libs/gnucash $(id)/usr/bin/gnucash.debug
# dh_strip
# cp src/.libs/gnucash $(id)/usr/bin/gnucash.debug
dh_compress
dh_fixperms
dh_suidregister

View File

@ -1,6 +1,6 @@
Begin3
Title: gnucash -- simple single-user accounting program
Version: 1.5.0
Version: 1.4.9
Entered-date: 18JUN99
Description: GnuCash is a personal finance manager. A check-book like
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
Author: rclark@cs.hmc.edu (Robin Clark)
Maintained-by: linas@linas.org (Linas Vepstas)
Primary-site: http://gnucash.org/
Alternate-site: http://linas.org/linux/xacc
885KB gnucash-1.1.22.tar.gz
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
Primary-site: ftp://ftp.gnucash.org/pub/gnucash/sources/stable/
3463kB gnucash-1.4.9.tar.gz
Platforms: Linux/Unix/X Windows/Gnome/Gtk/Sparc/Intel/PowerPC
Copying-policy: GPL
End

View File

@ -1,4 +1,5 @@
#!@-PERL-@ -w
# -*- perl -*-
#
# This perl script is used to make a patch for your GnuCash
# development work. All patches should be submitted to the
@ -12,18 +13,18 @@
use strict;
use File::Basename;
###########################################################
# This section must be configured for your own setup. #
###########################################################
# The directory with the original gnucash sources
my $old = 'gnucash.pristine';
my $old = undef;
# The directory where you do your development
my $new = 'gnucash';
chomp(my $cwd = `pwd`);
# The directory where the above two directories reside
my $gnc_home = '/usr/src/misc/gnc';
my ($new, $gnc_home) = fileparse($cwd);
###########################################################
# 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'};
}
# 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";
# 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
my @args = ('-diff', 'diff -u', '-exclude-vc');
# Add in the exclude patterns from the __DATA__ section
foreach my $pat (<DATA>) {
chomp($pat);
push(@args, '-exclude', $pat) if $pat;
if (not -d "diffs") {
mkdir "diffs";
}
# Add the from and to directories for makepatch
push(@args, $old, $new);
my $date = `date '+%s'`;
chomp($date);
my $who = `whoami`;
chomp($who);
my $outfilename = "gnucash-$date-$who.diff";
# Invoke makepatch with standard out redirected to 'gnucash.diff'
open(OLDOUT, ">&STDOUT");
open(STDOUT, "> gnucash.diff") || die "Can't redirect stdout";
open(STDOUT, "> diffs/$outfilename") || die "Can't redirect stdout";
system('makepatch', @args);
close(STDOUT);
open(STDOUT, ">&OLDOUT");
# Make a copy of the ascii diff in 'gnc.diff'
system('cp gnucash.diff gnc.diff');
print "makepatch done\n";
# Compress the patch
system('gzip -9vf gnucash.diff');
if (-f "diffs/$outfilename") {
system("gzip", "-9vf", "diffs/$outfilename");
}
# UU encode the compressed patch
# '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);
@ -100,72 +151,5 @@ __DATA__
*.tar.gz
*.wrap
*.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
version.texi
stamp-vti
gnucash-design.tps
gnucash-design.fns
gnucash-design.cps
@ -13,7 +12,7 @@ gnucash-design.tp
gnucash-design.vr
gnucash-design.fn
gnucash-design.cp
*.info
*.info-*
*.html
texinfo.tex

View File

@ -1828,19 +1828,26 @@ xaccTransOrder (Transaction *ta, Transaction *tb)
/********************************************************************\
\********************************************************************/
void
xaccTransSetDateSecs (Transaction *trans, time_t secs)
enum { TDATE_POSTED, TDATE_ENTERED };
static void
xaccTransSetDateInternal(Transaction *trans, int which, time_t secs,
long int nsecs)
{
Timespec *dadate = 0;
if(!trans) return;
check_open(trans);
PINFO ("addr=%p set date to %lu %s \n",
trans, secs, ctime (&secs));
trans->date_posted.tv_sec = secs;
trans->date_posted.tv_nsec = 0;
PINFO ("addr=%p set %d date to %lu %li %s \n",
trans, which, secs, nsecs, ctime (&secs));
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
* splits is properly ordered in each of their accounts. We could do that
* 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
xaccTransSetDateEnteredSecs (Transaction *trans, time_t secs)
{
if (!trans) return;
check_open (trans);
trans->date_entered.tv_sec = secs;
trans->date_entered.tv_nsec = 0;
mark_trans (trans);
xaccTransSetDateInternal(trans, TDATE_ENTERED, secs, 0);
}
void
xaccTransSetDateTS (Transaction *trans, const Timespec *ts)
{
if (!trans || !ts) return;
check_open (trans);
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);
if (!ts) return;
xaccTransSetDateInternal(trans, TDATE_POSTED, ts->tv_sec, ts->tv_nsec);
}
void
xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
{
if (!trans || !ts) return;
check_open (trans);
trans->date_entered.tv_sec = ts->tv_sec;
trans->date_entered.tv_nsec = ts->tv_nsec;
mark_trans (trans);
if (!ts) return;
xaccTransSetDateInternal(trans, TDATE_ENTERED, ts->tv_sec, ts->tv_nsec);
}
void
xaccTransSetDate (Transaction *trans, int day, int mon, int year)
{
Timespec ts = gnc_dmy2timespec(day, mon, year);
xaccTransSetDateTS (trans, &ts);
xaccTransSetDateInternal(trans, TDATE_POSTED, ts.tv_sec, ts.tv_nsec);
}
void
xaccTransSetDateToday (Transaction *trans)
{
struct timeval tv;
if (!trans) return;
check_open (trans);
gettimeofday (&tv, NULL);
trans->date_posted.tv_sec = tv.tv_sec;
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));
xaccTransSetDateInternal(trans, TDATE_POSTED, tv.tv_sec, tv.tv_usec);
}

View File

@ -157,12 +157,6 @@ static AccountGroup *maingrp; /* temporary holder for file
static GHashTable *ids_to_finished_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 ******************************************************/
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 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
* of account type. These numbers are used (are to be
@ -236,17 +220,6 @@ xaccFlipInt (int val)
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
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
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;
}
#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
@ -370,10 +315,6 @@ sixtp_sax_start_handler(void *user_data,
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_parser = current_frame->parser;
@ -492,10 +433,6 @@ sixtp_sax_end_handler(void *user_data, const xmlChar *name) {
if(!pdata->parsing_ok) return;
#if 0
fprintf(stderr, "Hit end tag </%s>\n", name);
#endif
current_frame = (sixtp_stack_frame *) pdata->stack->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);
}
#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
because this string is held by the parent parser's hash table. */
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);
#if 0
printf("REMAINING STACK:\n");
sixtp_print_frame_stack(pdata->stack, stderr);
#endif
/* reset pointer after stack pop */
current_frame = (sixtp_stack_frame *) pdata->stack->data;
/* 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);
}
#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
sixtp_set_start(sixtp *parser, sixtp_start_handler start_handler) {
parser->start_handler = start_handler;
@ -960,18 +827,6 @@ allow_and_ignore_only_whitespace(GSList *sibling_data,
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
generic_accumulate_chars(GSList *sibling_data,
gpointer parent_data,
@ -4664,67 +4519,3 @@ is_gncxml_file(const gchar *filename) {
if(f) fclose(f);
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 <stdio.h>
#include <string.h>
#include <tree.h>
#include <parser.h>
@ -38,6 +39,10 @@
#define xmlRootNode root
#endif
static const gchar *gncxml_emacs_trailer =
"<!-- Local variables: -->\n"
"<!-- mode: xml -->\n"
"<!-- End: -->\n";
static gboolean
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(!xml_add_kvp_frame(split_xml, "slots", s->kvp_data, FALSE))
return(FALSE);
@ -766,6 +745,24 @@ xml_add_account_restorers(xmlNodePtr p, AccountGroup *g) {
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
gncxml_write(AccountGroup *group, const gchar *filename) {
/* 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);
xmlFreeDoc(doc);
gncxml_append_emacs_trailer(filename);
/* FIXME: This gives me a non-zero result, even when everything's fine ???
status = xmlDocDump(outfile, doc);

View File

@ -195,7 +195,6 @@ gnucash_ui_init(void)
restargv2 = (char**)poptGetArgs(returnedPoptContext);
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 */
poptFreeContext (returnedPoptContext);
@ -274,7 +273,7 @@ gnucash_ui_init(void)
xaccRecnCellSetStringGetter(gnc_get_reconcile_str);
mainWindow();
/* gnc_default_ui_start */
gnucash_style_init();
gnucash_color_init();
@ -285,6 +284,16 @@ gnucash_ui_init(void)
return 0;
}
static int hasstarted = 0;
void gnc_default_ui_start(void)
{
if(!hasstarted)
{
mainWindow();
hasstarted = 1;
}
}
/* ============================================================== */
void
@ -348,6 +357,7 @@ gnc_ui_main(void)
{
/* Initialize gnome */
gnucash_ui_init();
gnc_default_ui_start();
gnc_refresh_main_window();
gtk_widget_show(app);

View File

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

View File

@ -146,6 +146,9 @@
(begin
;; (gnc:load-account-file)
(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:hook-remove-dangler gnc:*ui-shutdown-hook* gnc:ui-finish))

View File

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