2001-11-21 19:23:07 -06:00
|
|
|
/*
|
|
|
|
* gncInvoice.h -- the Core Business Invoice Interface
|
|
|
|
* Copyright (C) 2001 Derek Atkins
|
|
|
|
* Author: Derek Atkins <warlord@MIT.EDU>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GNC_INVOICE_H_
|
|
|
|
#define GNC_INVOICE_H_
|
|
|
|
|
|
|
|
struct _gncInvoice;
|
|
|
|
typedef struct _gncInvoice GncInvoice;
|
|
|
|
|
2002-06-21 21:38:13 -05:00
|
|
|
#include "gncBillTerm.h"
|
2001-11-29 17:04:34 -06:00
|
|
|
#include "gncEntry.h"
|
2001-12-05 23:46:42 -06:00
|
|
|
#include "gncOwner.h"
|
2002-06-24 17:30:36 -05:00
|
|
|
#include "gnc-lot.h"
|
2001-11-29 17:04:34 -06:00
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
#define GNC_INVOICE_MODULE_NAME "gncInvoice"
|
|
|
|
|
|
|
|
/* Create/Destroy Functions */
|
|
|
|
|
2001-12-05 23:46:42 -06:00
|
|
|
GncInvoice *gncInvoiceCreate (GNCBook *book);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncInvoiceDestroy (GncInvoice *invoice);
|
|
|
|
|
|
|
|
/* Set Functions */
|
|
|
|
|
|
|
|
void gncInvoiceSetID (GncInvoice *invoice, const char *id);
|
2001-12-07 21:17:51 -06:00
|
|
|
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
|
2002-02-26 17:42:11 -06:00
|
|
|
void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date);
|
|
|
|
void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date);
|
2002-06-21 21:38:13 -05:00
|
|
|
void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms);
|
2002-05-08 15:42:38 -05:00
|
|
|
void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes);
|
2002-03-04 13:34:52 -06:00
|
|
|
void gncInvoiceSetCommonCommodity (GncInvoice *invoice, gnc_commodity *com);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncInvoiceSetActive (GncInvoice *invoice, gboolean active);
|
2002-07-10 16:07:46 -05:00
|
|
|
void gncInvoiceSetBillTo (GncInvoice *invoice, GncOwner *billto);
|
2001-11-21 19:23:07 -06:00
|
|
|
|
|
|
|
void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry);
|
|
|
|
void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry);
|
|
|
|
|
2002-07-09 23:12:19 -05:00
|
|
|
/* Call this function when adding an entry to a bill instead of an invoice */
|
|
|
|
void gncBillAddEntry (GncInvoice *bill, GncEntry *entry);
|
|
|
|
void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry);
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
/* Get Functions */
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
GNCBook * gncInvoiceGetBook (GncInvoice *invoice);
|
2001-11-21 19:23:07 -06:00
|
|
|
const GUID * gncInvoiceGetGUID (GncInvoice *invoice);
|
|
|
|
const char * gncInvoiceGetID (GncInvoice *invoice);
|
2001-12-05 23:46:42 -06:00
|
|
|
GncOwner * gncInvoiceGetOwner (GncInvoice *invoice);
|
2001-11-21 19:23:07 -06:00
|
|
|
Timespec gncInvoiceGetDateOpened (GncInvoice *invoice);
|
2002-02-10 19:59:54 -06:00
|
|
|
Timespec gncInvoiceGetDatePosted (GncInvoice *invoice);
|
2001-11-21 19:23:07 -06:00
|
|
|
Timespec gncInvoiceGetDateDue (GncInvoice *invoice);
|
2002-06-21 21:38:13 -05:00
|
|
|
GncBillTerm * gncInvoiceGetTerms (GncInvoice *invoice);
|
2002-05-08 15:42:38 -05:00
|
|
|
const char * gncInvoiceGetBillingID (GncInvoice *invoice);
|
2001-11-21 19:23:07 -06:00
|
|
|
const char * gncInvoiceGetNotes (GncInvoice *invoice);
|
2002-05-16 17:45:50 -05:00
|
|
|
const char * gncInvoiceGetType (GncInvoice *invoice);
|
2002-03-04 13:34:52 -06:00
|
|
|
gnc_commodity * gncInvoiceGetCommonCommodity (GncInvoice *invoice);
|
2002-07-10 16:07:46 -05:00
|
|
|
GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice);
|
2001-11-21 19:23:07 -06:00
|
|
|
gboolean gncInvoiceGetActive (GncInvoice *invoice);
|
|
|
|
|
2002-06-24 17:30:36 -05:00
|
|
|
GNCLot * gncInvoiceGetPostedLot (GncInvoice *invoice);
|
2001-11-23 23:35:08 -06:00
|
|
|
Transaction * gncInvoiceGetPostedTxn (GncInvoice *invoice);
|
|
|
|
Account * gncInvoiceGetPostedAcc (GncInvoice *invoice);
|
|
|
|
|
2002-10-27 19:44:18 -06:00
|
|
|
/* return the "total" amount of the invoice */
|
|
|
|
gnc_numeric gncInvoiceGetTotal (GncInvoice *invoice);
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
GList * gncInvoiceGetEntries (GncInvoice *invoice);
|
|
|
|
|
2001-11-23 23:35:08 -06:00
|
|
|
/* Post this invoice to an account. Returns the new Transaction
|
|
|
|
* that is tied to this invoice. The transaction is set with
|
2002-05-16 17:45:50 -05:00
|
|
|
* the supplied posted date, due date, and memo. The Transaction
|
|
|
|
* description is set to the name of the company.
|
2001-11-23 23:35:08 -06:00
|
|
|
*/
|
2002-01-22 21:58:07 -06:00
|
|
|
Transaction *
|
|
|
|
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
2002-05-08 15:42:38 -05:00
|
|
|
Timespec *posted_date, Timespec *due_date,
|
2002-05-16 17:45:50 -05:00
|
|
|
const char *memo);
|
2001-11-23 23:35:08 -06:00
|
|
|
|
2003-01-01 22:07:58 -06:00
|
|
|
/*
|
|
|
|
* UNpost this invoice. This will destroy the posted transaction
|
|
|
|
* and return the invoice to its unposted state. It may leave empty
|
|
|
|
* lots out there.
|
|
|
|
*
|
|
|
|
* Returns TRUE if successful, FALSE if there is a problem.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gncInvoiceUnpost (GncInvoice *invoice);
|
|
|
|
|
2003-01-01 20:30:44 -06:00
|
|
|
/*
|
|
|
|
* Apply a payment of "amount" for the owner, between the xfer_account
|
|
|
|
* (bank or other asset) and the posted_account (A/R or A/P).
|
|
|
|
*
|
|
|
|
* XXX: yes, this should be in gncOwner, but all the other logic is
|
|
|
|
* in gncInvoice...
|
|
|
|
*/
|
|
|
|
Transaction *
|
|
|
|
gncOwnerApplyPayment (GncOwner *owner, Account *posted_acc, Account *xfer_acc,
|
|
|
|
gnc_numeric amount, Timespec date,
|
|
|
|
const char *memo, const char *num);
|
|
|
|
|
2002-02-10 19:59:54 -06:00
|
|
|
|
2001-11-23 23:35:08 -06:00
|
|
|
/* Given a transaction, find and return the Invoice */
|
|
|
|
GncInvoice * gncInvoiceGetInvoiceFromTxn (Transaction *txn);
|
|
|
|
|
2002-06-24 17:30:36 -05:00
|
|
|
/* Given a LOT, find and return the Invoice attached to the lot */
|
|
|
|
GncInvoice * gncInvoiceGetInvoiceFromLot (GNCLot *lot);
|
|
|
|
|
2002-05-27 13:17:31 -05:00
|
|
|
GUID gncInvoiceRetGUID (GncInvoice *invoice);
|
|
|
|
GncInvoice * gncInvoiceLookupDirect (GUID guid, GNCBook *book);
|
|
|
|
|
2001-11-24 23:34:34 -06:00
|
|
|
GncInvoice * gncInvoiceLookup (GNCBook *book, const GUID *guid);
|
2001-11-21 19:23:07 -06:00
|
|
|
gboolean gncInvoiceIsDirty (GncInvoice *invoice);
|
2001-11-30 01:37:50 -06:00
|
|
|
void gncInvoiceBeginEdit (GncInvoice *invoice);
|
2001-11-21 19:23:07 -06:00
|
|
|
void gncInvoiceCommitEdit (GncInvoice *invoice);
|
2002-02-03 14:01:08 -06:00
|
|
|
int gncInvoiceCompare (GncInvoice *a, GncInvoice *b);
|
2002-02-19 12:23:53 -06:00
|
|
|
gboolean gncInvoiceIsPosted (GncInvoice *invoice);
|
|
|
|
gboolean gncInvoiceIsPaid (GncInvoice *invoice);
|
2002-02-03 14:01:08 -06:00
|
|
|
|
2002-02-08 22:18:50 -06:00
|
|
|
#define INVOICE_ID "id"
|
|
|
|
#define INVOICE_OWNER "owner"
|
|
|
|
#define INVOICE_OPENED "date_opened"
|
2002-02-10 19:59:54 -06:00
|
|
|
#define INVOICE_POSTED "date_posted"
|
2002-02-08 22:18:50 -06:00
|
|
|
#define INVOICE_DUE "date_due"
|
2002-02-19 12:23:53 -06:00
|
|
|
#define INVOICE_IS_POSTED "is_posted?"
|
2002-05-08 15:42:38 -05:00
|
|
|
#define INVOICE_TERMS "terms"
|
|
|
|
#define INVOICE_BILLINGID "billing_id"
|
2002-02-08 22:18:50 -06:00
|
|
|
#define INVOICE_NOTES "notes"
|
2002-02-03 19:55:33 -06:00
|
|
|
#define INVOICE_ACC "account"
|
2002-02-10 19:59:54 -06:00
|
|
|
#define INVOICE_POST_TXN "posted_txn"
|
2002-05-16 17:45:50 -05:00
|
|
|
#define INVOICE_TYPE "type"
|
2002-07-10 16:07:46 -05:00
|
|
|
#define INVOICE_BILLTO "bill-to"
|
2001-11-21 19:23:07 -06:00
|
|
|
|
2002-06-27 23:39:18 -05:00
|
|
|
#define INVOICE_FROM_LOT "invoice-from-lot"
|
|
|
|
#define INVOICE_FROM_TXN "invoice-from-txn"
|
|
|
|
|
2001-11-21 19:23:07 -06:00
|
|
|
#endif /* GNC_INVOICE_H_ */
|