start adding secondary account info to the mix

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1534 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/xacc-12-patch
Linas Vepstas 28 years ago
parent 62b09c3539
commit e55822ef1f

@ -1,7 +1,30 @@
/********************************************************************\
* AccInfo.c -- the Account Info data structures *
* Copyright (C) 1998, 1999 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. *
\********************************************************************/
#include <stdlib.h>
#include <string.h>
#include "AccInfo.h"
#include "AccInfoP.h"
#include "messages.h"
/* whoa! */
/* =========================================================== */
char *account_type_name[NUM_ACCOUNT_TYPES] =
{
@ -24,10 +47,65 @@ char *account_type_name[NUM_ACCOUNT_TYPES] =
*/
};
char * xaccAccountGetTypeStr (int type)
{
if (0 > type) return "";
if (NUM_ACCOUNT_TYPES <= type) return "";
return (account_type_name [type]);
}
/* =========================================================== */
InvAcct *
xaccMallocInvAcct (void)
{
InvAcct *iacc;
iacc = (InvAcct *) malloc (sizeof (InvAcct));
xaccInitInvAcct (iacc);
return iacc;
}
void
xaccInitInvAcct (InvAcct *iacc)
{
if (!iacc) return;
iacc->pricesrc = NULL;
iacc->brokerid = NULL;
iacc->acctid = NULL;
iacc->accttype = NULL;
iacc->prodtype = NULL;
iacc->secid = NULL;
iacc->secidtype = strdup ("CUSIP");
}
void
xaccFreeInvAcct (InvAcct *iacc)
{
if (!iacc) return;
if (iacc->pricesrc) { free(iacc->pricesrc); iacc->pricesrc = NULL; }
if (iacc->brokerid) { free(iacc->brokerid); iacc->brokerid = NULL; }
if (iacc->acctid) { free(iacc->acctid); iacc->acctid = NULL; }
if (iacc->accttype) { free(iacc->accttype); iacc->accttype = NULL; }
if (iacc->prodtype) { free(iacc->prodtype); iacc->prodtype = NULL; }
if (iacc->secid) { free(iacc->secid); iacc->secid = NULL; }
if (iacc->secidtype) { free(iacc->secidtype); iacc->secidtype = NULL; }
}
/* =========================================================== */
void
xaccInvAcctSetPriceSrc (InvAcct *iacc, const char *src)
{
if (!iacc || !src) return;
if (iacc->pricesrc) { free(iacc->pricesrc); }
iacc->pricesrc = strdup (src);
}
char *
xaccInvAcctGetPriceSrc (InvAcct *iacc)
{
if (!iacc) return NULL;
return (iacc->pricesrc);
}
/* ==================== END OF FILE ========================== */

@ -1,6 +1,6 @@
/********************************************************************\
* AccInfo.h -- the Account Info data structures *
* Copyright (C) 1998 Linas Vepstas *
* Copyright (C) 1998, 1999 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 *
@ -15,11 +15,6 @@
* 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 *
\********************************************************************/
/*
@ -99,21 +94,21 @@ enum
char * xaccAccountGetTypeStr (int type);
struct _BankAcct
{
char * bankid; /* routing and transit number */
char * branchid; /* branch office bank identifier */
char * acctid; /* account number */
char * accttype; /* account type */
char * acctkey; /* checksum key */
int acctype; /* account type. Must be one of
* CHECKING = 10;
* SAVINGS = 11;
* MONEYMRKT = 12;
* CREDITLINE = 13;
*/
typedef struct _BankAcct BankAcct;
typedef struct _InvAcct InvAcct;
typedef union _AccInfo AccInfo;
};
InvAcct * xaccMallocInvAcct (void);
void xaccInitInvAcct (InvAcct *iacc);
void xaccFreeInvAcct (InvAcct *iacc);
/*
* The xaccInvAcctSetPriceSrc() and xaccInvAcctGetPriceSrc()
* routines are used to get and set a string that identifies the current
* source for investment pricing info.
* Currently supported values include "yahoo", "fidelity", "troweprice", etc.
*/
void xaccInvAcctSetPriceSrc (InvAcct *iacc, const char *src);
char * xaccInvAcctGetPriceSrc (InvAcct *iacc);
#endif /* __ACCINFO_H__ */

@ -0,0 +1,81 @@
/********************************************************************\
* AccInfoP.h -- the Account Info data structures *
* Copyright (C) 1998, 1999 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. *
\********************************************************************/
/*
* Most of the structures here more or less resemble
* matching structures in the OFX DTD's. The match
* is not exact.
*/
#ifndef __XACC_ACCINFO_P_H__
#define __XACC_ACCINFO_P_H__
#include "config.h"
#include "AccInfo.h"
/*
* Most of the structures here more or less resemble
* matching structures in the OFX DTD's. The match
* is not exact.
*/
/* The BankAcct structure only applies when the account type is one of
* CHECKING = 10;
* SAVINGS = 11;
* MONEYMRKT = 12;
* CREDITLINE = 13;
*/
struct _BankAcct
{
char * bankid; /* routing and transit number */
char * branchid; /* branch office bank identifier */
char * acctid; /* account number */
char * accttype; /* account type */
char * acctkey; /* checksum key */
};
/* The InvAcct structure only applies when the account type
* is one of
* MUTUAL STOCK
*/
struct _InvAcct
{
char * pricesrc; /* source for price quotes ...
* one of Yahoo, Fidelity, TRowePrice, etc.
*/
char * brokerid; /* unique identifier for the FI */
char * acctid; /* account number */
char * accttype; /* account type (OFX INVACCTYPE) */
/* possible values: INDIVIDUAL, JOINT
TRUST, CORPORATE */
char * prodtype; /* account type (OFX USPRODUCTTYPE) */
/* possible values: 401K 403B IRA KEOGH SARSEP
SIMPLE NORMAL TDA TRUST UGMA */
char * secid; /* security id (CUSIP) (OFX UNIQUEID) */
/* (9 digit alphanumeric) */
char * secidtype; /* "CUSIP" (OFX UNIQUEIDTYPE) */
};
union _AccInfo {
BankAcct bank_acct;
InvAcct inv_acct;
};
#endif /* __XACC_ACCINFO_P_H__ */

@ -43,7 +43,7 @@
* as it can lead to scrambled data.
* hack alert -- this should be a configurable parameter.
*/
int unsafe_ops = 0;
int unsafe_ops = 1;
int next_free_unique_account_id = 0;

@ -44,6 +44,7 @@
#define __XACC_ACCOUNT_P_H__
#include "config.h"
#include "AccInfo.h"
#include "Transaction.h"
/** STRUCTS *********************************************************/
@ -87,6 +88,13 @@ struct _account {
*/
short type;
/* The accInfo field provides a hook for storing additional
* account-type specific data. Thus, it will contain different
* structures depending on whether the account is a bank, investment
* or other type of account. Implemented as a union.
*/
AccInfo *accInfo;
/* The currency field denotes the default currency in which all
* splits in this account are denominated. It's value *MUST*
* be a three-letter ISO currency code, or it must be a comma followed

Loading…
Cancel
Save