GnuCash 2.4.99
gncOwner.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * gncOwner.h -- Business Interface:  Object OWNERs                 *
00003  *                                                                  *
00004  * This program is free software; you can redistribute it and/or    *
00005  * modify it under the terms of the GNU General Public License as   *
00006  * published by the Free Software Foundation; either version 2 of   *
00007  * the License, or (at your option) any later version.              *
00008  *                                                                  *
00009  * This program is distributed in the hope that it will be useful,  *
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00012  * GNU General Public License for more details.                     *
00013  *                                                                  *
00014  * You should have received a copy of the GNU General Public License*
00015  * along with this program; if not, contact:                        *
00016  *                                                                  *
00017  * Free Software Foundation           Voice:  +1-617-542-5942       *
00018  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00019  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00020  *                                                                  *
00021 \********************************************************************/
00033 #ifndef GNC_OWNER_H_
00034 #define GNC_OWNER_H_
00035 
00036 typedef struct _gncOwner GncOwner;
00037 
00038 #define GNC_ID_OWNER   "gncOwner"
00039 
00040 typedef enum
00041 {
00042     GNC_OWNER_NONE ,
00043     GNC_OWNER_UNDEFINED ,
00044     GNC_OWNER_CUSTOMER ,
00045     GNC_OWNER_JOB ,
00046     GNC_OWNER_VENDOR ,
00047     GNC_OWNER_EMPLOYEE ,
00048 } GncOwnerType;
00049 
00050 #include "qof.h"
00051 #include "gncCustomer.h"
00052 #include "gncJob.h"
00053 #include "gncVendor.h"
00054 #include "gncEmployee.h"
00055 #include "gncInvoice.h"
00056 #include "Account.h"
00057 #include "gnc-lot.h"
00058 
00067 QofIdTypeConst qofOwnerGetType(const GncOwner *owner);
00069 QofInstance* qofOwnerGetOwner (const GncOwner *owner);
00071 void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
00075 gboolean GNC_IS_OWNER (QofInstance *ent);
00076 
00079 QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t);
00080 
00081 gboolean
00082 gncOwnerRegister(void);
00083 
00086 #ifndef SWIG
00087 
00089 struct _gncOwner
00090 {
00091     GncOwnerType     type;      
00092     union
00093     {
00094         gpointer       undefined;
00095         GncCustomer *  customer;
00096         GncJob *       job;
00097         GncVendor *    vendor;
00098         GncEmployee *  employee;
00099     } owner;                   
00100     gpointer         qof_temp; 
00101 };
00102 
00103 #endif /* SWIG */
00104 
00108 void gncOwnerInitUndefined (GncOwner *owner, gpointer obj);
00109 void gncOwnerInitCustomer (GncOwner *owner, GncCustomer *customer);
00110 void gncOwnerInitJob (GncOwner *owner, GncJob *job);
00111 void gncOwnerInitVendor (GncOwner *owner, GncVendor *vendor);
00112 void gncOwnerInitEmployee (GncOwner *owner, GncEmployee *employee);
00118 GncOwnerType gncOwnerGetType (const GncOwner *owner);
00121 gboolean gncOwnerIsValid (const GncOwner *owner);
00122 
00125 gpointer gncOwnerGetUndefined (const GncOwner *owner);
00128 GncCustomer * gncOwnerGetCustomer (const GncOwner *owner);
00131 GncJob * gncOwnerGetJob (const GncOwner *owner);
00134 GncVendor * gncOwnerGetVendor (const GncOwner *owner);
00137 GncEmployee * gncOwnerGetEmployee (const GncOwner *owner);
00138 
00139 const char * gncOwnerGetID (const GncOwner *owner);
00140 const char * gncOwnerGetName (const GncOwner *owner);
00141 GncAddress * gncOwnerGetAddr (const GncOwner *owner);
00142 gboolean gncOwnerGetActive (const GncOwner *owner);
00143 gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner);
00149 void gncOwnerSetActive (const GncOwner *owner, gboolean active);
00152 void gncOwnerCopy (const GncOwner *src, GncOwner *dest);
00153 
00161 gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
00164 int gncOwnerGCompareFunc (const GncOwner *a, const GncOwner *b);
00166 int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
00170 const GncGUID * gncOwnerGetGUID (const GncOwner *owner);
00171 GncGUID gncOwnerRetGUID (GncOwner *owner);
00172 
00177 const GncOwner * gncOwnerGetEndOwner (const GncOwner *owner);
00178 const GncGUID * gncOwnerGetEndGUID (const GncOwner *owner);
00179 
00181 void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot);
00182 
00185 gboolean gncOwnerLotMatchOwnerFunc (GNCLot *lot, gpointer user_data);
00186 
00191 gint gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB);
00192 
00196 gboolean gncOwnerGetOwnerFromLot (GNCLot *lot, GncOwner *owner);
00197 
00198 gboolean gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType type, GncGUID *guid);
00199 
00201 KvpFrame* gncOwnerGetSlots(GncOwner* owner);
00202 
00210 GNCLot *
00211 gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction *txn,
00212                           Account *posted_acc, Account *xfer_acc,
00213                           gnc_numeric amount, gnc_numeric exch, Timespec date,
00214                           const char *memo, const char *num);
00215 
00250 void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots);
00251 
00263 void
00264 gncOwnerApplyPayment (const GncOwner *owner, Transaction *txn, GList *lots,
00265                       Account *posted_acc, Account *xfer_acc,
00266                       gnc_numeric amount, gnc_numeric exch, Timespec date,
00267                       const char *memo, const char *num);
00268 
00270 GList * gncOwnerGetAccountTypesList (const GncOwner *owner);
00271 
00273 GList * gncOwnerGetCommoditiesList (const GncOwner *owner);
00274 
00275 
00279 gnc_numeric
00280 gncOwnerGetBalanceInCurrency (const GncOwner *owner,
00281                               const gnc_commodity *report_currency);
00282 
00283 #define OWNER_TYPE        "type"
00284 #define OWNER_TYPE_STRING "type-string"  
00285 #define OWNER_CUSTOMER    "customer"
00286 #define OWNER_JOB         "job"
00287 #define OWNER_VENDOR      "vendor"
00288 #define OWNER_EMPLOYEE    "employee"
00289 #define OWNER_PARENT      "parent"
00290 #define OWNER_PARENTG     "parent-guid"
00291 #define OWNER_NAME        "name"
00292 
00293 #define OWNER_FROM_LOT    "owner-from-lot"
00294 
00300 GncOwner * gncOwnerNew (void);
00301 void gncOwnerFree (GncOwner *owner);
00302 
00303 
00309 void gncOwnerBeginEdit (GncOwner *owner);
00310 void gncOwnerDestroy (GncOwner *owner);
00311 
00312 #endif /* GNC_OWNER_H_ */
00313 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines