GnuCash c935c2f+
Loading...
Searching...
No Matches
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 GList AccountValueList
 

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)
 How to apply the discount and taxes.
 
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)
 
GncOrder * gncEntryGetOrder (const GncEntry *entry)
 
GncInvoice * gncEntryGetInvoice (const GncEntry *entry)
 
GncInvoice * gncEntryGetBill (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

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

Generic (shared) data

void gncEntrySetDateGDate (GncEntry *entry, const GDate *date)
 Set the date of this entry.
 
void gncEntrySetDate (GncEntry *entry, time64 date)
 DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day is a misleading extra information.
 
void gncEntrySetDateEntered (GncEntry *entry, time64 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)
 Set the internal quantity without any conversion.
 
void gncEntrySetDocQuantity (GncEntry *entry, gnc_numeric quantity, gboolean is_cn)
 Set the internal quantity converting from the quantity as visible on the physical document.
 
GDate gncEntryGetDateGDate (const GncEntry *entry)
 Returns the day of this entry.
 
time64 gncEntryGetDate (const GncEntry *entry)
 DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day is a misleading extra information.
 
time64 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)
 Get the quantity as stored internally.
 
gnc_numeric gncEntryGetDocQuantity (const GncEntry *entry, gboolean is_cn)
 Get the quantity as on the physical document.
 

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 gncEntryGetPrice (const GncEntry *entry, const gboolean cust_doc, const gboolean net)
 
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.

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)
 Careful: the returned list is NOT owned by the entry and should be freed by the caller.
 
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)
 Careful: the returned list is NOT owned by the entry and should be freed by the caller.
 
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)
 Compute the Entry value, tax_value, and discount_value, based on the quantity, price, discount, tax_-table, and types.
 

Detailed Description

Macro Definition Documentation

◆ ENTRY_ACTION

#define ENTRY_ACTION   "action"

Definition at line 307 of file gncEntry.h.

◆ ENTRY_BACCT

#define ENTRY_BACCT   "bill-account"

Definition at line 313 of file gncEntry.h.

◆ ENTRY_BILL

#define ENTRY_BILL   "bill"

Definition at line 320 of file gncEntry.h.

◆ ENTRY_BILL_PAY_TYPE

#define ENTRY_BILL_PAY_TYPE   "bill-payment-type"

Definition at line 330 of file gncEntry.h.

◆ ENTRY_BILL_TAX_INC

#define ENTRY_BILL_TAX_INC   "bill-tax-included"

Definition at line 328 of file gncEntry.h.

◆ ENTRY_BILL_TAXABLE

#define ENTRY_BILL_TAXABLE   "bill-taxable"

Definition at line 326 of file gncEntry.h.

◆ ENTRY_BILLABLE

#define ENTRY_BILLABLE   "billable?"

Definition at line 315 of file gncEntry.h.

◆ ENTRY_BILLTO

#define ENTRY_BILLTO   "bill-to"

Definition at line 316 of file gncEntry.h.

◆ ENTRY_BPRICE

#define ENTRY_BPRICE   "bprice"

Definition at line 314 of file gncEntry.h.

◆ ENTRY_DATE

#define ENTRY_DATE   "date"

Definition at line 304 of file gncEntry.h.

◆ ENTRY_DATE_ENTERED

#define ENTRY_DATE_ENTERED   "date-entered"

Definition at line 305 of file gncEntry.h.

◆ ENTRY_DESC

#define ENTRY_DESC   "desc"

Definition at line 306 of file gncEntry.h.

◆ ENTRY_IACCT

#define ENTRY_IACCT   "invoice-account"

Definition at line 312 of file gncEntry.h.

◆ ENTRY_INV_DISC_HOW

#define ENTRY_INV_DISC_HOW   "discount-method"

Definition at line 323 of file gncEntry.h.

◆ ENTRY_INV_DISC_TYPE

#define ENTRY_INV_DISC_TYPE   "discount-type"

Definition at line 322 of file gncEntry.h.

◆ ENTRY_INV_DISCOUNT

#define ENTRY_INV_DISCOUNT   "invoice-discount"

Definition at line 329 of file gncEntry.h.

◆ ENTRY_INV_TAX_INC

#define ENTRY_INV_TAX_INC   "invoice-tax-included"

Definition at line 327 of file gncEntry.h.

◆ ENTRY_INV_TAXABLE

#define ENTRY_INV_TAXABLE   "invoice-taxable"

Definition at line 325 of file gncEntry.h.

◆ ENTRY_INVOICE

#define ENTRY_INVOICE   "invoice"

Definition at line 319 of file gncEntry.h.

◆ ENTRY_IPRICE

#define ENTRY_IPRICE   "iprice"

Definition at line 311 of file gncEntry.h.

◆ ENTRY_NOTES

#define ENTRY_NOTES   "notes"

Definition at line 308 of file gncEntry.h.

◆ ENTRY_ORDER

#define ENTRY_ORDER   "order"

Definition at line 318 of file gncEntry.h.

◆ ENTRY_QTY

#define ENTRY_QTY   "qty"

Definition at line 309 of file gncEntry.h.

◆ GNC_ENTRY

#define GNC_ENTRY (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ENTRY, GncEntry))

Definition at line 68 of file gncEntry.h.

295{
296 QOF_BOOK_RETURN_ENTITY(book, guid, GNC_ID_ENTRY, GncEntry);
297}
298
299gboolean gncEntryIsOpen (const GncEntry *entry);
300void gncEntryBeginEdit (GncEntry *entry);
301void gncEntryCommitEdit (GncEntry *entry);
302int gncEntryCompare (const GncEntry *a, const GncEntry *b);
303
304#define ENTRY_DATE "date"
305#define ENTRY_DATE_ENTERED "date-entered"
306#define ENTRY_DESC "desc"
307#define ENTRY_ACTION "action"
308#define ENTRY_NOTES "notes"
309#define ENTRY_QTY "qty"
310
311#define ENTRY_IPRICE "iprice"
312#define ENTRY_IACCT "invoice-account"
313#define ENTRY_BACCT "bill-account"
314#define ENTRY_BPRICE "bprice"
315#define ENTRY_BILLABLE "billable?"
316#define ENTRY_BILLTO "bill-to"
317
318#define ENTRY_ORDER "order"
319#define ENTRY_INVOICE "invoice"
320#define ENTRY_BILL "bill"
321
322#define ENTRY_INV_DISC_TYPE "discount-type"
323#define ENTRY_INV_DISC_HOW "discount-method"
324
325#define ENTRY_INV_TAXABLE "invoice-taxable"
326#define ENTRY_BILL_TAXABLE "bill-taxable"
327#define ENTRY_INV_TAX_INC "invoice-tax-included"
328#define ENTRY_BILL_TAX_INC "bill-tax-included"
329#define ENTRY_INV_DISCOUNT "invoice-discount"
330#define ENTRY_BILL_PAY_TYPE "bill-payment-type"
331
332
333/* deprecated functions, should be removed */
334#define gncEntryGetGUID(x) qof_instance_get_guid(QOF_INSTANCE(x))
335
336#ifdef __cplusplus
337}
338#endif
339
340#endif /* GNC_ENTRY_H_ */
#define QOF_BOOK_RETURN_ENTITY(book, guid, e_type, c_type)
Encapsulates all the information about a dataset manipulated by QOF.
Definition qofbook.h:101

◆ GNC_ENTRY_CLASS

#define GNC_ENTRY_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ENTRY, GncEntryClass))

Definition at line 70 of file gncEntry.h.

◆ GNC_ENTRY_GET_CLASS

#define GNC_ENTRY_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ENTRY, GncEntryClass))

Definition at line 76 of file gncEntry.h.

◆ GNC_ID_ENTRY

#define GNC_ID_ENTRY   "gncEntry"

Definition at line 64 of file gncEntry.h.

◆ GNC_IS_ENTRY

#define GNC_IS_ENTRY (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ENTRY))

Definition at line 72 of file gncEntry.h.

◆ GNC_IS_ENTRY_CLASS

#define GNC_IS_ENTRY_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ENTRY))

Definition at line 74 of file gncEntry.h.

◆ GNC_TYPE_ENTRY

#define GNC_TYPE_ENTRY   (gnc_entry_get_type ())

Definition at line 67 of file gncEntry.h.

◆ gncEntryGetGUID

#define gncEntryGetGUID (   x)    qof_instance_get_guid(QOF_INSTANCE(x))

Definition at line 334 of file gncEntry.h.

Typedef Documentation

◆ AccountValueList

typedef GList AccountValueList

Definition at line 56 of file gncEntry.h.

Enumeration Type Documentation

◆ GncDiscountHow

enum GncDiscountHow

Definition at line 49 of file gncEntry.h.

50{
51 GNC_DISC_PRETAX = 1,
52 GNC_DISC_SAMETIME,
53 GNC_DISC_POSTTAX
54} GncDiscountHow;

◆ GncEntryPaymentType

enum GncEntryPaymentType

Definition at line 43 of file gncEntry.h.

44{
45 GNC_PAYMENT_CASH = 1,
46 GNC_PAYMENT_CARD
47} GncEntryPaymentType;

Function Documentation

◆ gncEntryBeginEdit()

void gncEntryBeginEdit ( GncEntry *  entry)

Definition at line 1616 of file gncEntry.c.

1617{
1618 qof_begin_edit(&entry->inst);
1619}
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ gncEntryCommitEdit()

void gncEntryCommitEdit ( GncEntry *  entry)

Definition at line 1635 of file gncEntry.c.

1636{
1637 /* GnuCash 2.6.3 and earlier didn't handle entry kvp's... */
1638 if (qof_instance_has_kvp(QOF_INSTANCE(entry)))
1639 gnc_features_set_used (qof_instance_get_book (QOF_INSTANCE (entry)),
1640 GNC_FEATURE_KVP_EXTRA_DATA);
1641
1642 if (!qof_commit_edit (QOF_INSTANCE(entry))) return;
1643 qof_commit_edit_part2 (&entry->inst, gncEntryOnError,
1644 gncEntryOnDone, entry_free);
1645}
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
gboolean qof_instance_has_kvp(QofInstance *inst)
Report whether a QofInstance has anything stored in KVP.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers

◆ gncEntryCompare()

int gncEntryCompare ( const GncEntry *  a,
const GncEntry *  b 
)

Definition at line 1647 of file gncEntry.c.

1648{
1649 int compare;
1650
1651 if (a == b) return 0;
1652 if (!a && b) return -1;
1653 if (a && !b) return 1;
1654 g_assert (a && b); /* Silence a static analysis warning. */
1655 if (a->date != b->date) return a->date - b->date;
1656 if (a->date_entered != b->date_entered) return a->date_entered - b->date_entered;
1657
1658 compare = g_strcmp0 (a->desc, b->desc);
1659 if (compare) return compare;
1660
1661 compare = g_strcmp0 (a->action, b->action);
1662 if (compare) return compare;
1663
1664 return qof_instance_guid_compare(a, b);
1665}
gint qof_instance_guid_compare(gconstpointer ptr1, gconstpointer ptr2)
Compare the GncGUID values of two instances.

◆ gncEntryComputeValue()

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.

If the tax_values list is owned by the entry, it will be destroyed automatically. Otherwise use gncAccountValueDestroy to free it.

◆ gncEntryCopy()

void gncEntryCopy ( const GncEntry *  src,
GncEntry *  dest,
gboolean  add_entry 
)

