GnuCash
2.6.99
|
Files | |
file | gncOwner.h |
Business Interface: Object OWNERs. | |
Data Structures | |
struct | _gncOwner |
struct | GncOwner |
Macros | |
#define | GNC_ID_OWNER "gncOwner" |
#define | OWNER_TYPE "type" |
#define | OWNER_TYPE_STRING "type-string" |
#define | OWNER_CUSTOMER "customer" |
#define | OWNER_JOB "job" |
#define | OWNER_VENDOR "vendor" |
#define | OWNER_EMPLOYEE "employee" |
#define | OWNER_PARENT "parent" |
#define | OWNER_PARENTG "parent-guid" |
#define | OWNER_NAME "name" |
#define | OWNER_FROM_LOT "owner-from-lot" |
Typedefs | |
typedef struct _gncOwner | GncOwner |
Enumerations | |
enum | GncOwnerType { GNC_OWNER_NONE, GNC_OWNER_UNDEFINED, GNC_OWNER_CUSTOMER, GNC_OWNER_JOB, GNC_OWNER_VENDOR, GNC_OWNER_EMPLOYEE } |
Functions | |
void | gncOwnerCopy (const GncOwner *src, GncOwner *dest) |
const GncGUID * | gncOwnerGetGUID (const GncOwner *owner) |
GncGUID | gncOwnerRetGUID (GncOwner *owner) |
const GncOwner * | gncOwnerGetEndOwner (const GncOwner *owner) |
const GncGUID * | gncOwnerGetEndGUID (const GncOwner *owner) |
void | gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot) |
gboolean | gncOwnerLotMatchOwnerFunc (GNCLot *lot, gpointer user_data) |
gint | gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB) |
gboolean | gncOwnerGetOwnerFromLot (GNCLot *lot, GncOwner *owner) |
gboolean | gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType type, GncGUID *guid) |
GNCLot * | gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction *txn, Account *posted_acc, Account *xfer_acc, gnc_numeric amount, gnc_numeric exch, Timespec date, const char *memo, const char *num) |
void | gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots) |
void | gncOwnerApplyPayment (const GncOwner *owner, Transaction *txn, GList *lots, Account *posted_acc, Account *xfer_acc, gnc_numeric amount, gnc_numeric exch, Timespec date, const char *memo, const char *num, gboolean auto_pay) |
Split * | gncOwnerFindOffsettingSplit (GNCLot *pay_lot, gnc_numeric target_value) |
gboolean | gncOwnerReduceSplitTo (Split *split, gnc_numeric target_value) |
void | gncOwnerSetLotLinkMemo (Transaction *ll_txn) |
GList * | gncOwnerGetAccountTypesList (const GncOwner *owner) |
GList * | gncOwnerGetCommoditiesList (const GncOwner *owner) |
gnc_numeric | gncOwnerGetBalanceInCurrency (const GncOwner *owner, const gnc_commodity *report_currency) |
GncOwner * | gncOwnerNew (void) |
void | gncOwnerFree (GncOwner *owner) |
void | gncOwnerBeginEdit (GncOwner *owner) |
void | gncOwnerCommitEdit (GncOwner *owner) |
void | gncOwnerDestroy (GncOwner *owner) |
QOF handling | |
Whilst GncOwner is not a formal QOF object, these functions are still expected to be useful in making GncOwner transparent to QOF as they can be used by objects like GncInvoice. | |
QofIdTypeConst | qofOwnerGetType (const GncOwner *owner) |
QofInstance * | qofOwnerGetOwner (const GncOwner *owner) |
void | qofOwnerSetEntity (GncOwner *owner, QofInstance *ent) |
gboolean | GNC_IS_OWNER (QofInstance *ent) |
QofIdTypeConst | gncOwnerTypeToQofIdType (GncOwnerType t) |
gboolean | gncOwnerRegister (void) |
Setup routines | |
void | gncOwnerInitUndefined (GncOwner *owner, gpointer obj) |
void | gncOwnerInitCustomer (GncOwner *owner, GncCustomer *customer) |
void | gncOwnerInitJob (GncOwner *owner, GncJob *job) |
void | gncOwnerInitVendor (GncOwner *owner, GncVendor *vendor) |
void | gncOwnerInitEmployee (GncOwner *owner, GncEmployee *employee) |
Get routines. | |
GncOwnerType | gncOwnerGetType (const GncOwner *owner) |
gboolean | gncOwnerIsValid (const GncOwner *owner) |
gpointer | gncOwnerGetUndefined (const GncOwner *owner) |
GncCustomer * | gncOwnerGetCustomer (const GncOwner *owner) |
GncJob * | gncOwnerGetJob (const GncOwner *owner) |
GncVendor * | gncOwnerGetVendor (const GncOwner *owner) |
GncEmployee * | gncOwnerGetEmployee (const GncOwner *owner) |
const char * | gncOwnerGetID (const GncOwner *owner) |
const char * | gncOwnerGetName (const GncOwner *owner) |
GncAddress * | gncOwnerGetAddr (const GncOwner *owner) |
gboolean | gncOwnerGetActive (const GncOwner *owner) |
gnc_commodity * | gncOwnerGetCurrency (const GncOwner *owner) |
Set routines. | |
void | gncOwnerSetActive (const GncOwner *owner, gboolean active) |
Comparison routines. | |
gboolean | gncOwnerEqual (const GncOwner *a, const GncOwner *b) |
int | gncOwnerGCompareFunc (const GncOwner *a, const GncOwner *b) |
int | gncOwnerCompare (const GncOwner *a, const GncOwner *b) |
#define OWNER_TYPE_STRING "type-string" |
Allows the type to be handled externally.
Definition at line 309 of file gncOwner.h.
gboolean GNC_IS_OWNER | ( | QofInstance * | ent | ) |
Check if entity is an owner kind. This function conveniently imitates the various GNC_IS_ checks on the other gnucash objects even though an owner is not really a true object.
Definition at line 330 of file gncOwner.c.
void gncOwnerApplyPayment | ( | const GncOwner * | owner, |
Transaction * | txn, | ||
GList * | lots, | ||
Account * | posted_acc, | ||
Account * | xfer_acc, | ||
gnc_numeric | amount, | ||
gnc_numeric | exch, | ||
Timespec | date, | ||
const char * | memo, | ||
const char * | num, | ||
gboolean | auto_pay | ||
) |
A convenience function to apply a payment to the owner. It creates a lot for a payment, optionally based on an existing transaction and then tries to balance it with the list of document/payment lots passed in. If not lots were given, all open lots for the owner are considered.
This code is actually a convenience wrapper around gncOwnerCreatePaymentLot and gncOwnerAutoApplyPaymentsWithLots. See their descriptions for more details on what happens exactly.
Definition at line 1348 of file gncOwner.c.
Attach an owner to a lot
Definition at line 600 of file gncOwner.c.
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 between them. This can be used to automatically link invoices to payments (to "mark" invoices as paid) or to credit notes or the other way around.
The function starts with the first lot in the list and tries to create balancing transactions to the remainder of the lots in the list. If it reaches the end of the list, it will find the next still open lot in the list and tries to balance it with all lots that follow it (the ones that precede it are either already closed or not suitable or they would have been processed in a previous iteration).
By intelligently sorting the list of lots, you can play with the order of precedence in which the lots should be processed. For example, by sorting the oldest invoice lots first, the code will attempt to balance these first.
Some restrictions:
Definition at line 1199 of file gncOwner.c.
void gncOwnerBeginEdit | ( | GncOwner * | owner | ) |
These are convenience wrappers around gnc{Vender,Customer,Job,Employee}* functions. This allows you to begin edit, destroy commit edit an owner without knowing its type.
Definition at line 73 of file gncOwner.c.
Sort on name
Definition at line 568 of file gncOwner.c.
GNCLot* gncOwnerCreatePaymentLot | ( | const GncOwner * | owner, |
Transaction * | txn, | ||
Account * | posted_acc, | ||
Account * | xfer_acc, | ||
gnc_numeric | amount, | ||
gnc_numeric | exch, | ||
Timespec | date, | ||
const char * | memo, | ||
const char * | num | ||
) |
Create a lot for a payment to the owner using the other parameters passed in. If a transaction is set, this transaction will be reused if possible (meaning, if the transaction currency matches the owner's currency and if the transaction has (at least?) one split in the transfer account).
Definition at line 701 of file gncOwner.c.
Assess equality by checking
Definition at line 382 of file gncOwner.c.
Split* gncOwnerFindOffsettingSplit | ( | GNCLot * | pay_lot, |
gnc_numeric | target_value | ||
) |
Helper function to find a split in lot that best offsets target_value Obviously it should be of opposite sign. If there are more splits of opposite sign the following criteria are used in order of preference:
Definition at line 848 of file gncOwner.c.
Same as gncOwnerEqual, but returns 0 if equal to be used as a GList custom compare function
Definition at line 389 of file gncOwner.c.
GList* gncOwnerGetAccountTypesList | ( | const GncOwner * | owner | ) |
Returns a GList of account-types based on the owner type
Definition at line 1383 of file gncOwner.c.
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 at line 1417 of file gncOwner.c.
GList* gncOwnerGetCommoditiesList | ( | const GncOwner * | owner | ) |
Returns a GList of currencies associated with the owner
Definition at line 1401 of file gncOwner.c.
GncCustomer* gncOwnerGetCustomer | ( | const GncOwner * | owner | ) |
If the given owner is of type GNC_OWNER_CUSTOMER, returns the pointer to the customer object. Otherwise returns NULL.
Definition at line 347 of file gncOwner.c.
GncEmployee* gncOwnerGetEmployee | ( | const GncOwner * | owner | ) |
If the given owner is of type GNC_OWNER_EMPLOYEE, returns the pointer to the employee object. Otherwise returns NULL.
Definition at line 368 of file gncOwner.c.
Get the "parent" Owner or GncGUID thereof. The "parent" owner is the Customer or Vendor, or the Owner of a Job
Definition at line 550 of file gncOwner.c.
Get the GncGUID of the immediate owner
Definition at line 496 of file gncOwner.c.
If the given owner is of type GNC_OWNER_JOB, returns the pointer to the job object. Otherwise returns NULL.
Definition at line 354 of file gncOwner.c.
Get the owner from the lot. If an owner is found in the lot, fill in "owner" and return TRUE. Otherwise return FALSE.
Definition at line 614 of file gncOwner.c.
GncOwnerType gncOwnerGetType | ( | const GncOwner * | owner | ) |
Returns the GncOwnerType of this owner. (Not to be confused with qofOwnerGetType().)
Definition at line 201 of file gncOwner.c.
gpointer gncOwnerGetUndefined | ( | const GncOwner * | owner | ) |
If the given owner is of type GNC_OWNER_UNDEFINED, returns the undefined pointer, which is usually NULL. Otherwise returns NULL.
Definition at line 340 of file gncOwner.c.
If the given owner is of type GNC_OWNER_VENDOR, returns the pointer to the vendor object. Otherwise returns NULL.
Definition at line 361 of file gncOwner.c.
gboolean gncOwnerIsValid | ( | const GncOwner * | owner | ) |
Returns TRUE if the given owner is one of the valid objects. Returns FALSE if the owner is (still) undefined, or if it is NULL.
Definition at line 650 of file gncOwner.c.
gboolean gncOwnerLotMatchOwnerFunc | ( | GNCLot * | lot, |
gpointer | user_data | ||
) |
Helper function used to filter a list of lots by owner.
Definition at line 657 of file gncOwner.c.
Helper function used to sort lots by date. If the lot is linked to an invoice, use the invoice posted date, otherwise use the lot's opened date.
Definition at line 679 of file gncOwner.c.
GncOwner* gncOwnerNew | ( | void | ) |
These two functions are mainly for the convenience of scheme code. Normal C code has no need to ever use these two functions, and rather can just use a GncOwner directly and just pass around a pointer to it.
Definition at line 58 of file gncOwner.c.
gboolean gncOwnerReduceSplitTo | ( | Split * | split, |
gnc_numeric | target_value | ||
) |
Helper function to reduce the value of a split to target_value. To make sure the split's parent transaction remains balanced a second split will be created with the remainder. Similarly if the split was part of a (business) lot, the remainder split will be added to the same lot to keep the lot's balance unchanged.
Definition at line 914 of file gncOwner.c.
void gncOwnerSetLotLinkMemo | ( | Transaction * | ll_txn | ) |
To help a user understand what a lot link transaction does, we set the memo to name all documents involved in the link. The function below calculates this memo and sets it for all splits in the lot link transaction.
Definition at line 946 of file gncOwner.c.
QofIdTypeConst gncOwnerTypeToQofIdType | ( | GncOwnerType | t | ) |
Returns the QofIdType of the given GncOwnerType, or NULL if no suitable one exists.
Definition at line 213 of file gncOwner.c.
QofInstance* qofOwnerGetOwner | ( | const GncOwner * | owner | ) |
return the owner itself as an entity.
Definition at line 253 of file gncOwner.c.
QofIdTypeConst qofOwnerGetType | ( | const GncOwner * | owner | ) |
return the type for the collection.
Definition at line 208 of file gncOwner.c.
void qofOwnerSetEntity | ( | GncOwner * | owner, |
QofInstance * | ent | ||
) |
set the owner from the entity.
Definition at line 297 of file gncOwner.c.