GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Files | Macros | Typedefs | Enumerations | Functions

Files

file  gncEntry.h
 Business Entry Interface.
 

Macros

#define GNC_ID_ENTRY   "gncEntry"
 
#define GNC_TYPE_ENTRY   (gnc_entry_get_type ())
 
#define GNC_ENTRY(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry))
 
#define GNC_ENTRY_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass))
 
#define GNC_IS_ENTRY(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY))
 
#define GNC_IS_ENTRY_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY))
 
#define GNC_ENTRY_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass))
 
#define ENTRY_DATE   "date"
 
#define ENTRY_DATE_ENTERED   "date-entered"
 
#define ENTRY_DESC   "desc"
 
#define ENTRY_ACTION   "action"
 
#define ENTRY_NOTES   "notes"
 
#define ENTRY_QTY   "qty"
 
#define ENTRY_IPRICE   "iprice"
 
#define ENTRY_IACCT   "invoice-account"
 
#define ENTRY_BACCT   "bill-account"
 
#define ENTRY_BPRICE   "bprice"
 
#define ENTRY_BILLABLE   "billable?"
 
#define ENTRY_BILLTO   "bill-to"
 
#define ENTRY_ORDER   "order"
 
#define ENTRY_INVOICE   "invoice"
 
#define ENTRY_BILL   "bill"
 
#define ENTRY_INV_DISC_TYPE   "discount-type"
 
#define ENTRY_INV_DISC_HOW   "discount-method"
 
#define ENTRY_INV_TAXABLE   "invoice-taxable"
 
#define ENTRY_BILL_TAXABLE   "bill-taxable"
 
#define ENTRY_INV_TAX_INC   "invoice-tax-included"
 
#define ENTRY_BILL_TAX_INC   "bill-tax-included"
 
#define ENTRY_INV_DISCOUNT   "invoice-discount"
 
#define ENTRY_BILL_PAY_TYPE   "bill-payment-type"
 
#define gncEntryGetGUID(x)   qof_instance_get_guid(QOF_INSTANCE(x))
 

Typedefs

typedef struct _gncEntry GncEntry
 
typedef struct _gncEntryClass GncEntryClass
 

Enumerations

enum  GncEntryPaymentType { GNC_PAYMENT_CASH = 1, GNC_PAYMENT_CARD }
 
enum  GncDiscountHow { GNC_DISC_PRETAX = 1, GNC_DISC_SAMETIME, GNC_DISC_POSTTAX }
 

Functions

GType gnc_entry_get_type (void)
 
const char * gncEntryDiscountHowToString (GncDiscountHow how)
 
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how)
 
const char * gncEntryPaymentTypeToString (GncEntryPaymentType type)
 
gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type)
 
void gncEntryCopy (const GncEntry *src, GncEntry *dest, gboolean add_entry)
 
GncOrdergncEntryGetOrder (const GncEntry *entry)
 
GncInvoicegncEntryGetInvoice (const GncEntry *entry)
 
GncInvoicegncEntryGetBill (const GncEntry *entry)
 
gboolean gncEntryIsOpen (const GncEntry *entry)
 
void gncEntryBeginEdit (GncEntry *entry)
 
void gncEntryCommitEdit (GncEntry *entry)
 
int gncEntryCompare (const GncEntry *a, const GncEntry *b)
 

Create/Destroy Functions

GncEntrygncEntryCreate (QofBook *book)
 
void gncEntryDestroy (GncEntry *entry)
 

Generic (shared) data

void gncEntrySetDateGDate (GncEntry *entry, const GDate *date)
 
void gncEntrySetDate (GncEntry *entry, Timespec date)
 
void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
 
void gncEntrySetDescription (GncEntry *entry, const char *desc)
 
void gncEntrySetAction (GncEntry *entry, const char *action)
 
void gncEntrySetNotes (GncEntry *entry, const char *notes)
 
void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity)
 
void gncEntrySetDocQuantity (GncEntry *entry, gnc_numeric quantity, gboolean is_cn)
 
GDate gncEntryGetDateGDate (const GncEntry *entry)
 
Timespec gncEntryGetDate (const GncEntry *entry)
 
Timespec gncEntryGetDateEntered (const GncEntry *entry)
 
const char * gncEntryGetDescription (const GncEntry *entry)
 
