gncInvoice uses time64

This commit is contained in:
lmat 2017-12-29 16:07:08 -05:00 committed by Christopher Lam
parent 598cb6d861
commit 9a86dd222b
11 changed files with 89 additions and 129 deletions

View File

@ -308,7 +308,7 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
GtkTextBuffer* text_buffer; GtkTextBuffer* text_buffer;
GtkTextIter start, end; GtkTextIter start, end;
gchar *text; gchar *text;
Timespec ts; time64 time;
gboolean is_credit_note = gncInvoiceGetIsCreditNote (invoice); gboolean is_credit_note = gncInvoiceGetIsCreditNote (invoice);
if (iw->dialog_type == VIEW_INVOICE) if (iw->dialog_type == VIEW_INVOICE)
@ -341,8 +341,8 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
(GTK_EDITABLE (iw->billing_id_entry), 0, -1)); (GTK_EDITABLE (iw->billing_id_entry), 0, -1));
gncInvoiceSetTerms (invoice, iw->terms); gncInvoiceSetTerms (invoice, iw->terms);
ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (iw->opened_date)); time = gnc_date_edit_get_date (GNC_DATE_EDIT (iw->opened_date));
gncInvoiceSetDateOpened (invoice, ts); gncInvoiceSetDateOpened (invoice, time);
gnc_owner_get_owner (iw->owner_choice, &(iw->owner)); gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
if (iw->job_choice) if (iw->job_choice)
@ -948,7 +948,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
else else
auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY); auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY);
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, accumulate, auto_pay); gncInvoicePostToAccount (invoice, acc, postdate.tv_sec, ddue.tv_sec, memo, accumulate, auto_pay);
cleanup: cleanup:
gncInvoiceCommitEdit (invoice); gncInvoiceCommitEdit (invoice);
@ -1747,8 +1747,8 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
GtkTextBuffer* text_buffer; GtkTextBuffer* text_buffer;
const char *string; const char *string;
gchar * tmp_string; gchar * tmp_string;
Timespec ts, ts_zero = {0, 0};
Account *acct; Account *acct;
time64 time;
gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice)); gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice));
@ -1763,15 +1763,15 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (iw->active_check), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (iw->active_check),
gncInvoiceGetActive (invoice)); gncInvoiceGetActive (invoice));
ts = gncInvoiceGetDateOpened (invoice); time = gncInvoiceGetDateOpened (invoice);
if (timespec_equal (&ts, &ts_zero)) if (!time)
{ {
gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date), gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date),
gnc_time (NULL)); gnc_time (NULL));
} }
else else
{ {
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->opened_date), ts); gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date), time);
} }
/* fill in the terms text */ /* fill in the terms text */
@ -1816,8 +1816,8 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
*/ */
can_unpost = TRUE; can_unpost = TRUE;
ts = gncInvoiceGetDatePosted (invoice); time = gncInvoiceGetDatePosted (invoice);
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->posted_date), ts); gnc_date_edit_set_time (GNC_DATE_EDIT (iw->posted_date), time);
tmp_string = gnc_account_get_full_name (acct); tmp_string = gnc_account_get_full_name (acct);
gtk_entry_set_text (GTK_ENTRY (acct_entry), tmp_string); gtk_entry_set_text (GTK_ENTRY (acct_entry), tmp_string);

View File

@ -485,7 +485,6 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
const gchar *doc_deb_str = NULL; const gchar *doc_deb_str = NULL;
const gchar *doc_cred_str = NULL; const gchar *doc_cred_str = NULL;
GtkTreeIter iter; GtkTreeIter iter;
Timespec doc_date;
GncInvoice *document; GncInvoice *document;
gnc_numeric value = gnc_numeric_zero(); gnc_numeric value = gnc_numeric_zero();
gnc_numeric debit = gnc_numeric_zero(); gnc_numeric debit = gnc_numeric_zero();
@ -497,17 +496,16 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
/* Find the document's date or pre-payment date */ /* Find the document's date or pre-payment date */
if (document) if (document)
doc_date = gncInvoiceGetDatePosted (document); doc_date_time = gncInvoiceGetDatePosted (document);
else else
{ {
/* Calculate the payment date based on the lot splits */ /* Calculate the payment date based on the lot splits */
Transaction *trans = xaccSplitGetParent (gnc_lot_get_latest_split (lot)); Transaction *trans = xaccSplitGetParent (gnc_lot_get_latest_split (lot));
if (trans) if (trans)
doc_date = xaccTransRetDatePostedTS (trans); doc_date_time = xaccTransRetDatePosted (trans);
else else
continue; /* No valid split in this lot, skip it */ continue; /* No valid split in this lot, skip it */
} }
doc_date_time = timespecToTime64 (doc_date);
/* Find the document type. No type means pre-payment in this case */ /* Find the document type. No type means pre-payment in this case */
if (document) if (document)