Definition at line 859 of file gncEntry.c.

860{
861 if (!src || !dest) return;
862
863 gncEntryBeginEdit (dest);
864 dest->date = src->date;
865 dest->date_entered = src->date_entered; /* ??? */
866 gncEntrySetDescription (dest, src->desc);
867 gncEntrySetAction (dest, src->action);
868 gncEntrySetNotes (dest, src->notes);
869 dest->quantity = src->quantity;
870
871 dest->i_account = src->i_account;
872 dest->i_price = src->i_price;
873 dest->i_taxable = src->i_taxable;
874 dest->i_taxincluded = src->i_taxincluded;
875 dest->i_discount = src->i_discount;
876 dest->i_disc_type = src->i_disc_type;
877 dest->i_disc_how = src->i_disc_how;
878
879 /* vendor bill data */
880 dest->b_account = src->b_account;
881 dest->b_price = src->b_price;
882 dest->b_taxable = src->b_taxable;
883 dest->b_taxincluded = src->b_taxincluded;
884 dest->billable = src->billable;
885 dest->billto = src->billto;
886
887 if (src->i_tax_table)
888 gncEntrySetInvTaxTable (dest, src->i_tax_table);
889
890 if (src->b_tax_table)
891 gncEntrySetBillTaxTable (dest, src->b_tax_table);
892
893 if (add_entry)
894 {
895 if (src->order)
896 gncOrderAddEntry (src->order, dest);
897
898 if (src->invoice)
899 gncInvoiceAddEntry (src->invoice, dest);
900
901 if (src->bill)
902 gncBillAddEntry (src->bill, dest);
903 }
904
905 dest->values_dirty = TRUE;
906 mark_entry (dest);
907 gncEntryCommitEdit (dest);
908}
void gncBillAddEntry(GncInvoice *bill, GncEntry *entry)
Call this function when adding an entry to a bill instead of an invoice.
Definition gncInvoice.c:719

◆ gncEntryCreate()

GncEntry * gncEntryCreate ( QofBook book)

Definition at line 413 of file gncEntry.c.

414{
415 GncEntry *entry;
416 gnc_numeric zero = gnc_numeric_zero ();
417
418 if (!book) return NULL;
419
420 entry = g_object_new (GNC_TYPE_ENTRY, NULL);
421 qof_instance_init_data (&entry->inst, _GNC_MOD_NAME, book);
422
423 entry->desc = CACHE_INSERT ("");
424 entry->action = CACHE_INSERT ("");
425 entry->notes = CACHE_INSERT ("");
426 entry->quantity = zero;
427
428 entry->i_price = zero;
429 entry->i_taxable = TRUE;
430 entry->i_discount = zero;
431 entry->i_disc_type = GNC_AMT_TYPE_PERCENT;
432 entry->i_disc_how = GNC_DISC_PRETAX;
433
434 entry->b_price = zero;
435 entry->b_taxable = TRUE;
436 entry->billto.type = GNC_OWNER_CUSTOMER;
437 entry->b_payment = GNC_PAYMENT_CASH;
438
439 entry->values_dirty = TRUE;
440
441 qof_event_gen (&entry->inst, QOF_EVENT_CREATE, NULL);
442
443 return entry;
444}
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition qofevent.cpp:231
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.
@ GNC_AMT_TYPE_PERCENT
tax is a percentage
Definition gncTaxTable.h:81

◆ gncEntryDestroy()

void gncEntryDestroy ( GncEntry *  entry)

Definition at line 446 of file gncEntry.c.

447{
448 if (!entry) return;
449 qof_instance_set_destroying(entry, TRUE);
450 gncEntryCommitEdit(entry);
451}

◆ gncEntryDiscountHowToString()

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 113 of file gncEntry.c.

114{
115 switch (how)
116 {
117 case (GNC_DISC_PRETAX):
118 return "PRETAX";
119 case (GNC_DISC_SAMETIME):
120 return "SAMETIME";
121 case (GNC_DISC_POSTTAX):
122 return "POSTTAX";
123 default:
124 PWARN ("asked to translate unknown discount-how %d.\n", how);
125 break;
126 }
127 return NULL;
128}
#define PWARN(format, args...)
Log a warning.
Definition qoflog.h:250

◆ gncEntryDiscountStringToHow()

gboolean gncEntryDiscountStringToHow ( const char *  str,
GncDiscountHow *  how 
)

Definition at line 132 of file gncEntry.c.

133{
134 if (g_strcmp0 ("PRETAX", str) == 0)
135 {
136 *how = GNC_DISC_PRETAX;
137 return TRUE;
138 }
139 if (g_strcmp0 ("SAMETIME", str) == 0)
140 {
141 *how = GNC_DISC_SAMETIME;
142 return TRUE;
143 }
144 if (g_strcmp0 ("POSTTAX", str) == 0)
145 {
146 *how = GNC_DISC_POSTTAX;
147 return TRUE;
148 }
149 PWARN ("asked to translate unknown discount-how string %s.\n",
150 str ? str : "(null)");
151
152 return FALSE;
153}

◆ gncEntryGetAction()

const char * gncEntryGetAction ( const GncEntry *  entry)

Definition at line 934 of file gncEntry.c.

935{
936 if (!entry) return NULL;
937 return entry->action;
938}

◆ gncEntryGetBalDiscountValue()

gnc_numeric gncEntryGetBalDiscountValue ( GncEntry *  entry,
gboolean  round,
gboolean  is_cust_doc 
)

Definition at line 1601 of file gncEntry.c.

1602{
1603 gnc_numeric value = gncEntryGetIntDiscountValue (entry, round, is_cust_doc);
1604 return (is_cust_doc ? gnc_numeric_neg (value) : value);
1605}
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value.