const char * gncEntryGetAction (const GncEntry *entry)
 
const char * gncEntryGetNotes (const GncEntry *notes)
 
gnc_numeric gncEntryGetQuantity (const GncEntry *entry)
 
gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn)
 

Customer Invoices

void gncEntrySetInvAccount (GncEntry *entry, Account *acc)
 
void gncEntrySetInvPrice (GncEntry *entry, gnc_numeric price)
 
void gncEntrySetInvTaxable (GncEntry *entry, gboolean taxable)
 
void gncEntrySetInvTaxIncluded (GncEntry *entry, gboolean tax_included)
 
void gncEntrySetInvTaxTable (GncEntry *entry, GncTaxTable *table)
 
void gncEntrySetInvDiscount (GncEntry *entry, gnc_numeric discount)
 
void gncEntrySetInvDiscountType (GncEntry *entry, GncAmountType type)
 
void gncEntrySetInvDiscountHow (GncEntry *entry, GncDiscountHow how)
 
void qofEntrySetInvDiscType (GncEntry *entry, const char *type)
 
void qofEntrySetInvDiscHow (GncEntry *entry, const char *type)
 
AccountgncEntryGetInvAccount (const GncEntry *entry)
 
gnc_numeric gncEntryGetInvPrice (const GncEntry *entry)
 
gnc_numeric gncEntryGetInvDiscount (const GncEntry *entry)
 
GncAmountType gncEntryGetInvDiscountType (const GncEntry *entry)
 
GncDiscountHow gncEntryGetInvDiscountHow (const GncEntry *entry)
 
char * qofEntryGetInvDiscType (const GncEntry *entry)
 
char * qofEntryGetInvDiscHow (const GncEntry *entry)
 
gboolean gncEntryGetInvTaxable (const GncEntry *entry)
 
gboolean gncEntryGetInvTaxIncluded (const GncEntry *entry)
 
GncTaxTablegncEntryGetInvTaxTable (const GncEntry *entry)
 

Vendor Bills (and Employee Expenses)

void gncEntrySetBillAccount (GncEntry *entry, Account *acc)
 
void gncEntrySetBillPrice (GncEntry *entry, gnc_numeric price)
 
void gncEntrySetBillTaxable (GncEntry *entry, gboolean taxable)
 
void gncEntrySetBillTaxIncluded (GncEntry *entry, gboolean tax_included)
 
void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table)
 
void gncEntrySetBillable (GncEntry *entry, gboolean billable)
 
void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto)
 
AccountgncEntryGetBillAccount (const GncEntry *entry)
 
gnc_numeric gncEntryGetBillPrice (const GncEntry *entry)
 
gboolean gncEntryGetBillTaxable (const GncEntry *entry)
 
gboolean gncEntryGetBillTaxIncluded (const GncEntry *entry)
 
GncTaxTablegncEntryGetBillTaxTable (const GncEntry *entry)
 
gboolean gncEntryGetBillable (const GncEntry *entry)
 
GncOwnergncEntryGetBillTo (GncEntry *entry)
 
GncEntryPaymentType gncEntryGetBillPayment (const GncEntry *entry)
 

employee-stuff

void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type)
 

Getting Values

An entry has three important values:

  • entry value: the amount the merchant gets
  • tax value: the amount the government gets
  • discount value: the amount the customer saved

These values can be retrieved in several variants. Depending on how they will be used some sign reversals can be applied on the values:

  • Doc value: the value as listed on the document. This is usually a positive value, unless the document was a negative invoice/bill or negative credit note. Since credit note entry values are stored negatively internally, they will be sign-reversed before returning them.
  • Bal value: the value as it will impact the balance. Customer invoices and vendor credit notes have a positive influence on the balance, so these values will be positive. For vendor bills and customer credit notes, the values will be negative.

For tax there are TaxValue and TaxValues variants: the first one returns to total tax value for this entry, meaning the sum of all individual taxes. The second one returns a list of all the individual tax values for this entry. This list holds unrounded values only, there's no variant with rounded values.

Note that this list is not owned by the entry. When no longer needed, it should be freed with gncAccountValueDestroy.

Finally, there are rounded and unrounded variants of most of these functions.

typedef GList AccountValueList
 
gnc_numeric gncEntryGetDocValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
 
gnc_numeric gncEntryGetDocTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
 