View File

@ -968,7 +968,6 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action,
Account *bank_acct = xaccMallocAccount(book); Account *bank_acct = xaccMallocAccount(book);
Account *tax_acct = xaccMallocAccount(book); Account *tax_acct = xaccMallocAccount(book);
Account *ar_acct = xaccMallocAccount(book); Account *ar_acct = xaccMallocAccount(book);
Timespec now;
// Create Customer // Create Customer
gncCustomerSetID(customer, "000001"); gncCustomerSetID(customer, "000001");
@ -983,10 +982,9 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action,
gncOwnerInitCustomer(owner, customer); gncOwnerInitCustomer(owner, customer);
// Create the Invoice // Create the Invoice
timespecFromTime64(&now, time(NULL));
gncInvoiceSetID(invoice, "000012"); gncInvoiceSetID(invoice, "000012");
gncInvoiceSetOwner(invoice, owner); gncInvoiceSetOwner(invoice, owner);
gncInvoiceSetDateOpened(invoice, now); gncInvoiceSetDateOpened(invoice, gnc_time (NULL));
gncInvoiceSetCurrency(invoice, gnc_default_currency()); gncInvoiceSetCurrency(invoice, gnc_default_currency());
// Create the Job // Create the Job

View File

@ -566,7 +566,7 @@ void gnc_entry_ledger_set_default_invoice (GncEntryLedger *ledger,
* to understand why. * to understand why.
*/ */
if (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR) if (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR)
ledger->last_date_entered = timespec_to_gdate(gncInvoiceGetDateOpened (invoice)); ledger->last_date_entered = time64_to_gdate(gncInvoiceGetDateOpened (invoice));
if (!ledger->query && invoice) if (!ledger->query && invoice)
create_invoice_query (ledger); create_invoice_query (ledger);

View File

@ -81,17 +81,17 @@ maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
} }
static void static void
maybe_add_timespec (xmlNodePtr ptr, const char* tag, Timespec ts) maybe_add_time64 (xmlNodePtr ptr, const char* tag, time64 time)
{ {
if (ts.tv_sec) if (time)
xmlAddChild (ptr, time64_to_dom_tree (tag, ts.tv_sec)); xmlAddChild (ptr, time64_to_dom_tree (tag, time));
} }
static xmlNodePtr static xmlNodePtr
invoice_dom_tree_create (GncInvoice* invoice) invoice_dom_tree_create (GncInvoice* invoice)
{ {
xmlNodePtr ret; xmlNodePtr ret;
Timespec ts; time64 time;
Transaction* txn; Transaction* txn;
GNCLot* lot; GNCLot* lot;
Account* acc; Account* acc;
@ -111,11 +111,10 @@ invoice_dom_tree_create (GncInvoice* invoice)
xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string, xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string,
gncInvoiceGetOwner (invoice))); gncInvoiceGetOwner (invoice)));
ts = gncInvoiceGetDateOpened (invoice); time = gncInvoiceGetDateOpened (invoice);
xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, ts.tv_sec)); xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, time));
maybe_add_timespec (ret, invoice_posted_string, maybe_add_time64 (ret, invoice_posted_string, gncInvoiceGetDatePosted (invoice));
gncInvoiceGetDatePosted (invoice));
term = gncInvoiceGetTerms (invoice); term = gncInvoiceGetTerms (invoice);
if (term) if (term)
@ -185,14 +184,12 @@ set_string (xmlNodePtr node, GncInvoice* invoice,
} }
static inline gboolean static inline gboolean
set_timespec (xmlNodePtr node, GncInvoice* invoice, set_time64 (xmlNodePtr node, GncInvoice* invoice,
void (*func) (GncInvoice* invoice, Timespec ts)) void (*func) (GncInvoice* invoice, time64 time))
{ {
time64 time = dom_tree_to_time64 (node); time64 time = dom_tree_to_time64 (node);
if (!dom_tree_valid_time64 (time, node->name)) return FALSE; if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
func (invoice, time);
Timespec ts = {time, 0};
func (invoice, ts);
return TRUE; return TRUE;
} }
@ -248,16 +245,14 @@ static gboolean
invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata) invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata)
{ {
struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata); struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
return set_time64 (node, pdata->invoice, gncInvoiceSetDateOpened);
return set_timespec (node, pdata->invoice, gncInvoiceSetDateOpened);
} }
static gboolean static gboolean
invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata) invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata)
{ {
struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata); struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
return set_time64 (node, pdata->invoice, gncInvoiceSetDatePosted);
return set_timespec (node, pdata->invoice, gncInvoiceSetDatePosted);
} }
static gboolean static gboolean