◆ gncEntryGetBalTaxValue()

gnc_numeric gncEntryGetBalTaxValue ( GncEntry *  entry,
gboolean  round,
gboolean  is_cust_doc 
)

Definition at line 1577 of file gncEntry.c.

1578{
1579 gnc_numeric value = gncEntryGetIntTaxValue (entry, round, is_cust_doc);
1580 return (is_cust_doc ? gnc_numeric_neg (value) : value);
1581}

◆ gncEntryGetBalTaxValues()

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 1584 of file gncEntry.c.

1585{
1586 AccountValueList *int_values = gncEntryGetIntTaxValues (entry, is_cust_doc);
1587 AccountValueList *values = NULL, *node;
1588
1589 /* Make a copy of the list with negated values if necessary. */
1590 for (node = int_values; node; node = node->next)
1591 {
1592 GncAccountValue *acct_val = node->data;
1593 values = gncAccountValueAdd (values, acct_val->account,
1594 (is_cust_doc ? gnc_numeric_neg (acct_val->value)
1595 : acct_val->value));
1596 }
1597
1598 return values;
1599}
GList * gncAccountValueAdd(GList *list, Account *acc, gnc_numeric value)
This will add value to the account-value for acc, creating a new list object if necessary.

◆ gncEntryGetBalValue()

gnc_numeric gncEntryGetBalValue ( GncEntry *  entry,
gboolean  round,
gboolean  is_cust_doc 
)

Definition at line 1571 of file gncEntry.c.

1572{
1573 gnc_numeric value = gncEntryGetIntValue (entry, round, is_cust_doc);
1574 return (is_cust_doc ? gnc_numeric_neg (value) : value);
1575}

◆ gncEntryGetBill()

GncInvoice * gncEntryGetBill ( const GncEntry *  entry)

Definition at line 1082 of file gncEntry.c.

1083{
1084 if (!entry) return NULL;
1085 return entry->bill;
1086}

◆ gncEntryGetBillable()

gboolean gncEntryGetBillable ( const GncEntry *  entry)

Definition at line 1058 of file gncEntry.c.

1059{
1060 if (!entry) return FALSE;
1061 return entry->billable;
1062}

◆ gncEntryGetBillAccount()

Account * gncEntryGetBillAccount ( const GncEntry *  entry)

Definition at line 1028 of file gncEntry.c.

1029{
1030 if (!entry) return NULL;
1031 return entry->b_account;
1032}

◆ gncEntryGetBillPayment()

GncEntryPaymentType gncEntryGetBillPayment ( const GncEntry *  entry)

Definition at line 1070 of file gncEntry.c.

1071{
1072 if (!entry) return 0;
1073 return entry->b_payment;
1074}

◆ gncEntryGetBillPrice()

gnc_numeric gncEntryGetBillPrice ( const GncEntry *  entry)

Definition at line 1034 of file gncEntry.c.

1035{
1036 if (!entry) return gnc_numeric_zero();
1037 return entry->b_price;
1038}

◆ gncEntryGetBillTaxable()

gboolean gncEntryGetBillTaxable ( const GncEntry *  entry)

Definition at line 1040 of file gncEntry.c.

1041{
1042 if (!entry) return FALSE;
1043 return entry->b_taxable;
1044}

◆ gncEntryGetBillTaxIncluded()

gboolean gncEntryGetBillTaxIncluded ( const GncEntry *  entry)

Definition at line 1046 of file gncEntry.c.

1047{
1048 if (!entry) return FALSE;
1049 return entry->b_taxincluded;
1050}

◆ gncEntryGetBillTaxTable()

GncTaxTable * gncEntryGetBillTaxTable ( const GncEntry *  entry)

Definition at line 1052 of file gncEntry.c.

1053{
1054 if (!entry) return NULL;
1055 return entry->b_tax_table;
1056}

◆ gncEntryGetBillTo()

GncOwner * gncEntryGetBillTo ( GncEntry *  entry)

Definition at line 1064 of file gncEntry.c.

1065{
1066 if (!entry) return NULL;
1067 return &entry->billto;
1068}

◆ gncEntryGetDate()

time64 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 913 of file gncEntry.c.

914{
915 return entry ? entry->date : 0;
916}

◆ gncEntryGetDateEntered()

time64 gncEntryGetDateEntered ( const GncEntry *  entry)

Definition at line 923 of file gncEntry.c.

924{
925 return entry ? entry->date_entered : 0;
926}

◆ gncEntryGetDateGDate()

GDate gncEntryGetDateGDate ( const GncEntry *  entry)

Returns the day of this entry.

Definition at line 918 of file gncEntry.c.

919{
920 return time64_to_gdate(gncEntryGetDate(entry));
921}
GDate time64_to_gdate(time64 t)
Returns the GDate in which the time64 occurs.
time64 gncEntryGetDate(const GncEntry *entry)
DEPRECATED - use gncEntryGetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
Definition gncEntry.c:913

◆ gncEntryGetDescription()

const char * gncEntryGetDescription ( const GncEntry *  entry)

Definition at line 928 of file gncEntry.c.

929{
930 if (!entry) return NULL;
931 return entry->desc;
932}

◆ gncEntryGetDocDiscountValue()

gnc_numeric gncEntryGetDocDiscountValue ( GncEntry *  entry,
gboolean  round,
gboolean  is_cust_doc,
gboolean  is_cn 
)

Definition at line 1565 of file gncEntry.c.

1566{
1567 gnc_numeric value = gncEntryGetIntDiscountValue (entry, round, is_cust_doc);
1568 return (is_cn ? gnc_numeric_neg (value) : value);
1569}

◆ gncEntryGetDocQuantity()

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 952 of file gncEntry.c.

