GnuCash c935c2f+
Loading...
Searching...
No Matches
gncOwner.h
Go to the documentation of this file.
1/********************************************************************\
2 * gncOwner.h -- Business Interface: Object OWNERs *
3 * *
4 * This program is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU General Public License as *
6 * published by the Free Software Foundation; either version 2 of *
7 * the License, or (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License*
15 * along with this program; if not, contact: *
16 * *
17 * Free Software Foundation Voice: +1-617-542-5942 *
18 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
19 * Boston, MA 02110-1301, USA gnu@gnu.org *
20 * *
21\********************************************************************/
33#ifndef GNC_OWNER_H_
34#define GNC_OWNER_H_
35
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41typedef struct _gncOwner GncOwner;
42
43#define GNC_ID_OWNER "gncOwner"
44
45typedef enum
46{
47 GNC_OWNER_NONE ,
48 GNC_OWNER_UNDEFINED ,
49 GNC_OWNER_CUSTOMER ,
50 GNC_OWNER_JOB ,
51 GNC_OWNER_VENDOR ,
52 GNC_OWNER_EMPLOYEE ,
53} GncOwnerType;
54
55#include "qof.h"
56#include "gncCustomer.h"
57#include "gncJob.h"
58#include "gncVendor.h"
59#include "gncEmployee.h"
60#include "gncInvoice.h"
61#include "Account.h"
62#include "gnc-lot.h"
63
74const char * gncOwnerGetTypeString (const GncOwner *owner);
82gboolean GNC_IS_OWNER (QofInstance *ent);
83
87
88gboolean
89gncOwnerRegister(void);
90
93#ifndef SWIG
94
97{
98 GncOwnerType type;
99 union
100 {
101 gpointer undefined;
102 GncCustomer * customer;
103 GncJob * job;
104 GncVendor * vendor;
105 GncEmployee * employee;
107 gpointer qof_temp;
108};
109
110#endif /* SWIG */
111
115void gncOwnerInitUndefined (GncOwner *owner, gpointer obj);
116void gncOwnerInitCustomer (GncOwner *owner, GncCustomer *customer);
117void gncOwnerInitJob (GncOwner *owner, GncJob *job);
118void gncOwnerInitVendor (GncOwner *owner, GncVendor *vendor);
119void gncOwnerInitEmployee (GncOwner *owner, GncEmployee *employee);
125GncOwnerType gncOwnerGetType (const GncOwner *owner);
128gboolean gncOwnerIsValid (const GncOwner *owner);
129
132gpointer gncOwnerGetUndefined (const GncOwner *owner);
138GncJob * gncOwnerGetJob (const GncOwner *owner);
141GncVendor * gncOwnerGetVendor (const GncOwner *owner);
144GncEmployee * gncOwnerGetEmployee (const GncOwner *owner);
145
146const char * gncOwnerGetID (const GncOwner *owner);
147const char * gncOwnerGetName (const GncOwner *owner);
148GncAddress * gncOwnerGetAddr (const GncOwner *owner);
149gboolean gncOwnerGetActive (const GncOwner *owner);
150gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner);
156void gncOwnerSetActive (const GncOwner *owner, gboolean active);
159void gncOwnerCopy (const GncOwner *src, GncOwner *dest);
160
168gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
171int gncOwnerGCompareFunc (const GncOwner *a, const GncOwner *b);
173int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
177const GncGUID * gncOwnerGetGUID (const GncOwner *owner);
178GncGUID gncOwnerRetGUID (GncOwner *owner);
179
184const GncOwner * gncOwnerGetEndOwner (const GncOwner *owner);
185const GncGUID * gncOwnerGetEndGUID (const GncOwner *owner);
186
188void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot);
189
192gboolean gncOwnerLotMatchOwnerFunc (GNCLot *lot, gpointer user_data);
193
198gint gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB);
199
203gboolean gncOwnerGetOwnerFromLot (GNCLot *lot, GncOwner *owner);
204
212gboolean gncOwnerGetOwnerFromTxn (Transaction *txn, GncOwner *owner);
213
214gboolean gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType type, GncGUID *guid);
215
223GNCLot *
224gncOwnerCreatePaymentLotSecs (const GncOwner *owner, Transaction **preset_txn,
225 Account *posted_acc, Account *xfer_acc,
226 gnc_numeric amount, gnc_numeric exch, time64 date,
227 const char *memo, const char *num);
228
263void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots);
264
276void
277gncOwnerApplyPaymentSecs (const GncOwner *owner, Transaction **preset_txn,
278 GList *lots, Account *posted_acc, Account *xfer_acc,
279 gnc_numeric amount, gnc_numeric exch, time64 date,
280 const char *memo, const char *num, gboolean auto_pay);
281
293Split* gncOwnerFindOffsettingSplit(GNCLot* lot, gnc_numeric target_amount);
294
301gboolean gncOwnerReduceSplitTo(Split* split, gnc_numeric target_amount);
302
308void gncOwnerSetLotLinkMemo (Transaction *ll_txn);
309
311GList * gncOwnerGetAccountTypesList (const GncOwner *owner);
312
314GList * gncOwnerGetCommoditiesList (const GncOwner *owner);
315
316
320gnc_numeric
322 const gnc_commodity *report_currency);
323
324#define OWNER_TYPE "type"
325#define OWNER_TYPE_STRING "type-string"
326#define OWNER_CUSTOMER "customer"
327#define OWNER_JOB "job"
328#define OWNER_VENDOR "vendor"
329#define OWNER_EMPLOYEE "employee"
330#define OWNER_PARENT "parent"
331#define OWNER_PARENTG "parent-guid"
332#define OWNER_NAME "name"
333
334#define OWNER_FROM_LOT "owner-from-lot"
335
341GncOwner * gncOwnerNew (void);
342void gncOwnerFree (GncOwner *owner);
343
344
350void gncOwnerBeginEdit (GncOwner *owner);
351void gncOwnerCommitEdit (GncOwner *owner);
352void gncOwnerDestroy (GncOwner *owner);
353
354#ifdef __cplusplus
355}
356#endif
357
358#endif /* GNC_OWNER_H_ */
Account handling public routines.
Core Customer Interface.
Employee Interface.
Business Invoice Interface.
Job Interface.
Vendor Interface.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
const gchar * QofIdType
QofIdType declaration.
Definition qofid.h:80
const gchar * QofIdTypeConst
QofIdTypeConst declaration.
Definition qofid.h:82
GncCustomer * gncOwnerGetCustomer(const GncOwner *owner)
If the given owner is of type GNC_OWNER_CUSTOMER, returns the pointer to the customer object.
Definition gncOwner.c:369
void gncOwnerAutoApplyPaymentsWithLots(const GncOwner *owner, GList *lots)
Given a list of lots, try to balance as many of them as possible by creating balancing transactions b...
Definition gncOwner.c:1256
gboolean GNC_IS_OWNER(QofInstance *ent)
Check if entity is an owner kind.
Definition gncOwner.c:352
gboolean gncOwnerIsValid(const GncOwner *owner)
Returns TRUE if the given owner is one of the valid objects.
Definition gncOwner.c:699
gboolean gncOwnerGetOwnerFromLot(GNCLot *lot, GncOwner *owner)
Get the owner from the lot.
Definition gncOwner.c:636
void gncOwnerAttachToLot(const GncOwner *owner, GNCLot *lot)
Attach an owner to a lot.
Definition gncOwner.c:622
GList * gncOwnerGetCommoditiesList(const GncOwner *owner)
Returns a GList of currencies associated with the owner.
Definition gncOwner.c:1462
void gncOwnerBeginEdit(GncOwner *owner)
These are convenience wrappers around gnc{Vendor,Customer,Job,Employee}* functions.
Definition gncOwner.c:72
GncEmployee * gncOwnerGetEmployee(const GncOwner *owner)
If the given owner is of type GNC_OWNER_EMPLOYEE, returns the pointer to the employee object.
Definition gncOwner.c:390
QofIdTypeConst qofOwnerGetType(const GncOwner *owner)
return the type for the collection.
Definition gncOwner.c:230
GList * gncOwnerGetAccountTypesList(const GncOwner *owner)
Returns a GList of account-types based on the owner type.
Definition gncOwner.c:1444
GncJob * gncOwnerGetJob(const GncOwner *owner)
If the given owner is of type GNC_OWNER_JOB, returns the pointer to the job object.
Definition gncOwner.c:376
GNCLot * gncOwnerCreatePaymentLotSecs(const GncOwner *owner, Transaction **preset_txn, Account *posted_acc, Account *xfer_acc, gnc_numeric amount, gnc_numeric exch, time64 date, const char *memo, const char *num)
Create a lot for a payment to the owner using the other parameters passed in.
Definition gncOwner.c:750
Split * gncOwnerFindOffsettingSplit(GNCLot *lot, gnc_numeric target_amount)
Helper function to find a split in lot that best offsets target_amount Obviously it should be of oppo...
Definition gncOwner.c:896
void gncOwnerApplyPaymentSecs(const GncOwner *owner, Transaction **preset_txn, GList *lots, Account *posted_acc, Account *xfer_acc, gnc_numeric amount, gnc_numeric exch, time64 date, const char *memo, const char *num, gboolean auto_pay)
A convenience function to apply a payment to the owner.
Definition gncOwner.c:1405
gboolean gncOwnerReduceSplitTo(Split *split, gnc_numeric target_amount)
Helper function to reduce the amount of a split to target_amount.
Definition gncOwner.c:959
void gncOwnerSetLotLinkMemo(Transaction *ll_txn)
To help a user understand what a lot link transaction does, we set the memo to name all documents inv...
Definition gncOwner.c:1010
int gncOwnerCompare(const GncOwner *a, const GncOwner *b)
Sort on name.
Definition gncOwner.c:590
gint gncOwnerLotsSortFunc(GNCLot *lotA, GNCLot *lotB)
Helper function used to sort lots by date.
Definition gncOwner.c:728
GncVendor * gncOwnerGetVendor(const GncOwner *owner)
If the given owner is of type GNC_OWNER_VENDOR, returns the pointer to the vendor object.
Definition gncOwner.c:383
const GncOwner * gncOwnerGetEndOwner(const GncOwner *owner)
Get the "parent" Owner or GncGUID thereof.
Definition gncOwner.c:572
int gncOwnerGCompareFunc(const GncOwner *a, const GncOwner *b)
Same as gncOwnerEqual, but returns 0 if equal to be used as a GList custom compare function.
Definition gncOwner.c:411
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
Assess equality by checking.
Definition gncOwner.c:404
gboolean gncOwnerLotMatchOwnerFunc(GNCLot *lot, gpointer user_data)
Helper function used to filter a list of lots by owner.
Definition gncOwner.c:706
gpointer gncOwnerGetUndefined(const GncOwner *owner)
If the given owner is of type GNC_OWNER_UNDEFINED, returns the undefined pointer, which is usually NU...
Definition gncOwner.c:362
const GncGUID * gncOwnerGetGUID(const GncOwner *owner)
Get the GncGUID of the immediate owner.
Definition gncOwner.c:518
GncOwner * gncOwnerNew(void)
These two functions are mainly for the convenience of scheme code.
Definition gncOwner.c:57
GncOwnerType gncOwnerGetType(const GncOwner *owner)
Returns the GncOwnerType of this owner.
Definition gncOwner.c:200
const char * gncOwnerGetTypeString(const GncOwner *owner)
return the type for the owner as an untranslated string.
Definition gncOwner.c:206
QofInstance * qofOwnerGetOwner(const GncOwner *owner)
return the owner itself as an entity.
Definition gncOwner.c:275
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
Definition gncOwner.c:235
void qofOwnerSetEntity(GncOwner *owner, QofInstance *ent)
set the owner from the entity.
Definition gncOwner.c:319
gboolean gncOwnerGetOwnerFromTxn(Transaction *txn, GncOwner *owner)
Convenience function to get the owner from a transaction.
Definition gncOwner.c:674
gnc_numeric gncOwnerGetBalanceInCurrency(const GncOwner *owner, const gnc_commodity *report_currency)
Given an owner, extract the open balance from the owner and then convert it to the desired currency.
Definition gncOwner.c:1478
STRUCTS.
credit, discount and shipaddr are unique to GncCustomer id, name, notes, terms, addr,...
The type used to store guids in C.
Definition guid.h:75
QofBook reference.
Definition qofbook-p.hpp:47
gpointer qof_temp
Set type independently of the owner.
Definition gncOwner.h:107
GncOwnerType type
Customer, Job, Vendor, Employee or Undefined.
Definition gncOwner.h:98
union _gncOwner::@21 owner
holds the pointer to the owner object.