View File

@ -2055,6 +2055,13 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
g_free(date); g_free(date);
} }
void
xaccTransSetDateDue (Transaction * trans, time64 time)
{
Timespec ts_send = {time, 0};
xaccTransSetDateDueTS (trans, &ts_send);
}
void void
xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts) xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts)
{ {

View File

@ -640,6 +640,7 @@ void xaccTransSetDateEnteredTS (Transaction *trans,
/** Dates and txn-type for A/R and A/P "invoice" postings */ /** Dates and txn-type for A/R and A/P "invoice" postings */
void xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts); void xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts);
void xaccTransSetDateDue (Transaction * trans, time64 time);
/** Retrieve the posted date of the transaction. The posted date is /** Retrieve the posted date of the transaction. The posted date is
the date when this transaction was posted at the bank. (Although the date when this transaction was posted at the bank. (Although

View File

@ -61,8 +61,8 @@ struct _gncInvoice
GncOwner owner; GncOwner owner;
GncOwner billto; GncOwner billto;
GncJob *job; GncJob *job;
Timespec date_opened; time64 date_opened;
Timespec date_posted; time64 date_posted;
gnc_numeric to_charge_amount; gnc_numeric to_charge_amount;
@ -481,23 +481,23 @@ qofInvoiceSetBillTo (GncInvoice *invoice, QofInstance *ent)
void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date) void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date)
{ {
g_assert (date); g_assert (date);
gncInvoiceSetDateOpened(invoice, timespecCanonicalDayTime(gdate_to_timespec(*date))); gncInvoiceSetDateOpened(invoice, time64CanonicalDayTime(gdate_to_time64 (*date)));
} }
void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date) void gncInvoiceSetDateOpened (GncInvoice *invoice, time64 date)
{ {
if (!invoice) return; if (!invoice) return;
if (timespec_equal (&invoice->date_opened, &date)) return; if (date == invoice->date_opened) return;
gncInvoiceBeginEdit (invoice); gncInvoiceBeginEdit (invoice);
invoice->date_opened = date; invoice->date_opened = date;
mark_invoice (invoice); mark_invoice (invoice);
gncInvoiceCommitEdit (invoice); gncInvoiceCommitEdit (invoice);
} }
void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date) void gncInvoiceSetDatePosted (GncInvoice *invoice, time64 date)
{ {
if (!invoice) return; if (!invoice) return;
if (timespec_equal (&invoice->date_posted, &date)) return; if (date == invoice->date_posted) return;
gncInvoiceBeginEdit (invoice); gncInvoiceBeginEdit (invoice);
invoice->date_posted = date; invoice->date_posted = date;
mark_invoice (invoice); mark_invoice (invoice);
@ -805,52 +805,25 @@ qofInvoiceGetBillTo (GncInvoice *invoice)
return QOF_INSTANCE(billto); return QOF_INSTANCE(billto);
} }
Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice) time64 gncInvoiceGetDateOpened (const GncInvoice *invoice)
{ {
Timespec ts; if (!invoice) return 0;
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (!invoice) return ts;
return invoice->date_opened; return invoice->date_opened;
} }
Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice) time64 gncInvoiceGetDatePosted (const GncInvoice *invoice)
{ {
Timespec ts; if (!invoice) return 0;
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (!invoice) return ts;
return invoice->date_posted; return invoice->date_posted;
} }
Timespec gncInvoiceGetDateDue (const GncInvoice *invoice) time64 gncInvoiceGetDateDue (const GncInvoice *invoice)
{ {
Transaction *txn; Transaction *txn;
Timespec ts; if (!invoice) return 0;
ts.tv_sec = 0;
ts.tv_nsec = 0;
if (!invoice) return ts;
txn = gncInvoiceGetPostedTxn (invoice); txn = gncInvoiceGetPostedTxn (invoice);
if (!txn) return ts; if (!txn) return 0;
return xaccTransRetDateDueTS (txn); return xaccTransRetDateDue (txn);
}
time64 gncInvoiceGetDateOpenedTT (const GncInvoice *invoice)
{
if (!invoice) return 0;
return invoice->date_opened.tv_sec;
}
time64 gncInvoiceGetDatePostedTT (const GncInvoice *invoice)
{
if (!invoice) return 0;
return invoice->date_posted.tv_sec;
}
time64 gncInvoiceGetDateDueTT (const GncInvoice *invoice)
{
if (!invoice) return 0;
return gncInvoiceGetDateDue (invoice).tv_sec;
} }
GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice) GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice)
@ -1384,7 +1357,7 @@ static gboolean gncInvoicePostAddSplit (QofBook *book,
} }
Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc, Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Timespec *post_date, Timespec *due_date, time64 post_date, time64 due_date,
const char * memo, gboolean accumulatesplits, const char * memo, gboolean accumulatesplits,
gboolean autopay) gboolean autopay)
{ {
@ -1446,14 +1419,10 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
/* Entered and Posted at date */ /* Entered and Posted at date */
xaccTransSetDateEnteredSecs (txn, gnc_time (NULL)); xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
if (post_date) xaccTransSetDatePostedSecs (txn, post_date);
{ gncInvoiceSetDatePosted (invoice, post_date);
xaccTransSetDatePostedTS (txn, post_date);
gncInvoiceSetDatePosted (invoice, *post_date);
}
if (due_date) xaccTransSetDateDue (txn, due_date);
xaccTransSetDateDueTS (txn, due_date);
/* Iterate through the entries; sum up everything for each account. /* Iterate through the entries; sum up everything for each account.
* then create the appropriate splits in this txn. * then create the appropriate splits in this txn.
@ -1749,7 +1718,7 @@ gncInvoiceUnpost (GncInvoice *invoice, gboolean reset_tax_tables)
invoice->posted_acc = NULL; invoice->posted_acc = NULL;
invoice->posted_txn = NULL; invoice->posted_txn = NULL;
invoice->posted_lot = NULL; invoice->posted_lot = NULL;
invoice->date_posted.tv_sec = invoice->date_posted.tv_nsec = 0; invoice->date_posted = 0;
/* if we've been asked to reset the tax tables, then do so */ /* if we've been asked to reset the tax tables, then do so */
if (reset_tax_tables) if (reset_tax_tables)
@ -1857,12 +1826,13 @@ void gncInvoiceAutoApplyPayments (GncInvoice *invoice)
void void
gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn, gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
Account *xfer_acc, gnc_numeric amount, Account *xfer_acc, gnc_numeric amount,
gnc_numeric exch, Timespec date, gnc_numeric exch, time64 date,
const char *memo, const char *num) const char *memo, const char *num)
{ {
GNCLot *payment_lot; GNCLot *payment_lot;
GList *selected_lots = NULL; GList *selected_lots = NULL;
const GncOwner *owner; const GncOwner *owner;
Timespec ts_pass = {date,0};
/* Verify our arguments */ /* Verify our arguments */
if (!invoice || !gncInvoiceIsPosted (invoice) || !xfer_acc) return; if (!invoice || !gncInvoiceIsPosted (invoice) || !xfer_acc) return;
@ -1872,7 +1842,7 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
/* Create a lot for this payment */ /* Create a lot for this payment */
payment_lot = gncOwnerCreatePaymentLot (owner, &txn, invoice->posted_acc, xfer_acc, payment_lot = gncOwnerCreatePaymentLot (owner, &txn, invoice->posted_acc, xfer_acc,
amount, exch, date, memo, num); amount, exch, ts_pass, memo, num);
/* Select the invoice as only payment candidate */ /* Select the invoice as only payment candidate */
selected_lots = g_list_prepend (selected_lots, invoice->posted_lot); selected_lots = g_list_prepend (selected_lots, invoice->posted_lot);
@ -1883,17 +1853,15 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
gncOwnerAutoApplyPaymentsWithLots (owner, selected_lots); gncOwnerAutoApplyPaymentsWithLots (owner, selected_lots);
} }
static gboolean gncInvoiceDateExists (const Timespec *date) static gboolean gncInvoiceDateExists (time64 date)
{ {
g_return_val_if_fail (date, FALSE); return date;
if (date->tv_sec || date->tv_nsec) return TRUE;
return FALSE;
} }
gboolean gncInvoiceIsPosted (const GncInvoice *invoice) gboolean gncInvoiceIsPosted (const GncInvoice *invoice)
{ {
if (!invoice) return FALSE; if (!invoice) return FALSE;
return gncInvoiceDateExists (&(invoice->date_posted)); return gncInvoiceDateExists (invoice->date_posted);
} }
gboolean gncInvoiceIsPaid (const GncInvoice *invoice) gboolean gncInvoiceIsPaid (const GncInvoice *invoice)
@ -1941,13 +1909,8 @@ int gncInvoiceCompare (const GncInvoice *a, const GncInvoice *b)
compare = g_strcmp0 (a->id, b->id); compare = g_strcmp0 (a->id, b->id);
if (compare) return compare; if (compare) return compare;
if (a->date_opened != b->date_opened) return a->date_opened - b->date_opened;
compare = timespec_cmp (&(a->date_opened), &(b->date_opened)); if (a->date_posted != b->date_posted) return a->date_posted - b->date_posted;
if (compare) return compare;
compare = timespec_cmp (&(a->date_posted), &(b->date_posted));
if (compare) return compare;
return qof_instance_guid_compare(a, b); return qof_instance_guid_compare(a, b);
} }
@ -2033,8 +1996,8 @@ gboolean gncInvoiceEqual(const GncInvoice *a, const GncInvoice *b)
GList *prices; GList *prices;
GncOwner owner; GncOwner owner;
GncOwner billto; GncOwner billto;
Timespec date_opened; time64 date_opened;
Timespec date_posted; time64 date_posted;
gnc_numeric to_charge_amount; gnc_numeric to_charge_amount;
#endif #endif

