GnuCash  4.8a-132-gcdaeb421d+
Files | Functions

This file implements Accounting Policy. More...

Files

file  policy.h
 Implement Accounting Policy.
 

Functions

GList * gnc_get_valid_policy_list (void)
 Valid Policy List Provides a glist of implemented policies. More...
 
gboolean gnc_valid_policy_name (const gchar *policy_name)
 Valid Policy Name Uses the Valid Policy List to determine if a policy name is valid.
 
const char * PolicyGetName (const GNCPolicy *pcy)
 
const char * PolicyGetDescription (const GNCPolicy *pcy)
 
const char * PolicyGetHint (const GNCPolicy *pcy)
 
GNCPolicy * xaccGetFIFOPolicy (void)
 First-in, First-out Policy This policy will create FIFO Lots. More...
 
GNCPolicy * xaccGetLIFOPolicy (void)
 Last-in, Last-out Policy This policy will create LIFO Lots. More...
 

Detailed Description

This file implements Accounting Policy.

The Accounting Policy determines how Splits are assigned to Lots. The contents of a Lot determines the Gains on that Lot. The default policy is the FIFO policy: the first thing bought is also the first thing sold.

Function Documentation

◆ gnc_get_valid_policy_list()

GList* gnc_get_valid_policy_list ( void  )

Valid Policy List Provides a glist of implemented policies.

List must be freed with g_list_free().

Definition at line 67 of file policy.c.

68 {
69  GList *return_list = NULL;
70 
71 /* return_list = g_list_prepend (return_list, xaccGetManualPolicy());
72  return_list = g_list_prepend (return_list, xaccGetAveragePolicy()); */
73  return_list = g_list_prepend (return_list, xaccGetLIFOPolicy());
74  return_list = g_list_prepend (return_list, xaccGetFIFOPolicy());
75 
76  return return_list;
77 }
GNCPolicy * xaccGetLIFOPolicy(void)
Last-in, Last-out Policy This policy will create LIFO Lots.
Definition: policy.c:308
GNCPolicy * xaccGetFIFOPolicy(void)
First-in, First-out Policy This policy will create FIFO Lots.
Definition: policy.c:251

◆ xaccGetFIFOPolicy()

GNCPolicy* xaccGetFIFOPolicy ( void  )

First-in, First-out Policy This policy will create FIFO Lots.

FIFO Lots have the following properties: – The lot is started with the earliest posted split that isn't a part of another lot already. – Splits are added to the lot in date order, with earliest splits added first. – All splits in the lot share the same transaction currency as the split that opened the lot (if book-currency book option selected, this will always be book currency).

Definition at line 251 of file policy.c.

252 {
253  static GNCPolicy *pcy = NULL;
254 
255  if (!pcy)
256  {
257  pcy = g_new (GNCPolicy, 1);
258  pcy->name = FIFO_POLICY;
259  pcy->description = FIFO_POLICY_DESC;
260  pcy->hint = FIFO_POLICY_HINT;
261  pcy->PolicyGetLot = FIFOPolicyGetLot;
262  pcy->PolicyGetSplit = FIFOPolicyGetSplit;
263  pcy->PolicyGetLotOpening = FIFOPolicyGetLotOpening;
264  pcy->PolicyIsOpeningSplit = FIFOPolicyIsOpeningSplit;
265  }
266  return pcy;
267 }

◆ xaccGetLIFOPolicy()

GNCPolicy* xaccGetLIFOPolicy ( void  )

Last-in, Last-out Policy This policy will create LIFO Lots.

LIFO Lots have the following properties: – The lot is started with the latest posted split that isn't a part of another lot already. – Splits are added to the lot in date order, with latest splits added first. – All splits in the lot share the same transaction currency as the split that opened the lot (if book-currency book option selected, this will always be book currency).

Definition at line 308 of file policy.c.

309 {
310  static GNCPolicy *pcy = NULL;
311 
312  if (!pcy)
313  {
314  pcy = g_new (GNCPolicy, 1);
315  pcy->name = LIFO_POLICY;
316  pcy->description = LIFO_POLICY_DESC;
317  pcy->hint = LIFO_POLICY_HINT;
318  pcy->PolicyGetLot = LIFOPolicyGetLot;
319  pcy->PolicyGetSplit = LIFOPolicyGetSplit;
320  pcy->PolicyGetLotOpening = LIFOPolicyGetLotOpening;
321  pcy->PolicyIsOpeningSplit = LIFOPolicyIsOpeningSplit;
322  }
323  return pcy;
324 }