953{
954 gnc_numeric value = gncEntryGetQuantity (entry);
955 return (is_cn ? gnc_numeric_neg (value) : value);
956}
gnc_numeric gncEntryGetQuantity(const GncEntry *entry)
Get the quantity as stored internally.
Definition gncEntry.c:946

◆ gncEntryGetDocTaxValue()

gnc_numeric gncEntryGetDocTaxValue ( GncEntry *  entry,
gboolean  round,
gboolean  is_cust_doc,
gboolean  is_cn 
)

Definition at line 1541 of file gncEntry.c.

1542{
1543 gnc_numeric value = gncEntryGetIntTaxValue (entry, round, is_cust_doc);
1544 return (is_cn ? gnc_numeric_neg (value) : value);
1545}

◆ gncEntryGetDocTaxValues()

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 1548 of file gncEntry.c.

1549{
1550 AccountValueList *int_values = gncEntryGetIntTaxValues (entry, is_cust_doc);
1551 AccountValueList *values = NULL, *node;
1552
1553 /* Make a copy of the list with negated values if necessary. */
1554 for (node = int_values; node; node = node->next)
1555 {
1556 GncAccountValue *acct_val = node->data;
1557 values = gncAccountValueAdd (values, acct_val->account,
1558 (is_cn ? gnc_numeric_neg (acct_val->value)
1559 : acct_val->value));
1560 }
1561
1562 return values;
1563}

◆ gncEntryGetDocValue()

gnc_numeric gncEntryGetDocValue ( GncEntry *  entry,
gboolean  round,
gboolean  is_cust_doc,
gboolean  is_cn 
)

Definition at line 1535 of file gncEntry.c.

1536{
1537 gnc_numeric value = gncEntryGetIntValue (entry, round, is_cust_doc);
1538 return (is_cn ? gnc_numeric_neg (value) : value);
1539}

◆ gncEntryGetInvAccount()

Account * gncEntryGetInvAccount ( const GncEntry *  entry)

Definition at line 960 of file gncEntry.c.

961{
962 if (!entry) return NULL;
963 return entry->i_account;
964}

◆ gncEntryGetInvDiscount()

gnc_numeric gncEntryGetInvDiscount ( const GncEntry *  entry)

Definition at line 972 of file gncEntry.c.

973{
974 if (!entry) return gnc_numeric_zero();
975 return entry->i_discount;
976}

◆ gncEntryGetInvDiscountHow()

GncDiscountHow gncEntryGetInvDiscountHow ( const GncEntry *  entry)

Definition at line 984 of file gncEntry.c.

985{
986 if (!entry) return 0;
987 return entry->i_disc_how;
988}

◆ gncEntryGetInvDiscountType()

GncAmountType gncEntryGetInvDiscountType ( const GncEntry *  entry)

Definition at line 978 of file gncEntry.c.

979{
980 if (!entry) return 0;
981 return entry->i_disc_type;
982}

◆ gncEntryGetInvoice()

GncInvoice * gncEntryGetInvoice ( const GncEntry *  entry)

Definition at line 1076 of file gncEntry.c.

1077{
1078 if (!entry) return NULL;
1079 return entry->invoice;
1080}

◆ gncEntryGetInvPrice()

gnc_numeric gncEntryGetInvPrice ( const GncEntry *  entry)

Definition at line 966 of file gncEntry.c.

967{
968 if (!entry) return gnc_numeric_zero();
969 return entry->i_price;
970}

◆ gncEntryGetInvTaxable()

gboolean gncEntryGetInvTaxable ( const GncEntry *  entry)

Definition at line 1008 of file gncEntry.c.

1009{
1010 if (!entry) return FALSE;
1011 return entry->i_taxable;
1012}

◆ gncEntryGetInvTaxIncluded()

gboolean gncEntryGetInvTaxIncluded ( const GncEntry *  entry)

Definition at line 1014 of file gncEntry.c.

1015{
1016 if (!entry) return FALSE;
1017 return entry->i_taxincluded;
1018}

◆ gncEntryGetInvTaxTable()

GncTaxTable * gncEntryGetInvTaxTable ( const GncEntry *  entry)

Definition at line 1020 of file gncEntry.c.

1021{
1022 if (!entry) return NULL;
1023 return entry->i_tax_table;
1024}

◆ gncEntryGetNotes()

const char * gncEntryGetNotes ( const GncEntry *  notes)

Definition at line 940 of file gncEntry.c.

941{
942 if (!entry) return NULL;
943 return entry->notes;
944}

◆ gncEntryGetOrder()

GncOrder * gncEntryGetOrder ( const GncEntry *  entry)

Definition at line 1088 of file gncEntry.c.

1089{
1090 if (!entry) return NULL;
1091 return entry->order;
1092}

◆ gncEntryGetPrice()

gnc_numeric gncEntryGetPrice ( const GncEntry *  entry,
const gboolean  cust_doc,
const gboolean  net 
)

Definition at line 1502 of file gncEntry.c.

1503{
1504 gnc_numeric result;
1505 int denom;
1506
1507 if (!entry) return gnc_numeric_zero();
1508 if (!net) return (cust_doc ? entry->i_price : entry->b_price);
1509
1510
1511 /* Compute the net price */
1512 if (cust_doc)
1513 gncEntryComputeValueInt (entry->quantity, entry->i_price,
1514 (entry->i_taxable ? entry->i_tax_table : NULL),
1515 entry->i_taxincluded,
1516 entry->i_discount, entry->i_disc_type,
1517 entry->i_disc_how,
1518 NULL, NULL, NULL, &result);
1519 else
1520 gncEntryComputeValueInt (entry->quantity, entry->b_price,
1521 (entry->b_taxable ? entry->b_tax_table : NULL),
1522 entry->b_taxincluded,
1523 gnc_numeric_zero(), GNC_AMT_TYPE_VALUE, GNC_DISC_PRETAX,
1524 NULL, NULL, NULL, &result);
1525
1526 /* Determine the commodity denominator */
1527 denom = get_entry_commodity_denom (entry);
1528
1529 result = gnc_numeric_convert (result, denom,
1530 GNC_HOW_DENOM_EXACT | GNC_HOW_RND_ROUND_HALF_UP);
1531
1532 return result;
1533}
@ GNC_AMT_TYPE_VALUE
tax is a number
Definition gncTaxTable.h:80

