mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
start adding customer-copying code, for closing of periods
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9471 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f2f56a1a27
commit
a4b2bd9f34
@ -17,7 +17,8 @@
|
||||
#include "gncAddress.h"
|
||||
#include "gncAddressP.h"
|
||||
|
||||
struct _gncAddress {
|
||||
struct _gncAddress
|
||||
{
|
||||
QofBook * book;
|
||||
const GUID * parent_guid;
|
||||
QofIdType parent_type;
|
||||
@ -30,7 +31,6 @@ struct _gncAddress {
|
||||
char * phone;
|
||||
char * fax;
|
||||
char * email;
|
||||
|
||||
};
|
||||
|
||||
#define _GNC_MOD_NAME GNC_ADDRESS_MODULE_NAME
|
||||
@ -49,7 +49,8 @@ mark_address (GncAddress *address)
|
||||
|
||||
/* Create/Destroy functions */
|
||||
|
||||
GncAddress * gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype)
|
||||
GncAddress *
|
||||
gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
@ -73,6 +74,31 @@ GncAddress * gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptyp
|
||||
return addr;
|
||||
}
|
||||
|
||||
GncAddress *
|
||||
gncCloneAddress (GncAddress *from, QofBook *book)
|
||||
{
|
||||
GncAddress *addr;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
addr = g_new0 (GncAddress, 1);
|
||||
addr->book = book;
|
||||
addr->dirty = TRUE;
|
||||
addr->parent_guid = from->parent_guid;
|
||||
addr->parent_type = from->parent_type;
|
||||
|
||||
addr->name = CACHE_INSERT (from->name);
|
||||
addr->addr1 = CACHE_INSERT (from->addr1);
|
||||
addr->addr2 = CACHE_INSERT (from->addr2);
|
||||
addr->addr3 = CACHE_INSERT (from->addr3);
|
||||
addr->addr4 = CACHE_INSERT (from->addr4);
|
||||
addr->phone = CACHE_INSERT (from->phone);
|
||||
addr->fax = CACHE_INSERT (from->fax);
|
||||
addr->email = CACHE_INSERT (from->email);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
||||
void gncAddressDestroy (GncAddress *addr){
|
||||
if (!addr) return;
|
||||
|
||||
|
@ -11,12 +11,13 @@
|
||||
|
||||
#define GNC_ADDRESS_MODULE_NAME "gncAddress"
|
||||
|
||||
struct _gncAddress;
|
||||
typedef struct _gncAddress GncAddress;
|
||||
|
||||
/* Create/Destroy functions */
|
||||
|
||||
GncAddress * gncAddressCreate (QofBook *book, const GUID *parent, QofIdType ptype);
|
||||
|
||||
/** make a copy of the address, but associate it with a different book */
|
||||
GncAddress * gncCloneAddress (GncAddress *from, QofBook *book);
|
||||
void gncAddressDestroy (GncAddress *addr);
|
||||
|
||||
/* Set functions */
|
||||
|
@ -1,6 +1,28 @@
|
||||
/********************************************************************\
|
||||
* gncCustomer.c -- the Core Customer Interface *
|
||||
* *
|
||||
* 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, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* gncCustomer.c -- the Core Customer Interface
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Copyright (C) 2003 Linas Vepstas <linas@linas.org>
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@ -98,6 +120,35 @@ GncCustomer *gncCustomerCreate (QofBook *book)
|
||||
return cust;
|
||||
}
|
||||
|
||||
/** Create a copy of a customer, placing the copy into a new book. */
|
||||
GncCustomer *
|
||||
gncCloneCustomer (GncCustomer *from, QofBook *book)
|
||||
{
|
||||
GncCustomer *cust;
|
||||
|
||||
cust = g_new0 (GncCustomer, 1);
|
||||
|
||||
qof_instance_init (&cust->inst, book);
|
||||
qof_instance_gemini (&cust->inst, &from->inst);
|
||||
|
||||
cust->id = CACHE_INSERT (from->id);
|
||||
cust->name = CACHE_INSERT (from->name);
|
||||
cust->notes = CACHE_INSERT (from->notes);
|
||||
cust->discount = from->discount;
|
||||
cust->credit = from->credit;
|
||||
cust->taxincluded = from->taxincluded;
|
||||
cust->active = from->active;
|
||||
|
||||
/* cust->jobs = ??? XXX fixme not sure what to do here */
|
||||
/* cust->terms = ??? XXX fixme not sure what to do here */
|
||||
/* cust->taxtable = ??? XXX fixme not sure what to do here */
|
||||
cust->addr = gncCloneAddress (from->addr, book);
|
||||
cust->shipaddr = gncCloneAddress (from->shipaddr, book);
|
||||
addObj (cust);
|
||||
|
||||
return cust;
|
||||
}
|
||||
|
||||
void gncCustomerDestroy (GncCustomer *cust)
|
||||
{
|
||||
if (!cust) return;
|
||||
|
@ -1,5 +1,26 @@
|
||||
/********************************************************************\
|
||||
* gncCustomer.h -- the Core Customer Interface *
|
||||
* *
|
||||
* 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, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* gncCustomer.h -- the Core Customer Interface
|
||||
* Copyright (C) 2001,2002 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
@ -1,6 +1,28 @@
|
||||
/********************************************************************\
|
||||
* gncCustomerP.h -- the Core Customer Interface *
|
||||
* *
|
||||
* 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, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/*
|
||||
* gncCustomerP.h -- the Core Customer Interface
|
||||
* Copyright (C) 2001 Derek Atkins
|
||||
* Copyright (C) 2003 Linas Vepstas <linas@linas.org>
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
*/
|
||||
|
||||
@ -13,4 +35,14 @@ gboolean gncCustomerRegister (void);
|
||||
gint64 gncCustomerNextID (QofBook *book);
|
||||
void gncCustomerSetGUID (GncCustomer *customer, const GUID *guid);
|
||||
|
||||
/** The gncCloneCustomer() routine makes a copy of the indicated
|
||||
* customer, placing it in the indicated book. It copies
|
||||
* the addresses, credits, etc.
|
||||
* It does not copy jobs?? or bill terms??. Or tax terms ???
|
||||
* XXX the above need fixin....
|
||||
* It then adds a pair of 'gemini' kvp pointers so that each copy
|
||||
* can be found from the other.
|
||||
*/
|
||||
GncCustomer * gncCloneCustomer (GncCustomer *from, QofBook *book);
|
||||
|
||||
#endif /* GNC_CUSTOMERP_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user