mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add alpha-level double-entry system;
segregate some accounting functions from gui alpha-level transaction types added git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@11 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
1a6ffbe672
commit
f5db2d0fff
2
Makefile
2
Makefile
@ -60,7 +60,7 @@ default :
|
||||
@cd src ; $(MAKE) $(OPTIONS)
|
||||
|
||||
clean :
|
||||
rm -f *~ *.bak
|
||||
rm -f core junk tmp *~ *.bak
|
||||
@cd include ; rm -f *~
|
||||
@cd help ; rm -f *~
|
||||
@cd libhtmlw ; $(MAKE) clean
|
||||
|
6
README
6
README
@ -50,7 +50,7 @@ An alpha version of import from quicken files is also present,
|
||||
but it is very broken, and many/most quicken formats are not
|
||||
supported.
|
||||
|
||||
Note: in general, transfers between accounts are not handled
|
||||
properly as a double-entry system, and so deletion of a
|
||||
transfer is not handled properly.
|
||||
An alpha-level double-entry system has been created. Its use
|
||||
is not currently forced. It is used only during transfers
|
||||
between accounts. It is not saved to file, or read from file.
|
||||
|
||||
|
@ -633,15 +633,12 @@ createCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
}
|
||||
|
||||
/* Add an opening balance transaction (as the first transaction) */
|
||||
trans = (Transaction *)_malloc(sizeof(Transaction));
|
||||
trans = mallocTransaction();
|
||||
|
||||
todaysDate( &(trans->date) );
|
||||
trans->num = XtNewString("");
|
||||
trans->description = XtNewString("Opening Balance\0");
|
||||
trans->memo = XtNewString("");
|
||||
trans->catagory = 0;
|
||||
trans->reconciled = NREC;
|
||||
trans->damount = 0.0;
|
||||
|
||||
/* add the new transaction to the account */
|
||||
insertTransaction( acc, trans );
|
||||
|
@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* Account.c -- the Account data structure *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 1997 Linas Vepstas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -79,8 +80,18 @@ freeAccount( Account *acc )
|
||||
|
||||
freeQuickFill(acc->qfRoot);
|
||||
|
||||
for( i=0; i<acc->numTrans; i++ )
|
||||
_free( acc->transaction[i] );
|
||||
for( i=0; i<acc->numTrans; i++ ) {
|
||||
Transaction *trans = acc->transaction[i];
|
||||
struct _account * _acc = (struct _account *) acc;
|
||||
|
||||
/* free the transaction only if its not
|
||||
* a part of a double entry */
|
||||
if (trans->credit == _acc) trans->credit = NULL;
|
||||
if (trans->debit == _acc) trans->debit = NULL;
|
||||
if ( (NULL == trans->debit) && (NULL == trans->credit) ) {
|
||||
freeTransaction( trans );
|
||||
}
|
||||
}
|
||||
|
||||
_free( acc->transaction );
|
||||
|
||||
@ -113,6 +124,7 @@ removeTransaction( Account *acc, int num )
|
||||
if( acc != NULL )
|
||||
{
|
||||
int i,j;
|
||||
struct _account * _acc = (struct _account *) acc;
|
||||
Transaction **oldTrans = acc->transaction;
|
||||
|
||||
/* Set this flag, so we know we need to save the data file: */
|
||||
@ -136,7 +148,13 @@ removeTransaction( Account *acc, int num )
|
||||
}
|
||||
}
|
||||
|
||||
_free(oldTrans);
|
||||
_free (oldTrans);
|
||||
|
||||
/* if this is a double-entry transaction, be sure to
|
||||
* unmark it. */
|
||||
if (trans->credit == _acc) trans->credit = NULL;
|
||||
if (trans->debit == _acc) trans->debit = NULL;
|
||||
|
||||
}
|
||||
return trans;
|
||||
}
|
||||
@ -153,8 +171,36 @@ insertTransaction( Account *acc, Transaction *trans )
|
||||
int i,j;
|
||||
Date *dj,*dt;
|
||||
int inserted = False;
|
||||
struct _account * _acc = (struct _account *) acc;
|
||||
Transaction **oldTrans = acc->transaction;
|
||||
|
||||
/* provide a default behavior for double-entry insertion */
|
||||
/* If this appears to be a new transaction, then default
|
||||
* it to being a credit. If this transaction is already
|
||||
* in another account, assume this is the other half.
|
||||
* This algoriothm is not robust against internal programming
|
||||
* errors ... various bizarre situations can sneak by without
|
||||
* warning ... however, this will do for now.
|
||||
*/
|
||||
|
||||
if ( !((_acc == trans->debit) || (_acc == trans->credit)) ) {
|
||||
if ( (NULL == trans->debit) && (NULL == trans->credit) ) {
|
||||
trans->credit = _acc;
|
||||
} else {
|
||||
if (NULL == trans->debit) {
|
||||
trans->debit = _acc;
|
||||
} else
|
||||
if (NULL == trans->credit) {
|
||||
trans->credit = _acc;
|
||||
} else
|
||||
{
|
||||
printf ("Internal Error: insertTransaction: inserting transaction \n");
|
||||
printf ("that already exists! \n");
|
||||
printf ("This error should not occur, please report it \n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* mark the data file as needing to be saved: */
|
||||
if( data != NULL )
|
||||
data->saved = False;
|
||||
@ -204,8 +250,43 @@ insertTransaction( Account *acc, Transaction *trans )
|
||||
return position;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
double xaccGetAmount (Account *acc, Transaction *trans)
|
||||
{
|
||||
double themount; /* amount */
|
||||
|
||||
/* for a double-entry, determine if this is a credit or a debit */
|
||||
if ( trans->credit == ((struct _account *) acc) ) {
|
||||
themount = trans->damount;
|
||||
} else
|
||||
if ( trans->debit == ((struct _account *) acc) ) {
|
||||
themount = - (trans->damount);
|
||||
} else {
|
||||
printf ("Internal Error: xaccGetAmount: missing double entry \n");
|
||||
printf ("this error should not occur. Please report the problem. \n");
|
||||
themount = 0.0; /* punt */
|
||||
}
|
||||
return themount;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void xaccSetAmount (Account *acc, Transaction *trans, double themount)
|
||||
{
|
||||
/* for a double-entry, determine if this is a credit or a debit */
|
||||
if ( trans->credit == ((struct _account *) acc) ) {
|
||||
trans->damount = themount;
|
||||
} else
|
||||
if ( trans->debit == ((struct _account *) acc) ) {
|
||||
trans->damount = - themount;
|
||||
} else {
|
||||
printf ("Internal Error: xaccSetAmount: missing double entry \n");
|
||||
printf ("this error should not occur. Please report the problem. \n");
|
||||
trans->damount = 0.0; /* punt */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -------------------- end of file --------------- */
|
||||
|
@ -269,9 +269,9 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
Transaction *trans, *tempTrans;
|
||||
Account *acc;
|
||||
String str;
|
||||
int dollar=0,cent=0;
|
||||
float val = 0.0;
|
||||
int pos=0;
|
||||
double damount=0.0,dcurrAmount=0.0;
|
||||
double themount=0.0,dcurrAmount=0.0;
|
||||
int i;
|
||||
|
||||
data->saved = False;
|
||||
@ -286,8 +286,8 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
sscanf( str, "%d/%d/%d", &(trans->date.month),
|
||||
&(trans->date.day), &(trans->date.year) );
|
||||
str = XmTextGetString(adjBData->balance);
|
||||
sscanf( str, "%d.%2d", &dollar, ¢ );
|
||||
damount = ((double) dollar) + 0.01 * ((double) cent);
|
||||
sscanf( str, "%f", &val ); /* sscanf must take float not double as arg */
|
||||
themount = val;
|
||||
|
||||
/* fill out the rest of the fields */
|
||||
trans->num = XtNewString("");
|
||||
@ -303,9 +303,9 @@ adjBOkCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
for( i=0; i<pos; i++ )
|
||||
{
|
||||
tempTrans = getTransaction(acc,i);
|
||||
dcurrAmount += tempTrans->damount;
|
||||
dcurrAmount += xaccGetAmount (acc, trans);
|
||||
}
|
||||
trans->damount = damount - dcurrAmount;
|
||||
xaccSetAmount (acc, trans, themount - dcurrAmount);
|
||||
|
||||
/* Refresh the account register window */
|
||||
regRefresh(acc->regData);
|
||||
|
11
src/FileIO.c
11
src/FileIO.c
@ -78,7 +78,7 @@ char *readString( int fd, int token );
|
||||
Date *readDate( int fd, int token );
|
||||
|
||||
int writeAccount( int fd, Account *account );
|
||||
int writeTransaction( int fd, Transaction *trans );
|
||||
int writeTransaction( int fd, Account *, Transaction *trans );
|
||||
int writeString( int fd, char *str );
|
||||
int writeDate( int fd, Date *date );
|
||||
|
||||
@ -292,7 +292,7 @@ readTransaction( int fd, int token )
|
||||
{
|
||||
int err=0;
|
||||
Date *date;
|
||||
Transaction *trans = (Transaction *)_malloc(sizeof(Transaction));
|
||||
Transaction *trans = mallocTransaction();
|
||||
int amount;
|
||||
|
||||
trans->num = readString( fd, token );
|
||||
@ -551,7 +551,7 @@ writeAccount( int fd, Account *acc )
|
||||
|
||||
for( i=0; i<numTrans; i++ )
|
||||
{
|
||||
err = writeTransaction( fd, getTransaction(acc,i) );
|
||||
err = writeTransaction( fd, acc, getTransaction(acc,i) );
|
||||
if( err == -1 )
|
||||
return err;
|
||||
}
|
||||
@ -564,11 +564,12 @@ writeAccount( int fd, Account *acc )
|
||||
* saves the data for a transaction to the datafile *
|
||||
* *
|
||||
* Args: fd - the filedescriptor of the data file *
|
||||
* acc - the account that the trans came from *
|
||||
* trans - the transaction data to save *
|
||||
* Return: -1 on failure *
|
||||
\********************************************************************/
|
||||
int
|
||||
writeTransaction( int fd, Transaction *trans )
|
||||
writeTransaction( int fd, Account * acc, Transaction *trans )
|
||||
{
|
||||
int err=0;
|
||||
int tmp;
|
||||
@ -599,7 +600,7 @@ writeTransaction( int fd, Transaction *trans )
|
||||
if( err != sizeof(char) )
|
||||
return -1;
|
||||
|
||||
tmp = (int) (100.0 * (trans->damount)); /* file stores pennies */
|
||||
tmp = (int) (100.0 * xaccGetAmount (acc, trans)); /* file stores pennies */
|
||||
XACC_FLIP_INT (tmp);
|
||||
err = write( fd, &tmp, sizeof(int) );
|
||||
if( err != sizeof(int) )
|
||||
|
@ -96,7 +96,7 @@ refreshMainWindow( void )
|
||||
|
||||
j=0;
|
||||
while( (trans = getTransaction(acc,j++)) != NULL ) {
|
||||
share_balance += trans->damount;
|
||||
share_balance += xaccGetAmount (acc, trans);
|
||||
dbalance = share_balance * trans->share_price;
|
||||
}
|
||||
|
||||
|
199
src/Makefile
199
src/Makefile
@ -28,20 +28,13 @@
|
||||
|
||||
OBJS = main.o util.o date.o MainWindow.o RegWindow.o BuildMenu.o \
|
||||
AccWindow.o FileIO.o Account.o Data.o XferWindow.o FileBox.o \
|
||||
QuickFill.o Reports.o RecnWindow.o HelpWindow.o AdjBWindow.o QIFIO.o
|
||||
|
||||
HOBJS = hack.o util.o date.o MainWindow.o RegWindow.o BuildMenu.o \
|
||||
FileIO.o Account.o Data.o XferWindow.o FileBox.o \
|
||||
QuickFill.o Reports.o RecnWindow.o HelpWindow.o AdjBWindow.o
|
||||
QuickFill.o Reports.o RecnWindow.o HelpWindow.o AdjBWindow.o \
|
||||
QIFIO.o Transaction.o
|
||||
|
||||
SRCS = ${OBJS:.o=.c}
|
||||
|
||||
TARGET = ../xacc
|
||||
|
||||
# hack: $(HOBJS)
|
||||
# @echo "++++++"
|
||||
# $(CC) $(HOBJS) $(LFLAGS) $(LIBS) ../libhtmlw/libhtmlw.a -o $@
|
||||
|
||||
default: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS) ../libhtmlw/libhtmlw.a
|
||||
@ -90,12 +83,12 @@ main.o: /usr/X11/include/Xm/Manager.h /usr/X11/include/Xm/Gadget.h
|
||||
main.o: /usr/X11/include/Xm/TxtPropCv.h /usr/X11/include/Xm/VendorS.h
|
||||
main.o: /usr/X11/include/Xm/XmIm.h ../include/BuildMenu.h
|
||||
main.o: /usr/X11/include/Xm/PushB.h /usr/X11/include/Xm/Separator.h
|
||||
main.o: ../include/RegWindow.h ../include/Account.h ../include/main.h
|
||||
main.o: ../include/date.h ../include/QuickFill.h ../include/FileIO.h
|
||||
main.o: ../include/RegWindow.h ../include/Account.h ../include/QuickFill.h
|
||||
main.o: ../include/Transaction.h ../include/date.h ../include/FileIO.h
|
||||
main.o: ../include/Data.h ../include/FileBox.h ../include/util.h
|
||||
main.o: /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h
|
||||
main.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
main.o: /usr/include/asm/errno.h
|
||||
main.o: /usr/include/asm/errno.h ../include/main.h
|
||||
util.o: /usr/X11/include/X11/X11/X11/X.h /usr/X11/include/X11/X11/Xlib.h
|
||||
util.o: /usr/include/sys/types.h /usr/include/linux/types.h
|
||||
util.o: /usr/include/linux/posix_types.h /usr/include/asm/posix_types.h
|
||||
@ -126,8 +119,10 @@ util.o: /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h
|
||||
util.o: /usr/X11/include/Xm/PanedW.h /usr/X11/include/Xm/Form.h
|
||||
util.o: /usr/X11/include/Xm/BulletinB.h /usr/X11/include/Xm/PushB.h
|
||||
util.o: /usr/X11/include/Xm/DialogS.h /usr/X11/include/Xm/RowColumn.h
|
||||
util.o: /usr/X11/include/Xm/MessageB.h ../include/util.h /usr/include/errno.h
|
||||
util.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
util.o: /usr/X11/include/Xm/MessageB.h /usr/X11/include/Xbae/Matrix.h
|
||||
util.o: /usr/X11/include/Xbae/patchlevel.h ../include/util.h
|
||||
util.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
util.o: /usr/include/asm/errno.h
|
||||
date.o: /usr/include/time.h /usr/include/features.h /usr/include/sys/cdefs.h
|
||||
date.o: /usr/include/sys/time.h /usr/include/linux/types.h
|
||||
date.o: /usr/include/linux/posix_types.h /usr/include/asm/posix_types.h
|
||||
@ -200,16 +195,17 @@ MainWindow.o: /usr/X11/include/X11/X11/RectObjP.h
|
||||
MainWindow.o: /usr/X11/include/Xm/ColorP.h /usr/X11/include/Xm/AccColorT.h
|
||||
MainWindow.o: /usr/X11/include/Xm/BaseClassP.h
|
||||
MainWindow.o: /usr/X11/include/Xm/ExtObjectP.h /usr/X11/include/Xm/List.h
|
||||
MainWindow.o: /usr/X11/include/Xm/RowColumn.h ../include/main.h
|
||||
MainWindow.o: ../include/date.h ../include/util.h /usr/include/stdio.h
|
||||
MainWindow.o: /usr/include/libio.h /usr/include/_G_config.h
|
||||
MainWindow.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
MainWindow.o: /usr/include/asm/errno.h ../include/Data.h ../include/Account.h
|
||||
MainWindow.o: ../include/QuickFill.h ../include/FileIO.h ../include/FileBox.h
|
||||
MainWindow.o: ../include/BuildMenu.h /usr/X11/include/Xm/PushB.h
|
||||
MainWindow.o: /usr/X11/include/Xm/Separator.h ../include/MainWindow.h
|
||||
MainWindow.o: ../include/RegWindow.h ../include/XferWindow.h
|
||||
MainWindow.o: ../include/HelpWindow.h
|
||||
MainWindow.o: /usr/X11/include/Xm/RowColumn.h /usr/X11/include/Xbae/Matrix.h
|
||||
MainWindow.o: /usr/X11/include/Xbae/patchlevel.h ../include/main.h
|
||||
MainWindow.o: ../include/date.h ../include/Transaction.h ../include/util.h
|
||||
MainWindow.o: /usr/include/stdio.h /usr/include/libio.h
|
||||
MainWindow.o: /usr/include/_G_config.h /usr/include/errno.h
|
||||
MainWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
MainWindow.o: ../include/Data.h ../include/Account.h ../include/QuickFill.h
|
||||
MainWindow.o: ../include/FileIO.h ../include/FileBox.h ../include/BuildMenu.h
|
||||
MainWindow.o: /usr/X11/include/Xm/PushB.h /usr/X11/include/Xm/Separator.h
|
||||
MainWindow.o: ../include/MainWindow.h ../include/RegWindow.h
|
||||
MainWindow.o: ../include/XferWindow.h ../include/HelpWindow.h
|
||||
RegWindow.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
RegWindow.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
RegWindow.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
@ -251,13 +247,14 @@ RegWindow.o: /usr/X11/include/X11/X11/ConstrainP.h
|
||||
RegWindow.o: /usr/X11/include/X11/X11/ObjectP.h
|
||||
RegWindow.o: /usr/X11/include/X11/X11/RectObjP.h /usr/X11/include/Xm/ColorP.h
|
||||
RegWindow.o: /usr/X11/include/Xm/AccColorT.h /usr/X11/include/Xm/BaseClassP.h
|
||||
RegWindow.o: /usr/X11/include/Xm/ExtObjectP.h ../include/main.h
|
||||
RegWindow.o: ../include/date.h ../include/util.h /usr/include/errno.h
|
||||
RegWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
RegWindow.o: ../include/Data.h ../include/Account.h ../include/QuickFill.h
|
||||
RegWindow.o: ../include/MainWindow.h ../include/BuildMenu.h
|
||||
RegWindow.o: /usr/X11/include/Xm/Separator.h ../include/RecnWindow.h
|
||||
RegWindow.o: ../include/AdjBWindow.h
|
||||
RegWindow.o: /usr/X11/include/Xm/ExtObjectP.h /usr/X11/include/Xbae/Matrix.h
|
||||
RegWindow.o: /usr/X11/include/Xbae/patchlevel.h ../include/main.h
|
||||
RegWindow.o: ../include/date.h ../include/Transaction.h ../include/util.h
|
||||
RegWindow.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
RegWindow.o: /usr/include/asm/errno.h ../include/Data.h ../include/Account.h
|
||||
RegWindow.o: ../include/QuickFill.h ../include/MainWindow.h
|
||||
RegWindow.o: ../include/BuildMenu.h /usr/X11/include/Xm/Separator.h
|
||||
RegWindow.o: ../include/RecnWindow.h ../include/AdjBWindow.h
|
||||
BuildMenu.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
BuildMenu.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
BuildMenu.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
@ -340,8 +337,9 @@ AccWindow.o: /usr/X11/include/Xm/AccColorT.h /usr/X11/include/Xm/BaseClassP.h
|
||||
AccWindow.o: /usr/X11/include/Xm/ExtObjectP.h /usr/X11/include/Xm/ToggleB.h
|
||||
AccWindow.o: /usr/X11/include/Xm/PushB.h /usr/X11/include/Xm/Text.h
|
||||
AccWindow.o: /usr/include/stdio.h /usr/include/libio.h
|
||||
AccWindow.o: /usr/include/_G_config.h ../include/Account.h ../include/main.h
|
||||
AccWindow.o: ../include/date.h ../include/QuickFill.h ../include/Data.h
|
||||
AccWindow.o: /usr/include/_G_config.h ../include/Account.h
|
||||
AccWindow.o: ../include/QuickFill.h ../include/Transaction.h
|
||||
AccWindow.o: ../include/date.h ../include/Data.h ../include/main.h
|
||||
AccWindow.o: ../include/util.h /usr/include/errno.h
|
||||
AccWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
FileIO.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
@ -373,11 +371,11 @@ FileIO.o: /usr/X11/include/Xm/Gadget.h /usr/X11/include/Xm/TxtPropCv.h
|
||||
FileIO.o: /usr/X11/include/Xm/VendorS.h /usr/X11/include/Xm/XmIm.h
|
||||
FileIO.o: /usr/include/fcntl.h /usr/include/gnu/types.h
|
||||
FileIO.o: /usr/include/linux/fcntl.h /usr/include/asm/fcntl.h
|
||||
FileIO.o: ../include/main.h ../include/date.h ../include/util.h
|
||||
FileIO.o: /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h
|
||||
FileIO.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
FileIO.o: /usr/include/asm/errno.h ../include/Account.h
|
||||
FileIO.o: ../include/QuickFill.h ../include/Data.h
|
||||
FileIO.o: ../include/main.h ../include/date.h ../include/Transaction.h
|
||||
FileIO.o: ../include/util.h /usr/include/stdio.h /usr/include/libio.h
|
||||
FileIO.o: /usr/include/_G_config.h /usr/include/errno.h
|
||||
FileIO.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
FileIO.o: ../include/Account.h ../include/QuickFill.h ../include/Data.h
|
||||
Account.o: ../include/util.h /usr/X11/include/Xm/Xm.h
|
||||
Account.o: /usr/X11/include/X11/Intrinsic.h /usr/X11/include/X11/X11/Xlib.h
|
||||
Account.o: /usr/include/sys/types.h /usr/include/linux/types.h
|
||||
@ -409,13 +407,15 @@ Account.o: /usr/X11/include/Xm/VendorS.h /usr/X11/include/Xm/XmIm.h
|
||||
Account.o: /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h
|
||||
Account.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
Account.o: /usr/include/asm/errno.h ../include/main.h ../include/date.h
|
||||
Account.o: ../include/Data.h ../include/Account.h ../include/QuickFill.h
|
||||
Data.o: ../include/Data.h ../include/Account.h ../include/main.h
|
||||
Data.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
Data.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
Data.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
Data.o: /usr/include/asm/posix_types.h /usr/include/asm/types.h
|
||||
Data.o: /usr/include/sys/bitypes.h /usr/X11/include/X11/X11/X11/X.h
|
||||
Account.o: ../include/Transaction.h ../include/Data.h ../include/Account.h
|
||||
Account.o: ../include/QuickFill.h
|
||||
Data.o: ../include/Data.h ../include/Account.h ../include/QuickFill.h
|
||||
Data.o: ../include/Transaction.h /usr/X11/include/Xm/Xm.h
|
||||
Data.o: /usr/X11/include/X11/Intrinsic.h /usr/X11/include/X11/X11/Xlib.h
|
||||
Data.o: /usr/include/sys/types.h /usr/include/linux/types.h
|
||||
Data.o: /usr/include/linux/posix_types.h /usr/include/asm/posix_types.h
|
||||
Data.o: /usr/include/asm/types.h /usr/include/sys/bitypes.h
|
||||
Data.o: /usr/X11/include/X11/X11/X11/X.h
|
||||
Data.o: /usr/X11/include/X11/X11/X11/Xfuncproto.h
|
||||
Data.o: /usr/X11/include/X11/X11/X11/Xosdefs.h
|
||||
Data.o: /usr/lib/gcc-lib/i486-linux/2.7.2/include/stddef.h
|
||||
@ -436,10 +436,10 @@ Data.o: /usr/X11/include/Xm/DragIcon.h /usr/X11/include/Xm/DropTrans.h
|
||||
Data.o: /usr/X11/include/Xm/DragOverS.h /usr/X11/include/Xm/Primitive.h
|
||||
Data.o: /usr/X11/include/Xm/Manager.h /usr/X11/include/Xm/Gadget.h
|
||||
Data.o: /usr/X11/include/Xm/TxtPropCv.h /usr/X11/include/Xm/VendorS.h
|
||||
Data.o: /usr/X11/include/Xm/XmIm.h ../include/date.h ../include/QuickFill.h
|
||||
Data.o: ../include/util.h /usr/include/stdio.h /usr/include/libio.h
|
||||
Data.o: /usr/include/_G_config.h /usr/include/errno.h
|
||||
Data.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
Data.o: /usr/X11/include/Xm/XmIm.h ../include/date.h ../include/util.h
|
||||
Data.o: /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h
|
||||
Data.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
Data.o: /usr/include/asm/errno.h
|
||||
XferWindow.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
XferWindow.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
XferWindow.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
@ -484,10 +484,10 @@ XferWindow.o: /usr/X11/include/Xm/ExtObjectP.h /usr/X11/include/Xm/PushB.h
|
||||
XferWindow.o: /usr/X11/include/Xm/Text.h /usr/include/stdio.h
|
||||
XferWindow.o: /usr/include/libio.h /usr/include/_G_config.h
|
||||
XferWindow.o: ../include/BuildMenu.h /usr/X11/include/Xm/Separator.h
|
||||
XferWindow.o: ../include/Account.h ../include/main.h ../include/date.h
|
||||
XferWindow.o: ../include/QuickFill.h ../include/Data.h ../include/util.h
|
||||
XferWindow.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
XferWindow.o: /usr/include/asm/errno.h
|
||||
XferWindow.o: ../include/Account.h ../include/QuickFill.h
|
||||
XferWindow.o: ../include/Transaction.h ../include/date.h ../include/Data.h
|
||||
XferWindow.o: ../include/main.h ../include/util.h /usr/include/errno.h
|
||||
XferWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
FileBox.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
FileBox.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
FileBox.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
@ -551,8 +551,8 @@ QuickFill.o: /usr/X11/include/Xm/VendorS.h /usr/X11/include/Xm/XmIm.h
|
||||
QuickFill.o: /usr/include/stdio.h /usr/include/libio.h
|
||||
QuickFill.o: /usr/include/_G_config.h /usr/include/errno.h
|
||||
QuickFill.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
QuickFill.o: ../include/main.h ../include/date.h ../include/Account.h
|
||||
QuickFill.o: ../include/QuickFill.h
|
||||
QuickFill.o: ../include/main.h ../include/date.h ../include/Transaction.h
|
||||
QuickFill.o: ../include/Account.h ../include/QuickFill.h
|
||||
Reports.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
Reports.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
Reports.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
@ -640,10 +640,12 @@ RecnWindow.o: /usr/X11/include/X11/X11/ObjectP.h
|
||||
RecnWindow.o: /usr/X11/include/X11/X11/RectObjP.h
|
||||
RecnWindow.o: /usr/X11/include/Xm/ColorP.h /usr/X11/include/Xm/AccColorT.h
|
||||
RecnWindow.o: /usr/X11/include/Xm/BaseClassP.h
|
||||
RecnWindow.o: /usr/X11/include/Xm/ExtObjectP.h ../include/Data.h
|
||||
RecnWindow.o: ../include/Account.h ../include/main.h ../include/date.h
|
||||
RecnWindow.o: ../include/QuickFill.h ../include/RegWindow.h
|
||||
RecnWindow.o: ../include/MainWindow.h ../include/util.h /usr/include/errno.h
|
||||
RecnWindow.o: /usr/X11/include/Xm/ExtObjectP.h /usr/X11/include/Xbae/Matrix.h
|
||||
RecnWindow.o: /usr/X11/include/Xbae/patchlevel.h ../include/Data.h
|
||||
RecnWindow.o: ../include/Account.h ../include/QuickFill.h
|
||||
RecnWindow.o: ../include/Transaction.h ../include/date.h
|
||||
RecnWindow.o: ../include/RegWindow.h ../include/MainWindow.h
|
||||
RecnWindow.o: ../include/main.h ../include/util.h /usr/include/errno.h
|
||||
RecnWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
HelpWindow.o: /usr/include/sys/types.h /usr/include/linux/types.h
|
||||
HelpWindow.o: /usr/include/linux/posix_types.h /usr/include/asm/posix_types.h
|
||||
@ -683,8 +685,8 @@ HelpWindow.o: /usr/X11/include/Xm/XmIm.h /usr/X11/include/Xm/DialogS.h
|
||||
HelpWindow.o: /usr/X11/include/Xm/PanedW.h /usr/X11/include/Xm/Frame.h
|
||||
HelpWindow.o: /usr/X11/include/Xm/Form.h /usr/X11/include/Xm/BulletinB.h
|
||||
HelpWindow.o: /usr/X11/include/Xm/PushB.h /usr/X11/include/X11/xpm.h
|
||||
HelpWindow.o: ../include/main.h ../include/date.h ../include/util.h
|
||||
HelpWindow.o: /usr/include/stdio.h /usr/include/libio.h
|
||||
HelpWindow.o: ../include/main.h ../include/date.h ../include/Transaction.h
|
||||
HelpWindow.o: ../include/util.h /usr/include/stdio.h /usr/include/libio.h
|
||||
HelpWindow.o: /usr/include/_G_config.h /usr/include/errno.h
|
||||
HelpWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
HelpWindow.o: ../libhtmlw/HTML.h
|
||||
@ -732,7 +734,74 @@ AdjBWindow.o: /usr/X11/include/X11/X11/RectObjP.h
|
||||
AdjBWindow.o: /usr/X11/include/Xm/ColorP.h /usr/X11/include/Xm/AccColorT.h
|
||||
AdjBWindow.o: /usr/X11/include/Xm/BaseClassP.h
|
||||
AdjBWindow.o: /usr/X11/include/Xm/ExtObjectP.h ../include/main.h
|
||||
AdjBWindow.o: ../include/date.h ../include/util.h /usr/include/errno.h
|
||||
AdjBWindow.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
AdjBWindow.o: ../include/Data.h ../include/Account.h ../include/QuickFill.h
|
||||
AdjBWindow.o: ../include/MainWindow.h
|
||||
AdjBWindow.o: ../include/date.h ../include/Transaction.h ../include/util.h
|
||||
AdjBWindow.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
AdjBWindow.o: /usr/include/asm/errno.h ../include/Data.h ../include/Account.h
|
||||
AdjBWindow.o: ../include/QuickFill.h ../include/MainWindow.h
|
||||
QIFIO.o: /usr/X11/include/Xm/Xm.h /usr/X11/include/X11/Intrinsic.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
QIFIO.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
QIFIO.o: /usr/include/asm/posix_types.h /usr/include/asm/types.h
|
||||
QIFIO.o: /usr/include/sys/bitypes.h /usr/X11/include/X11/X11/X11/X.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/X11/Xfuncproto.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/X11/Xosdefs.h
|
||||
QIFIO.o: /usr/lib/gcc-lib/i486-linux/2.7.2/include/stddef.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/Xutil.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/Xresource.h /usr/include/string.h
|
||||
QIFIO.o: /usr/include/features.h /usr/include/sys/cdefs.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/Core.h /usr/X11/include/X11/X11/Composite.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/Constraint.h
|
||||
QIFIO.o: /usr/X11/include/X11/X11/Object.h /usr/X11/include/X11/X11/RectObj.h
|
||||
QIFIO.o: /usr/X11/include/X11/Shell.h /usr/X11/include/X11/X11/SM/SMlib.h
|
||||
QIFIO.o: /usr/X11/include/X11/SM/SM.h /usr/X11/include/X11/ICE/ICElib.h
|
||||
QIFIO.o: /usr/X11/include/X11/ICE/ICE.h /usr/X11/include/X11/Xatom.h
|
||||
QIFIO.o: /usr/X11/include/Xm/XmStrDefs.h /usr/X11/include/X11/StringDefs.h
|
||||
QIFIO.o: /usr/X11/include/Xm/VirtKeys.h /usr/X11/include/Xm/Transfer.h
|
||||
QIFIO.o: /usr/X11/include/Xm/DragDrop.h /usr/X11/include/Xm/DragC.h
|
||||
QIFIO.o: /usr/X11/include/Xm/Display.h /usr/X11/include/Xm/DropSMgr.h
|
||||
QIFIO.o: /usr/X11/include/Xm/DragIcon.h /usr/X11/include/Xm/DropTrans.h
|
||||
QIFIO.o: /usr/X11/include/Xm/DragOverS.h /usr/X11/include/Xm/Primitive.h
|
||||
QIFIO.o: /usr/X11/include/Xm/Manager.h /usr/X11/include/Xm/Gadget.h
|
||||
QIFIO.o: /usr/X11/include/Xm/TxtPropCv.h /usr/X11/include/Xm/VendorS.h
|
||||
QIFIO.o: /usr/X11/include/Xm/XmIm.h /usr/include/fcntl.h
|
||||
QIFIO.o: /usr/include/gnu/types.h /usr/include/linux/fcntl.h
|
||||
QIFIO.o: /usr/include/asm/fcntl.h ../include/main.h ../include/date.h
|
||||
QIFIO.o: ../include/Transaction.h ../include/util.h /usr/include/stdio.h
|
||||
QIFIO.o: /usr/include/libio.h /usr/include/_G_config.h /usr/include/errno.h
|
||||
QIFIO.o: /usr/include/linux/errno.h /usr/include/asm/errno.h
|
||||
QIFIO.o: ../include/Account.h ../include/QuickFill.h ../include/Data.h
|
||||
Transaction.o: ../include/Transaction.h /usr/X11/include/Xm/Xm.h
|
||||
Transaction.o: /usr/X11/include/X11/Intrinsic.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Xlib.h /usr/include/sys/types.h
|
||||
Transaction.o: /usr/include/linux/types.h /usr/include/linux/posix_types.h
|
||||
Transaction.o: /usr/include/asm/posix_types.h /usr/include/asm/types.h
|
||||
Transaction.o: /usr/include/sys/bitypes.h /usr/X11/include/X11/X11/X11/X.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/X11/Xfuncproto.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/X11/Xosdefs.h
|
||||
Transaction.o: /usr/lib/gcc-lib/i486-linux/2.7.2/include/stddef.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Xutil.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Xresource.h /usr/include/string.h
|
||||
Transaction.o: /usr/include/features.h /usr/include/sys/cdefs.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Core.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Composite.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Constraint.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/Object.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/RectObj.h
|
||||
Transaction.o: /usr/X11/include/X11/Shell.h
|
||||
Transaction.o: /usr/X11/include/X11/X11/SM/SMlib.h
|
||||
Transaction.o: /usr/X11/include/X11/SM/SM.h /usr/X11/include/X11/ICE/ICElib.h
|
||||
Transaction.o: /usr/X11/include/X11/ICE/ICE.h /usr/X11/include/X11/Xatom.h
|
||||
Transaction.o: /usr/X11/include/Xm/XmStrDefs.h
|
||||
Transaction.o: /usr/X11/include/X11/StringDefs.h
|
||||
Transaction.o: /usr/X11/include/Xm/VirtKeys.h /usr/X11/include/Xm/Transfer.h
|
||||
Transaction.o: /usr/X11/include/Xm/DragDrop.h /usr/X11/include/Xm/DragC.h
|
||||
Transaction.o: /usr/X11/include/Xm/Display.h /usr/X11/include/Xm/DropSMgr.h
|
||||
Transaction.o: /usr/X11/include/Xm/DragIcon.h /usr/X11/include/Xm/DropTrans.h
|
||||
Transaction.o: /usr/X11/include/Xm/DragOverS.h
|
||||
Transaction.o: /usr/X11/include/Xm/Primitive.h /usr/X11/include/Xm/Manager.h
|
||||
Transaction.o: /usr/X11/include/Xm/Gadget.h /usr/X11/include/Xm/TxtPropCv.h
|
||||
Transaction.o: /usr/X11/include/Xm/VendorS.h /usr/X11/include/Xm/XmIm.h
|
||||
Transaction.o: ../include/date.h ../include/util.h /usr/include/stdio.h
|
||||
Transaction.o: /usr/include/libio.h /usr/include/_G_config.h
|
||||
Transaction.o: /usr/include/errno.h /usr/include/linux/errno.h
|
||||
Transaction.o: /usr/include/asm/errno.h
|
||||
|
@ -81,6 +81,7 @@ recnRefresh( RecnWindow *recnData )
|
||||
int i,nrows;
|
||||
char buf[BUFSIZE];
|
||||
Transaction *trans;
|
||||
Account *acc = recnData->acc;
|
||||
|
||||
/* NOTE: an improvement of the current design would be to use the
|
||||
* user-data in the rows to detect where transactions need
|
||||
@ -97,12 +98,13 @@ recnRefresh( RecnWindow *recnData )
|
||||
|
||||
/* Add the non-reconciled transactions */
|
||||
i=0;
|
||||
while( (trans=getTransaction(recnData->acc,i++)) != NULL )
|
||||
while( (trans=getTransaction(acc,i++)) != NULL )
|
||||
{
|
||||
String rows[5];
|
||||
|
||||
if( trans->reconciled != YREC )
|
||||
{
|
||||
double themount = xaccGetAmount (acc, trans);
|
||||
sprintf( buf, "%c", trans->reconciled );
|
||||
rows[0] = XtNewString(buf);
|
||||
rows[1] = trans->num;
|
||||
@ -112,10 +114,10 @@ recnRefresh( RecnWindow *recnData )
|
||||
(trans->date.year%100) );
|
||||
rows[2] = XtNewString(buf);
|
||||
rows[3] = trans->description;
|
||||
sprintf( buf, "%.2f\0", DABS(trans->damount) );
|
||||
sprintf( buf, "%.2f\0", DABS(themount) );
|
||||
rows[4] = XtNewString(buf);
|
||||
|
||||
if( 0.0 > trans->damount)
|
||||
if( 0.0 > themount)
|
||||
{
|
||||
XtVaGetValues( recnData->debit, XmNrows, &nrows, NULL );
|
||||
XbaeMatrixAddRows( recnData->debit, nrows, rows, NULL, NULL, 1 );
|
||||
@ -146,6 +148,7 @@ void
|
||||
recnRecalculateBalance( RecnWindow *recnData )
|
||||
{
|
||||
Transaction *trans;
|
||||
Account *acc = recnData ->acc;
|
||||
char buf[BUFSIZE];
|
||||
int i,nrows;
|
||||
double ddebit = 0.0;
|
||||
@ -160,7 +163,7 @@ recnRecalculateBalance( RecnWindow *recnData )
|
||||
if( recn[0] == YREC )
|
||||
{
|
||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->debit, i );
|
||||
ddebit += trans->damount;
|
||||
ddebit += xaccGetAmount (acc, trans);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +175,7 @@ recnRecalculateBalance( RecnWindow *recnData )
|
||||
if( recn[0] == YREC )
|
||||
{
|
||||
trans = (Transaction *)XbaeMatrixGetRowUserData( recnData->credit, i );
|
||||
dcredit += trans->damount;
|
||||
dcredit += xaccGetAmount (acc, trans);
|
||||
}
|
||||
}
|
||||
|
||||
@ -236,7 +239,7 @@ startRecnWindow( Widget parent, Account *acc, double *diff )
|
||||
j=0;
|
||||
while( (trans = getTransaction(acc,j++)) != NULL )
|
||||
if( trans->reconciled == YREC )
|
||||
dendBalance += trans->damount;
|
||||
dendBalance += xaccGetAmount (acc, trans);
|
||||
|
||||
/* Create the dialog box... XmNdeleteResponse is set to
|
||||
* XmDESTROY so the dialog's memory is freed when it is closed */
|
||||
@ -387,10 +390,10 @@ startRecnWindow( Widget parent, Account *acc, double *diff )
|
||||
/* Get the amount from the "end-balance" field */
|
||||
{
|
||||
String str;
|
||||
int dollar=0,cent=0;
|
||||
float val=0.0;
|
||||
str = XmTextGetString(newB);
|
||||
sscanf( str, "%d.%2d", &dollar, ¢ );
|
||||
*diff = dendBalance - (((double) dollar) + 0.01 * ((double) cent));
|
||||
sscanf( str, "%f", &val ); /* sscanf must take float not double as arg */
|
||||
*diff = dendBalance - ((double) val);
|
||||
}
|
||||
|
||||
XtDestroyWidget(dialog);
|
||||
|
214
src/RegWindow.c
214
src/RegWindow.c
@ -43,6 +43,7 @@
|
||||
#include "BuildMenu.h"
|
||||
#include "RecnWindow.h"
|
||||
#include "AdjBWindow.h"
|
||||
#include "Transaction.h"
|
||||
|
||||
/** STRUCTS *********************************************************/
|
||||
/* The RegWindow struct contains info needed by an instance of an open
|
||||
@ -101,46 +102,56 @@ extern Pixel negPixel;
|
||||
#define MOD_SHRS 0x20
|
||||
#define MOD_PRIC 0x40
|
||||
#define MOD_MEMO 0x80
|
||||
#define MOD_NEW 0x100
|
||||
#define MOD_ALL 0x1ff
|
||||
#define MOD_ACTN 0x100
|
||||
#define MOD_NEW 0x200
|
||||
#define MOD_ALL 0x3ff
|
||||
|
||||
/* ??? TODO: Use these #defines, instead of hard-coding cell
|
||||
* locations throughout the code */
|
||||
/* These defines are indexes into the column location array */
|
||||
#define DATE_COL_ID 0
|
||||
#define NUM_COL_ID 1
|
||||
#define DESC_COL_ID 2
|
||||
#define RECN_COL_ID 3
|
||||
#define PAY_COL_ID 4
|
||||
#define DEP_COL_ID 5
|
||||
#define PRIC_COL_ID 6
|
||||
#define SHRS_COL_ID 7
|
||||
#define BALN_COL_ID 8
|
||||
#define ACTN_COL_ID 9
|
||||
|
||||
/* the actual column location is pulled out of the column location array */
|
||||
#define DATE_CELL_R 0
|
||||
#define DATE_CELL_C 0
|
||||
#define DATE_CELL_C (acc->columnLocation[DATE_COL_ID])
|
||||
#define NUM_CELL_R 0
|
||||
#define NUM_CELL_C 1
|
||||
#define NUM_CELL_C (acc->columnLocation[NUM_COL_ID])
|
||||
#define DESC_CELL_R 0
|
||||
#define DESC_CELL_C 2
|
||||
#define DESC_CELL_C (acc->columnLocation[DESC_COL_ID])
|
||||
#define RECN_CELL_R 0
|
||||
#define RECN_CELL_C 3
|
||||
#define RECN_CELL_C (acc->columnLocation[RECN_COL_ID])
|
||||
#define PAY_CELL_R 0
|
||||
#define PAY_CELL_C 4
|
||||
#define PAY_CELL_C (acc->columnLocation[PAY_COL_ID])
|
||||
#define DEP_CELL_R 0
|
||||
#define DEP_CELL_C 5
|
||||
|
||||
#define PRIC_CELL_C 6
|
||||
#define SHRS_CELL_C 7
|
||||
|
||||
#define DEP_CELL_C (acc->columnLocation[DEP_COL_ID])
|
||||
#define BALN_CELL_R 0
|
||||
/* #define BALN_CELL_C 6 */
|
||||
#define BALN_CELL_C ((acc->numCols) -1) /* the last column */
|
||||
#define BALN_CELL_C (acc->columnLocation[BALN_COL_ID])
|
||||
|
||||
#define PRIC_CELL_C (acc->columnLocation[PRIC_COL_ID])
|
||||
#define SHRS_CELL_C (acc->columnLocation[SHRS_COL_ID])
|
||||
#define ACTN_CELL_C (acc->columnLocation[ACTN_COL_ID])
|
||||
|
||||
/* these columns/rows are still hard coded ... should be switched over, I guess */
|
||||
#define MEMO_CELL_R 1
|
||||
#define MEMO_CELL_C 2
|
||||
|
||||
/** COOL MACROS *****************************************************/
|
||||
#define IN_DATE_CELL(R,C) (((R-1)%2==0) && (C==0)) /* Date cell */
|
||||
#define IN_NUM_CELL(R,C) (((R-1)%2==0) && (C==1)) /* Number cell */
|
||||
#define IN_DESC_CELL(R,C) (((R-1)%2==0) && (C==2)) /* Description cell */
|
||||
#define IN_RECN_CELL(R,C) (((R-1)%2==0) && (C==3)) /* Reconciled cell */
|
||||
#define IN_PAY_CELL(R,C) (((R-1)%2==0) && (C==4)) /* Payment cell */
|
||||
#define IN_DEP_CELL(R,C) (((R-1)%2==0) && (C==5)) /* Deposit cell */
|
||||
/* #define IN_BALN_CELL(R,C) (((R-1)%2==0) && (C==6)) /* Balance cell */
|
||||
#define IN_DATE_CELL(R,C) (((R-1)%2==0) && (C==DATE_CELL_C)) /* Date cell */
|
||||
#define IN_NUM_CELL(R,C) (((R-1)%2==0) && (C==NUM_CELL_C)) /* Number cell */
|
||||
#define IN_DESC_CELL(R,C) (((R-1)%2==0) && (C==DESC_CELL_C)) /* Description cell */
|
||||
#define IN_RECN_CELL(R,C) (((R-1)%2==0) && (C==RECN_CELL_C)) /* Reconciled cell */
|
||||
#define IN_PAY_CELL(R,C) (((R-1)%2==0) && (C==PAY_CELL_C)) /* Payment cell */
|
||||
#define IN_DEP_CELL(R,C) (((R-1)%2==0) && (C==DEP_CELL_C)) /* Deposit cell */
|
||||
#define IN_BALN_CELL(R,C) (((R-1)%2==0) && (C==BALN_CELL_C)) /* Balance cell */
|
||||
#define IN_PRIC_CELL(R,C) (((R-1)%2==0) && (C==PRIC_CELL_C)) /* Balance cell */
|
||||
#define IN_YEAR_CELL(R,C) (((R-1)%2==1) && (C==0)) /* Year cell */
|
||||
#define IN_PRIC_CELL(R,C) (((R-1)%2==0) && (C==PRIC_CELL_C)) /* Price cell */
|
||||
#define IN_YEAR_CELL(R,C) (((R-1)%2==1) && (C==DATE_CELL_C)) /* Year cell */
|
||||
#define IN_MEMO_CELL(R,C) (((R-1)%2==1) && (C==2)) /* Memo cell */
|
||||
#define IN_BAD_CELL(R,C) (((R-1)%2==1) && (C==3)) /* cell after memo */
|
||||
|
||||
@ -167,6 +178,7 @@ regRefresh( RegWindow *regData )
|
||||
String **data = NULL;
|
||||
String **newData;
|
||||
Account *acc;
|
||||
double themount; /* amount */
|
||||
|
||||
XtVaGetValues( regData->reg, XmNrows, &nrows, NULL );
|
||||
XtVaGetValues( regData->reg, XmNcells, &data, NULL );
|
||||
@ -226,15 +238,18 @@ regRefresh( RegWindow *regData )
|
||||
|
||||
newData[row+1][RECN_CELL_C] = XtNewString("");
|
||||
|
||||
if( 0.0 > trans->damount )
|
||||
themount = xaccGetAmount (acc, trans);
|
||||
|
||||
/* hack alert -- share amounts should have three digits */
|
||||
if( 0.0 > themount )
|
||||
{
|
||||
sprintf( buf, "%.2f ", (-1.0*(trans->damount)) );
|
||||
sprintf( buf, "%.2f ", -themount );
|
||||
newData[row][PAY_CELL_C] = XtNewString(buf);
|
||||
newData[row][DEP_CELL_C] = XtNewString("");
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buf, "%.2f ", (trans->damount) );
|
||||
sprintf( buf, "%.2f ", themount );
|
||||
newData[row][PAY_CELL_C] = XtNewString("");
|
||||
newData[row][DEP_CELL_C] = XtNewString(buf);
|
||||
}
|
||||
@ -340,11 +355,11 @@ regRecalculateBalance( RegWindow *regData )
|
||||
|
||||
for( i=0; (trans=getTransaction(regData->acc,i)) != NULL; i++ )
|
||||
{
|
||||
share_balance += trans->damount;
|
||||
share_balance += xaccGetAmount (acc, trans);
|
||||
dbalance = trans -> share_price * share_balance;
|
||||
|
||||
if( trans->reconciled != NREC ) {
|
||||
share_clearedBalance += trans->damount;
|
||||
share_clearedBalance += xaccGetAmount (acc, trans);
|
||||
dclearedBalance = trans->share_price * share_clearedBalance;
|
||||
}
|
||||
|
||||
@ -381,11 +396,11 @@ regRecalculateBalance( RegWindow *regData )
|
||||
XbaeMatrixSetCellColor( reg, position, SHRS_CELL_C, negPixel );
|
||||
else
|
||||
XbaeMatrixSetCellColor( reg, position, SHRS_CELL_C, posPixel );
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Put the value in the cell */
|
||||
XbaeMatrixSetCell( reg, position, SHRS_CELL_C, buf );
|
||||
/* Put the value in the cell */
|
||||
XbaeMatrixSetCell( reg, position, SHRS_CELL_C, buf );
|
||||
}
|
||||
|
||||
position+=2; /* each transaction has two rows */
|
||||
}
|
||||
@ -427,13 +442,15 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
char buf[BUFSIZE];
|
||||
int newPosition;
|
||||
int row = (position * 2) + 1;
|
||||
|
||||
Account *acc;
|
||||
Transaction *trans;
|
||||
trans = getTransaction( regData->acc, position );
|
||||
|
||||
acc = regData->acc;
|
||||
trans = getTransaction( acc, position );
|
||||
|
||||
/* If anything changes, we have to set this flag, so we
|
||||
* remember to prompt the user to save! */
|
||||
if( regData->changed != MOD_NONE )
|
||||
if( MOD_NONE != regData->changed )
|
||||
data->saved = False;
|
||||
|
||||
if( trans == NULL )
|
||||
@ -445,17 +462,8 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
if( !(regData->changed & MOD_ALL) )
|
||||
return;
|
||||
|
||||
trans = (Transaction *)_malloc(sizeof(Transaction));
|
||||
|
||||
/* fill in some sane defaults */
|
||||
trans->num = NULL;
|
||||
trans->description = NULL;
|
||||
trans->memo = NULL;
|
||||
trans->catagory = 0;
|
||||
trans->reconciled = NREC;
|
||||
trans->damount = 0.0;
|
||||
trans->share_price = 1.0;
|
||||
|
||||
trans = mallocTransaction();
|
||||
trans->credit = (struct _account *) acc;
|
||||
regData->changed = MOD_ALL;
|
||||
}
|
||||
if( regData->changed & MOD_NUM )
|
||||
@ -477,10 +485,34 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
|
||||
if( regData->changed & MOD_MEMO )
|
||||
{
|
||||
String tmp;
|
||||
String memo = NULL;
|
||||
DEBUG("MOD_MEMO");
|
||||
/* ... the memo ... */
|
||||
XtFree( trans->memo );
|
||||
trans->memo = XtNewString( XbaeMatrixGetCell(regData->reg,row+1,MEMO_CELL_C) );
|
||||
|
||||
tmp = XbaeMatrixGetCell(regData->reg,row+1,MEMO_CELL_C);
|
||||
|
||||
/* if its a transfer, indicate where its from ... */
|
||||
if ((NULL != trans->debit) && (NULL != trans->credit)) {
|
||||
Account *fromAccount = NULL;
|
||||
if (((struct _account *) acc) == trans->debit) {
|
||||
fromAccount = (Account *) trans->credit;
|
||||
} else {
|
||||
fromAccount = (Account *) trans->debit;
|
||||
}
|
||||
|
||||
/* Get the memo, and add the "from" account name to it */
|
||||
memo = (String)malloc (strlen(tmp)+
|
||||
strlen(fromAccount->accountName)+
|
||||
strlen("[From: ] ") );
|
||||
|
||||
sprintf( memo, "[From: %s] %s\0", fromAccount->accountName, tmp);
|
||||
|
||||
trans->memo = memo;
|
||||
} else {
|
||||
trans->memo = XtNewString( tmp );
|
||||
}
|
||||
}
|
||||
|
||||
if( regData->changed & MOD_RECN )
|
||||
@ -497,28 +529,32 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
{
|
||||
String amount;
|
||||
float val=0.0; /* must be float for sscanf to work */
|
||||
double themount = 0.0;
|
||||
|
||||
DEBUG("MOD_AMNT");
|
||||
/* ...and the amounts */
|
||||
amount = XbaeMatrixGetCell(regData->reg,row,DEP_CELL_C);
|
||||
sscanf( amount, "%f", &val );
|
||||
trans->damount = val;
|
||||
themount = val;
|
||||
|
||||
val = 0.0;
|
||||
amount = XbaeMatrixGetCell(regData->reg,row,PAY_CELL_C);
|
||||
sscanf( amount, "%f", &val );
|
||||
trans->damount -= val;
|
||||
themount -= val;
|
||||
|
||||
xaccSetAmount (acc, trans, themount);
|
||||
|
||||
/* Reset so there is only one field filled */
|
||||
if( 0.0 > trans->damount )
|
||||
if( 0.0 > themount )
|
||||
{
|
||||
/* hack alert -- keep 3 digits for share amounts */
|
||||
sprintf( buf, "%.2f ", (-1.0*(trans->damount)) );
|
||||
sprintf( buf, "%.2f ", -themount );
|
||||
XbaeMatrixSetCell( regData->reg, row, PAY_CELL_C, buf );
|
||||
XbaeMatrixSetCell( regData->reg, row, DEP_CELL_C, "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf( buf, "%.2f ", (trans->damount) );
|
||||
sprintf( buf, "%.2f ", themount );
|
||||
XbaeMatrixSetCell( regData->reg, row, PAY_CELL_C, "" );
|
||||
XbaeMatrixSetCell( regData->reg, row, DEP_CELL_C, buf );
|
||||
}
|
||||
@ -526,7 +562,9 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
regRecalculateBalance(regData);
|
||||
}
|
||||
|
||||
if( regData->changed & MOD_PRIC )
|
||||
/* ignore MOD_PRIC if for non-stock accounts */
|
||||
if( (regData->changed & MOD_PRIC) &&
|
||||
((MUTUAL == acc->type) || (PORTFOLIO==acc->type)) )
|
||||
{
|
||||
String price;
|
||||
float val=0.0; /* must be float for sscanf to work */
|
||||
@ -538,7 +576,6 @@ regSaveTransaction( RegWindow *regData, int position )
|
||||
price = XbaeMatrixGetCell(regData->reg,row,PRIC_CELL_C);
|
||||
sscanf( price, "%f", &val );
|
||||
trans->share_price = val;
|
||||
printf ("got share price %f \n", val);
|
||||
|
||||
sprintf( buf, "%.2f ", trans->share_price );
|
||||
XbaeMatrixSetCell( regData->reg, row, PRIC_CELL_C, buf );
|
||||
@ -575,8 +612,8 @@ printf ("got share price %f \n", val);
|
||||
{
|
||||
Transaction *prevTrans;
|
||||
Transaction *nextTrans;
|
||||
prevTrans = getTransaction( regData->acc, position-1 );
|
||||
nextTrans = getTransaction( regData->acc, position+1 );
|
||||
prevTrans = getTransaction( acc, position-1 );
|
||||
nextTrans = getTransaction( acc, position+1 );
|
||||
|
||||
DEBUG("MOD_DATE");
|
||||
/* read in the date stuff... */
|
||||
@ -605,9 +642,9 @@ printf ("got share price %f \n", val);
|
||||
|
||||
/* We don't need to remove if it isn't in the transaction list */
|
||||
if( !(regData->changed & MOD_NEW) )
|
||||
removeTransaction( regData->acc, position );
|
||||
removeTransaction( acc, position );
|
||||
|
||||
insertTransaction( regData->acc, trans );
|
||||
insertTransaction( acc, trans );
|
||||
|
||||
regRefresh(regData);
|
||||
}
|
||||
@ -628,8 +665,8 @@ printf ("got share price %f \n", val);
|
||||
regData->changed = 0;
|
||||
|
||||
/* If the reconcile window is open, update it!!! */
|
||||
if( regData->acc->recnData != NULL )
|
||||
recnRefresh( regData->acc->recnData );
|
||||
if( acc->recnData != NULL )
|
||||
recnRefresh( acc->recnData );
|
||||
|
||||
return;
|
||||
}
|
||||
@ -772,7 +809,8 @@ regWindow( Widget parent, Account *acc )
|
||||
String **data;
|
||||
int i,j;
|
||||
/* ----------------------------------- */
|
||||
/* set up number of displayed columns */
|
||||
/* define where each column shows up, and total number of columns. */
|
||||
/* the number on the right hand side is the physical location of the column */
|
||||
switch(acc->type)
|
||||
{
|
||||
case BANK:
|
||||
@ -780,11 +818,29 @@ regWindow( Widget parent, Account *acc )
|
||||
case ASSET:
|
||||
case CREDIT:
|
||||
case LIABILITY:
|
||||
acc->columnLocation [DATE_COL_ID] = 0;
|
||||
acc->columnLocation [NUM_COL_ID] = 1;
|
||||
acc->columnLocation [DESC_COL_ID] = 2;
|
||||
acc->columnLocation [RECN_COL_ID] = 3;
|
||||
acc->columnLocation [PAY_COL_ID] = 4;
|
||||
acc->columnLocation [DEP_COL_ID] = 5;
|
||||
acc->columnLocation [BALN_COL_ID] = 6;
|
||||
acc -> numCols = 7;
|
||||
|
||||
break;
|
||||
case PORTFOLIO:
|
||||
case MUTUAL:
|
||||
acc -> numCols = 9;
|
||||
acc->columnLocation [DATE_COL_ID] = 0;
|
||||
acc->columnLocation [NUM_COL_ID] = 1;
|
||||
acc->columnLocation [ACTN_COL_ID] = 2;
|
||||
acc->columnLocation [DESC_COL_ID] = 3;
|
||||
acc->columnLocation [RECN_COL_ID] = 4;
|
||||
acc->columnLocation [PAY_COL_ID] = 5;
|
||||
acc->columnLocation [DEP_COL_ID] = 6;
|
||||
acc->columnLocation [PRIC_COL_ID] = 7;
|
||||
acc->columnLocation [SHRS_COL_ID] = 8;
|
||||
acc->columnLocation [BALN_COL_ID] = 9;
|
||||
acc -> numCols = 10;
|
||||
break;
|
||||
default:
|
||||
fprintf( stderr, "Ineternal Error: Account type: %d is unknown!\n", acc->type);
|
||||
@ -799,7 +855,7 @@ regWindow( Widget parent, Account *acc )
|
||||
acc -> colWidths[RECN_CELL_C] = 1; /* the widths of columns */
|
||||
acc -> colWidths[PAY_CELL_C] = 8; /* the widths of columns */
|
||||
acc -> colWidths[DEP_CELL_C] = 8; /* the widths of columns */
|
||||
acc -> colWidths[BALN_CELL_C] = 8; /* the widths of columns */
|
||||
acc -> colWidths[BALN_CELL_C] = 8; /* $ balance */
|
||||
|
||||
switch(acc->type)
|
||||
{
|
||||
@ -813,7 +869,7 @@ regWindow( Widget parent, Account *acc )
|
||||
case MUTUAL:
|
||||
acc -> colWidths[PRIC_CELL_C] = 8; /* price */
|
||||
acc -> colWidths[SHRS_CELL_C] = 8; /* share balance */
|
||||
acc -> colWidths[BALN_CELL_C] = 8; /* $ balance */
|
||||
acc -> colWidths[ACTN_CELL_C] = 6; /* action (category) */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -841,7 +897,7 @@ regWindow( Widget parent, Account *acc )
|
||||
case MUTUAL:
|
||||
acc -> alignments[PRIC_CELL_C] = XmALIGNMENT_END; /* price */
|
||||
acc -> alignments[SHRS_CELL_C] = XmALIGNMENT_END; /* share balance */
|
||||
acc -> alignments[BALN_CELL_C] = XmALIGNMENT_END; /* $balance */
|
||||
acc -> alignments[ACTN_CELL_C] = XmALIGNMENT_BEGINNING; /* action */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -856,6 +912,7 @@ regWindow( Widget parent, Account *acc )
|
||||
acc -> rows[0][DATE_CELL_C] = "Date";
|
||||
acc -> rows[0][NUM_CELL_C] = "Num";
|
||||
acc -> rows[0][DESC_CELL_C] = "Description";
|
||||
acc -> rows[0][BALN_CELL_C] = "Balance";
|
||||
switch(acc->type)
|
||||
{
|
||||
case BANK:
|
||||
@ -863,13 +920,12 @@ regWindow( Widget parent, Account *acc )
|
||||
case ASSET:
|
||||
case CREDIT:
|
||||
case LIABILITY:
|
||||
acc -> rows[0][BALN_CELL_C] = "Balance";
|
||||
break;
|
||||
case PORTFOLIO:
|
||||
case MUTUAL:
|
||||
acc -> rows[0][PRIC_CELL_C] = "Price";
|
||||
acc -> rows[0][SHRS_CELL_C] = "Tot Shrs";
|
||||
acc -> rows[0][BALN_CELL_C] = "Balance";
|
||||
acc -> rows[0][ACTN_CELL_C] = "Cat";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1435,13 +1491,16 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
{
|
||||
tcbs->next_column = PAY_CELL_C;
|
||||
if( regData->qf != NULL )
|
||||
if( regData->qf->trans != NULL )
|
||||
if( 0.0 > regData->qf->trans->damount )
|
||||
if( regData->qf->trans != NULL ) {
|
||||
double themount;
|
||||
themount = xaccGetAmount (acc, regData->qf->trans);
|
||||
if( 0.0 > themount )
|
||||
{
|
||||
sprintf( buf, "%.2f ", (-1.0*(regData->qf->trans->damount)) );
|
||||
sprintf( buf, "%.2f ", - themount );
|
||||
XbaeMatrixSetCell( reg, tcbs->next_row,
|
||||
tcbs->next_column, buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( IN_PAY_CELL(row,col) )
|
||||
@ -1463,13 +1522,16 @@ regCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
{
|
||||
tcbs->next_column = DEP_CELL_C;
|
||||
if( regData->qf != NULL )
|
||||
if( regData->qf->trans != NULL )
|
||||
if( 0.0 <= regData->qf->trans->damount )
|
||||
if( regData->qf->trans != NULL ) {
|
||||
double themount;
|
||||
themount = xaccGetAmount (acc, regData->qf->trans);
|
||||
if( 0.0 <= themount )
|
||||
{
|
||||
sprintf( buf, "%.2f ", (regData->qf->trans->damount) );
|
||||
sprintf( buf, "%.2f ", themount );
|
||||
XbaeMatrixSetCell( reg, tcbs->next_row,
|
||||
tcbs->next_column, buf );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1631,8 +1693,8 @@ dateCellFormat( Widget mw, XbaeMatrixModifyVerifyCallbackStruct *mvcbs )
|
||||
count++;
|
||||
if( count >= 1 )
|
||||
{
|
||||
XbaeMatrixEditCell( mw, row+1, DATE_CELL_C );
|
||||
XbaeMatrixSelectCell( mw, row+1, DATE_CELL_C );
|
||||
XbaeMatrixEditCell( mw, row+1, col );
|
||||
XbaeMatrixSelectCell( mw, row+1, col );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
84
src/Transaction.c
Normal file
84
src/Transaction.c
Normal file
@ -0,0 +1,84 @@
|
||||
/********************************************************************\
|
||||
* Transaction.c -- the transaction data structure *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 1997 Linas Vepstas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
* *
|
||||
* Author: Rob Clark *
|
||||
* Internet: rclark@cs.hmc.edu *
|
||||
* Address: 609 8th Street *
|
||||
* Huntington Beach, CA 92648-4632 *
|
||||
\********************************************************************/
|
||||
|
||||
#include "Transaction.h"
|
||||
#include "util.h"
|
||||
|
||||
/********************************************************************\
|
||||
* Because I can't use C++ for this project, doesn't mean that I *
|
||||
* can't pretend too! These functions perform actions on the *
|
||||
* Transaction data structure, in order to encapsulate the knowledge *
|
||||
* of the internals of the Transaction in one file. *
|
||||
\********************************************************************/
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
initTransaction( Transaction * trans )
|
||||
{
|
||||
|
||||
/* fill in some sane defaults */
|
||||
trans->debit = 0x0;
|
||||
trans->credit = 0x0;
|
||||
|
||||
trans->num = NULL;
|
||||
trans->description = NULL;
|
||||
trans->memo = NULL;
|
||||
trans->catagory = 0;
|
||||
trans->reconciled = NREC;
|
||||
trans->damount = 0.0;
|
||||
trans->share_price = 1.0;
|
||||
|
||||
trans->date.year = 1900;
|
||||
trans->date.month = 1;
|
||||
trans->date.day = 1;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
Transaction *
|
||||
mallocTransaction( void )
|
||||
{
|
||||
Transaction *trans = (Transaction *)_malloc(sizeof(Transaction));
|
||||
initTransaction (trans);
|
||||
return trans;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
void
|
||||
freeTransaction( Transaction *trans )
|
||||
{
|
||||
if( trans != NULL ) {
|
||||
initTransaction (trans); /* just in case someone looks up freed memory ... */
|
||||
_free(trans);
|
||||
}
|
||||
}
|
||||
|
||||
/************************ END OF ************************************\
|
||||
\************************* FILE *************************************/
|
||||
|
105
src/XferWindow.c
105
src/XferWindow.c
@ -2,6 +2,7 @@
|
||||
* XferWindow.c -- the transfer window for xacc (X-Accountant) *
|
||||
* (for transferring between accounts) *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 1997 Linas Vepstas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -416,91 +417,55 @@ void
|
||||
xferCB( Widget mw, XtPointer cd, XtPointer cb )
|
||||
{
|
||||
XferWindow *xferData = (XferWindow *)cd;
|
||||
Transaction *toTrans, *fromTrans;
|
||||
Transaction *trans;
|
||||
Account *acc;
|
||||
String str;
|
||||
int dollar=0,cent=0,pos=0;
|
||||
float val=0.0;
|
||||
|
||||
data->saved = False;
|
||||
|
||||
/* "toTrans" is the transfer transaction that goes into the to account,
|
||||
* and "fromTrans" goes into the from account */
|
||||
toTrans = (Transaction *)_malloc(sizeof(Transaction));
|
||||
fromTrans = (Transaction *)_malloc(sizeof(Transaction));
|
||||
/* a double-entry transfer -- just one record, two accounts */
|
||||
trans = mallocTransaction();
|
||||
|
||||
/* Create the "toTrans" transaction */
|
||||
/* Create the transaction */
|
||||
str = XmTextGetString(xferData->date);
|
||||
todaysDate(&(toTrans->date));
|
||||
sscanf( str, "%d/%d/%d", &(toTrans->date.month),
|
||||
&(toTrans->date.day), &(toTrans->date.year) );
|
||||
todaysDate(&(trans->date));
|
||||
sscanf( str, "%d/%d/%d", &(trans->date.month),
|
||||
&(trans->date.day), &(trans->date.year) );
|
||||
str = XmTextGetString(xferData->amount);
|
||||
sscanf( str, "%d.%2d", &dollar, ¢ );
|
||||
toTrans->damount = ((double) dollar) + 0.01 * ((double) cent);
|
||||
toTrans->num = XtNewString("");
|
||||
sscanf( str, "%f", &val ); /* sscanf must take float not double arg */
|
||||
trans->damount = val;
|
||||
trans->num = XtNewString("");
|
||||
|
||||
/* Get the memo, and add the "from" account name to it */
|
||||
{
|
||||
String memo = NULL;
|
||||
/* Note, don't use _malloc/_free here, because otherwise it
|
||||
* would mess up the memory accounting if memory debugging
|
||||
* is turned on */
|
||||
trans->memo = XmTextGetString(xferData->memo);
|
||||
trans->description = XmTextGetString(xferData->desc);
|
||||
trans->catagory = 0;
|
||||
trans->reconciled = NREC;
|
||||
|
||||
/* make note of which accounts this was transfered from & to */
|
||||
trans->debit = (struct _account *) getAccount(data,xferData->from);
|
||||
trans->credit = (struct _account *) getAccount(data,xferData->to);
|
||||
|
||||
|
||||
/* insert transaction into from acount */
|
||||
acc = getAccount(data,xferData->from);
|
||||
str = XmTextGetString(xferData->memo);
|
||||
memo = (String)malloc(strlen(str)+
|
||||
strlen(acc->accountName)+
|
||||
strlen("[From: ] ") );
|
||||
sprintf( memo, "[From: %s] %s\0", acc->accountName, str );
|
||||
toTrans->memo = memo;
|
||||
free(str);
|
||||
}
|
||||
|
||||
toTrans->description = XmTextGetString(xferData->desc);
|
||||
toTrans->catagory = 0;
|
||||
toTrans->reconciled = NREC;
|
||||
|
||||
acc = getAccount(data,xferData->to);
|
||||
pos = insertTransaction( acc, toTrans );
|
||||
|
||||
/* Refresh the "to" account register window */
|
||||
regRefresh(acc->regData);
|
||||
/* Refresh the "to" account reconcile window */
|
||||
recnRefresh(acc->recnData);
|
||||
|
||||
/* Create the "fromTrans" transaction */
|
||||
str = XmTextGetString(xferData->date);
|
||||
todaysDate(&(fromTrans->date));
|
||||
sscanf( str, "%d/%d/%d", &(fromTrans->date.month),
|
||||
&(fromTrans->date.day), &(fromTrans->date.year) );
|
||||
fromTrans->damount = -1.0*toTrans->damount;
|
||||
fromTrans->num = XtNewString("");
|
||||
|
||||
/* Get the memo, and add the "to" account name to it */
|
||||
{
|
||||
String memo = NULL;
|
||||
/* Note, don't use _malloc/_free here, because otherwise it
|
||||
* would mess up the memory accounting if memory debugging
|
||||
* is turned on */
|
||||
acc = getAccount(data,xferData->to);
|
||||
str = XmTextGetString(xferData->memo);
|
||||
memo = (String)malloc(strlen(str)+
|
||||
strlen(acc->accountName)+
|
||||
strlen("[To: ] ") );
|
||||
sprintf( memo, "[To: %s] %s\0", acc->accountName, str );
|
||||
fromTrans->memo = memo;
|
||||
free(str);
|
||||
}
|
||||
|
||||
fromTrans->description = XmTextGetString(xferData->desc);
|
||||
fromTrans->catagory = 0;
|
||||
fromTrans->reconciled = NREC;
|
||||
|
||||
acc = getAccount(data,xferData->from);
|
||||
pos = insertTransaction( acc, fromTrans );
|
||||
insertTransaction( acc, trans );
|
||||
|
||||
/* Refresh the "from" account register window */
|
||||
regRefresh(acc->regData);
|
||||
/* Refresh the "from" account reconcile window */
|
||||
recnRefresh(acc->recnData);
|
||||
|
||||
/* insert transaction into to acount */
|
||||
acc = getAccount(data,xferData->to);
|
||||
insertTransaction( acc, trans );
|
||||
|
||||
/* Refresh the "to" account register window */
|
||||
regRefresh(acc->regData);
|
||||
/* Refresh the "to" account reconcile window */
|
||||
recnRefresh(acc->recnData);
|
||||
|
||||
refreshMainWindow();
|
||||
}
|
||||
|
||||
/* ********************** END OF FILE *************************/
|
||||
|
Loading…
Reference in New Issue
Block a user