mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Timespec->time64 in business code.
This commit is contained in:
parent
c8b372e390
commit
92a8cf330a
@ -973,9 +973,9 @@ gnc_payment_ok_cb (G_GNUC_UNUSED GtkWidget *widget, gpointer data)
|
||||
else
|
||||
auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY);
|
||||
|
||||
gncOwnerApplyPayment (&pw->owner, &(pw->tx_info->txn), selected_lots,
|
||||
pw->post_acct, pw->xfer_acct, pw->amount_tot,
|
||||
exch, t, memo, num, auto_pay);
|
||||
gncOwnerApplyPaymentSecs (&pw->owner, &(pw->tx_info->txn), selected_lots,
|
||||
pw->post_acct, pw->xfer_acct, pw->amount_tot,
|
||||
exch, t, memo, num, auto_pay);
|
||||
}
|
||||
gnc_resume_gui_refresh ();
|
||||
|
||||
|
@ -764,7 +764,7 @@ compute_monthyear (const GncBillTerm *term, time64 post_date,
|
||||
gnc_localtime_r (&post_date, &tm);
|
||||
iday = tm.tm_mday;
|
||||
imonth = tm.tm_mon + 1;
|
||||
iyear = tm.tm_year + 1;
|
||||
iyear = tm.tm_year + 1900;
|
||||
|
||||
if (cutoff <= 0)
|
||||
cutoff += gnc_date_get_last_mday (imonth - 1, iyear);
|
||||
@ -801,23 +801,23 @@ compute_monthyear (const GncBillTerm *term, time64 post_date,
|
||||
* detailed explanation of proximo.
|
||||
*/
|
||||
|
||||
static Timespec
|
||||
compute_time (const GncBillTerm *term, Timespec post_date, int days)
|
||||
static time64
|
||||
compute_time (const GncBillTerm *term, time64 post_date, int days)
|
||||
{
|
||||
Timespec res = post_date;
|
||||
time64 res = post_date;
|
||||
int day, month, year;
|
||||
|
||||
switch (term->type)
|
||||
{
|
||||
case GNC_TERM_TYPE_DAYS:
|
||||
res.tv_sec += (SECS_PER_DAY * days);
|
||||
res += (SECS_PER_DAY * days);
|
||||
break;
|
||||
case GNC_TERM_TYPE_PROXIMO:
|
||||
compute_monthyear (term, post_date.tv_sec, &month, &year);
|
||||
compute_monthyear (term, post_date, &month, &year);
|
||||
day = gnc_date_get_last_mday (month - 1, year);
|
||||
if (days < day)
|
||||
day = days;
|
||||
res = gnc_dmy2timespec (day, month, year);
|
||||
res = gnc_dmy2time64 (day, month, year);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
@ -826,9 +826,8 @@ compute_time (const GncBillTerm *term, Timespec post_date, int days)
|
||||
time64
|
||||
gncBillTermComputeDueDate (const GncBillTerm *term, time64 post_date)
|
||||
{
|
||||
Timespec pass = {post_date, 0};
|
||||
if (!term) return post_date;
|
||||
return compute_time (term, pass, term->due_days).tv_sec;
|
||||
return compute_time (term, post_date, term->due_days);
|
||||
}
|
||||
|
||||
/* Package-Private functions */
|
||||
|
@ -1324,20 +1324,20 @@ gncEntryRecomputeValues (GncEntry *entry)
|
||||
/* See if either tax table changed since we last computed values */
|
||||
if (entry->i_tax_table)
|
||||
{
|
||||
Timespec modtime = gncTaxTableLastModified (entry->i_tax_table);
|
||||
if (entry->i_taxtable_modtime != modtime.tv_sec)
|
||||
time64 modtime = gncTaxTableLastModifiedSecs (entry->i_tax_table);
|
||||
if (entry->i_taxtable_modtime != modtime)
|
||||
{
|
||||
entry->values_dirty = TRUE;
|
||||
entry->i_taxtable_modtime = modtime.tv_sec;
|
||||
entry->i_taxtable_modtime = modtime;
|
||||
}
|
||||
}
|
||||
if (entry->b_tax_table)
|
||||
{
|
||||
Timespec modtime = gncTaxTableLastModified (entry->b_tax_table);
|
||||
if (entry->b_taxtable_modtime == modtime.tv_sec)
|
||||
time64 modtime = gncTaxTableLastModifiedSecs (entry->b_tax_table);
|
||||
if (entry->b_taxtable_modtime == modtime)
|
||||
{
|
||||
entry->values_dirty = TRUE;
|
||||
entry->b_taxtable_modtime = modtime.tv_sec;
|
||||
entry->b_taxtable_modtime = modtime;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1943,9 +1943,10 @@ gncInvoiceApplyPayment (const GncInvoice *invoice, Transaction *txn,
|
||||
g_return_if_fail (owner->owner.undefined);
|
||||
|
||||
/* Create a lot for this payment */
|
||||
payment_lot = gncOwnerCreatePaymentLot (owner, &txn, invoice->posted_acc,
|
||||
xfer_acc, amount, exch,
|
||||
date, memo, num);
|
||||
payment_lot = gncOwnerCreatePaymentLotSecs (owner, &txn,
|
||||
invoice->posted_acc,
|
||||
xfer_acc, amount, exch,
|
||||
date, memo, num);
|
||||
|
||||
/* Select the invoice as only payment candidate */
|
||||
selected_lots = g_list_prepend (selected_lots, invoice->posted_lot);
|
||||
|
@ -246,7 +246,7 @@ gncInvoiceAutoApplyPayments (GncInvoice *invoice);
|
||||
* or payments for the owner will be considered
|
||||
* to balance the payment.
|
||||
*
|
||||
* This code is actually a convenience wrapper around gncOwnerCreatePaymentLot
|
||||
* This code is actually a convenience wrapper around gncOwnerCreatePaymentLotSecs
|
||||
* and gncOwnerAutoApplyPaymentsWithLots. See their descriptions for more
|
||||
* details on what happens exactly.
|
||||
*/
|
||||
|
@ -723,10 +723,10 @@ gncOwnerLotsSortFunc (GNCLot *lotA, GNCLot *lotB)
|
||||
}
|
||||
|
||||
GNCLot *
|
||||
gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn,
|
||||
Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num)
|
||||
gncOwnerCreatePaymentLotSecs (const GncOwner *owner, Transaction **preset_txn,
|
||||
Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num)
|
||||
{
|
||||
QofBook *book;
|
||||
Split *split;
|
||||
@ -1376,10 +1376,10 @@ void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots)
|
||||
* then all open lots for the owner are considered.
|
||||
*/
|
||||
void
|
||||
gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lots,
|
||||
Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num, gboolean auto_pay)
|
||||
gncOwnerApplyPaymentSecs (const GncOwner *owner, Transaction **preset_txn,
|
||||
GList *lots, Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num, gboolean auto_pay)
|
||||
{
|
||||
GNCLot *payment_lot = NULL;
|
||||
GList *selected_lots = NULL;
|
||||
@ -1391,8 +1391,10 @@ gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lo
|
||||
|
||||
/* If there's a real amount to transfer create a lot for this payment */
|
||||
if (!gnc_numeric_zero_p (amount))
|
||||
payment_lot = gncOwnerCreatePaymentLot (owner, preset_txn, posted_acc, xfer_acc,
|
||||
amount, exch, date, memo, num);
|
||||
payment_lot = gncOwnerCreatePaymentLotSecs (owner, preset_txn,
|
||||
posted_acc, xfer_acc,
|
||||
amount, exch, date, memo,
|
||||
num);
|
||||
|
||||
if (lots)
|
||||
selected_lots = lots;
|
||||
|
@ -214,10 +214,10 @@ gboolean gncOwnerGetOwnerFromTypeGuid (QofBook *book, GncOwner *owner, QofIdType
|
||||
* split in the transfer account).
|
||||
*/
|
||||
GNCLot *
|
||||
gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn,
|
||||
Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num);
|
||||
gncOwnerCreatePaymentLotSecs (const GncOwner *owner, Transaction **preset_txn,
|
||||
Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num);
|
||||
|
||||
/**
|
||||
* Given a list of lots, try to balance as many of them as possible
|
||||
@ -267,10 +267,10 @@ void gncOwnerAutoApplyPaymentsWithLots (const GncOwner *owner, GList *lots);
|
||||
* details on what happens exactly.
|
||||
*/
|
||||
void
|
||||
gncOwnerApplyPayment (const GncOwner *owner, Transaction **preset_txn, GList *lots,
|
||||
Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num, gboolean auto_pay);
|
||||
gncOwnerApplyPaymentSecs (const GncOwner *owner, Transaction **preset_txn,
|
||||
GList *lots, Account *posted_acc, Account *xfer_acc,
|
||||
gnc_numeric amount, gnc_numeric exch, time64 date,
|
||||
const char *memo, const char *num, gboolean auto_pay);
|
||||
|
||||
/** Helper function to find a split in lot that best offsets target_value
|
||||
* Obviously it should be of opposite sign.
|
||||
|
@ -39,7 +39,7 @@ struct _gncTaxTable
|
||||
QofInstance inst;
|
||||
char * name;
|
||||
GncTaxTableEntryList* entries;
|
||||
Timespec modtime; /* internal date of last modtime */
|
||||
time64 modtime; /* internal date of last modtime */
|
||||
|
||||
/* See src/doc/business.txt for an explanation of the following */
|
||||
/* Code that handles this is *identical* to that in gncBillTerm */
|
||||
@ -165,7 +165,7 @@ maybe_resort_list (GncTaxTable *table)
|
||||
static inline void
|
||||
mod_table (GncTaxTable *table)
|
||||
{
|
||||
timespecFromTime64 (&table->modtime, gnc_time (NULL));
|
||||
table->modtime = gnc_time (NULL);
|
||||
}
|
||||
|
||||
static inline void addObj (GncTaxTable *table)
|
||||
@ -761,10 +761,9 @@ gint64 gncTaxTableGetRefcount (const GncTaxTable *table)
|
||||
return table->refcount;
|
||||
}
|
||||
|
||||
Timespec gncTaxTableLastModified (const GncTaxTable *table)
|
||||
time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table)
|
||||
{
|
||||
Timespec ts = { 0 , 0 };
|
||||
if (!table) return ts;
|
||||
if (!table) return 0;
|
||||
return table->modtime;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ is *identical* to that in ::GncBillTerm
|
||||
@param QofInstance inst;
|
||||
@param char * name;
|
||||
@param GncTaxTableEntryList* entries;
|
||||
@param Timespec modtime;
|
||||
@param time64 modtime;
|
||||
@param gint64 refcount;
|
||||
@param GncTaxTable * parent; if non-null, we are an immutable child
|
||||
@param GncTaxTable * child; if non-null, we have not changed
|
||||
@ -162,7 +162,7 @@ GncTaxTable *gncTaxTableReturnChild (GncTaxTable *table, gboolean make_new);
|
||||
typedef GList GncTaxTableEntryList;
|
||||
GncTaxTableEntryList* gncTaxTableGetEntries (const GncTaxTable *table);
|
||||
gint64 gncTaxTableGetRefcount (const GncTaxTable *table);
|
||||
Timespec gncTaxTableLastModified (const GncTaxTable *table);
|
||||
time64 gncTaxTableLastModifiedSecs (const GncTaxTable *table);
|
||||
|
||||
Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry);
|
||||
GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry);
|
||||
|
Loading…
Reference in New Issue
Block a user