◆ gncEntryGetQuantity()

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 946 of file gncEntry.c.

947{
948 if (!entry) return gnc_numeric_zero();
949 return entry->quantity;
950}

◆ gncEntryIsOpen()

gboolean gncEntryIsOpen ( const GncEntry *  entry)

Definition at line 1608 of file gncEntry.c.

1609{
1610 if (!entry) return FALSE;
1611 return (qof_instance_get_editlevel(entry) > 0);
1612}

◆ gncEntryPaymentStringToType()

gboolean gncEntryPaymentStringToType ( const char *  str,
GncEntryPaymentType *  type 
)

Definition at line 174 of file gncEntry.c.

175{
176 if (g_strcmp0 ("CASH", str) == 0)
177 {
178 *type = GNC_PAYMENT_CASH;
179 return TRUE;
180 }
181 if (g_strcmp0 ("CARD", str) == 0)
182 {
183 *type = GNC_PAYMENT_CARD;
184 return TRUE;
185 }
186 PWARN ("asked to translate unknown discount-how string %s.\n",
187 str ? str : "(null)");
188
189 return FALSE;
190}

◆ gncEntryPaymentTypeToString()

const char * gncEntryPaymentTypeToString ( GncEntryPaymentType  type)

Definition at line 157 of file gncEntry.c.

158{
159 switch (type)
160 {
161 case (GNC_PAYMENT_CASH):
162 return "CASH";
163 case (GNC_PAYMENT_CARD):
164 return "CARD";
165 default:
166 PWARN ("asked to translate unknown payment type %d.\n", type);
167 break;
168 }
169 return NULL ;
170}

◆ gncEntrySetAction()

void gncEntrySetAction ( GncEntry *  entry,
const char *  action 
)

Definition at line 535 of file gncEntry.c.

536{
537 if (!entry || !action) return;
538 SET_STR (entry, entry->action, action);
539 mark_entry (entry);
540 gncEntryCommitEdit (entry);
541}

◆ gncEntrySetBillable()

void gncEntrySetBillable ( GncEntry *  entry,
gboolean  billable 
)

Definition at line 793 of file gncEntry.c.

794{
795 if (!entry) return;
796 if (entry->billable == billable) return;
797
798 gncEntryBeginEdit (entry);
799 entry->billable = billable;
800 mark_entry (entry);
801 gncEntryCommitEdit (entry);
802}

◆ gncEntrySetBillAccount()

void gncEntrySetBillAccount ( GncEntry *  entry,
Account acc 
)

Definition at line 717 of file gncEntry.c.

718{
719 if (!entry) return;
720 if (entry->b_account == acc) return;
721 gncEntryBeginEdit (entry);
722 entry->b_account = acc;
723 mark_entry (entry);
724 gncEntryCommitEdit (entry);
725}

◆ gncEntrySetBillPayment()

void gncEntrySetBillPayment ( GncEntry *  entry,
GncEntryPaymentType  type 
)

Definition at line 815 of file gncEntry.c.

816{
817 if (!entry) return;
818 if (entry->b_payment == type) return;
819 gncEntryBeginEdit (entry);
820 entry->b_payment = type;
821 mark_entry (entry);
822 gncEntryCommitEdit (entry);
823}

◆ gncEntrySetBillPrice()

void gncEntrySetBillPrice ( GncEntry *  entry,
gnc_numeric  price 
)

Definition at line 727 of file gncEntry.c.