AccountValueList * gncEntryGetDocTaxValues (GncEntry *entry, gboolean is_cust_doc, gboolean is_cn)
 
gnc_numeric gncEntryGetDocDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc, gboolean is_cn)
 
gnc_numeric gncEntryGetBalValue (GncEntry *entry, gboolean round, gboolean is_cust_doc)
 
gnc_numeric gncEntryGetBalTaxValue (GncEntry *entry, gboolean round, gboolean is_cust_doc)
 
AccountValueList * gncEntryGetBalTaxValues (GncEntry *entry, gboolean is_cust_doc)
 
gnc_numeric gncEntryGetBalDiscountValue (GncEntry *entry, gboolean round, gboolean is_cust_doc)
 
void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price, const GncTaxTable *tax_table, gboolean tax_included, gnc_numeric discount, GncAmountType discount_type, GncDiscountHow discount_how, int SCU, gnc_numeric *value, gnc_numeric *discount_value, GList **tax_values)
 

Detailed Description

Function Documentation

void gncEntryComputeValue ( gnc_numeric  qty,
gnc_numeric  price,
const GncTaxTable tax_table,
gboolean  tax_included,
gnc_numeric  discount,
GncAmountType  discount_type,
GncDiscountHow  discount_how,
int  SCU,
gnc_numeric value,
gnc_numeric discount_value,
GList **  tax_values 
)

Compute the Entry value, tax_value, and discount_value, based on the quantity, price, discount, tax_-table, and types. The value is the amount the merchant gets, the taxes are what the gov't gets, and the discount is how much the customer saved. The SCU is the target denominator of the value and tax – it should be the account or commodity SCU of the target.

The return values are NOT rounded.

The tax_values list is owned by the entry and will be destroyed automatically, so use it quickly.

Definition at line 1102 of file gncEntry.c.