View File

@ -101,10 +101,10 @@ GncInvoice *gncInvoiceCopy (const GncInvoice *other_invoice);
void gncInvoiceSetID (GncInvoice *invoice, const char *id); void gncInvoiceSetID (GncInvoice *invoice, const char *id);
void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner); void gncInvoiceSetOwner (GncInvoice *invoice, GncOwner *owner);
/** Set the DateOpened using a GDate argument. (Note: Internally this stores /** Set the DateOpened using a GDate argument. (Note: Internally this stores
the date in a Timespec as created through timespecCanonicalDayTime()). */ the date in a time64 as created through timespecCanonicalDayTime()). */
void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date); void gncInvoiceSetDateOpenedGDate (GncInvoice *invoice, const GDate *date);
void gncInvoiceSetDateOpened (GncInvoice *invoice, Timespec date); void gncInvoiceSetDateOpened (GncInvoice *invoice, time64 date);
void gncInvoiceSetDatePosted (GncInvoice *invoice, Timespec date); void gncInvoiceSetDatePosted (GncInvoice *invoice, time64 date);
void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms); void gncInvoiceSetTerms (GncInvoice *invoice, GncBillTerm *terms);
void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id); void gncInvoiceSetBillingID (GncInvoice *invoice, const char *billing_id);
void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes); void gncInvoiceSetNotes (GncInvoice *invoice, const char *notes);
@ -137,12 +137,9 @@ void gncInvoiceRemoveEntries (GncInvoice *invoice);
@{ */ @{ */
const char * gncInvoiceGetID (const GncInvoice *invoice); const char * gncInvoiceGetID (const GncInvoice *invoice);
const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice); const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice);
Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice); time64 gncInvoiceGetDateOpened (const GncInvoice *invoice);
time64 gncInvoiceGetDateOpenedTT (const GncInvoice *invoice); time64 gncInvoiceGetDatePosted (const GncInvoice *invoice);
Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice); time64 gncInvoiceGetDateDue (const GncInvoice *invoice);
time64 gncInvoiceGetDatePostedTT (const GncInvoice *invoice);
Timespec gncInvoiceGetDateDue (const GncInvoice *invoice);
time64 gncInvoiceGetDateDueTT (const GncInvoice *invoice);
GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice); GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
const char * gncInvoiceGetBillingID (const GncInvoice *invoice); const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
const char * gncInvoiceGetNotes (const GncInvoice *invoice); const char * gncInvoiceGetNotes (const GncInvoice *invoice);
@ -212,7 +209,7 @@ GHashTable *gncInvoiceGetForeignCurrencies (const GncInvoice *invoice);
*/ */
Transaction * Transaction *
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc, gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Timespec *posted_date, Timespec *due_date, time64 posted_date, time64 due_date,
const char *memo, gboolean accumulatesplits, const char *memo, gboolean accumulatesplits,
gboolean autopay); gboolean autopay);
@ -253,7 +250,7 @@ gncInvoiceAutoApplyPayments (GncInvoice *invoice);
void void
gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn, gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
Account *xfer_acc, gnc_numeric amount, Account *xfer_acc, gnc_numeric amount,
gnc_numeric exch, Timespec date, gnc_numeric exch, time64 date,
const char *memo, const char *num); const char *memo, const char *num);