728{
729 if (!entry) return;
730 if (gnc_numeric_eq (entry->b_price, price)) return;
731 gncEntryBeginEdit (entry);
732 entry->b_price = price;
733 entry->values_dirty = TRUE;
734 mark_entry (entry);
735 gncEntryCommitEdit (entry);
736}
gboolean gnc_numeric_eq(gnc_numeric a, gnc_numeric b)
Equivalence predicate: Returns TRUE (1) if a and b are exactly the same (have the same numerator and ...

◆ gncEntrySetBillTaxable()

void gncEntrySetBillTaxable ( GncEntry *  entry,
gboolean  taxable 
)

Definition at line 738 of file gncEntry.c.

739{
740 if (!entry) return;
741
742 ENTER ("%d", taxable);
743 if (entry->b_taxable == taxable) {
744 LEAVE ("Value already set");
745 return;
746 }
747 gncEntryBeginEdit (entry);
748 entry->b_taxable = taxable;
749 entry->values_dirty = TRUE;
750 mark_entry (entry);
751 gncEntryCommitEdit (entry);
752 LEAVE ("");
753}
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272

◆ gncEntrySetBillTaxIncluded()

void gncEntrySetBillTaxIncluded ( GncEntry *  entry,
gboolean  tax_included 
)

Definition at line 755 of file gncEntry.c.

756{
757 if (!entry) return;
758
759 ENTER ("%d", taxincluded);
760 if (entry->b_taxincluded == taxincluded) {
761 LEAVE ("Value already set");
762 return;
763 }
764 gncEntryBeginEdit (entry);
765 entry->b_taxincluded = taxincluded;
766 entry->values_dirty = TRUE;
767 mark_entry (entry);
768 gncEntryCommitEdit (entry);
769 LEAVE ("");
770}

◆ gncEntrySetBillTaxTable()

void gncEntrySetBillTaxTable ( GncEntry *  entry,
GncTaxTable table 
)

Definition at line 772 of file gncEntry.c.

773{
774 if (!entry) return;
775
776 ENTER ("%s", gncTaxTableGetName (table));
777 if (entry->b_tax_table == table) {
778 LEAVE ("Value already set");
779 return;
780 }
781 gncEntryBeginEdit (entry);
782 if (entry->b_tax_table)
783 gncTaxTableDecRef (entry->b_tax_table);
784 if (table)
785 gncTaxTableIncRef (table);
786 entry->b_tax_table = table;
787 entry->values_dirty = TRUE;
788 mark_entry (entry);
789 gncEntryCommitEdit (entry);
790 LEAVE ("");
791}

◆ gncEntrySetBillTo()

void gncEntrySetBillTo ( GncEntry *  entry,
GncOwner billto 
)

Definition at line 804 of file gncEntry.c.

805{
806 if (!entry || !billto) return;
807 if (gncOwnerEqual (&entry->billto, billto)) return;
808
809 gncEntryBeginEdit (entry);
810 gncOwnerCopy (billto, &entry->billto);
811 mark_entry (entry);
812 gncEntryCommitEdit (entry);
813}
gboolean gncOwnerEqual(const GncOwner *a, const GncOwner *b)
Assess equality by checking.
Definition gncOwner.c:404

◆ gncEntrySetDate()

void gncEntrySetDate ( GncEntry *  entry,
time64  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 482 of file gncEntry.c.

483{
484 gboolean first_date = FALSE;
485 if (!entry) return;
486 if (entry->date == date) return;
487 if (!entry->date)
488 first_date = TRUE;
489 gncEntryBeginEdit (entry);
490 entry->date = date;
491 mark_entry (entry);
492 gncEntryCommitEdit (entry);
493
494 /* Don't re-sort the first time we set the date on this entry */
495 if (!first_date)
496 {
497 if (entry->invoice)
498 gncInvoiceSortEntries(entry->invoice);
499 if (entry->bill)
500 gncInvoiceSortEntries(entry->bill);
501 }
502}
void gncInvoiceSortEntries(GncInvoice *invoice)
Call this function when an Entry is changed and you want to re-sort the list of entries.
Definition gncInvoice.c:750

◆ gncEntrySetDateEntered()

void gncEntrySetDateEntered ( GncEntry *  entry,
time64  date 
)

Definition at line 517 of file gncEntry.c.

518{
519 if (!entry) return;
520 if (entry->date_entered == date) return;
521 gncEntryBeginEdit (entry);
522 entry->date_entered = date;
523 mark_entry (entry);
524 gncEntryCommitEdit (entry);
525}

◆ gncEntrySetDateGDate()

void gncEntrySetDateGDate ( GncEntry *  entry,
const GDate *  date 
)

Set the date of this entry.

Definition at line 504 of file gncEntry.c.

505{
506 if (!entry || !date || !g_date_valid(date))
507 return;
508
509 /* Watch out: Here we are deviating from the initial convention that a
510 GDate always converts to the start time of the day. Instead, the GDate is
511 converted to "noon" on the respective date. This is not nice, but this
512 convention was used for the time64 of GncEntry all the time, so we better
513 stick to it.*/
515}
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
time64 time64CanonicalDayTime(time64 t)
convert a time64 on a certain day (localtime) to the time64 representing midday on that day.
Definition gnc-date.cpp:404
void gncEntrySetDate(GncEntry *entry, time64 date)
DEPRECATED - use gncEntrySetDateGDate() instead! (Because the time-of-day is a misleading extra infor...
Definition gncEntry.c:482

◆ gncEntrySetDescription()

void gncEntrySetDescription ( GncEntry *  entry,
const char *  desc 
)

Definition at line 527 of file gncEntry.c.

528{
529 if (!entry || !desc) return;
530 SET_STR (entry, entry->desc, desc);
531 mark_entry (entry);
532 gncEntryCommitEdit (entry);
533}

◆ gncEntrySetDocQuantity()

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 562 of file gncEntry.c.

563{
564 if (!entry) return;
565 if (gnc_numeric_eq (entry->quantity, (is_cn ? gnc_numeric_neg (quantity) : quantity))) return;
566 gncEntryBeginEdit (entry);
567 entry->quantity = (is_cn ? gnc_numeric_neg (quantity) : quantity);
568 entry->values_dirty = TRUE;
569 mark_entry (entry);
570 gncEntryCommitEdit (entry);
571}

◆ gncEntrySetInvAccount()

void gncEntrySetInvAccount ( GncEntry *  entry,
Account acc 
)

Definition at line 575 of file gncEntry.c.

576{
577 if (!entry) return;
578 if (entry->i_account == acc) return;
579 gncEntryBeginEdit (entry);
580 entry->i_account = acc;
581 mark_entry (entry);
582 gncEntryCommitEdit (entry);
583}

◆ gncEntrySetInvDiscount()

void gncEntrySetInvDiscount ( GncEntry *  entry,
gnc_numeric  discount 
)

Definition at line 651 of file gncEntry.c.

652{
653 if (!entry) return;
654 if (gnc_numeric_eq (entry->i_discount, discount)) return;
655 gncEntryBeginEdit (entry);
656 entry->i_discount = discount;
657 entry->values_dirty = TRUE;
658 mark_entry (entry);
659 gncEntryCommitEdit (entry);
660}

◆ gncEntrySetInvDiscountHow()

void gncEntrySetInvDiscountHow ( GncEntry *  entry,
GncDiscountHow  how 
)

Definition at line 674 of file gncEntry.c.

675{
676 if (!entry) return;
677 if (entry->i_disc_how == how) return;
678
679 gncEntryBeginEdit (entry);
680 entry->i_disc_how = how;
681 entry->values_dirty = TRUE;
682 mark_entry (entry);
683 gncEntryCommitEdit (entry);
684}

◆ gncEntrySetInvDiscountType()

void gncEntrySetInvDiscountType ( GncEntry *  entry,
GncAmountType  type 
)

Definition at line 662 of file gncEntry.c.

663{
664 if (!entry) return;
665 if (entry->i_disc_type == type) return;
666
667 gncEntryBeginEdit (entry);
668 entry->i_disc_type = type;
669 entry->values_dirty = TRUE;
670 mark_entry (entry);
671 gncEntryCommitEdit (entry);
672}

◆ gncEntrySetInvPrice()

void gncEntrySetInvPrice ( GncEntry *  entry,
gnc_numeric  price 
)

Definition at line 585 of file gncEntry.c.

586{
587 if (!entry) return;
588 if (gnc_numeric_eq (entry->i_price, price)) return;
589 gncEntryBeginEdit (entry);
590 entry->i_price = price;
591 entry->values_dirty = TRUE;
592 mark_entry (entry);
593 gncEntryCommitEdit (entry);
594}

◆ gncEntrySetInvTaxable()

void gncEntrySetInvTaxable ( GncEntry *  entry,
gboolean  taxable 
)

Definition at line 596 of file gncEntry.c.

597{
598 if (!entry) return;
599
600 ENTER ("%d", taxable);
601 if (entry->i_taxable == taxable) {
602 LEAVE ("Value already set");
603 return;
604 }
605 gncEntryBeginEdit (entry);
606 entry->i_taxable = taxable;
607 entry->values_dirty = TRUE;
608 mark_entry (entry);
609 gncEntryCommitEdit (entry);
610 LEAVE ("");
611}

◆ gncEntrySetInvTaxIncluded()

void gncEntrySetInvTaxIncluded ( GncEntry *  entry,
gboolean  tax_included 
)

Definition at line 613 of file gncEntry.c.

614{
615 if (!entry) return;
616
617 ENTER ("%d", taxincluded);
618 if (entry->i_taxincluded == taxincluded) {
619 LEAVE ("Value already set");
620 return;
621 }
622 gncEntryBeginEdit (entry);
623 entry->i_taxincluded = taxincluded;
624 entry->values_dirty = TRUE;
625 mark_entry (entry);
626 gncEntryCommitEdit (entry);
627 LEAVE ("");
628}

◆ gncEntrySetInvTaxTable()

void gncEntrySetInvTaxTable ( GncEntry *  entry,
GncTaxTable table 
)

Definition at line 630 of file gncEntry.c.

631{
632 if (!entry) return;
633
634 ENTER ("%s", gncTaxTableGetName (table));
635 if (entry->i_tax_table == table) {
636 LEAVE ("Value already set");
637 return;
638 }
639 gncEntryBeginEdit (entry);
640 if (entry->i_tax_table)
641 gncTaxTableDecRef (entry->i_tax_table);
642 if (table)
643 gncTaxTableIncRef (table);
644 entry->i_tax_table = table;
645 entry->values_dirty = TRUE;
646 mark_entry (entry);
647 gncEntryCommitEdit (entry);
648 LEAVE ("");
649}

◆ gncEntrySetNotes()

void gncEntrySetNotes ( GncEntry *  entry,
const char *  notes 
)

Definition at line 543 of file gncEntry.c.

544{
545 if (!entry || !notes) return;
546 SET_STR (entry, entry->notes, notes);
547 mark_entry (entry);
548 gncEntryCommitEdit (entry);
549}

◆ gncEntrySetQuantity()

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 551 of file gncEntry.c.

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

◆ qofEntryGetInvDiscHow()

char * qofEntryGetInvDiscHow ( const GncEntry *  entry)

Definition at line 999 of file gncEntry.c.

1000{
1001 char *type_string;
1002
1003 if (!entry) return 0;
1004 type_string = g_strdup(gncEntryDiscountHowToString(entry->i_disc_how));
1005 return type_string;
1006}
const char * gncEntryDiscountHowToString(GncDiscountHow how)
How to apply the discount and taxes.
Definition gncEntry.c:113

◆ qofEntryGetInvDiscType()

char * qofEntryGetInvDiscType ( const GncEntry *  entry)

Definition at line 990 of file gncEntry.c.

991{
992 char *type_string;
993
994 if (!entry) return 0;
995 type_string = g_strdup(gncAmountTypeToString(entry->i_disc_type));
996 return type_string;
997}

◆ qofEntrySetInvDiscHow()

void qofEntrySetInvDiscHow ( GncEntry *  entry,
const char *  type 
)

Definition at line 701 of file gncEntry.c.

702{
703 GncDiscountHow how = GNC_DISC_PRETAX;
704
705 if (!entry) return;
706 gncEntryBeginEdit (entry);
707 gncEntryDiscountStringToHow(type, &how);
708 if (entry->i_disc_how == how) return;
709 entry->i_disc_how = how;
710 entry->values_dirty = TRUE;
711 mark_entry (entry);
712 gncEntryCommitEdit (entry);
713}

◆ qofEntrySetInvDiscType()

void qofEntrySetInvDiscType ( GncEntry *  entry,
const char *  type 
)

Definition at line 686 of file gncEntry.c.

687{
688 GncAmountType type;
689
690 if (!entry) return;
691 gncAmountStringToType(type_string, &type);
692 if (entry->i_disc_type == type) return;
693 gncEntryBeginEdit (entry);
694 entry->i_disc_type = type;
695 entry->values_dirty = TRUE;
696 mark_entry (entry);
697 gncEntryCommitEdit (entry);
698
699}
GncAmountType
How to interpret the amount.
Definition gncTaxTable.h:79