1108 {
1109  gnc_numeric aggregate;
1110  gnc_numeric pretax;
1111  gnc_numeric result;
1112  gnc_numeric tax;
1113  gnc_numeric percent = gnc_numeric_create (100, 1);
1114  gnc_numeric tpercent = gnc_numeric_zero ();
1115  gnc_numeric tvalue = gnc_numeric_zero ();
1116 
1117  GList * entries = gncTaxTableGetEntries (tax_table);
1118  GList * node;
1119 
1120  /* Step 1: compute the aggregate price */
1121 
1122  aggregate = gnc_numeric_mul (qty, price, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
1123 
1124  /* Step 2: compute the pre-tax aggregate */
1125 
1126  /* First, compute the aggregate tpercent and tvalue numbers */
1127  for (node = entries; node; node = node->next)
1128  {
1129  GncTaxTableEntry *entry = node->data;
1130  gnc_numeric amount = gncTaxTableEntryGetAmount (entry);
1131 
1132  switch (gncTaxTableEntryGetType (entry))
1133  {
1134  case GNC_AMT_TYPE_VALUE:
1135  tvalue = gnc_numeric_add (tvalue, amount, GNC_DENOM_AUTO,
1137  break;
1138  case GNC_AMT_TYPE_PERCENT:
1139  tpercent = gnc_numeric_add (tpercent, amount, GNC_DENOM_AUTO,
1141  break;
1142  default:
1143  g_warning ("Unknown tax type: %d", gncTaxTableEntryGetType (entry));
1144  break;
1145  }
1146  }
1147  /* now we need to convert from 5% -> .05 */
1148  tpercent = gnc_numeric_div (tpercent, percent, GNC_DENOM_AUTO,
1150 
1151  /* Next, actually compute the pre-tax aggregate value based on the
1152  * taxincluded flag.
1153  */
1154  if (tax_table && tax_included)
1155  {
1156  /* Back-compute the pre-tax aggregate value.
1157  * We know that aggregate = pretax + pretax*tpercent + tvalue, so
1158  * pretax = (aggregate-tvalue)/(1+tpercent)
1159  */
1160  pretax = gnc_numeric_sub (aggregate, tvalue, GNC_DENOM_AUTO,
1162  pretax = gnc_numeric_div (pretax,
1163  gnc_numeric_add (tpercent,
1164  gnc_numeric_create (1, 1),
1167  }
1168  else
1169  {
1170  pretax = aggregate;
1171  }
1172 
1173  /* Step 3: apply discount and taxes in the appropriate order */
1174 
1175  /*
1176  * There are two ways to apply discounts and taxes. In one way, you
1177  * always compute the discount off the pretax number, and compute
1178  * the taxes off of either the pretax value or "pretax-discount"
1179  * value. In the other way, you always compute the tax on "pretax",
1180  * and compute the discount on either "pretax" or "pretax+taxes".
1181  *
1182  * I don't know which is the "correct" way.
1183  */
1184 
1185  /*
1186  * Type: discount tax
1187  * PRETAX pretax pretax-discount
1188  * SAMETIME pretax pretax
1189  * POSTTAX pretax+tax pretax
1190  */
1191 
1192  switch (discount_how)
1193  {
1194  case GNC_DISC_PRETAX:
1195  case GNC_DISC_SAMETIME:
1196  /* compute the discount from pretax */
1197 
1198  if (discount_type == GNC_AMT_TYPE_PERCENT)
1199  {
1200  discount = gnc_numeric_div (discount, percent, GNC_DENOM_AUTO,
1202  discount = gnc_numeric_mul (pretax, discount, GNC_DENOM_AUTO,
1204  }
1205 
1206  result = gnc_numeric_sub (pretax, discount, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
1207 
1208  /* Figure out when to apply the tax, pretax or pretax-discount */
1209  if (discount_how == GNC_DISC_PRETAX)
1210  pretax = result;
1211  break;
1212 
1213  case GNC_DISC_POSTTAX:
1214  /* compute discount on pretax+taxes */
1215 
1216  if (discount_type == GNC_AMT_TYPE_PERCENT)
1217  {
1218  gnc_numeric after_tax;
1219 
1220  tax = gnc_numeric_mul (pretax, tpercent, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
1221  after_tax = gnc_numeric_add (pretax, tax, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
1222  after_tax = gnc_numeric_add (after_tax, tvalue, GNC_DENOM_AUTO,
1224  discount = gnc_numeric_div (discount, percent, GNC_DENOM_AUTO,
1226  discount = gnc_numeric_mul (after_tax, discount, GNC_DENOM_AUTO,
1228  }
1229 
1230  result = gnc_numeric_sub (pretax, discount, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
1231  break;
1232 
1233  default:
1234  g_warning ("unknown DiscountHow value: %d", discount_how);
1235  break;
1236  }
1237 
1238  /* Step 4: return the requested results. */
1239 
1240  /* result == amount merchant gets
1241  * discount == amount of discount
1242  * need to compute taxes (based on 'pretax') if the caller wants it.
1243  */
1244 
1245  if (discount_value != NULL)
1246  {
1247  if (SCU) discount = gnc_numeric_convert(discount, SCU, GNC_HOW_RND_ROUND_HALF_UP);
1248  *discount_value = discount;
1249  }
1250 
1251  if (value != NULL)
1252  {
1253  if (SCU) result = gnc_numeric_convert(result, SCU, GNC_HOW_RND_ROUND_HALF_UP);
1254  *value = result;
1255  }
1256 
1257  /* Now... Compute the list of tax values (if the caller wants it) */
1258 
1259  if (tax_value != NULL)
1260  {
1261  GList * taxes = NULL;
1262 
1263  for (node = entries; node; node = node->next)
1264  {
1265  GncTaxTableEntry *entry = node->data;
1266  Account *acc = gncTaxTableEntryGetAccount (entry);
1267  gnc_numeric amount = gncTaxTableEntryGetAmount (entry);
1268 
1269  g_return_if_fail (acc);
1270 
1271  switch (gncTaxTableEntryGetType (entry))
1272  {
1273  case GNC_AMT_TYPE_VALUE:
1274  if (SCU) amount = gnc_numeric_convert(amount, SCU, GNC_HOW_RND_ROUND_HALF_UP);
1275  taxes = gncAccountValueAdd (taxes, acc, amount);
1276  break;
1277  case GNC_AMT_TYPE_PERCENT:
1278  amount = gnc_numeric_div (amount, percent, GNC_DENOM_AUTO,
1280  tax = gnc_numeric_mul (pretax, amount, GNC_DENOM_AUTO, GNC_HOW_DENOM_LCD);
1281  if (SCU) tax = gnc_numeric_convert(tax, SCU, GNC_HOW_RND_ROUND_HALF_UP);
1282  taxes = gncAccountValueAdd (taxes, acc, tax);
1283  break;
1284  default:
1285  break;
1286  }
1287  }
1288  *tax_value = taxes;
1289  }
1290 
1291  return;
1292 }
gnc_numeric gnc_numeric_add(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
gnc_numeric gnc_numeric_mul(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
gnc_numeric gnc_numeric_div(gnc_numeric x, gnc_numeric y, gint64 denom, gint how)
gnc_numeric gnc_numeric_sub(gnc_numeric a, gnc_numeric b, gint64 denom, gint how)
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
Definition: gncTaxTable.c:923
#define GNC_DENOM_AUTO
Definition: gnc-numeric.h:246
const char* gncEntryDiscountHowToString ( GncDiscountHow  how)

How to apply the discount and taxes. There are three distinct ways to apply them:

Type: discount tax PRETAX pretax pretax-discount SAMETIME pretax pretax POSTTAX pretax+tax pretax

Definition at line 112 of file gncEntry.c.

113 {
114  switch (how)
115  {
116  case (GNC_DISC_PRETAX):
117  return "PRETAX";
118  case (GNC_DISC_SAMETIME):
119  return "SAMETIME";
120  case (GNC_DISC_POSTTAX):
121  return "POSTTAX";
122  default:
123  g_warning ("asked to translate unknown discount-how %d.\n", how);
124  break;
125  }
126  return NULL;
127 }
AccountValueList* gncEntryGetBalTaxValues ( GncEntry entry,
gboolean  is_cust_doc 
)

Careful: the returned list is NOT owned by the entry and should be freed by the caller

Definition at line 1481 of file gncEntry.c.

1482 {
1483  AccountValueList *int_values = gncEntryGetIntTaxValues (entry, is_cust_doc);
1484  AccountValueList *values = NULL, *node;
1485 
1486  /* Make a copy of the list with negated values if necessary. */
1487  for (node = int_values; node; node = node->next)
1488  {
1489  GncAccountValue *acct_val = node->data;
1490  values = gncAccountValueAdd (values, acct_val->account,
1491  (is_cust_doc ? gnc_numeric_neg (acct_val->value)
1492  : acct_val->value));
1493  }
1494 
1495  return values;
1496 }
gnc_numeric gnc_numeric_neg(gnc_numeric a)
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
Definition: gncTaxTable.c:923
Timespec gncEntryGetDate ( const GncEntry entry)

DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day is a misleading extra information. We are only dealing with the day information!

Definition at line 878 of file gncEntry.c.

879 {
880  Timespec ts;
881  ts.tv_sec = 0;
882  ts.tv_nsec = 0;
883  if (!entry) return ts;
884  return entry->date;
885 }
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
GDate gncEntryGetDateGDate ( const GncEntry entry)

Returns the day of this entry

Definition at line 887 of file gncEntry.c.

888 {
889  return timespec_to_gdate(gncEntryGetDate(entry));
890 }
Timespec gncEntryGetDate(const GncEntry *entry)
Definition: gncEntry.c:878
GDate timespec_to_gdate(Timespec ts)
gnc_numeric gncEntryGetDocQuantity ( const GncEntry entry,
gboolean  is_cn 
)

Get the quantity as on the physical document. This distinction is made because credit notes store their quantity sign-reversed compared to how the quantity is written on the actual credit note (and hence how the ledger and reports show it to the user).

Definition at line 925 of file gncEntry.c.

926 {
927  gnc_numeric value = gncEntryGetQuantity (entry);
928  return (is_cn ? gnc_numeric_neg (value) : value);
929 }
gnc_numeric gnc_numeric_neg(gnc_numeric a)
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
Definition: gncEntry.c:919
AccountValueList* gncEntryGetDocTaxValues ( GncEntry entry,
gboolean  is_cust_doc,
gboolean  is_cn 
)

Careful: the returned list is NOT owned by the entry and should be freed by the caller

Definition at line 1445 of file gncEntry.c.

1446 {
1447  AccountValueList *int_values = gncEntryGetIntTaxValues (entry, is_cust_doc);
1448  AccountValueList *values = NULL, *node;
1449 
1450  /* Make a copy of the list with negated values if necessary. */
1451  for (node = int_values; node; node = node->next)
1452  {
1453  GncAccountValue *acct_val = node->data;
1454  values = gncAccountValueAdd (values, acct_val->account,
1455  (is_cn ? gnc_numeric_neg (acct_val->value)
1456  : acct_val->value));
1457  }
1458 
1459  return values;
1460 }
gnc_numeric gnc_numeric_neg(gnc_numeric a)
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
Definition: gncTaxTable.c:923
gnc_numeric gncEntryGetQuantity ( const GncEntry entry)

Get the quantity as stored internally. This distinction is made because credit notes store their quantity sign-reversed compared to how the quantity is written on the actual credit note (and hence how the ledger and reports show it to the user).

Definition at line 919 of file gncEntry.c.

920 {
921  if (!entry) return gnc_numeric_zero();
922  return entry->quantity;
923 }
void gncEntrySetDate ( GncEntry entry,
Timespec  date 
)

DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day is a misleading extra information. We are only dealing with the day information!

Definition at line 481 of file gncEntry.c.

482 {
483  gboolean first_date = FALSE;
484  Timespec zero_time = { 0, 0 };
485 
486  if (!entry) return;
487  if (timespec_equal (&entry->date, &date)) return;
488  if (timespec_equal (&entry->date, &zero_time))
489  first_date = TRUE;
490  gncEntryBeginEdit (entry);
491  entry->date = date;
492  mark_entry (entry);
493  gncEntryCommitEdit (entry);
494 
495  /* Don't re-sort the first time we set the date on this entry */
496  if (!first_date)
497  {
498  if (entry->invoice)
499  gncInvoiceSortEntries(entry->invoice);
500  if (entry->bill)
501  gncInvoiceSortEntries(entry->bill);
502  }
503 }
gboolean timespec_equal(const Timespec *ta, const Timespec *tb)
Use a 64-bit unsigned int timespec.
Definition: gnc-date.h:299
void gncInvoiceSortEntries(GncInvoice *invoice)
Definition: gncInvoice.c:717
void gncEntrySetDateGDate ( GncEntry entry,
const GDate *  date 
)

Set the date of this entry

Definition at line 505 of file gncEntry.c.

506 {
507  if (!entry || !date || !g_date_valid(date))
508  return;
509 
510  /* Watch out: Here we are deviating from the initial convention that a
511  GDate always converts to the start time of the day. Instead, the GDate is
512  converted to "noon" on the respective date. This is not nice, but this
513  convention was used for the Timespec of GncEntry all the time, so we better
514  stick to it.*/
516 }
void gncEntrySetDate(GncEntry *entry, Timespec date)
Definition: gncEntry.c:481
Timespec timespecCanonicalDayTime(Timespec t)
Timespec gdate_to_timespec(GDate d)
void gncEntrySetDocQuantity ( GncEntry entry,
gnc_numeric  quantity,
gboolean  is_cn 
)

Set the internal quantity converting from the quantity as visible on the physical document. This distinction is made because credit notes store their quantity sign-reversed compared to how the quantity is written on the actual credit note (and hence how the ledger and reports show it to the user).

Definition at line 563 of file gncEntry.c.

564 {
565  if (!entry) return;
566  if (gnc_numeric_eq (entry->quantity, (is_cn ? gnc_numeric_neg (quantity) : quantity))) return;
567  gncEntryBeginEdit (entry);
568  entry->quantity = (is_cn ? gnc_numeric_neg (quantity) : quantity);
569  entry->values_dirty = TRUE;
570  mark_entry (entry);
571  gncEntryCommitEdit (entry);
572 }
gnc_numeric gnc_numeric_neg(gnc_numeric a)
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
void gncEntrySetQuantity ( GncEntry entry,
gnc_numeric  quantity 
)

Set the internal quantity without any conversion. This distinction is made because credit notes store their quantity sign-reversed compared to how the quantity is written on the actual credit note (and hence how the ledger and reports show it to the user).

Definition at line 552 of file gncEntry.c.

553 {
554  if (!entry) return;
555  if (gnc_numeric_eq (entry->quantity, quantity)) return;
556  gncEntryBeginEdit (entry);
557  entry->quantity = quantity;
558  entry->values_dirty = TRUE;
559  mark_entry (entry);
560  gncEntryCommitEdit (entry);
561 }
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)