View File

@ -704,7 +704,7 @@ gint
gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB) gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
{ {
GncInvoice *ia, *ib; GncInvoice *ia, *ib;
Timespec da, db; time64 da, db;
ia = gncInvoiceGetInvoiceFromLot (lotA); ia = gncInvoiceGetInvoiceFromLot (lotA);
ib = gncInvoiceGetInvoiceFromLot (lotB); ib = gncInvoiceGetInvoiceFromLot (lotB);
@ -712,14 +712,14 @@ gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
if (ia) if (ia)
da = gncInvoiceGetDateDue (ia); da = gncInvoiceGetDateDue (ia);
else else
da = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA))); da = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA))).tv_sec;
if (ib) if (ib)
db = gncInvoiceGetDateDue (ib); db = gncInvoiceGetDateDue (ib);
else else
db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB))); db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB))).tv_sec;
return timespec_cmp (&da, &db); return (da > db) - (da < db);
} }
GNCLot * GNCLot *

View File

@ -69,7 +69,8 @@ static void
test_invoice_post ( Fixture *fixture, gconstpointer pData ) test_invoice_post ( Fixture *fixture, gconstpointer pData )
{ {
GncInvoice *invoice = gncInvoiceCreate(fixture->book); GncInvoice *invoice = gncInvoiceCreate(fixture->book);
Timespec ts1 = timespec_now(), ts2 = ts1; time64 ts1 = gnc_time(NULL);
time64 ts2 = ts1;
g_assert(invoice); g_assert(invoice);
g_assert(!gncInvoiceGetIsCreditNote(invoice)); g_assert(!gncInvoiceGetIsCreditNote(invoice));
g_assert(gncInvoiceGetActive(invoice)); g_assert(gncInvoiceGetActive(invoice));
@ -81,7 +82,7 @@ test_invoice_post ( Fixture *fixture, gconstpointer pData )
g_test_message( "Will now post the invoice" ); g_test_message( "Will now post the invoice" );
g_assert(!gncInvoiceIsPosted(invoice)); g_assert(!gncInvoiceIsPosted(invoice));
gncInvoicePostToAccount(invoice, fixture->account, &ts1, &ts2, "memo", TRUE, FALSE); gncInvoicePostToAccount(invoice, fixture->account, ts1, ts2, "memo", TRUE, FALSE);
g_assert(gncInvoiceIsPosted(invoice)); g_assert(gncInvoiceIsPosted(invoice));
gncInvoiceUnpost(invoice, TRUE); gncInvoiceUnpost(invoice, TRUE);