GnuCash
5.6-150-g038405b370+
|
One often needs to know that the item 'bought' in one transaction is the same one as the item 'sold' in a different transaction. More...
Files | |
file | gnc-lot.h |
Data Structures | |
struct | GncLotClass |
Macros | |
#define | GNCLotClass GncLotClass |
#define | GNC_TYPE_LOT (gnc_lot_get_type ()) |
#define | GNC_LOT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_LOT, GNCLot)) |
#define | GNC_LOT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_LOT, GNCLotClass)) |
#define | GNC_IS_LOT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_LOT)) |
#define | GNC_IS_LOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_LOT)) |
#define | GNC_LOT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_LOT, GNCLotClass)) |
#define | gnc_lot_get_guid(X) qof_entity_get_guid(QOF_INSTANCE(X)) |
#define | LOT_IS_CLOSED "is-closed?" |
#define | LOT_BALANCE "balance" |
#define | LOT_TITLE "lot-title" |
#define | LOT_NOTES "notes" |
Functions | |
GType | gnc_lot_get_type (void) |
GNCLot * | gnc_lot_new (QofBook *) |
void | gnc_lot_destroy (GNCLot *) |
GNCLot * | gnc_lot_lookup (const GncGUID *guid, QofBook *book) |
QofBook * | gnc_lot_get_book (GNCLot *) |
void | gnc_lot_begin_edit (GNCLot *lot) |
void | gnc_lot_commit_edit (GNCLot *lot) |
void | gnc_lot_add_split (GNCLot *, Split *) |
Adds a split to this lot. More... | |
void | gnc_lot_remove_split (GNCLot *, Split *) |
Adds a split from this lot. | |
SplitList * | gnc_lot_get_split_list (const GNCLot *) |
Returns a list of all the splits in this lot. More... | |
gint | gnc_lot_count_splits (const GNCLot *) |
Account * | gnc_lot_get_account (const GNCLot *) |
Returns the account with which this lot is associated. | |
void | gnc_lot_set_account (GNCLot *, Account *) |
GncInvoice * | gnc_lot_get_cached_invoice (const GNCLot *lot) |
Returns the invoice with which this lot is associated. | |
void | gnc_lot_set_cached_invoice (GNCLot *lot, GncInvoice *invoice) |
gnc_numeric | gnc_lot_get_balance (GNCLot *) |
Returns the lot balance. More... | |
void | gnc_lot_get_balance_before (const GNCLot *, const Split *, gnc_numeric *, gnc_numeric *) |
Computes both the balance and value in the lot considering only splits in transactions prior to the one containing the given split or other splits in the same transaction. More... | |
gboolean | gnc_lot_is_closed (GNCLot *) |
Returns closed status of the given lot. More... | |
Split * | gnc_lot_get_earliest_split (GNCLot *lot) |
Convenience routine to identify the earliest date in the lot. More... | |
Split * | gnc_lot_get_latest_split (GNCLot *lot) |
Convenience routineto identify the date this lot was closed. More... | |
void | gnc_lot_set_closed_unknown (GNCLot *) |
Reset closed flag so that it will be recalculated. More... | |
GNCLot * | gnc_lot_make_default (Account *acc) |
One often needs to know that the item 'bought' in one transaction is the same one as the item 'sold' in a different transaction.
Lots are used to make this association. One Lot holds all of the splits that involve the same item. A lot is typically formed when the item is bought, and is closed when the item is sold out. A lot need not be a single item, it can be a quantity of the same thing e.g. 500 gallons of paint (sold off a few gallons at a time).
Lots are required to correctly implement invoices, inventory, depreciation and stock market investment gains. See the file src/doc/lots.txt for a detailed implementation overview.
A lot is "closed" when the number of items in the lot has gone to zero. It is very easy to compute the gains/losses for a closed lot: it is the sum-total of the values of the items put into/taken out of the lot. (Realized) Gains on still-open lots can be computed by pro-rating the purchase prices.
Lots are nothing more than a collection or grouping of splits in an account. All of the splits in a lot must belong to the same account; there's no mix-n-match. Thus, in this sense, a lot belongs to an account as well.
Lots have an implicit "opening date": the date of the earliest split in the lot. The "close date" is the date of the split that brought the lot item balance down to zero.
void gnc_lot_add_split | ( | GNCLot * | , |
Split * | |||
) |
Adds a split to this lot.
Definition at line 594 of file gnc-lot.cpp.
gnc_numeric gnc_lot_get_balance | ( | GNCLot * | ) |
Returns the lot balance.
This balance will be expressed in the lot account's commodity.
Definition at line 502 of file gnc-lot.cpp.
void gnc_lot_get_balance_before | ( | const GNCLot * | , |
const Split * | , | ||
gnc_numeric * | , | ||
gnc_numeric * | |||
) |
Computes both the balance and value in the lot considering only splits in transactions prior to the one containing the given split or other splits in the same transaction.
The first return value is the amount and the second is the value.
Definition at line 544 of file gnc-lot.cpp.
Split* gnc_lot_get_earliest_split | ( | GNCLot * | lot | ) |
Convenience routine to identify the earliest date in the lot.
It loops over all of the splits in the lot, and returns the split with the earliest split->transaction->date_posted. It may not necessarily identify the lot opening split.
Definition at line 673 of file gnc-lot.cpp.
Split* gnc_lot_get_latest_split | ( | GNCLot * | lot | ) |
Convenience routineto identify the date this lot was closed.
It simply loops over all of the splits in the lot, and returns the split with the latest split->transaction->date_posted.
Definition at line 685 of file gnc-lot.cpp.
SplitList* gnc_lot_get_split_list | ( | const GNCLot * | ) |
Returns a list of all the splits in this lot.
This GList is owned and managed by the lot.
Definition at line 425 of file gnc-lot.cpp.
gboolean gnc_lot_is_closed | ( | GNCLot * | ) |
Returns closed status of the given lot.
A lot is closed if its balance is zero. This routine is faster than using gnc_lot_get_balance() because once the balance goes to zero, this fact is cached.
Definition at line 367 of file gnc-lot.cpp.
GNCLot* gnc_lot_make_default | ( | Account * | acc | ) |
Definition at line 780 of file gnc-lot.cpp.
void gnc_lot_set_closed_unknown | ( | GNCLot * | ) |
Reset closed flag so that it will be recalculated.
Definition at line 414 of file gnc-lot.cpp.