mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Transaction members Timespec->time64
This commit is contained in:
parent
9a86dd222b
commit
1f050fd1e5
@ -1504,7 +1504,7 @@ create_transaction(XferDialog *xferData, Timespec *ts,
|
|||||||
xaccTransBeginEdit(trans);
|
xaccTransBeginEdit(trans);
|
||||||
|
|
||||||
xaccTransSetCurrency(trans, xferData->from_commodity);
|
xaccTransSetCurrency(trans, xferData->from_commodity);
|
||||||
xaccTransSetDatePostedTS(trans, ts);
|
xaccTransSetDatePostedSecs(trans, ts->tv_sec);
|
||||||
|
|
||||||
/* Trans-Num or Split-Action set with gnc_set_num_action below per book
|
/* Trans-Num or Split-Action set with gnc_set_num_action below per book
|
||||||
* option */
|
* option */
|
||||||
|
@ -1521,7 +1521,7 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
|
|||||||
/* Only continue if both have the same date and num, because the
|
/* Only continue if both have the same date and num, because the
|
||||||
* "standard ordering" is tied to the date anyway. */
|
* "standard ordering" is tied to the date anyway. */
|
||||||
{
|
{
|
||||||
Timespec t1, t2;
|
time64 time1, time2;
|
||||||
GDate d1 = xaccTransGetDatePostedGDate(current_trans),
|
GDate d1 = xaccTransGetDatePostedGDate(current_trans),
|
||||||
d2 = xaccTransGetDatePostedGDate(target_trans);
|
d2 = xaccTransGetDatePostedGDate(target_trans);
|
||||||
if (g_date_compare(&d1, &d2) != 0)
|
if (g_date_compare(&d1, &d2) != 0)
|
||||||
@ -1540,9 +1540,9 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
|
|||||||
dates as timespec. See the comment in gncEntrySetDateGDate() for the
|
dates as timespec. See the comment in gncEntrySetDateGDate() for the
|
||||||
reason: Some code used the timespec at noon for the EntryDate, other
|
reason: Some code used the timespec at noon for the EntryDate, other
|
||||||
code used the timespec at the start of day. */
|
code used the timespec at the start of day. */
|
||||||
t1 = xaccTransRetDatePostedTS(current_trans);
|
time1 = xaccTransRetDatePosted(current_trans);
|
||||||
t2 = xaccTransRetDatePostedTS(target_trans);
|
time2 = xaccTransRetDatePosted(target_trans);
|
||||||
if (really_do_it && !timespec_equal(&t1, &t2))
|
if (really_do_it && time1 != time2)
|
||||||
{
|
{
|
||||||
/* Timespecs are not equal, even though the GDates were equal? Then
|
/* Timespecs are not equal, even though the GDates were equal? Then
|
||||||
we set the GDates again. This will force the timespecs to be equal
|
we set the GDates again. This will force the timespecs to be equal
|
||||||
@ -1587,12 +1587,12 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
|
|||||||
/* Swap the date-entered of both entries. That's already
|
/* Swap the date-entered of both entries. That's already
|
||||||
* sufficient! */
|
* sufficient! */
|
||||||
{
|
{
|
||||||
Timespec time_current = xaccTransRetDateEnteredTS(current_trans);
|
time64 time_current = xaccTransRetDateEntered(current_trans);
|
||||||
Timespec time_target = xaccTransRetDateEnteredTS(target_trans);
|
time64 time_target = xaccTransRetDateEntered(target_trans);
|
||||||
|
|
||||||
/* Special treatment for identical times (potentially caused
|
/* Special treatment for identical times (potentially caused
|
||||||
* by the "duplicate entry" command) */
|
* by the "duplicate entry" command) */
|
||||||
if (timespec_equal(&time_current, &time_target))
|
if (time_current == time_target)
|
||||||
{
|
{
|
||||||
g_warning("Surprise - both DateEntered are equal.");
|
g_warning("Surprise - both DateEntered are equal.");
|
||||||
/* We just increment the DateEntered of the previously
|
/* We just increment the DateEntered of the previously
|
||||||
@ -1600,14 +1600,14 @@ static gboolean gtcsr_move_current_entry_updown(GncTreeViewSplitReg *view,
|
|||||||
* issues if multiple entries had this problem, but
|
* issues if multiple entries had this problem, but
|
||||||
* whatever. */
|
* whatever. */
|
||||||
if (move_up)
|
if (move_up)
|
||||||
time_current.tv_sec++;
|
++time_current;
|
||||||
else
|
else
|
||||||
time_target.tv_sec++;
|
++time_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the new DateEntered. */
|
/* Write the new DateEntered. */
|
||||||
xaccTransSetDateEnteredTS(current_trans, &time_target);
|
xaccTransSetDateEnteredSecs(current_trans, time_target);
|
||||||
xaccTransSetDateEnteredTS(target_trans, &time_current);
|
xaccTransSetDateEnteredSecs(target_trans, time_current);
|
||||||
|
|
||||||
/* FIXME: Do we need to notify anyone about the changed ordering? */
|
/* FIXME: Do we need to notify anyone about the changed ordering? */
|
||||||
}
|
}
|
||||||
|
@ -832,7 +832,6 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
|
|||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
const gchar *date_text;
|
const gchar *date_text;
|
||||||
const gchar *desc_text;
|
const gchar *desc_text;
|
||||||
Timespec ts = {0,0};
|
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
priv = model->priv;
|
priv = model->priv;
|
||||||
@ -849,7 +848,7 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
|
|||||||
return g_strconcat ("Blank Transaction", NULL);
|
return g_strconcat ("Blank Transaction", NULL);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xaccTransGetDatePostedTS (trans, &ts);
|
Timespec ts = {xaccTransRetDatePosted (trans), 0};
|
||||||
date_text = gnc_print_date (ts);
|
date_text = gnc_print_date (ts);
|
||||||
desc_text = xaccTransGetDescription (trans);
|
desc_text = xaccTransGetDescription (trans);
|
||||||
model->current_trans = trans;
|
model->current_trans = trans;
|
||||||
|
@ -192,7 +192,7 @@ gtu_sr_handle_exchange_rate (GncTreeViewSplitReg *view, gnc_numeric amount, Tran
|
|||||||
|
|
||||||
/* Get per book option */
|
/* Get per book option */
|
||||||
gnc_xfer_dialog_set_num (xfer, gnc_get_num_action (trans, split));
|
gnc_xfer_dialog_set_num (xfer, gnc_get_num_action (trans, split));
|
||||||
gnc_xfer_dialog_set_date (xfer, timespecToTime64 (xaccTransRetDatePostedTS (trans)));
|
gnc_xfer_dialog_set_date (xfer, xaccTransRetDatePosted (trans));
|
||||||
|
|
||||||
value = amount;
|
value = amount;
|
||||||
if (gnc_xfer_dialog_run_exchange_dialog (xfer, &rate_split, value, reg_acc, trans, xfer_comm, expanded))
|
if (gnc_xfer_dialog_run_exchange_dialog (xfer, &rate_split, value, reg_acc, trans, xfer_comm, expanded))
|
||||||
|
@ -1474,33 +1474,23 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
|||||||
show_extra_dates = TRUE;
|
show_extra_dates = TRUE;
|
||||||
|
|
||||||
if (is_trow1) {
|
if (is_trow1) {
|
||||||
Timespec ts = {0,0};
|
Timespec ts = {xaccTransRetDatePosted (trans),0};
|
||||||
xaccTransGetDatePostedTS (trans, &ts);
|
|
||||||
//If the time returned by xaccTransGetDatePostedTS is 0 then assume it
|
//If the time returned by xaccTransGetDatePostedTS is 0 then assume it
|
||||||
//is a new transaction and set the time to current time to show current
|
//is a new transaction and set the time to current time to show current
|
||||||
//date on new transactions
|
//date on new transactions
|
||||||
if (ts.tv_sec == 0)
|
if (ts.tv_sec == 0)
|
||||||
{
|
|
||||||
ts.tv_sec = gnc_time (NULL);
|
ts.tv_sec = gnc_time (NULL);
|
||||||
//xaccTransSetDatePostedSecs (trans, ts.tv_sec);
|
|
||||||
}//if
|
|
||||||
s = gnc_print_date (ts);
|
s = gnc_print_date (ts);
|
||||||
editable = TRUE;
|
editable = TRUE;
|
||||||
}
|
}
|
||||||
else if (is_trow2 && show_extra_dates) {
|
else if (is_trow2 && show_extra_dates) {
|
||||||
Timespec ts = {0,0};
|
Timespec ts = {xaccTransRetDateEntered (trans),0};
|
||||||
|
|
||||||
g_object_set (cell, "cell-background", YELLOWCELL, (gchar*)NULL);
|
g_object_set (cell, "cell-background", YELLOWCELL, (gchar*)NULL);
|
||||||
|
|
||||||
xaccTransGetDateEnteredTS (trans, &ts);
|
|
||||||
//If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
|
//If the time returned by xaccTransGetDateEnteredTS is 0 then assume it
|
||||||
//is a new transaction and set the time to current time to show current
|
//is a new transaction and set the time to current time to show current
|
||||||
//date on new transactions
|
//date on new transactions
|
||||||
if (ts.tv_sec == 0)
|
if (ts.tv_sec == 0)
|
||||||
{
|
|
||||||
ts.tv_sec = gnc_time (NULL);
|
ts.tv_sec = gnc_time (NULL);
|
||||||
//xaccTransSetDateEnteredSecs (trans, ts.tv_sec);
|
|
||||||
}//if
|
|
||||||
s = gnc_print_date (ts);
|
s = gnc_print_date (ts);
|
||||||
editable = FALSE;
|
editable = FALSE;
|
||||||
}
|
}
|
||||||
@ -1559,12 +1549,10 @@ gtv_sr_cdf0 (GtkTreeViewColumn *col, GtkCellRenderer *cell, GtkTreeModel *s_mode
|
|||||||
g_object_set (cell, "cell-background", "white", (gchar*)NULL);
|
g_object_set (cell, "cell-background", "white", (gchar*)NULL);
|
||||||
|
|
||||||
if (is_trow1) {
|
if (is_trow1) {
|
||||||
Timespec ts = {0,0};
|
|
||||||
|
|
||||||
/* Only print the due date for invoice transactions */
|
/* Only print the due date for invoice transactions */
|
||||||
if (type == TXN_TYPE_INVOICE)
|
if (type == TXN_TYPE_INVOICE)
|
||||||
{
|
{
|
||||||
xaccTransGetDateDueTS (trans, &ts);
|
Timespec ts = {xaccTransRetDateDue (trans), 0};
|
||||||
s = gnc_print_date (ts);
|
s = gnc_print_date (ts);
|
||||||
editable = FALSE;
|
editable = FALSE;
|
||||||
}
|
}
|
||||||
@ -2518,21 +2506,18 @@ gtv_sr_begin_edit (GncTreeViewSplitReg *view, Transaction *trans)
|
|||||||
|
|
||||||
if (trans != view->priv->dirty_trans)
|
if (trans != view->priv->dirty_trans)
|
||||||
{
|
{
|
||||||
Timespec ts = {0,0};
|
time64 time = xaccTransRetDatePosted (trans);
|
||||||
xaccTransGetDatePostedTS (trans, &ts);
|
|
||||||
|
|
||||||
if (!xaccTransIsOpen (trans))
|
if (!xaccTransIsOpen (trans))
|
||||||
xaccTransBeginEdit (trans);
|
xaccTransBeginEdit (trans);
|
||||||
view->priv->dirty_trans = trans;
|
view->priv->dirty_trans = trans;
|
||||||
|
|
||||||
if (ts.tv_sec == 0)
|
if (!time)
|
||||||
{
|
{
|
||||||
//If the time returned by xaccTransGetDatePostedTS is 0 then assume it
|
//If the time returned by xaccTransGetDatePostedTS is 0 then assume it
|
||||||
//is a new transaction and set the time to current time to show current
|
//is a new transaction and set the time to current time to show current
|
||||||
//date on new transactions
|
//date on new transactions
|
||||||
|
time = gnc_time (NULL);
|
||||||
ts.tv_sec = gnc_time (NULL);
|
xaccTransSetDatePostedSecs (trans, time);
|
||||||
xaccTransSetDatePostedSecs (trans, ts.tv_sec);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LEAVE(" ");
|
LEAVE(" ");
|
||||||
|
@ -344,8 +344,7 @@ get_trans_info (AssocDialog *assoc_dialog)
|
|||||||
{
|
{
|
||||||
gchar *uri_u;
|
gchar *uri_u;
|
||||||
gboolean rel = FALSE;
|
gboolean rel = FALSE;
|
||||||
Timespec ts = {0,0};
|
Timespec ts = {xaccTransRetDatePosted (trans),0};
|
||||||
xaccTransGetDatePostedTS (trans, &ts);
|
|
||||||
|
|
||||||
if (ts.tv_sec == 0)
|
if (ts.tv_sec == 0)
|
||||||
ts.tv_sec = gnc_time (NULL);
|
ts.tv_sec = gnc_time (NULL);
|
||||||
|
@ -552,10 +552,10 @@ static void trans_add_split (Transaction* trans, Account* account, GncNumeric am
|
|||||||
value = amount * *price;
|
value = amount * *price;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto tts = xaccTransRetDatePostedTS (trans);
|
Timespec ts = {xaccTransRetDatePosted (trans), 0};
|
||||||
/* Import data didn't specify price, let's lookup the nearest in time */
|
/* Import data didn't specify price, let's lookup the nearest in time */
|
||||||
auto nprice = gnc_pricedb_lookup_nearest_in_time(gnc_pricedb_get_db(book),
|
auto nprice = gnc_pricedb_lookup_nearest_in_time(gnc_pricedb_get_db(book),
|
||||||
acct_comm, trans_curr, tts);
|
acct_comm, trans_curr, ts);
|
||||||
if (nprice)
|
if (nprice)
|
||||||
{
|
{
|
||||||
/* Found a usable price. Let's check if the conversion direction is right */
|
/* Found a usable price. Let's check if the conversion direction is right */
|
||||||
|
@ -98,16 +98,13 @@ gnc_split_register_save_due_date_cell (BasicCell * cell,
|
|||||||
SRSaveData *sd = save_data;
|
SRSaveData *sd = save_data;
|
||||||
const char *value;
|
const char *value;
|
||||||
time64 time;
|
time64 time;
|
||||||
Timespec ts;
|
|
||||||
g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
|
g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
|
||||||
value = gnc_basic_cell_get_value (cell);
|
value = gnc_basic_cell_get_value (cell);
|
||||||
/* commit any pending changes */
|
/* commit any pending changes */
|
||||||
gnc_date_cell_commit ((DateCell *) cell);
|
gnc_date_cell_commit ((DateCell *) cell);
|
||||||
DEBUG ("DATE: %s", value ? value : "(null)");
|
DEBUG ("DATE: %s", value ? value : "(null)");
|
||||||
gnc_date_cell_get_date ((DateCell *) cell, &time);
|
gnc_date_cell_get_date ((DateCell *) cell, &time);
|
||||||
ts.tv_sec = time;
|
xaccTransSetDateDue (sd->trans, time);
|
||||||
ts.tv_nsec = 0;
|
|
||||||
xaccTransSetDateDueTS (sd->trans, &ts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -829,7 +829,7 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
|
|||||||
SplitRegister *reg = user_data;
|
SplitRegister *reg = user_data;
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
Split *split;
|
||||||
Timespec ts;
|
Timespec ts = {0, 0};
|
||||||
gboolean is_current;
|
gboolean is_current;
|
||||||
char type;
|
char type;
|
||||||
|
|
||||||
@ -866,7 +866,7 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
xaccTransGetDateDueTS (trans, &ts);
|
ts.tv_sec = xaccTransRetDateDue (trans);
|
||||||
//PWARN ("returning valid due_date entry");
|
//PWARN ("returning valid due_date entry");
|
||||||
|
|
||||||
return gnc_print_date (ts);
|
return gnc_print_date (ts);
|
||||||
@ -881,14 +881,14 @@ gnc_split_register_get_date_entry (VirtualLocation virt_loc,
|
|||||||
SplitRegister *reg = user_data;
|
SplitRegister *reg = user_data;
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *split;
|
Split *split;
|
||||||
Timespec ts;
|
Timespec ts = {0, 0};
|
||||||
|
|
||||||
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
||||||
trans = xaccSplitGetParent (split);
|
trans = xaccSplitGetParent (split);
|
||||||
if (!trans)
|
if (!trans)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
xaccTransGetDatePostedTS (trans, &ts);
|
ts.tv_sec = xaccTransRetDatePosted (trans);
|
||||||
|
|
||||||
return gnc_print_date (ts);
|
return gnc_print_date (ts);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,13 @@ add_gnc_num (xmlNodePtr node, const gchar* tag, gnc_numeric num)
|
|||||||
xmlAddChild (node, gnc_numeric_to_dom_tree (tag, &num));
|
xmlAddChild (node, gnc_numeric_to_dom_tree (tag, &num));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_time64 (xmlNodePtr node, const gchar * tag, time64 time, gboolean always)
|
||||||
|
{
|
||||||
|
if (always || time)
|
||||||
|
xmlAddChild (node, time64_to_dom_tree (tag, time));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_timespec (xmlNodePtr node, const gchar* tag, Timespec tms, gboolean always)
|
add_timespec (xmlNodePtr node, const gchar* tag, Timespec tms, gboolean always)
|
||||||
{
|
{
|
||||||
@ -172,10 +179,10 @@ gnc_transaction_dom_tree_create (Transaction* trn)
|
|||||||
}
|
}
|
||||||
g_free (str);
|
g_free (str);
|
||||||
|
|
||||||
add_timespec (ret, "trn:date-posted", xaccTransRetDatePostedTS (trn), TRUE);
|
add_time64 (ret, "trn:date-posted", xaccTransRetDatePosted (trn), TRUE);
|
||||||
|
|
||||||
add_timespec (ret, "trn:date-entered",
|
add_time64 (ret, "trn:date-entered",
|
||||||
xaccTransRetDateEnteredTS (trn), TRUE);
|
xaccTransRetDateEntered (trn), TRUE);
|
||||||
|
|
||||||
str = g_strdup (xaccTransGetDescription (trn));
|
str = g_strdup (xaccTransGetDescription (trn));
|
||||||
if (str)
|
if (str)
|
||||||
@ -426,6 +433,16 @@ set_tran_string (xmlNodePtr node, Transaction* trn,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
set_tran_time64 (xmlNodePtr node, Transaction * trn,
|
||||||
|
void (*func) (Transaction *, time64))
|
||||||
|
{
|
||||||
|
time64 time = dom_tree_to_time64 (node);
|
||||||
|
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||||
|
func (trn, time);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static inline gboolean
|
static inline gboolean
|
||||||
set_tran_date (xmlNodePtr node, Transaction* trn,
|
set_tran_date (xmlNodePtr node, Transaction* trn,
|
||||||
void (*func) (Transaction* trn, const Timespec* tm))
|
void (*func) (Transaction* trn, const Timespec* tm))
|
||||||
@ -481,7 +498,7 @@ trn_date_posted_handler (xmlNodePtr node, gpointer trans_pdata)
|
|||||||
struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
|
struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
|
||||||
Transaction* trn = pdata->trans;
|
Transaction* trn = pdata->trans;
|
||||||
|
|
||||||
return set_tran_date (node, trn, xaccTransSetDatePostedTS);
|
return set_tran_time64 (node, trn, xaccTransSetDatePostedSecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -490,7 +507,7 @@ trn_date_entered_handler (xmlNodePtr node, gpointer trans_pdata)
|
|||||||
struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
|
struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
|
||||||
Transaction* trn = pdata->trans;
|
Transaction* trn = pdata->trans;
|
||||||
|
|
||||||
return set_tran_date (node, trn, xaccTransSetDateEnteredTS);
|
return set_tran_time64 (node, trn, xaccTransSetDateEnteredSecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -277,10 +277,9 @@ equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
equals_node_val_vs_date (xmlNodePtr node, const Timespec tm)
|
equals_node_val_vs_date (xmlNodePtr node, time64 time)
|
||||||
{
|
{
|
||||||
time64 time = dom_tree_to_time64 (node);
|
return time == dom_tree_to_time64 (node);
|
||||||
return time == tm.tv_sec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@ -57,7 +57,7 @@ gboolean equals_node_val_vs_guid (xmlNodePtr node, const GncGUID* id);
|
|||||||
gboolean equals_node_val_vs_commodity (xmlNodePtr node,
|
gboolean equals_node_val_vs_commodity (xmlNodePtr node,
|
||||||
const gnc_commodity* com, QofBook*);
|
const gnc_commodity* com, QofBook*);
|
||||||
gboolean equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm);
|
gboolean equals_node_val_vs_kvp_frame (xmlNodePtr node, const KvpFrame* frm);
|
||||||
gboolean equals_node_val_vs_date (xmlNodePtr node, const Timespec tm);
|
gboolean equals_node_val_vs_date (xmlNodePtr node, time64);
|
||||||
gboolean equals_node_val_vs_int (xmlNodePtr node, gint64 val);
|
gboolean equals_node_val_vs_int (xmlNodePtr node, gint64 val);
|
||||||
gboolean equals_node_val_vs_boolean (xmlNodePtr node, gboolean val);
|
gboolean equals_node_val_vs_boolean (xmlNodePtr node, gboolean val);
|
||||||
|
|
||||||
|
@ -287,14 +287,14 @@ node_and_transaction_equal (xmlNodePtr node, Transaction* trn)
|
|||||||
}
|
}
|
||||||
else if (g_strcmp0 ((char*)mark->name, "trn:date-posted") == 0)
|
else if (g_strcmp0 ((char*)mark->name, "trn:date-posted") == 0)
|
||||||
{
|
{
|
||||||
if (!equals_node_val_vs_date (mark, xaccTransRetDatePostedTS (trn)))
|
if (!equals_node_val_vs_date (mark, xaccTransRetDatePosted (trn)))
|
||||||
{
|
{
|
||||||
return "posted dates differ";
|
return "posted dates differ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (g_strcmp0 ((char*)mark->name, "trn:date-entered") == 0)
|
else if (g_strcmp0 ((char*)mark->name, "trn:date-entered") == 0)
|
||||||
{
|
{
|
||||||
if (!equals_node_val_vs_date (mark, xaccTransRetDateEnteredTS (trn)))
|
if (!equals_node_val_vs_date (mark, xaccTransRetDateEntered (trn)))
|
||||||
{
|
{
|
||||||
return "entered dates differ";
|
return "entered dates differ";
|
||||||
}
|
}
|
||||||
|
@ -3292,7 +3292,6 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
|
|||||||
*/
|
*/
|
||||||
AccountPrivate *priv;
|
AccountPrivate *priv;
|
||||||
GList *lp;
|
GList *lp;
|
||||||
Timespec ts, trans_ts;
|
|
||||||
gboolean found = FALSE;
|
gboolean found = FALSE;
|
||||||
gnc_numeric balance;
|
gnc_numeric balance;
|
||||||
|
|
||||||
@ -3316,15 +3315,12 @@ xaccAccountGetBalanceAsOfDate (Account *acc, time64 date)
|
|||||||
* xaccAccountGetPresentBalance gets this right, and its algorithm
|
* xaccAccountGetPresentBalance gets this right, and its algorithm
|
||||||
* should be used here.
|
* should be used here.
|
||||||
*/
|
*/
|
||||||
ts.tv_sec = date;
|
|
||||||
ts.tv_nsec = 0;
|
|
||||||
|
|
||||||
lp = priv->splits;
|
lp = priv->splits;
|
||||||
while ( lp && !found )
|
while ( lp && !found )
|
||||||
{
|
{
|
||||||
xaccTransGetDatePostedTS( xaccSplitGetParent( (Split *)lp->data ),
|
time64 trans_time = xaccTransRetDatePosted( xaccSplitGetParent( (Split *)lp->data ));
|
||||||
&trans_ts );
|
if ( trans_time >= date )
|
||||||
if ( timespec_cmp( &trans_ts, &ts ) >= 0 )
|
|
||||||
found = TRUE;
|
found = TRUE;
|
||||||
else
|
else
|
||||||
lp = lp->next;
|
lp = lp->next;
|
||||||
|
@ -597,13 +597,13 @@ xaccQueryGetEarliestDateFound(QofQuery * q)
|
|||||||
|
|
||||||
/* Safe until 2038 on archs where time64 is 32bit */
|
/* Safe until 2038 on archs where time64 is 32bit */
|
||||||
sp = spl->data;
|
sp = spl->data;
|
||||||
earliest = sp->parent->date_posted.tv_sec;
|
earliest = sp->parent->date_posted;
|
||||||
for (; spl; spl = spl->next)
|
for (; spl; spl = spl->next)
|
||||||
{
|
{
|
||||||
sp = spl->data;
|
sp = spl->data;
|
||||||
if (sp->parent->date_posted.tv_sec < earliest)
|
if (sp->parent->date_posted < earliest)
|
||||||
{
|
{
|
||||||
earliest = sp->parent->date_posted.tv_sec;
|
earliest = sp->parent->date_posted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return earliest;
|
return earliest;
|
||||||
@ -627,9 +627,9 @@ xaccQueryGetLatestDateFound(QofQuery * q)
|
|||||||
for (; spl; spl = spl->next)
|
for (; spl; spl = spl->next)
|
||||||
{
|
{
|
||||||
sp = spl->data;
|
sp = spl->data;
|
||||||
if (sp->parent->date_posted.tv_sec > latest)
|
if (sp->parent->date_posted > latest)
|
||||||
{
|
{
|
||||||
latest = sp->parent->date_posted.tv_sec;
|
latest = sp->parent->date_posted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return latest;
|
return latest;
|
||||||
|
@ -1399,11 +1399,11 @@ xaccTransScrubPostedDate (Transaction *trans)
|
|||||||
{
|
{
|
||||||
time64 orig = xaccTransGetDate(trans);
|
time64 orig = xaccTransGetDate(trans);
|
||||||
GDate date = xaccTransGetDatePostedGDate(trans);
|
GDate date = xaccTransGetDatePostedGDate(trans);
|
||||||
Timespec ts = gdate_to_timespec(date);
|
time64 time = gdate_to_time64(date);
|
||||||
if (orig && orig != ts.tv_sec)
|
if (orig && orig != time)
|
||||||
{
|
{
|
||||||
/* xaccTransSetDatePostedTS handles committing the change. */
|
/* xaccTransSetDatePostedTS handles committing the change. */
|
||||||
xaccTransSetDatePostedTS(trans, &ts);
|
xaccTransSetDatePostedSecs(trans, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1538,11 +1538,9 @@ xaccSplitOrderDateOnly (const Split *sa, const Split *sb)
|
|||||||
if ( !tb ) return -1;
|
if ( !tb ) return -1;
|
||||||
if ( !ta ) return +1;
|
if ( !ta ) return +1;
|
||||||
|
|
||||||
/* if dates differ, return */
|
if (ta->date_posted == tb->date_posted)
|
||||||
DATE_CMP(ta, tb, date_posted);
|
return -1; // Keep the same order
|
||||||
|
return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
|
||||||
/* If the dates are the same, do not change the order */
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -227,7 +227,6 @@ xaccTransWriteLog (Transaction *trans, char flag)
|
|||||||
char split_guid_str[GUID_ENCODING_LENGTH + 1];
|
char split_guid_str[GUID_ENCODING_LENGTH + 1];
|
||||||
const char *trans_notes;
|
const char *trans_notes;
|
||||||
char dnow[100], dent[100], dpost[100], drecn[100];
|
char dnow[100], dent[100], dpost[100], drecn[100];
|
||||||
Timespec ts;
|
|
||||||
|
|
||||||
if (!gen_logs)
|
if (!gen_logs)
|
||||||
{
|
{
|
||||||
@ -236,21 +235,16 @@ xaccTransWriteLog (Transaction *trans, char flag)
|
|||||||
}
|
}
|
||||||
if (!trans_log) return;
|
if (!trans_log) return;
|
||||||
|
|
||||||
timespecFromTime64(&ts, gnc_time (NULL));
|
gnc_time64_to_iso8601_buff (gnc_time(NULL), dnow);
|
||||||
gnc_timespec_to_iso8601_buff (ts, dnow);
|
gnc_time64_to_iso8601_buff (trans->date_entered, dent);
|
||||||
|
gnc_time64_to_iso8601_buff (trans->date_posted, dpost);
|
||||||
timespecFromTime64(&ts, trans->date_entered.tv_sec);
|
|
||||||
gnc_timespec_to_iso8601_buff (ts, dent);
|
|
||||||
|
|
||||||
timespecFromTime64(&ts, trans->date_posted.tv_sec);
|
|
||||||
gnc_timespec_to_iso8601_buff (ts, dpost);
|
|
||||||
|
|
||||||
guid_to_string_buff (xaccTransGetGUID(trans), trans_guid_str);
|
guid_to_string_buff (xaccTransGetGUID(trans), trans_guid_str);
|
||||||
trans_notes = xaccTransGetNotes(trans);
|
trans_notes = xaccTransGetNotes(trans);
|
||||||
fprintf (trans_log, "===== START\n");
|
fprintf (trans_log, "===== START\n");
|
||||||
|
|
||||||
for (node = trans->splits; node; node = node->next)
|
for (node = trans->splits; node; node = node->next)
|
||||||
{
|
{
|
||||||
|
Timespec ts;
|
||||||
Split *split = node->data;
|
Split *split = node->data;
|
||||||
const char * accname = "";
|
const char * accname = "";
|
||||||
char acc_guid_str[GUID_ENCODING_LENGTH + 1];
|
char acc_guid_str[GUID_ENCODING_LENGTH + 1];
|
||||||
|
@ -275,16 +275,10 @@ gnc_transaction_init(Transaction* trans)
|
|||||||
/* Fill in some sane defaults */
|
/* Fill in some sane defaults */
|
||||||
trans->num = CACHE_INSERT("");
|
trans->num = CACHE_INSERT("");
|
||||||
trans->description = CACHE_INSERT("");
|
trans->description = CACHE_INSERT("");
|
||||||
|
|
||||||
trans->common_currency = NULL;
|
trans->common_currency = NULL;
|
||||||
trans->splits = NULL;
|
trans->splits = NULL;
|
||||||
|
trans->date_entered = 0;
|
||||||
trans->date_entered.tv_sec = 0;
|
trans->date_posted = 0;
|
||||||
trans->date_entered.tv_nsec = 0;
|
|
||||||
|
|
||||||
trans->date_posted.tv_sec = 0;
|
|
||||||
trans->date_posted.tv_nsec = 0;
|
|
||||||
|
|
||||||
trans->marker = 0;
|
trans->marker = 0;
|
||||||
trans->orig = NULL;
|
trans->orig = NULL;
|
||||||
LEAVE (" ");
|
LEAVE (" ");
|
||||||
@ -316,6 +310,7 @@ gnc_transaction_get_property(GObject* object,
|
|||||||
{
|
{
|
||||||
Transaction* tx;
|
Transaction* tx;
|
||||||
gchar *key;
|
gchar *key;
|
||||||
|
Timespec ts = {0,0};
|
||||||
|
|
||||||
g_return_if_fail(GNC_IS_TRANSACTION(object));
|
g_return_if_fail(GNC_IS_TRANSACTION(object));
|
||||||
|
|
||||||
@ -332,10 +327,12 @@ gnc_transaction_get_property(GObject* object,
|
|||||||
g_value_take_object(value, tx->common_currency);
|
g_value_take_object(value, tx->common_currency);
|
||||||
break;
|
break;
|
||||||
case PROP_POST_DATE:
|
case PROP_POST_DATE:
|
||||||
g_value_set_boxed(value, &tx->date_posted);
|
ts.tv_sec = tx->date_posted;
|
||||||
|
g_value_set_boxed(value, &ts);
|
||||||
break;
|
break;
|
||||||
case PROP_ENTER_DATE:
|
case PROP_ENTER_DATE:
|
||||||
g_value_set_boxed(value, &tx->date_entered);
|
ts.tv_sec = tx->date_entered;
|
||||||
|
g_value_set_boxed(value, &ts);
|
||||||
break;
|
break;
|
||||||
case PROP_INVOICE:
|
case PROP_INVOICE:
|
||||||
qof_instance_get_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
qof_instance_get_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||||
@ -378,10 +375,10 @@ gnc_transaction_set_property(GObject* object,
|
|||||||
xaccTransSetCurrency(tx, g_value_get_object(value));
|
xaccTransSetCurrency(tx, g_value_get_object(value));
|
||||||
break;
|
break;
|
||||||
case PROP_POST_DATE:
|
case PROP_POST_DATE:
|
||||||
xaccTransSetDatePostedTS(tx, g_value_get_boxed(value));
|
xaccTransSetDatePostedSecs(tx, ((Timespec*)g_value_get_boxed(value))->tv_sec);
|
||||||
break;
|
break;
|
||||||
case PROP_ENTER_DATE:
|
case PROP_ENTER_DATE:
|
||||||
xaccTransSetDateEnteredTS(tx, g_value_get_boxed(value));
|
xaccTransSetDateEnteredSecs(tx, ((Timespec*)g_value_get_boxed(value))->tv_sec);
|
||||||
break;
|
break;
|
||||||
case PROP_INVOICE:
|
case PROP_INVOICE:
|
||||||
qof_instance_set_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
qof_instance_set_kvp (QOF_INSTANCE (tx), value, 2, GNC_INVOICE_ID, GNC_INVOICE_GUID);
|
||||||
@ -741,7 +738,6 @@ void
|
|||||||
xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
|
xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
|
||||||
const Account *from_acc, Account *to_acc, gboolean no_date)
|
const Account *from_acc, Account *to_acc, gboolean no_date)
|
||||||
{
|
{
|
||||||
Timespec ts = {0,0};
|
|
||||||
gboolean change_accounts = FALSE;
|
gboolean change_accounts = FALSE;
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
||||||
@ -764,8 +760,7 @@ xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
|
|||||||
xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
|
xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
|
||||||
if(!no_date)
|
if(!no_date)
|
||||||
{
|
{
|
||||||
xaccTransGetDatePostedTS(from_trans, &ts);
|
xaccTransSetDatePostedSecs(to_trans, xaccTransRetDatePosted (from_trans));
|
||||||
xaccTransSetDatePostedTS(to_trans, &ts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Each new split will be parented to 'to' */
|
/* Each new split will be parented to 'to' */
|
||||||
@ -813,12 +808,8 @@ xaccFreeTransaction (Transaction *trans)
|
|||||||
/* Just in case someone looks up freed memory ... */
|
/* Just in case someone looks up freed memory ... */
|
||||||
trans->num = (char *) 1;
|
trans->num = (char *) 1;
|
||||||
trans->description = NULL;
|
trans->description = NULL;
|
||||||
|
trans->date_entered = 0;
|
||||||
trans->date_entered.tv_sec = 0;
|
trans->date_posted = 0;
|
||||||
trans->date_entered.tv_nsec = 0;
|
|
||||||
trans->date_posted.tv_sec = 0;
|
|
||||||
trans->date_posted.tv_nsec = 0;
|
|
||||||
|
|
||||||
if (trans->orig)
|
if (trans->orig)
|
||||||
{
|
{
|
||||||
xaccFreeTransaction (trans->orig);
|
xaccFreeTransaction (trans->orig);
|
||||||
@ -892,24 +883,24 @@ xaccTransEqual(const Transaction *ta, const Transaction *tb,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timespec_cmp(&(ta->date_entered), &(tb->date_entered)))
|
if (ta->date_entered != tb->date_entered)
|
||||||
{
|
{
|
||||||
char buf1[100];
|
char buf1[100];
|
||||||
char buf2[100];
|
char buf2[100];
|
||||||
|
|
||||||
(void)gnc_timespec_to_iso8601_buff(ta->date_entered, buf1);
|
(void)gnc_time64_to_iso8601_buff(ta->date_entered, buf1);
|
||||||
(void)gnc_timespec_to_iso8601_buff(tb->date_entered, buf2);
|
(void)gnc_time64_to_iso8601_buff(tb->date_entered, buf2);
|
||||||
PINFO ("date entered differs: '%s' vs '%s'", buf1, buf2);
|
PINFO ("date entered differs: '%s' vs '%s'", buf1, buf2);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timespec_cmp(&(ta->date_posted), &(tb->date_posted)))
|
if (ta->date_posted != tb->date_posted)
|
||||||
{
|
{
|
||||||
char buf1[100];
|
char buf1[100];
|
||||||
char buf2[100];
|
char buf2[100];
|
||||||
|
|
||||||
(void)gnc_timespec_to_iso8601_buff(ta->date_posted, buf1);
|
(void)gnc_time64_to_iso8601_buff(ta->date_posted, buf1);
|
||||||
(void)gnc_timespec_to_iso8601_buff(tb->date_posted, buf2);
|
(void)gnc_time64_to_iso8601_buff(tb->date_posted, buf2);
|
||||||
PINFO ("date posted differs: '%s' vs '%s'", buf1, buf2);
|
PINFO ("date posted differs: '%s' vs '%s'", buf1, buf2);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1683,9 +1674,9 @@ xaccTransCommitEdit (Transaction *trans)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Record the time of last modification */
|
/* Record the time of last modification */
|
||||||
if (0 == trans->date_entered.tv_sec)
|
if (0 == trans->date_entered)
|
||||||
{
|
{
|
||||||
trans->date_entered.tv_sec = gnc_time(NULL);
|
trans->date_entered = gnc_time(NULL);
|
||||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1890,8 +1881,8 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
|
|||||||
if ( !ta && tb ) return +1;
|
if ( !ta && tb ) return +1;
|
||||||
if ( !ta && !tb ) return 0;
|
if ( !ta && !tb ) return 0;
|
||||||
|
|
||||||
/* if dates differ, return */
|
if (ta->date_posted != tb->date_posted)
|
||||||
DATE_CMP(ta, tb, date_posted);
|
return (ta->date_posted > tb->date_posted) - (ta->date_posted < tb->date_posted);
|
||||||
|
|
||||||
/* otherwise, sort on number string */
|
/* otherwise, sort on number string */
|
||||||
if (actna && actnb) /* split action string, if not NULL */
|
if (actna && actnb) /* split action string, if not NULL */
|
||||||
@ -1907,8 +1898,8 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
|
|||||||
if (na < nb) return -1;
|
if (na < nb) return -1;
|
||||||
if (na > nb) return +1;
|
if (na > nb) return +1;
|
||||||
|
|
||||||
/* if dates differ, return */
|
if (ta->date_entered != tb->date_entered)
|
||||||
DATE_CMP(ta, tb, date_entered);
|
return (ta->date_entered > tb->date_entered) - (ta->date_entered < tb->date_entered);
|
||||||
|
|
||||||
/* otherwise, sort on description string */
|
/* otherwise, sort on description string */
|
||||||
da = ta->description ? ta->description : "";
|
da = ta->description ? ta->description : "";
|
||||||
@ -1925,7 +1916,7 @@ xaccTransOrder_num_action (const Transaction *ta, const char *actna,
|
|||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
xaccTransSetDateInternal(Transaction *trans, Timespec *dadate, Timespec val)
|
xaccTransSetDateInternal(Transaction *trans, time64 *dadate, time64 val)
|
||||||
{
|
{
|
||||||
xaccTransBeginEdit(trans);
|
xaccTransBeginEdit(trans);
|
||||||
|
|
||||||
@ -1962,9 +1953,8 @@ set_gains_date_dirty (Transaction *trans)
|
|||||||
void
|
void
|
||||||
xaccTransSetDatePostedSecs (Transaction *trans, time64 secs)
|
xaccTransSetDatePostedSecs (Transaction *trans, time64 secs)
|
||||||
{
|
{
|
||||||
Timespec ts = {secs, 0};
|
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
xaccTransSetDateInternal(trans, &trans->date_posted, ts);
|
xaccTransSetDateInternal(trans, &trans->date_posted, secs);
|
||||||
set_gains_date_dirty (trans);
|
set_gains_date_dirty (trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1990,16 +1980,15 @@ xaccTransSetDatePostedGDate (Transaction *trans, GDate date)
|
|||||||
qof_instance_set_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_DATE_POSTED);
|
qof_instance_set_kvp (QOF_INSTANCE(trans), &v, 1, TRANS_DATE_POSTED);
|
||||||
/* mark dirty and commit handled by SetDateInternal */
|
/* mark dirty and commit handled by SetDateInternal */
|
||||||
xaccTransSetDateInternal(trans, &trans->date_posted,
|
xaccTransSetDateInternal(trans, &trans->date_posted,
|
||||||
gdate_to_timespec(date));
|
gdate_to_time64(date));
|
||||||
set_gains_date_dirty (trans);
|
set_gains_date_dirty (trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccTransSetDateEnteredSecs (Transaction *trans, time64 secs)
|
xaccTransSetDateEnteredSecs (Transaction *trans, time64 secs)
|
||||||
{
|
{
|
||||||
Timespec ts = {secs, 0};
|
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
xaccTransSetDateInternal(trans, &trans->date_entered, ts);
|
xaccTransSetDateInternal(trans, &trans->date_entered, secs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2008,36 +1997,23 @@ qofTransSetDatePosted (Transaction *trans, Timespec ts)
|
|||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
|
if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
|
||||||
if (!qof_begin_edit(&trans->inst)) return;
|
if (!qof_begin_edit(&trans->inst)) return;
|
||||||
xaccTransSetDateInternal(trans, &trans->date_posted, ts);
|
xaccTransSetDateInternal(trans, &trans->date_posted, ts.tv_sec);
|
||||||
set_gains_date_dirty(trans);
|
set_gains_date_dirty(trans);
|
||||||
qof_commit_edit(&trans->inst);
|
qof_commit_edit(&trans->inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransSetDatePostedTS (Transaction *trans, const Timespec *ts)
|
|
||||||
{
|
|
||||||
if (!trans || !ts) return;
|
|
||||||
xaccTransSetDateInternal(trans, &trans->date_posted, *ts);
|
|
||||||
set_gains_date_dirty (trans);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qofTransSetDateEntered (Transaction *trans, Timespec ts)
|
qofTransSetDateEntered (Transaction *trans, Timespec ts)
|
||||||
{
|
{
|
||||||
|
/*This is called from the query framework, so we'll leave the timespec
|
||||||
|
* until the query framework is converted, too.*/
|
||||||
if (!trans) return;
|
if (!trans) return;
|
||||||
if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
|
if ((ts.tv_nsec == 0) && (ts.tv_sec == 0)) return;
|
||||||
if (!qof_begin_edit(&trans->inst)) return;
|
if (!qof_begin_edit(&trans->inst)) return;
|
||||||
xaccTransSetDateInternal(trans, &trans->date_entered, ts);
|
xaccTransSetDateInternal(trans, &trans->date_entered, ts.tv_sec);
|
||||||
qof_commit_edit(&trans->inst);
|
qof_commit_edit(&trans->inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransSetDateEnteredTS (Transaction *trans, const Timespec *ts)
|
|
||||||
{
|
|
||||||
if (!trans || !ts) return;
|
|
||||||
xaccTransSetDateInternal(trans, &trans->date_entered, *ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xaccTransSetDate (Transaction *trans, int day, int mon, int year)
|
xaccTransSetDate (Transaction *trans, int day, int mon, int year)
|
||||||
{
|
{
|
||||||
@ -2057,18 +2033,12 @@ xaccTransSetDate (Transaction *trans, int day, int mon, int year)
|
|||||||
|
|
||||||
void
|
void
|
||||||
xaccTransSetDateDue (Transaction * trans, time64 time)
|
xaccTransSetDateDue (Transaction * trans, time64 time)
|
||||||
{
|
|
||||||
Timespec ts_send = {time, 0};
|
|
||||||
xaccTransSetDateDueTS (trans, &ts_send);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransSetDateDueTS (Transaction *trans, const Timespec *ts)
|
|
||||||
{
|
{
|
||||||
GValue v = G_VALUE_INIT;
|
GValue v = G_VALUE_INIT;
|
||||||
if (!trans || !ts) return;
|
Timespec send_ts = {time, 0};
|
||||||
|
if (!trans) return;
|
||||||
g_value_init (&v, GNC_TYPE_TIMESPEC);
|
g_value_init (&v, GNC_TYPE_TIMESPEC);
|
||||||
g_value_set_boxed (&v, ts);
|
g_value_set_boxed (&v, &send_ts);
|
||||||
xaccTransBeginEdit(trans);
|
xaccTransBeginEdit(trans);
|
||||||
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
qof_instance_set_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||||
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
qof_instance_set_dirty(QOF_INSTANCE(trans));
|
||||||
@ -2377,42 +2347,21 @@ xaccTransGetIsClosingTxn (const Transaction *trans)
|
|||||||
time64
|
time64
|
||||||
xaccTransGetDate (const Transaction *trans)
|
xaccTransGetDate (const Transaction *trans)
|
||||||
{
|
{
|
||||||
return trans ? trans->date_posted.tv_sec : 0;
|
return trans ? trans->date_posted : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*################## Added for Reg2 #################*/
|
/*################## Added for Reg2 #################*/
|
||||||
time64
|
time64
|
||||||
xaccTransGetDateEntered (const Transaction *trans)
|
xaccTransGetDateEntered (const Transaction *trans)
|
||||||
{
|
{
|
||||||
return trans ? trans->date_entered.tv_sec : 0;
|
return trans ? trans->date_entered : 0;;
|
||||||
}
|
}
|
||||||
/*################## Added for Reg2 #################*/
|
/*################## Added for Reg2 #################*/
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts)
|
|
||||||
{
|
|
||||||
if (trans && ts)
|
|
||||||
*ts = trans->date_posted;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts)
|
|
||||||
{
|
|
||||||
if (trans && ts)
|
|
||||||
*ts = trans->date_entered;
|
|
||||||
}
|
|
||||||
|
|
||||||
Timespec
|
|
||||||
xaccTransRetDatePostedTS (const Transaction *trans)
|
|
||||||
{
|
|
||||||
Timespec ts = {0, 0};
|
|
||||||
return trans ? trans->date_posted : ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
time64
|
time64
|
||||||
xaccTransRetDatePosted (const Transaction *trans)
|
xaccTransRetDatePosted (const Transaction *trans)
|
||||||
{
|
{
|
||||||
return trans ? trans->date_posted.tv_sec : 0;
|
return trans ? trans->date_posted : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GDate
|
GDate
|
||||||
@ -2451,44 +2400,24 @@ xaccTransGetDatePostedGDate (const Transaction *trans)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timespec
|
|
||||||
xaccTransRetDateEnteredTS (const Transaction *trans)
|
|
||||||
{
|
|
||||||
Timespec ts = {0, 0};
|
|
||||||
return trans ? trans->date_entered : ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
time64
|
time64
|
||||||
xaccTransRetDateEntered (const Transaction *trans)
|
xaccTransRetDateEntered (const Transaction *trans)
|
||||||
{
|
{
|
||||||
return trans ? trans->date_entered.tv_sec : 0;
|
return trans ? trans->date_entered : 0;
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts)
|
|
||||||
{
|
|
||||||
GValue v = G_VALUE_INIT;
|
|
||||||
if (!trans || !ts) return;
|
|
||||||
|
|
||||||
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
|
||||||
if (G_VALUE_HOLDS_BOXED (&v))
|
|
||||||
*ts = *(Timespec*)g_value_get_boxed (&v);
|
|
||||||
if (ts->tv_sec == 0)
|
|
||||||
xaccTransGetDatePostedTS (trans, ts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
time64
|
time64
|
||||||
xaccTransRetDateDue(const Transaction *trans)
|
xaccTransRetDateDue(const Transaction *trans)
|
||||||
{
|
{
|
||||||
return xaccTransRetDateDueTS (trans).tv_sec;
|
time64 ret = 0;
|
||||||
}
|
GValue v = G_VALUE_INIT;
|
||||||
|
if (!trans) return 0;
|
||||||
Timespec
|
qof_instance_get_kvp (QOF_INSTANCE (trans), &v, 1, TRANS_DATE_DUE_KVP);
|
||||||
xaccTransRetDateDueTS (const Transaction *trans)
|
if (G_VALUE_HOLDS_BOXED (&v))
|
||||||
{
|
ret = ((Timespec*)g_value_get_boxed (&v))->tv_sec;
|
||||||
Timespec ts = {0, 0};
|
if (!ret)
|
||||||
if (trans) xaccTransGetDateDueTS (trans, &ts);
|
return xaccTransRetDatePosted (trans);
|
||||||
return ts;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
char
|
||||||
@ -2596,7 +2525,7 @@ gboolean xaccTransInFutureByPostedDate (const Transaction *trans)
|
|||||||
|
|
||||||
present = gnc_time64_get_today_end ();
|
present = gnc_time64_get_today_end ();
|
||||||
|
|
||||||
if (trans->date_posted.tv_sec > present)
|
if (trans->date_posted > present)
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
else
|
else
|
||||||
result = FALSE;
|
result = FALSE;
|
||||||
@ -2881,8 +2810,6 @@ static void
|
|||||||
xaccTransScrubGainsDate (Transaction *trans)
|
xaccTransScrubGainsDate (Transaction *trans)
|
||||||
{
|
{
|
||||||
SplitList *node;
|
SplitList *node;
|
||||||
Timespec ts = {0, 0};
|
|
||||||
//restart_search:
|
|
||||||
for (node = trans->splits; node; node = node->next)
|
for (node = trans->splits; node; node = node->next)
|
||||||
{
|
{
|
||||||
Split *s = node->data;
|
Split *s = node->data;
|
||||||
@ -2896,13 +2823,10 @@ xaccTransScrubGainsDate (Transaction *trans)
|
|||||||
(s->gains & GAINS_STATUS_DATE_DIRTY)))
|
(s->gains & GAINS_STATUS_DATE_DIRTY)))
|
||||||
{
|
{
|
||||||
Transaction *source_trans = s->gains_split->parent;
|
Transaction *source_trans = s->gains_split->parent;
|
||||||
ts = source_trans->date_posted;
|
|
||||||
s->gains &= ~GAINS_STATUS_DATE_DIRTY;
|
s->gains &= ~GAINS_STATUS_DATE_DIRTY;
|
||||||
s->gains_split->gains &= ~GAINS_STATUS_DATE_DIRTY;
|
s->gains_split->gains &= ~GAINS_STATUS_DATE_DIRTY;
|
||||||
|
xaccTransSetDatePostedSecs(trans, source_trans->date_posted);
|
||||||
xaccTransSetDatePostedTS(trans, &ts);
|
|
||||||
FOR_EACH_SPLIT(trans, s->gains &= ~GAINS_STATUS_DATE_DIRTY);
|
FOR_EACH_SPLIT(trans, s->gains &= ~GAINS_STATUS_DATE_DIRTY);
|
||||||
//goto restart_search;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3015,6 +2939,39 @@ trans_is_balanced_p (const Transaction *trans)
|
|||||||
return trans ? xaccTransIsBalanced(trans) : FALSE;
|
return trans ? xaccTransIsBalanced(trans) : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Timespec
|
||||||
|
xaccTransRetDateEnteredTS (Transaction * trans)
|
||||||
|
{
|
||||||
|
Timespec ret = {xaccTransRetDateEntered (trans), 0};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
qofTransSetDateEnteredTS (Transaction * trans, Timespec t)
|
||||||
|
{
|
||||||
|
xaccTransSetDateEnteredSecs (trans, t.tv_sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Timespec
|
||||||
|
xaccTransRetDatePostedTS (Transaction * trans)
|
||||||
|
{
|
||||||
|
Timespec ret = {xaccTransRetDatePosted (trans), 0};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
qofTransSetDatePostedTS (Transaction * trans, Timespec t)
|
||||||
|
{
|
||||||
|
xaccTransSetDatePostedSecs (trans, t.tv_sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Timespec
|
||||||
|
xaccTransRetDateDueTS (Transaction * trans)
|
||||||
|
{
|
||||||
|
Timespec ret = {xaccTransRetDateDue (trans), 0};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean xaccTransRegister (void)
|
gboolean xaccTransRegister (void)
|
||||||
{
|
{
|
||||||
static QofParam params[] =
|
static QofParam params[] =
|
||||||
@ -3033,12 +2990,12 @@ gboolean xaccTransRegister (void)
|
|||||||
{
|
{
|
||||||
TRANS_DATE_ENTERED, QOF_TYPE_DATE,
|
TRANS_DATE_ENTERED, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccTransRetDateEnteredTS,
|
(QofAccessFunc)xaccTransRetDateEnteredTS,
|
||||||
(QofSetterFunc)qofTransSetDateEntered
|
(QofSetterFunc)qofTransSetDateEnteredTS
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
TRANS_DATE_POSTED, QOF_TYPE_DATE,
|
TRANS_DATE_POSTED, QOF_TYPE_DATE,
|
||||||
(QofAccessFunc)xaccTransRetDatePostedTS,
|
(QofAccessFunc)xaccTransRetDatePostedTS,
|
||||||
(QofSetterFunc)qofTransSetDatePosted
|
(QofSetterFunc)qofTransSetDatePostedTS
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
TRANS_DATE_DUE, QOF_TYPE_DATE,
|
TRANS_DATE_DUE, QOF_TYPE_DATE,
|
||||||
|
@ -625,21 +625,11 @@ void xaccTransSetDatePostedSecs (Transaction *trans, time64 time);
|
|||||||
* The posted date is the date when this transaction was posted at the bank. */
|
* The posted date is the date when this transaction was posted at the bank. */
|
||||||
void xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time);
|
void xaccTransSetDatePostedSecsNormalized (Transaction *trans, time64 time);
|
||||||
|
|
||||||
/** The xaccTransSetDatePostedTS() method does the same thing as
|
|
||||||
xaccTransSetDatePostedSecs(), but takes a struct timespec64. */
|
|
||||||
void xaccTransSetDatePostedTS (Transaction *trans,
|
|
||||||
const Timespec *ts);
|
|
||||||
|
|
||||||
/** Modify the date of when the transaction was entered. The entered
|
/** Modify the date of when the transaction was entered. The entered
|
||||||
* date is the date when the register entry was made. */
|
* date is the date when the register entry was made. */
|
||||||
void xaccTransSetDateEnteredSecs (Transaction *trans, time64 time);
|
void xaccTransSetDateEnteredSecs (Transaction *trans, time64 time);
|
||||||
/** Modify the date of when the transaction was entered. The entered
|
|
||||||
* date is the date when the register entry was made. */
|
|
||||||
void xaccTransSetDateEnteredTS (Transaction *trans,
|
|
||||||
const Timespec *ts);
|
|
||||||
|
|
||||||
/** 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 xaccTransSetDateDue (Transaction * trans, time64 time);
|
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
|
||||||
@ -651,12 +641,6 @@ time64 xaccTransGetDate (const Transaction *trans);
|
|||||||
the date when this transaction was posted at the bank. (Although
|
the date when this transaction was posted at the bank. (Although
|
||||||
having different function names, GetDate and GetDatePosted refer
|
having different function names, GetDate and GetDatePosted refer
|
||||||
to the same single date.)*/
|
to the same single date.)*/
|
||||||
void xaccTransGetDatePostedTS (const Transaction *trans, Timespec *ts);
|
|
||||||
/** Retrieve the posted date of the transaction. The posted date is
|
|
||||||
the date when this transaction was posted at the bank. (Although
|
|
||||||
having different function names, GetDate and GetDatePosted refer
|
|
||||||
to the same single date.)*/
|
|
||||||
Timespec xaccTransRetDatePostedTS (const Transaction *trans);
|
|
||||||
time64 xaccTransRetDatePosted (const Transaction *trans);
|
time64 xaccTransRetDatePosted (const Transaction *trans);
|
||||||
/** 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. */
|
the date when this transaction was posted at the bank. */
|
||||||
@ -669,17 +653,10 @@ time64 xaccTransGetDateEntered (const Transaction *trans);
|
|||||||
/*################## Added for Reg2 #################*/
|
/*################## Added for Reg2 #################*/
|
||||||
/** Retrieve the date of when the transaction was entered. The entered
|
/** Retrieve the date of when the transaction was entered. The entered
|
||||||
* date is the date when the register entry was made.*/
|
* date is the date when the register entry was made.*/
|
||||||
void xaccTransGetDateEnteredTS (const Transaction *trans, Timespec *ts);
|
|
||||||
/** Retrieve the date of when the transaction was entered. The entered
|
|
||||||
* date is the date when the register entry was made.*/
|
|
||||||
Timespec xaccTransRetDateEnteredTS (const Transaction *trans);
|
|
||||||
time64 xaccTransRetDateEntered (const Transaction *trans);
|
time64 xaccTransRetDateEntered (const 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 */
|
||||||
Timespec xaccTransRetDateDueTS (const Transaction *trans);
|
|
||||||
time64 xaccTransRetDateDue (const Transaction *trans);
|
time64 xaccTransRetDateDue (const Transaction *trans);
|
||||||
/** Dates and txn-type for A/R and A/P "invoice" postings */
|
|
||||||
void xaccTransGetDateDueTS (const Transaction *trans, Timespec *ts);
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ struct transaction_s
|
|||||||
{
|
{
|
||||||
QofInstance inst; /* glbally unique id */
|
QofInstance inst; /* glbally unique id */
|
||||||
|
|
||||||
Timespec date_entered; /* date register entry was made */
|
time64 date_entered; /* date register entry was made */
|
||||||
Timespec date_posted; /* date transaction was posted at bank */
|
time64 date_posted; /* date transaction was posted at bank */
|
||||||
|
|
||||||
/* The num field is a arbitrary user-assigned field.
|
/* The num field is a arbitrary user-assigned field.
|
||||||
* It is intended to store a short id number, typically the check number,
|
* It is intended to store a short id number, typically the check number,
|
||||||
|
@ -133,6 +133,7 @@ finder_helper (GNCLot *lot, gpointer user_data)
|
|||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
gnc_numeric bal;
|
gnc_numeric bal;
|
||||||
gboolean opening_is_positive, bal_is_positive;
|
gboolean opening_is_positive, bal_is_positive;
|
||||||
|
Timespec posted_ts = {0,0};
|
||||||
|
|
||||||
if (gnc_lot_is_closed (lot)) return NULL;
|
if (gnc_lot_is_closed (lot)) return NULL;
|
||||||
|
|
||||||
@ -157,9 +158,10 @@ finder_helper (GNCLot *lot, gpointer user_data)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (els->date_pred (els->ts, trans->date_posted))
|
posted_ts.tv_sec = trans->date_posted;
|
||||||
|
if (els->date_pred (els->ts, posted_ts))
|
||||||
{
|
{
|
||||||
els->ts = trans->date_posted;
|
els->ts.tv_sec = trans->date_posted;
|
||||||
els->lot = lot;
|
els->lot = lot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,7 +764,6 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
|
|||||||
{
|
{
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Split *lot_split, *gain_split;
|
Split *lot_split, *gain_split;
|
||||||
Timespec ts;
|
|
||||||
gboolean new_gain_split;
|
gboolean new_gain_split;
|
||||||
gnc_numeric negvalue = gnc_numeric_neg (value);
|
gnc_numeric negvalue = gnc_numeric_neg (value);
|
||||||
|
|
||||||
@ -869,8 +870,8 @@ xaccSplitComputeCapGains(Split *split, Account *gain_acc)
|
|||||||
if (new_gain_split)
|
if (new_gain_split)
|
||||||
{
|
{
|
||||||
/* Common to both */
|
/* Common to both */
|
||||||
ts = xaccTransRetDatePostedTS (split->parent);
|
time64 time = xaccTransRetDatePosted (split->parent);
|
||||||
xaccTransSetDatePostedTS (trans, &ts);
|
xaccTransSetDatePostedSecs (trans, time);
|
||||||
xaccTransSetDateEnteredSecs (trans, gnc_time (NULL));
|
xaccTransSetDateEnteredSecs (trans, gnc_time (NULL));
|
||||||
|
|
||||||
xaccSplitSetAmount (lot_split, zero);
|
xaccSplitSetAmount (lot_split, zero);
|
||||||
|
@ -54,17 +54,15 @@ static QofLogModule log_module = GNC_MOD_ENGINE;
|
|||||||
Timespec
|
Timespec
|
||||||
gnc_transaction_get_date_posted(const Transaction *t)
|
gnc_transaction_get_date_posted(const Transaction *t)
|
||||||
{
|
{
|
||||||
Timespec result;
|
Timespec ret = {xaccTransRetDatePosted(t), 0};
|
||||||
xaccTransGetDatePostedTS(t, &result);
|
return ret;
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Timespec
|
Timespec
|
||||||
gnc_transaction_get_date_entered(const Transaction *t)
|
gnc_transaction_get_date_entered(const Transaction *t)
|
||||||
{
|
{
|
||||||
Timespec result;
|
Timespec result = {xaccTransRetDateEntered(t), 0};
|
||||||
xaccTransGetDateEnteredTS(t, &result);
|
return result;
|
||||||
return(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Timespec
|
Timespec
|
||||||
@ -78,7 +76,7 @@ gnc_split_get_date_reconciled(const Split *s)
|
|||||||
void
|
void
|
||||||
gnc_transaction_set_date(Transaction *t, Timespec ts)
|
gnc_transaction_set_date(Transaction *t, Timespec ts)
|
||||||
{
|
{
|
||||||
xaccTransSetDatePostedTS(t, &ts);
|
xaccTransSetDatePostedSecs(t, ts.tv_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the transaction Number or split Action based on book option:
|
/** Gets the transaction Number or split Action based on book option:
|
||||||
|
@ -1223,6 +1223,13 @@ gnc_iso8601_to_time64_gmt(const char *cstr)
|
|||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
\********************************************************************/
|
\********************************************************************/
|
||||||
|
|
||||||
|
char *
|
||||||
|
gnc_time64_to_iso8601_buff (time64 time, char * buff)
|
||||||
|
{
|
||||||
|
Timespec ts = {time, 0};
|
||||||
|
return gnc_timespec_to_iso8601_buff (ts, buff);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
|
gnc_timespec_to_iso8601_buff (Timespec ts, char * buff)
|
||||||
{
|
{
|
||||||
|
@ -414,6 +414,7 @@ time64 gnc_iso8601_to_time64_gmt(const gchar *);
|
|||||||
* on the machine on which it is executing to create the time string.
|
* on the machine on which it is executing to create the time string.
|
||||||
*/
|
*/
|
||||||
gchar * gnc_timespec_to_iso8601_buff (Timespec ts, gchar * buff);
|
gchar * gnc_timespec_to_iso8601_buff (Timespec ts, gchar * buff);
|
||||||
|
gchar * gnc_time64_to_iso8601_buff (time64, char * buff);
|
||||||
|
|
||||||
/** Set the proleptic Gregorian day, month, and year from a Timespec
|
/** Set the proleptic Gregorian day, month, and year from a Timespec
|
||||||
* \param ts: input timespec
|
* \param ts: input timespec
|
||||||
|
@ -712,12 +712,12 @@ 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))).tv_sec;
|
da = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_earliest_split (lotA)));
|
||||||
|
|
||||||
if (ib)
|
if (ib)
|
||||||
db = gncInvoiceGetDateDue (ib);
|
db = gncInvoiceGetDateDue (ib);
|
||||||
else
|
else
|
||||||
db = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB))).tv_sec;
|
db = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_earliest_split (lotB)));
|
||||||
|
|
||||||
return (da > db) - (da < db);
|
return (da > db) - (da < db);
|
||||||
}
|
}
|
||||||
@ -814,7 +814,7 @@ gncOwnerCreatePaymentLot (const GncOwner *owner, Transaction **preset_txn,
|
|||||||
/* set per book option */
|
/* set per book option */
|
||||||
xaccTransSetCurrency (txn, commodity);
|
xaccTransSetCurrency (txn, commodity);
|
||||||
xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
|
xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
|
||||||
xaccTransSetDatePostedTS (txn, &date);
|
xaccTransSetDatePostedSecs (txn, date.tv_sec);
|
||||||
|
|
||||||
|
|
||||||
/* The split for the transfer account */
|
/* The split for the transfer account */
|
||||||
@ -1100,7 +1100,7 @@ gncOwnerCreateLotLink (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
|
|||||||
const gchar *name = gncOwnerGetName (gncOwnerGetEndOwner (owner));
|
const gchar *name = gncOwnerGetName (gncOwnerGetEndOwner (owner));
|
||||||
Transaction *ll_txn = NULL;
|
Transaction *ll_txn = NULL;
|
||||||
gnc_numeric from_lot_bal, to_lot_bal;
|
gnc_numeric from_lot_bal, to_lot_bal;
|
||||||
Timespec from_ts, to_ts;
|
time64 from_time, to_time;
|
||||||
time64 time_posted;
|
time64 time_posted;
|
||||||
Split *split;
|
Split *split;
|
||||||
|
|
||||||
@ -1110,12 +1110,12 @@ gncOwnerCreateLotLink (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Determine transaction date based on lot splits */
|
/* Determine transaction date based on lot splits */
|
||||||
from_ts = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_latest_split (from_lot)));
|
from_time = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_latest_split (from_lot)));
|
||||||
to_ts = xaccTransRetDatePostedTS (xaccSplitGetParent (gnc_lot_get_latest_split (to_lot)));
|
to_time = xaccTransRetDatePosted (xaccSplitGetParent (gnc_lot_get_latest_split (to_lot)));
|
||||||
if (timespecToTime64 (from_ts) >= timespecToTime64 (to_ts))
|
if (from_time >= to_time)
|
||||||
time_posted = timespecToTime64 (from_ts);
|
time_posted = from_time;
|
||||||
else
|
else
|
||||||
time_posted = timespecToTime64 (to_ts);
|
time_posted = to_time;
|
||||||
|
|
||||||
/* Figure out how much we can offset between the lots */
|
/* Figure out how much we can offset between the lots */
|
||||||
from_lot_bal = gnc_lot_get_balance (from_lot);
|
from_lot_bal = gnc_lot_get_balance (from_lot);
|
||||||
@ -1137,31 +1137,22 @@ gncOwnerCreateLotLink (GNCLot *from_lot, GNCLot *to_lot, const GncOwner *owner)
|
|||||||
if (!ll_txn)
|
if (!ll_txn)
|
||||||
{
|
{
|
||||||
/* No pre-existing lot link. Create one. */
|
/* No pre-existing lot link. Create one. */
|
||||||
Timespec ts;
|
|
||||||
|
|
||||||
timespecFromTime64 (&ts, time_posted);
|
|
||||||
|
|
||||||
ll_txn = xaccMallocTransaction (gnc_lot_get_book (from_lot));
|
ll_txn = xaccMallocTransaction (gnc_lot_get_book (from_lot));
|
||||||
xaccTransBeginEdit (ll_txn);
|
xaccTransBeginEdit (ll_txn);
|
||||||
|
|
||||||
xaccTransSetDescription (ll_txn, name ? name : "(Unknown)");
|
xaccTransSetDescription (ll_txn, name ? name : "(Unknown)");
|
||||||
xaccTransSetCurrency (ll_txn, xaccAccountGetCommodity(acct));
|
xaccTransSetCurrency (ll_txn, xaccAccountGetCommodity(acct));
|
||||||
xaccTransSetDateEnteredSecs (ll_txn, gnc_time (NULL));
|
xaccTransSetDateEnteredSecs (ll_txn, gnc_time (NULL));
|
||||||
xaccTransSetDatePostedTS (ll_txn, &ts);
|
xaccTransSetDatePostedSecs (ll_txn, time_posted);
|
||||||
xaccTransSetTxnType (ll_txn, TXN_TYPE_LINK);
|
xaccTransSetTxnType (ll_txn, TXN_TYPE_LINK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Timespec ts = xaccTransRetDatePostedTS (ll_txn);
|
time64 time = xaccTransRetDatePosted (ll_txn);
|
||||||
xaccTransBeginEdit (ll_txn);
|
xaccTransBeginEdit (ll_txn);
|
||||||
|
|
||||||
/* Maybe we need to update the post date of the transaction ? */
|
/* Maybe we need to update the post date of the transaction ? */
|
||||||
if (time_posted > timespecToTime64 (ts))
|
if (time_posted > time)
|
||||||
{
|
xaccTransSetDatePostedSecs (ll_txn, time_posted);
|
||||||
timespecFromTime64 (&ts, time_posted);
|
|
||||||
xaccTransSetDatePostedTS (ll_txn, &ts);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a split for the from_lot */
|
/* Create a split for the from_lot */
|
||||||
|
@ -114,7 +114,7 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse)
|
|||||||
gnc_numeric baln;
|
gnc_numeric baln;
|
||||||
Split *osplit;
|
Split *osplit;
|
||||||
Transaction *otrans;
|
Transaction *otrans;
|
||||||
Timespec open_ts;
|
time64 open_time;
|
||||||
Account* lot_account;
|
Account* lot_account;
|
||||||
|
|
||||||
if (!pcy || !lot || !gnc_lot_get_split_list(lot)) return NULL;
|
if (!pcy || !lot || !gnc_lot_get_split_list(lot)) return NULL;
|
||||||
@ -136,7 +136,7 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse)
|
|||||||
and the lot may end up too thin or too fat. */
|
and the lot may end up too thin or too fat. */
|
||||||
osplit = gnc_lot_get_latest_split (lot);
|
osplit = gnc_lot_get_latest_split (lot);
|
||||||
otrans = osplit ? xaccSplitGetParent (osplit) : 0;
|
otrans = osplit ? xaccSplitGetParent (osplit) : 0;
|
||||||
open_ts = xaccTransRetDatePostedTS (otrans);
|
open_time = xaccTransRetDatePosted (otrans);
|
||||||
|
|
||||||
/* Walk over *all* splits in the account, till we find one that
|
/* Walk over *all* splits in the account, till we find one that
|
||||||
* hasn't been assigned to a lot. Return that split.
|
* hasn't been assigned to a lot. Return that split.
|
||||||
@ -151,15 +151,13 @@ DirectionPolicyGetSplit (GNCPolicy *pcy, GNCLot *lot, short reverse)
|
|||||||
{
|
{
|
||||||
gboolean is_match;
|
gboolean is_match;
|
||||||
gboolean is_positive;
|
gboolean is_positive;
|
||||||
Timespec this_ts;
|
time64 this_time;
|
||||||
split = node->data;
|
split = node->data;
|
||||||
if (split->lot) goto donext;
|
if (split->lot) goto donext;
|
||||||
|
|
||||||
/* Skip it if it's too early */
|
/* Skip it if it's too early */
|
||||||
this_ts = xaccTransRetDatePostedTS ( xaccSplitGetParent (split));
|
this_time = xaccTransRetDatePosted ( xaccSplitGetParent (split));
|
||||||
if ((this_ts.tv_sec < open_ts.tv_sec) ||
|
if (this_time < open_time)
|
||||||
((this_ts.tv_sec == open_ts.tv_sec) &&
|
|
||||||
(this_ts.tv_nsec < open_ts.tv_nsec)))
|
|
||||||
{
|
{
|
||||||
if (reverse)
|
if (reverse)
|
||||||
/* Going backwards, no point in looking further */
|
/* Going backwards, no point in looking further */
|
||||||
|
@ -1420,16 +1420,10 @@ set_tran_random_string_from_array(
|
|||||||
(func)(trn, tmp_str);
|
(func)(trn, tmp_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
trn_add_ran_timespec(Transaction *trn, void (*func)(Transaction*,
|
trn_add_ran_time (Transaction *trn, void (*func)(Transaction*, time64))
|
||||||
const Timespec*))
|
|
||||||
{
|
{
|
||||||
Timespec *to_set;
|
func(trn, get_random_time());
|
||||||
|
|
||||||
to_set = get_random_timespec();
|
|
||||||
func(trn, to_set);
|
|
||||||
g_free(to_set);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1471,8 +1465,8 @@ get_random_transaction_with_currency(QofBook *book,
|
|||||||
xaccTransSetNum(trans, numstr);
|
xaccTransSetNum(trans, numstr);
|
||||||
set_tran_random_string_from_array(trans, xaccTransSetDescription,
|
set_tran_random_string_from_array(trans, xaccTransSetDescription,
|
||||||
sane_descriptions);
|
sane_descriptions);
|
||||||
trn_add_ran_timespec(trans, xaccTransSetDatePostedTS);
|
trn_add_ran_time(trans, xaccTransSetDatePostedSecs);
|
||||||
trn_add_ran_timespec(trans, xaccTransSetDateEnteredTS);
|
trn_add_ran_time(trans, xaccTransSetDateEnteredSecs);
|
||||||
|
|
||||||
f = get_random_kvp_frame();
|
f = get_random_kvp_frame();
|
||||||
qof_instance_set_slots (QOF_INSTANCE (trans), f);
|
qof_instance_set_slots (QOF_INSTANCE (trans), f);
|
||||||
@ -1531,8 +1525,8 @@ make_random_changes_to_transaction (QofBook *book, Transaction *trans)
|
|||||||
|
|
||||||
set_tran_random_string (trans, xaccTransSetNum);
|
set_tran_random_string (trans, xaccTransSetNum);
|
||||||
|
|
||||||
trn_add_ran_timespec (trans, xaccTransSetDatePostedTS);
|
trn_add_ran_time (trans, xaccTransSetDatePostedSecs);
|
||||||
trn_add_ran_timespec (trans, xaccTransSetDateEnteredTS);
|
trn_add_ran_time (trans, xaccTransSetDateEnteredSecs);
|
||||||
|
|
||||||
set_tran_random_string (trans, xaccTransSetDescription);
|
set_tran_random_string (trans, xaccTransSetDescription);
|
||||||
|
|
||||||
@ -2055,10 +2049,8 @@ make_trans_query (Transaction *trans, TestQueryTypes query_types)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Timespec ts;
|
time64 time = xaccTransRetDatePosted (trans);
|
||||||
|
xaccQueryAddDateMatchTT (q, TRUE, time, TRUE, time, QOF_QUERY_AND);
|
||||||
xaccTransGetDatePostedTS (trans, &ts);
|
|
||||||
xaccQueryAddDateMatchTS (q, TRUE, ts, TRUE, ts, QOF_QUERY_AND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xaccSplitGetMemo(s) && *xaccSplitGetMemo(s) != '\0')
|
if (xaccSplitGetMemo(s) && *xaccSplitGetMemo(s) != '\0')
|
||||||
|
@ -1125,7 +1125,7 @@ test_xaccSplitOrder (Fixture *fixture, gconstpointer pData)
|
|||||||
* split-action based on book option.
|
* split-action based on book option.
|
||||||
*/
|
*/
|
||||||
o_split->parent = o_txn;
|
o_split->parent = o_txn;
|
||||||
split->parent->date_posted = timespec_now ();
|
split->parent->date_posted = gnc_time (NULL);
|
||||||
o_split->parent->date_posted = split->parent->date_posted;
|
o_split->parent->date_posted = split->parent->date_posted;
|
||||||
|
|
||||||
/* The book_use_split_action_for_num_field book option hasn't been set so it
|
/* The book_use_split_action_for_num_field book option hasn't been set so it
|
||||||
@ -1249,13 +1249,13 @@ test_xaccSplitOrderDateOnly (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, 1);
|
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, 1);
|
||||||
split->parent = txn;
|
split->parent = txn;
|
||||||
|
|
||||||
txn->date_posted = timespec_now ();
|
txn->date_posted = gnc_time (nullptr);
|
||||||
o_txn->date_posted = timespec_now ();
|
o_txn->date_posted = gnc_time (nullptr);
|
||||||
o_txn->date_posted.tv_sec -= 50;
|
o_txn->date_posted -= 50;
|
||||||
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, 1);
|
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, 1);
|
||||||
o_txn->date_posted.tv_sec += 100;
|
o_txn->date_posted += 100;
|
||||||
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, -1);
|
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, -1);
|
||||||
o_txn->date_posted.tv_sec -= 50;
|
o_txn->date_posted -= 50;
|
||||||
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, -1);
|
g_assert_cmpint (xaccSplitOrderDateOnly (split, o_split), ==, -1);
|
||||||
|
|
||||||
test_destroy (o_split);
|
test_destroy (o_split);
|
||||||
|
@ -119,8 +119,8 @@ setup (Fixture *fixture, gconstpointer pData)
|
|||||||
QofBook *book = qof_book_new ();
|
QofBook *book = qof_book_new ();
|
||||||
TransMockBackend *mbe = new TransMockBackend;
|
TransMockBackend *mbe = new TransMockBackend;
|
||||||
Transaction *txn;
|
Transaction *txn;
|
||||||
Timespec entered = gnc_dmy2timespec (20, 4, 2012);
|
time64 entered = gnc_dmy2time64 (20, 4, 2012);
|
||||||
Timespec posted = gnc_dmy2timespec (21, 4, 2012);
|
time64 posted = gnc_dmy2time64 (21, 4, 2012);
|
||||||
auto frame = new KvpFrame ();
|
auto frame = new KvpFrame ();
|
||||||
|
|
||||||
qof_book_set_backend (book, mbe);
|
qof_book_set_backend (book, mbe);
|
||||||
@ -134,10 +134,8 @@ setup (Fixture *fixture, gconstpointer pData)
|
|||||||
fixture->acc2 = xaccMallocAccount (book);
|
fixture->acc2 = xaccMallocAccount (book);
|
||||||
xaccAccountSetCommodity (fixture->acc1, fixture->comm);
|
xaccAccountSetCommodity (fixture->acc1, fixture->comm);
|
||||||
xaccAccountSetCommodity (fixture->acc2, fixture->curr);
|
xaccAccountSetCommodity (fixture->acc2, fixture->curr);
|
||||||
txn->date_posted.tv_sec = posted.tv_sec;
|
txn->date_posted = posted;
|
||||||
txn->date_posted.tv_nsec = posted.tv_nsec;
|
txn->date_entered = entered;
|
||||||
txn->date_entered.tv_sec = entered.tv_sec;
|
|
||||||
txn->date_entered.tv_nsec = entered.tv_nsec;
|
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
@ -343,10 +341,8 @@ test_gnc_transaction_init ()
|
|||||||
g_assert_cmpstr (txn->description, ==, "");
|
g_assert_cmpstr (txn->description, ==, "");
|
||||||
g_assert (txn->common_currency == NULL);
|
g_assert (txn->common_currency == NULL);
|
||||||
g_assert (txn->splits == NULL);
|
g_assert (txn->splits == NULL);
|
||||||
g_assert_cmpint (txn->date_entered.tv_sec, ==, 0);
|
g_assert_cmpint (txn->date_entered, ==, 0);
|
||||||
g_assert_cmpint (txn->date_entered.tv_nsec, ==, 0);
|
g_assert_cmpint (txn->date_posted, ==, 0);
|
||||||
g_assert_cmpint (txn->date_posted.tv_sec, ==, 0);
|
|
||||||
g_assert_cmpint (txn->date_posted.tv_nsec, ==, 0);
|
|
||||||
g_assert_cmpint (txn->marker, ==, 0);
|
g_assert_cmpint (txn->marker, ==, 0);
|
||||||
g_assert (txn->orig == NULL);
|
g_assert (txn->orig == NULL);
|
||||||
|
|
||||||
@ -416,10 +412,8 @@ test_gnc_transaction_set_get_property (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpstr (txn->num, ==, "");
|
g_assert_cmpstr (txn->num, ==, "");
|
||||||
g_assert_cmpstr (txn->description, ==, "");
|
g_assert_cmpstr (txn->description, ==, "");
|
||||||
g_assert (txn->common_currency == NULL);
|
g_assert (txn->common_currency == NULL);
|
||||||
g_assert_cmpint (txn->date_entered.tv_sec, ==, 0);
|
g_assert_cmpint (txn->date_entered, ==, 0);
|
||||||
g_assert_cmpint (txn->date_entered.tv_nsec, ==, 0);
|
g_assert_cmpint (txn->date_posted, ==, 0);
|
||||||
g_assert_cmpint (txn->date_posted.tv_sec, ==, 0);
|
|
||||||
g_assert_cmpint (txn->date_posted.tv_nsec, ==, 0);
|
|
||||||
/* Kick up the edit counter to keep from committing */
|
/* Kick up the edit counter to keep from committing */
|
||||||
xaccTransBeginEdit (txn);
|
xaccTransBeginEdit (txn);
|
||||||
g_object_set (G_OBJECT (txn),
|
g_object_set (G_OBJECT (txn),
|
||||||
@ -433,8 +427,8 @@ test_gnc_transaction_set_get_property (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpstr (txn->num, ==, num);
|
g_assert_cmpstr (txn->num, ==, num);
|
||||||
g_assert_cmpstr (txn->description, ==, desc);
|
g_assert_cmpstr (txn->description, ==, desc);
|
||||||
g_assert (txn->common_currency == curr);
|
g_assert (txn->common_currency == curr);
|
||||||
g_assert (timespec_equal (&(txn->date_entered), &now));
|
g_assert (txn->date_entered == now.tv_sec);
|
||||||
g_assert (timespec_equal (&(txn->date_posted), &now));
|
g_assert (txn->date_posted == now.tv_sec);
|
||||||
|
|
||||||
g_object_get (G_OBJECT (txn),
|
g_object_get (G_OBJECT (txn),
|
||||||
"num", &t_num,
|
"num", &t_num,
|
||||||
@ -447,13 +441,12 @@ test_gnc_transaction_set_get_property (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpstr (t_num, ==, num);
|
g_assert_cmpstr (t_num, ==, num);
|
||||||
g_assert_cmpstr (t_desc, ==, desc);
|
g_assert_cmpstr (t_desc, ==, desc);
|
||||||
g_assert (t_curr == curr);
|
g_assert (t_curr == curr);
|
||||||
g_assert (timespec_equal (t_entered, &now));
|
g_assert (t_entered->tv_sec == now.tv_sec);
|
||||||
g_assert (timespec_equal (t_posted, &now));
|
g_assert (t_posted->tv_sec == now.tv_sec);
|
||||||
xaccTransRollbackEdit (txn);
|
xaccTransRollbackEdit (txn);
|
||||||
test_destroy (txn);
|
test_destroy (txn);
|
||||||
test_destroy (curr);
|
test_destroy (curr);
|
||||||
qof_book_destroy (book);
|
qof_book_destroy (book);
|
||||||
g_free (t_entered);
|
|
||||||
}
|
}
|
||||||
/* gnc_transaction_class_init
|
/* gnc_transaction_class_init
|
||||||
* xaccInitTransaction
|
* xaccInitTransaction
|
||||||
@ -554,8 +547,8 @@ dupe_trans (const Transaction *from)// Local: 1:0:0
|
|||||||
static void
|
static void
|
||||||
test_dupe_trans (Fixture *fixture, gconstpointer pData)
|
test_dupe_trans (Fixture *fixture, gconstpointer pData)
|
||||||
{
|
{
|
||||||
Timespec posted = gnc_dmy2timespec (12, 7, 2011);
|
time64 posted = gnc_dmy2time64 (12, 7, 2011);
|
||||||
Timespec entered = gnc_dmy2timespec (14, 7, 2011);
|
time64 entered = gnc_dmy2time64 (14, 7, 2011);
|
||||||
Transaction *newtxn = NULL, *oldtxn = fixture->txn;
|
Transaction *newtxn = NULL, *oldtxn = fixture->txn;
|
||||||
QofBook *old_book = qof_instance_get_book (QOF_INSTANCE (oldtxn));
|
QofBook *old_book = qof_instance_get_book (QOF_INSTANCE (oldtxn));
|
||||||
GList *newnode, *oldnode = oldtxn->splits;
|
GList *newnode, *oldnode = oldtxn->splits;
|
||||||
@ -579,8 +572,8 @@ test_dupe_trans (Fixture *fixture, gconstpointer pData)
|
|||||||
}
|
}
|
||||||
g_assert (newnode == NULL);
|
g_assert (newnode == NULL);
|
||||||
g_assert (oldnode == NULL);
|
g_assert (oldnode == NULL);
|
||||||
g_assert (timespec_equal (&(newtxn->date_posted), &posted));
|
g_assert (newtxn->date_posted == posted);
|
||||||
g_assert (timespec_equal (&(newtxn->date_entered), &entered));
|
g_assert (newtxn->date_entered == entered);
|
||||||
g_assert (qof_instance_version_cmp (QOF_INSTANCE (newtxn),
|
g_assert (qof_instance_version_cmp (QOF_INSTANCE (newtxn),
|
||||||
QOF_INSTANCE (oldtxn)) == 0);
|
QOF_INSTANCE (oldtxn)) == 0);
|
||||||
g_assert (newtxn->orig == NULL);
|
g_assert (newtxn->orig == NULL);
|
||||||
@ -600,8 +593,8 @@ xaccTransClone (const Transaction *from)// C: 1 Local: 1:0:0
|
|||||||
static void
|
static void
|
||||||
test_xaccTransClone (Fixture *fixture, gconstpointer pData)
|
test_xaccTransClone (Fixture *fixture, gconstpointer pData)
|
||||||
{
|
{
|
||||||
Timespec posted = gnc_dmy2timespec (12, 7, 2011);
|
time64 posted = gnc_dmy2time64 (12, 7, 2011);
|
||||||
Timespec entered = gnc_dmy2timespec (14, 7, 2011);
|
time64 entered = gnc_dmy2time64 (14, 7, 2011);
|
||||||
Transaction *newtxn = NULL, *oldtxn = fixture->txn;
|
Transaction *newtxn = NULL, *oldtxn = fixture->txn;
|
||||||
QofBook *old_book = qof_instance_get_book (QOF_INSTANCE (oldtxn));
|
QofBook *old_book = qof_instance_get_book (QOF_INSTANCE (oldtxn));
|
||||||
GList *newnode, *oldnode;
|
GList *newnode, *oldnode;
|
||||||
@ -631,8 +624,8 @@ test_xaccTransClone (Fixture *fixture, gconstpointer pData)
|
|||||||
}
|
}
|
||||||
g_assert (newnode == NULL);
|
g_assert (newnode == NULL);
|
||||||
g_assert (oldnode == NULL);
|
g_assert (oldnode == NULL);
|
||||||
g_assert (timespec_equal (&(newtxn->date_posted), &posted));
|
g_assert (newtxn->date_posted == posted);
|
||||||
g_assert (timespec_equal (&(newtxn->date_entered), &entered));
|
g_assert (newtxn->date_entered == entered);
|
||||||
g_assert (qof_instance_version_cmp (QOF_INSTANCE (newtxn),
|
g_assert (qof_instance_version_cmp (QOF_INSTANCE (newtxn),
|
||||||
QOF_INSTANCE (oldtxn)) == 0);
|
QOF_INSTANCE (oldtxn)) == 0);
|
||||||
g_assert_cmpint (qof_instance_get_version_check (newtxn), ==,
|
g_assert_cmpint (qof_instance_get_version_check (newtxn), ==,
|
||||||
@ -665,16 +658,16 @@ test_xaccTransCopyFromClipBoard (Fixture *fixture, gconstpointer pData)
|
|||||||
QofBook *book = qof_instance_get_book (QOF_INSTANCE (txn));
|
QofBook *book = qof_instance_get_book (QOF_INSTANCE (txn));
|
||||||
Account *acc1 = xaccMallocAccount (book);
|
Account *acc1 = xaccMallocAccount (book);
|
||||||
Transaction *to_txn = xaccMallocTransaction (book);
|
Transaction *to_txn = xaccMallocTransaction (book);
|
||||||
Timespec now = timespec_now();
|
time64 now = gnc_time (nullptr);
|
||||||
Timespec never = {0, 0};
|
time64 never = 0;
|
||||||
auto to_frame = to_txn->inst.kvp_data;
|
auto to_frame = to_txn->inst.kvp_data;
|
||||||
|
|
||||||
xaccAccountSetCommodity (acc1, fixture->comm);
|
xaccAccountSetCommodity (acc1, fixture->comm);
|
||||||
xaccTransCopyFromClipBoard (txn, to_txn, fixture->acc1, acc1, FALSE);
|
xaccTransCopyFromClipBoard (txn, to_txn, fixture->acc1, acc1, FALSE);
|
||||||
g_assert (gnc_commodity_equal (txn->common_currency,
|
g_assert (gnc_commodity_equal (txn->common_currency,
|
||||||
to_txn->common_currency));
|
to_txn->common_currency));
|
||||||
g_assert (timespec_equal (&(to_txn->date_entered), &now));
|
g_assert (to_txn->date_entered == now);
|
||||||
g_assert (timespec_equal (&(to_txn->date_posted), &txn->date_posted));
|
g_assert (to_txn->date_posted == txn->date_posted);
|
||||||
g_assert_cmpstr (txn->num, ==, to_txn->num);
|
g_assert_cmpstr (txn->num, ==, to_txn->num);
|
||||||
/* Notes also tests that KVP is copied */
|
/* Notes also tests that KVP is copied */
|
||||||
g_assert_cmpstr (xaccTransGetNotes (txn), ==, xaccTransGetNotes (to_txn));
|
g_assert_cmpstr (xaccTransGetNotes (txn), ==, xaccTransGetNotes (to_txn));
|
||||||
@ -692,15 +685,15 @@ test_xaccTransCopyFromClipBoard_no_start (Fixture *fixture, gconstpointer pData)
|
|||||||
QofBook *book = qof_instance_get_book (QOF_INSTANCE (txn));
|
QofBook *book = qof_instance_get_book (QOF_INSTANCE (txn));
|
||||||
Account *acc1 = xaccMallocAccount (book);
|
Account *acc1 = xaccMallocAccount (book);
|
||||||
Transaction *to_txn = xaccMallocTransaction (book);
|
Transaction *to_txn = xaccMallocTransaction (book);
|
||||||
Timespec now = timespec_now();
|
time64 now = gnc_time (nullptr);
|
||||||
Timespec never = {0, 0};
|
time64 never = 0;
|
||||||
|
|
||||||
xaccAccountSetCommodity (acc1, fixture->comm);
|
xaccAccountSetCommodity (acc1, fixture->comm);
|
||||||
xaccTransCopyFromClipBoard (txn, to_txn, fixture->acc1, acc1, TRUE);
|
xaccTransCopyFromClipBoard (txn, to_txn, fixture->acc1, acc1, TRUE);
|
||||||
g_assert (gnc_commodity_equal (txn->common_currency,
|
g_assert (gnc_commodity_equal (txn->common_currency,
|
||||||
to_txn->common_currency));
|
to_txn->common_currency));
|
||||||
g_assert (timespec_equal (&(to_txn->date_entered), &now));
|
g_assert (to_txn->date_entered == now);
|
||||||
g_assert (timespec_equal (&(to_txn->date_posted), &never));
|
g_assert (to_txn->date_posted == never);
|
||||||
g_assert_cmpstr (to_txn->num, ==, txn->num);
|
g_assert_cmpstr (to_txn->num, ==, txn->num);
|
||||||
/* Notes also tests that KVP is copied */
|
/* Notes also tests that KVP is copied */
|
||||||
g_assert_cmpstr (xaccTransGetNotes (txn), ==, xaccTransGetNotes (to_txn));
|
g_assert_cmpstr (xaccTransGetNotes (txn), ==, xaccTransGetNotes (to_txn));
|
||||||
@ -736,10 +729,8 @@ test_xaccFreeTransaction (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert (txn->splits == NULL);
|
g_assert (txn->splits == NULL);
|
||||||
g_assert_cmpint (GPOINTER_TO_INT(txn->num), ==, 1);
|
g_assert_cmpint (GPOINTER_TO_INT(txn->num), ==, 1);
|
||||||
g_assert (txn->description == NULL);
|
g_assert (txn->description == NULL);
|
||||||
g_assert_cmpint (txn->date_entered.tv_sec, ==, 0);
|
g_assert_cmpint (txn->date_entered, ==, 0);
|
||||||
g_assert_cmpint (txn->date_entered.tv_nsec, ==, 0);
|
g_assert_cmpint (txn->date_posted, ==, 0);
|
||||||
g_assert_cmpint (txn->date_posted.tv_sec, ==, 0);
|
|
||||||
g_assert_cmpint (txn->date_posted.tv_nsec, ==, 0);
|
|
||||||
g_assert_cmpint (GPOINTER_TO_INT(orig->num), ==, 1);
|
g_assert_cmpint (GPOINTER_TO_INT(orig->num), ==, 1);
|
||||||
g_assert (txn->orig == NULL);
|
g_assert (txn->orig == NULL);
|
||||||
test_destroy (orig);
|
test_destroy (orig);
|
||||||
@ -818,13 +809,13 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert (!xaccTransEqual (clone, txn0, TRUE, FALSE, TRUE, TRUE));
|
g_assert (!xaccTransEqual (clone, txn0, TRUE, FALSE, TRUE, TRUE));
|
||||||
g_assert_cmpint (check->hits, ==, 2);
|
g_assert_cmpint (check->hits, ==, 2);
|
||||||
|
|
||||||
gnc_timespec_to_iso8601_buff (clone->date_posted, posted);
|
gnc_time64_to_iso8601_buff (clone->date_posted, posted);
|
||||||
gnc_timespec_to_iso8601_buff (clone->date_entered, entered);
|
gnc_time64_to_iso8601_buff (clone->date_entered, entered);
|
||||||
xaccTransBeginEdit (clone);
|
xaccTransBeginEdit (clone);
|
||||||
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
||||||
/* This puts the value of the first split back, but leaves the amount changed */
|
/* This puts the value of the first split back, but leaves the amount changed */
|
||||||
xaccTransSetCurrency (clone, fixture->curr);
|
xaccTransSetCurrency (clone, fixture->curr);
|
||||||
clone->date_posted.tv_sec = txn0->date_entered.tv_sec;
|
clone->date_posted = txn0->date_entered;
|
||||||
xaccTransCommitEdit (clone);
|
xaccTransCommitEdit (clone);
|
||||||
g_free (cleanup->msg);
|
g_free (cleanup->msg);
|
||||||
g_free (check->msg);
|
g_free (check->msg);
|
||||||
@ -834,8 +825,8 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
|
|||||||
|
|
||||||
xaccTransBeginEdit (clone);
|
xaccTransBeginEdit (clone);
|
||||||
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
||||||
clone->date_posted.tv_sec = txn0->date_posted.tv_sec;
|
clone->date_posted = txn0->date_posted;
|
||||||
clone->date_entered.tv_sec = txn0->date_posted.tv_sec;
|
clone->date_entered = txn0->date_posted;
|
||||||
xaccTransCommitEdit (clone);
|
xaccTransCommitEdit (clone);
|
||||||
g_free (cleanup->msg);
|
g_free (cleanup->msg);
|
||||||
g_free (check->msg);
|
g_free (check->msg);
|
||||||
@ -845,7 +836,7 @@ test_xaccTransEqual (Fixture *fixture, gconstpointer pData)
|
|||||||
|
|
||||||
xaccTransBeginEdit (clone);
|
xaccTransBeginEdit (clone);
|
||||||
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
cleanup->msg = g_strdup_printf (cleanup_fmt, clone->orig);
|
||||||
clone->date_entered.tv_sec = txn0->date_entered.tv_sec;
|
clone->date_entered = txn0->date_entered;
|
||||||
clone->num = g_strdup("123");
|
clone->num = g_strdup("123");
|
||||||
xaccTransCommitEdit (clone);
|
xaccTransCommitEdit (clone);
|
||||||
g_free (cleanup->msg);
|
g_free (cleanup->msg);
|
||||||
@ -1590,7 +1581,7 @@ test_xaccTransCommitEdit (void)
|
|||||||
gnc_commodity *comm = gnc_commodity_new (book, "Wildebeest Fund",
|
gnc_commodity *comm = gnc_commodity_new (book, "Wildebeest Fund",
|
||||||
"FUND", "WBFXX", "", 1000);
|
"FUND", "WBFXX", "", 1000);
|
||||||
|
|
||||||
Timespec posted = gnc_dmy2timespec (21, 4, 2012);
|
time64 posted = gnc_dmy2time64 (21, 4, 2012);
|
||||||
|
|
||||||
auto sig_1_modify = test_signal_new (QOF_INSTANCE (split1),
|
auto sig_1_modify = test_signal_new (QOF_INSTANCE (split1),
|
||||||
QOF_EVENT_MODIFY, NULL);
|
QOF_EVENT_MODIFY, NULL);
|
||||||
@ -1602,8 +1593,7 @@ test_xaccTransCommitEdit (void)
|
|||||||
|
|
||||||
xaccAccountSetCommodity (acc1, comm);
|
xaccAccountSetCommodity (acc1, comm);
|
||||||
xaccAccountSetCommodity (acc2, curr);
|
xaccAccountSetCommodity (acc2, curr);
|
||||||
txn->date_posted.tv_sec = posted.tv_sec;
|
txn->date_posted = posted;
|
||||||
txn->date_posted.tv_nsec = posted.tv_nsec;
|
|
||||||
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
split1->memo = static_cast<char*>(CACHE_INSERT ("foo"));
|
||||||
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
split1->action = static_cast<char*>(CACHE_INSERT ("bar"));
|
||||||
split1->amount = gnc_numeric_create (100000, 1000);
|
split1->amount = gnc_numeric_create (100000, 1000);
|
||||||
@ -1626,7 +1616,7 @@ test_xaccTransCommitEdit (void)
|
|||||||
/* Setup's done, now test: */
|
/* Setup's done, now test: */
|
||||||
xaccTransCommitEdit (txn);
|
xaccTransCommitEdit (txn);
|
||||||
|
|
||||||
g_assert_cmpint (txn->date_entered.tv_sec, !=, 0);
|
g_assert_cmpint (txn->date_entered, !=, 0);
|
||||||
/* Signals make sure that trans_cleanup_commit got called */
|
/* Signals make sure that trans_cleanup_commit got called */
|
||||||
g_assert_cmpint (test_signal_return_hits (sig_1_modify), ==, 1);
|
g_assert_cmpint (test_signal_return_hits (sig_1_modify), ==, 1);
|
||||||
g_assert_cmpint (test_signal_return_hits (sig_2_modify), ==, 1);
|
g_assert_cmpint (test_signal_return_hits (sig_2_modify), ==, 1);
|
||||||
@ -1659,13 +1649,13 @@ test_xaccTransRollbackEdit (Fixture *fixture, gconstpointer pData)
|
|||||||
Transaction *txn = fixture->txn;
|
Transaction *txn = fixture->txn;
|
||||||
Transaction *orig = NULL;
|
Transaction *orig = NULL;
|
||||||
QofBook *book = qof_instance_get_book (txn);
|
QofBook *book = qof_instance_get_book (txn);
|
||||||
Timespec new_post = timespec_now ();
|
time64 new_post = gnc_time (nullptr);
|
||||||
Timespec new_entered = timespecCanonicalDayTime (timespec_now ());
|
time64 new_entered = time64CanonicalDayTime (new_post);
|
||||||
Timespec orig_post = txn->date_posted;
|
time64 orig_post = txn->date_posted;
|
||||||
Timespec orig_entered = txn->date_entered;
|
time64 orig_entered = txn->date_entered;
|
||||||
KvpFrame *base_frame = NULL;
|
KvpFrame *base_frame = NULL;
|
||||||
auto sig_account = test_signal_new (QOF_INSTANCE (fixture->acc1),
|
auto sig_account = test_signal_new (QOF_INSTANCE (fixture->acc1),
|
||||||
GNC_EVENT_ITEM_CHANGED, NULL);
|
GNC_EVENT_ITEM_CHANGED, NULL);
|
||||||
auto mbe = static_cast<TransMockBackend*>(qof_book_get_backend (book));
|
auto mbe = static_cast<TransMockBackend*>(qof_book_get_backend (book));
|
||||||
auto split_00 = static_cast<Split*>(txn->splits->data);
|
auto split_00 = static_cast<Split*>(txn->splits->data);
|
||||||
auto split_01 = static_cast<Split*>(txn->splits->next->data);
|
auto split_01 = static_cast<Split*>(txn->splits->next->data);
|
||||||
@ -1705,8 +1695,8 @@ test_xaccTransRollbackEdit (Fixture *fixture, gconstpointer pData)
|
|||||||
g_assert_cmpstr (txn->description, ==, "Waldo Pepper");
|
g_assert_cmpstr (txn->description, ==, "Waldo Pepper");
|
||||||
g_assert (txn->inst.kvp_data == base_frame);
|
g_assert (txn->inst.kvp_data == base_frame);
|
||||||
g_assert (txn->common_currency == fixture->curr);
|
g_assert (txn->common_currency == fixture->curr);
|
||||||
g_assert (timespec_equal (&(txn->date_posted), &orig_post));
|
g_assert (txn->date_posted == orig_post);
|
||||||
g_assert (timespec_equal (&(txn->date_entered), &orig_entered));
|
g_assert (txn->date_entered == orig_entered);
|
||||||
g_assert_cmpuint (test_signal_return_hits (sig_account), ==, 1);
|
g_assert_cmpuint (test_signal_return_hits (sig_account), ==, 1);
|
||||||
g_assert_cmpuint (g_list_length (txn->splits), ==, 2);
|
g_assert_cmpuint (g_list_length (txn->splits), ==, 2);
|
||||||
g_assert_cmpint (GPOINTER_TO_INT(split_02->memo), ==, 1);
|
g_assert_cmpint (GPOINTER_TO_INT(split_02->memo), ==, 1);
|
||||||
@ -1771,14 +1761,14 @@ test_xaccTransOrder_num_action (Fixture *fixture, gconstpointer pData)
|
|||||||
qof_instance_guid_compare (txnA, txnB));
|
qof_instance_guid_compare (txnA, txnB));
|
||||||
txnB->description = static_cast<char*>(CACHE_INSERT ("Salt Peanuts"));
|
txnB->description = static_cast<char*>(CACHE_INSERT ("Salt Peanuts"));
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), >=, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), >=, 1);
|
||||||
txnB->date_entered.tv_sec += 1;
|
txnB->date_entered += 1;
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, -1);
|
||||||
txnB->num = static_cast<char*>(CACHE_INSERT ("101"));
|
txnB->num = static_cast<char*>(CACHE_INSERT ("101"));
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
||||||
txnB->num = static_cast<char*>(CACHE_INSERT ("one-oh-one"));
|
txnB->num = static_cast<char*>(CACHE_INSERT ("one-oh-one"));
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, NULL, txnB, NULL), ==, 1);
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, -1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, -1);
|
||||||
txnB->date_posted.tv_sec -= 1;
|
txnB->date_posted -= 1;
|
||||||
g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, 1);
|
g_assert_cmpint (xaccTransOrder_num_action (txnA, "24", txnB, "42"), ==, 1);
|
||||||
|
|
||||||
fixture->func->xaccFreeTransaction (txnB);
|
fixture->func->xaccFreeTransaction (txnB);
|
||||||
@ -1954,8 +1944,7 @@ test_xaccTransScrubGainsDate_no_dirty (GainsFixture *fixture,
|
|||||||
|
|
||||||
fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
|
fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
|
||||||
|
|
||||||
g_assert (!timespec_equal (&(fixture->base.txn->date_posted),
|
g_assert (fixture->base.txn->date_posted != fixture->gains_txn->date_posted);
|
||||||
&(fixture->gains_txn->date_posted)));
|
|
||||||
g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
|
g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
|
||||||
g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
|
g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
|
||||||
==, 0);
|
==, 0);
|
||||||
@ -1973,8 +1962,7 @@ test_xaccTransScrubGainsDate_base_dirty (GainsFixture *fixture,
|
|||||||
|
|
||||||
fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
|
fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
|
||||||
|
|
||||||
g_assert (timespec_equal (&(fixture->base.txn->date_posted),
|
g_assert (fixture->base.txn->date_posted == fixture->gains_txn->date_posted);
|
||||||
&(fixture->gains_txn->date_posted)));
|
|
||||||
g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
|
g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
|
||||||
g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
|
g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
|
||||||
==, 0);
|
==, 0);
|
||||||
@ -1992,8 +1980,7 @@ test_xaccTransScrubGainsDate_gains_dirty (GainsFixture *fixture,
|
|||||||
|
|
||||||
fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
|
fixture->base.func->xaccTransScrubGainsDate (fixture->base.txn);
|
||||||
|
|
||||||
g_assert (timespec_equal (&(fixture->base.txn->date_posted),
|
g_assert (fixture->base.txn->date_posted == fixture->gains_txn->date_posted);
|
||||||
&(fixture->gains_txn->date_posted)));
|
|
||||||
g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
|
g_assert_cmphex (base_split->gains & GAINS_STATUS_DATE_DIRTY, ==, 0);
|
||||||
g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
|
g_assert_cmphex (base_split->gains_split->gains & GAINS_STATUS_DATE_DIRTY,
|
||||||
==, 0);
|
==, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user