mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 18:30:23 -06:00
Merge Chris Lam's and Aaron Laws's branch 'time64-ftw' into unstable.
This commit is contained in:
commit
74ddb671e4
@ -4,7 +4,7 @@ ADD_SUBDIRECTORY(tests)
|
||||
SET(PYEXEC_FILES __init__.py function_class.py gnucash_business.py gnucash_core.py)
|
||||
|
||||
IF (BUILDING_FROM_VCS)
|
||||
SET(SWIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core.i ${CMAKE_CURRENT_SOURCE_DIR}/timespec.i)
|
||||
SET(SWIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core.i ${CMAKE_CURRENT_SOURCE_DIR}/time64.i)
|
||||
SET(GNUCASH_CORE_C_INCLUDES
|
||||
${CONFIG_H}
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/engine/qofsession.h
|
||||
@ -104,7 +104,7 @@ ENDIF()
|
||||
SET(python_bindings_DATA ${PYEXEC_FILES}
|
||||
gnucash_core.i
|
||||
sqlite3test.c
|
||||
timespec.i)
|
||||
time64.i)
|
||||
|
||||
SET_LOCAL_DIST(python_bindings_DIST_local CMakeLists.txt
|
||||
${python_bindings_DATA})
|
||||
|
@ -85,7 +85,7 @@
|
||||
#include "Scrub3.h"
|
||||
%}
|
||||
|
||||
%include <timespec.i>
|
||||
%include <time64.i>
|
||||
|
||||
%include <base-typemaps.i>
|
||||
|
||||
|
@ -34,8 +34,8 @@ class TestAccount( AccountSession ):
|
||||
tx = Transaction(self.book)
|
||||
tx.BeginEdit()
|
||||
tx.SetCurrency(self.currency)
|
||||
tx.SetDateEnteredTS(datetime.now())
|
||||
tx.SetDatePostedTS(datetime.now())
|
||||
tx.SetDateEnteredSecs(datetime.now())
|
||||
tx.SetDatePostedSecs(datetime.now())
|
||||
|
||||
s1a = Split(self.book)
|
||||
s1a.SetParent(tx)
|
||||
|
@ -1,6 +1,6 @@
|
||||
from unittest import main
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from gnucash import Account, \
|
||||
ACCT_TYPE_RECEIVABLE, ACCT_TYPE_INCOME, ACCT_TYPE_BANK, \
|
||||
@ -56,6 +56,8 @@ class TestBusiness( BusinessSession ):
|
||||
self.assertEqual( NAME, self.employee.GetUsername() )
|
||||
|
||||
def test_post(self):
|
||||
self.assertEqual(self.today - timedelta(0, 0, self.today.microsecond),
|
||||
self.invoice.GetDatePosted())
|
||||
self.assertTrue( self.invoice.IsPosted() )
|
||||
|
||||
def test_owner(self):
|
||||
|
83
bindings/python/time64.i
Normal file
83
bindings/python/time64.i
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* time64.i -- SWIG interface file for type translation of time64 types
|
||||
*
|
||||
* Copyright (C) 2008 ParIT Worker Co-operative <paritinfo@parit.ca>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*
|
||||
* @author Mark Jenkins, ParIT Worker Co-operative <mark@parit.ca>
|
||||
*/
|
||||
|
||||
/** @file
|
||||
@brief SWIG interface file for type translation of time64 types
|
||||
@author Mark Jenkins, ParIT Worker Co-operative <mark@parit.ca>
|
||||
@author Jeff Green, ParIT Worker Co-operative <jeff@parit.ca>
|
||||
@ingroup python_bindings */
|
||||
|
||||
// A typemap for converting python dates to time64 in functions that
|
||||
// require time64 as an argument
|
||||
%typemap(in) time64 {
|
||||
PyDateTime_IMPORT;
|
||||
struct tm time = {PyDateTime_DATE_GET_SECOND($input),
|
||||
PyDateTime_DATE_GET_MINUTE($input),
|
||||
PyDateTime_DATE_GET_HOUR($input),
|
||||
PyDateTime_GET_DAY($input),
|
||||
PyDateTime_GET_MONTH($input) - 1,
|
||||
PyDateTime_GET_YEAR($input) - 1900};
|
||||
$1 = gnc_mktime(&time);
|
||||
}
|
||||
|
||||
// A typemap for converting python dates to time64 *, for functions that
|
||||
// requires a time64 * as an argument. BIG ASSUMPTION, the function
|
||||
// receiving this pointer is going to make a copy of the data. After the
|
||||
// function call, the memory for the time64 used to perform this conversion
|
||||
// is going to be lost, so make damn sure that the recipient of this pointer
|
||||
// is NOT going dereference it sometime after this function call takes place.
|
||||
//
|
||||
// As far as I know, the xaccTransSetDate[Posted|Entered|Due]TS functions
|
||||
// from Transaction.h are the only functions with time64 * that we re
|
||||
// actually using. I have personally verified in the source that the pointer
|
||||
// being produced by this typemap is being dereferenced, and the data copied
|
||||
// in all three functions.
|
||||
//
|
||||
// The memory for the time64 used for this conversion is allocated on the
|
||||
// stack. (SWIG will name the variables ts1, ts2, ts3...)
|
||||
//
|
||||
// Mark Jenkins <mark@parit.ca>
|
||||
%typemap(in) time64 * (time64 secs) {
|
||||
PyDateTime_IMPORT;
|
||||
struct tm time = {PyDateTime_DATE_GET_SECOND($input),
|
||||
PyDateTime_DATE_GET_MINUTE($input),
|
||||
PyDateTime_DATE_GET_HOUR($input),
|
||||
PyDateTime_GET_DAY($input),
|
||||
PyDateTime_GET_MONTH($input) - 1,
|
||||
PyDateTime_GET_YEAR($input) - 1900};
|
||||
time64 secs = gnc_mktime(&time);
|
||||
$1 = &secs;
|
||||
}
|
||||
|
||||
// A typemap for converting time64 values returned from functions to
|
||||
// python dates. Note that we can't use Python DateTime's fromtimestamp function because it relies upon libc's localtime. Note also that while we create times with timegm we retrieve it with localtime
|
||||
%typemap(out) time64 {
|
||||
PyDateTime_IMPORT;
|
||||
struct tm t;
|
||||
gnc_localtime_r(&$1, &t);
|
||||
$result = PyDateTime_FromDateAndTime(t.tm_year + 1900, t.tm_mon + 1,
|
||||
t.tm_mday, t.tm_hour, t.tm_min,
|
||||
t.tm_sec, 0);
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* timespec.i -- SWIG interface file for type translation of Timespec types
|
||||
*
|
||||
* Copyright (C) 2008 ParIT Worker Co-operative <paritinfo@parit.ca>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*
|
||||
* @author Mark Jenkins, ParIT Worker Co-operative <mark@parit.ca>
|
||||
*/
|
||||
|
||||
/** @file
|
||||
@brief SWIG interface file for type translation of Timespec types
|
||||
@author Mark Jenkins, ParIT Worker Co-operative <mark@parit.ca>
|
||||
@author Jeff Green, ParIT Worker Co-operative <jeff@parit.ca>
|
||||
@ingroup python_bindings */
|
||||
|
||||
// A typemap for converting python dates to Timespec in functions that
|
||||
// require Timespec as an argument
|
||||
%typemap(in) Timespec {
|
||||
PyDateTime_IMPORT;
|
||||
$1 = gnc_dmy2timespec(PyDateTime_GET_DAY($input),
|
||||
PyDateTime_GET_MONTH($input),
|
||||
PyDateTime_GET_YEAR($input) );
|
||||
}
|
||||
|
||||
// A typemap for converting python dates to Timespec *, for functions that
|
||||
// requires a Timespec * as an argument. BIG ASSUMPTION, the function
|
||||
// receiving this pointer is going to make a copy of the data. After the
|
||||
// function call, the memory for the Timespec used to perform this conversion
|
||||
// is going to be lost, so make damn sure that the recipient of this pointer
|
||||
// is NOT going dereference it sometime after this function call takes place.
|
||||
//
|
||||
// As far as I know, the xaccTransSetDate[Posted|Entered|Due]TS functions
|
||||
// from Transaction.h are the only functions with Timespec * that we re
|
||||
// actually using. I have personally verified in the source that the pointer
|
||||
// being produced by this typemap is being dereferenced, and the data copied
|
||||
// in all three functions.
|
||||
//
|
||||
// The memory for the Timespec used for this conversion is allocated on the
|
||||
// stack. (SWIG will name the variables ts1, ts2, ts3...)
|
||||
//
|
||||
// Mark Jenkins <mark@parit.ca>
|
||||
%typemap(in) Timespec * (Timespec ts) {
|
||||
PyDateTime_IMPORT;
|
||||
ts = gnc_dmy2timespec(PyDateTime_GET_DAY($input),
|
||||
PyDateTime_GET_MONTH($input),
|
||||
PyDateTime_GET_YEAR($input) );
|
||||
$1 = &ts;
|
||||
}
|
||||
|
||||
// A typemap for converting Timespec values returned from functions to
|
||||
// python dates.
|
||||
%typemap(out) Timespec {
|
||||
int year, month, day;
|
||||
gnc_timespec2dmy($1, &day, &month, &year);
|
||||
PyDateTime_IMPORT;
|
||||
$result = PyDate_FromDate(year, month, day);
|
||||
}
|
@ -50,10 +50,7 @@ typedef char gchar;
|
||||
%typemap(in) gboolean "$1 = scm_is_true($input) ? TRUE : FALSE;"
|
||||
%typemap(out) gboolean "$result = $1 ? SCM_BOOL_T : SCM_BOOL_F;"
|
||||
|
||||
%typemap(in) Timespec "$1 = gnc_timepair2timespec($input);"
|
||||
%typemap(out) Timespec "$result = gnc_timespec2timepair($1);"
|
||||
|
||||
%typemap(in) GDate "$1 = gnc_timepair_to_GDate($input);"
|
||||
%typemap(in) GDate "$1 = gnc_time64_to_GDate($input);"
|
||||
|
||||
%typemap(in) GncGUID "$1 = gnc_scm2guid($input);"
|
||||
%typemap(out) GncGUID "$result = gnc_guid2scm($1);"
|
||||
|
@ -3249,13 +3249,13 @@ gnc_option_set_ui_value_date (GNCOption *option, gboolean use_default,
|
||||
}
|
||||
else if (g_strcmp0(symbol_str, "absolute") == 0)
|
||||
{
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
|
||||
ts = gnc_date_option_value_get_absolute (value);
|
||||
time = gnc_date_option_value_get_absolute (value);
|
||||
|
||||
if (g_strcmp0(date_option_type, "absolute") == 0)
|
||||
{
|
||||
gnc_date_edit_set_time(GNC_DATE_EDIT(widget), ts.tv_sec);
|
||||
gnc_date_edit_set_time(GNC_DATE_EDIT(widget), time);
|
||||
}
|
||||
else if (g_strcmp0(date_option_type, "both") == 0)
|
||||
{
|
||||
@ -3267,7 +3267,7 @@ gnc_option_set_ui_value_date (GNCOption *option, gboolean use_default,
|
||||
GNC_RD_WID_AB_WIDGET_POS);
|
||||
g_list_free(widget_list);
|
||||
gnc_date_option_set_select_method(option, TRUE, TRUE);
|
||||
gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), ts.tv_sec);
|
||||
gnc_date_edit_set_time(GNC_DATE_EDIT(ab_widget), time);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3791,16 +3791,13 @@ gnc_option_get_ui_value_date (GNCOption *option, GtkWidget *widget)
|
||||
}
|
||||
else if (g_strcmp0(subtype, "absolute") == 0)
|
||||
{
|
||||
Timespec ts;
|
||||
|
||||
ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
|
||||
ts.tv_nsec = 0;
|
||||
|
||||
result = scm_cons(scm_from_locale_symbol ("absolute"), gnc_timespec2timepair(ts));
|
||||
time64 time;
|
||||
time = gnc_date_edit_get_date(GNC_DATE_EDIT(widget));
|
||||
result = scm_cons(scm_from_locale_symbol ("absolute"), scm_from_int64(time));
|
||||
}
|
||||
else if (g_strcmp0(subtype, "both") == 0)
|
||||
{
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
int index;
|
||||
SCM val;
|
||||
GList *widget_list;
|
||||
@ -3815,9 +3812,8 @@ gnc_option_get_ui_value_date (GNCOption *option, GtkWidget *widget)
|
||||
/* if it's an absolute date */
|
||||
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ab_button)))
|
||||
{
|
||||
ts.tv_sec = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
|
||||
ts.tv_nsec = 0;
|
||||
result = scm_cons(scm_from_locale_symbol ("absolute"), gnc_timespec2timepair(ts));
|
||||
time = gnc_date_edit_get_date(GNC_DATE_EDIT(ab_widget));
|
||||
result = scm_cons(scm_from_locale_symbol ("absolute"), scm_from_int64 (time));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1504,7 +1504,7 @@ create_transaction(XferDialog *xferData, Timespec *ts,
|
||||
xaccTransBeginEdit(trans);
|
||||
|
||||
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
|
||||
* 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
|
||||
* "standard ordering" is tied to the date anyway. */
|
||||
{
|
||||
Timespec t1, t2;
|
||||
time64 time1, time2;
|
||||
GDate d1 = xaccTransGetDatePostedGDate(current_trans),
|
||||
d2 = xaccTransGetDatePostedGDate(target_trans);
|
||||
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
|
||||
reason: Some code used the timespec at noon for the EntryDate, other
|
||||
code used the timespec at the start of day. */
|
||||
t1 = xaccTransRetDatePostedTS(current_trans);
|
||||
t2 = xaccTransRetDatePostedTS(target_trans);
|
||||
if (really_do_it && !timespec_equal(&t1, &t2))
|
||||
time1 = xaccTransRetDatePosted(current_trans);
|
||||
time2 = xaccTransRetDatePosted(target_trans);
|
||||
if (really_do_it && time1 != time2)
|
||||
{
|
||||
/* Timespecs are not equal, even though the GDates were equal? Then
|
||||
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
|
||||
* sufficient! */
|
||||
{
|
||||
Timespec time_current = xaccTransRetDateEnteredTS(current_trans);
|
||||
Timespec time_target = xaccTransRetDateEnteredTS(target_trans);
|
||||
time64 time_current = xaccTransRetDateEntered(current_trans);
|
||||
time64 time_target = xaccTransRetDateEntered(target_trans);
|
||||
|
||||
/* Special treatment for identical times (potentially caused
|
||||
* by the "duplicate entry" command) */
|
||||
if (timespec_equal(&time_current, &time_target))
|
||||
if (time_current == time_target)
|
||||
{
|
||||
g_warning("Surprise - both DateEntered are equal.");
|
||||
/* 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
|
||||
* whatever. */
|
||||
if (move_up)
|
||||
time_current.tv_sec++;
|
||||
++time_current;
|
||||
else
|
||||
time_target.tv_sec++;
|
||||
++time_target;
|
||||
}
|
||||
|
||||
/* Write the new DateEntered. */
|
||||
xaccTransSetDateEnteredTS(current_trans, &time_target);
|
||||
xaccTransSetDateEnteredTS(target_trans, &time_current);
|
||||
xaccTransSetDateEnteredSecs(current_trans, time_target);
|
||||
xaccTransSetDateEnteredSecs(target_trans, time_current);
|
||||
|
||||
/* 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;
|
||||
const gchar *date_text;
|
||||
const gchar *desc_text;
|
||||
Timespec ts = {0,0};
|
||||
GList *node;
|
||||
|
||||
priv = model->priv;
|
||||
@ -849,7 +848,7 @@ gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position
|
||||
return g_strconcat ("Blank Transaction", NULL);
|
||||
else
|
||||
{
|
||||
xaccTransGetDatePostedTS (trans, &ts);
|
||||
Timespec ts = {xaccTransRetDatePosted (trans), 0};
|
||||
date_text = gnc_print_date (ts);
|
||||
desc_text = xaccTransGetDescription (trans);
|
||||
model->current_trans = trans;
|
||||
|
@ -192,7 +192,7 @@ gtu_sr_handle_exchange_rate (GncTreeViewSplitReg *view, gnc_numeric amount, Tran
|
||||
|
||||
/* Get per book option */
|
||||
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;
|
||||
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;
|
||||
|
||||
if (is_trow1) {
|
||||
Timespec ts = {0,0};
|
||||
xaccTransGetDatePostedTS (trans, &ts);
|
||||
Timespec ts = {xaccTransRetDatePosted (trans),0};
|
||||
//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
|
||||
//date on new transactions
|
||||
if (ts.tv_sec == 0)
|
||||
{
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
//xaccTransSetDatePostedSecs (trans, ts.tv_sec);
|
||||
}//if
|
||||
s = gnc_print_date (ts);
|
||||
editable = TRUE;
|
||||
}
|
||||
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);
|
||||
|
||||
xaccTransGetDateEnteredTS (trans, &ts);
|
||||
//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
|
||||
//date on new transactions
|
||||
if (ts.tv_sec == 0)
|
||||
{
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
//xaccTransSetDateEnteredSecs (trans, ts.tv_sec);
|
||||
}//if
|
||||
s = gnc_print_date (ts);
|
||||
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);
|
||||
|
||||
if (is_trow1) {
|
||||
Timespec ts = {0,0};
|
||||
|
||||
/* Only print the due date for invoice transactions */
|
||||
if (type == TXN_TYPE_INVOICE)
|
||||
{
|
||||
xaccTransGetDateDueTS (trans, &ts);
|
||||
Timespec ts = {xaccTransRetDateDue (trans), 0};
|
||||
s = gnc_print_date (ts);
|
||||
editable = FALSE;
|
||||
}
|
||||
@ -2518,21 +2506,18 @@ gtv_sr_begin_edit (GncTreeViewSplitReg *view, Transaction *trans)
|
||||
|
||||
if (trans != view->priv->dirty_trans)
|
||||
{
|
||||
Timespec ts = {0,0};
|
||||
xaccTransGetDatePostedTS (trans, &ts);
|
||||
|
||||
time64 time = xaccTransRetDatePosted (trans);
|
||||
if (!xaccTransIsOpen (trans))
|
||||
xaccTransBeginEdit (trans);
|
||||
view->priv->dirty_trans = trans;
|
||||
|
||||
if (ts.tv_sec == 0)
|
||||
if (!time)
|
||||
{
|
||||
//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
|
||||
//date on new transactions
|
||||
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
xaccTransSetDatePostedSecs (trans, ts.tv_sec);
|
||||
time = gnc_time (NULL);
|
||||
xaccTransSetDatePostedSecs (trans, time);
|
||||
}
|
||||
}
|
||||
LEAVE(" ");
|
||||
|
@ -92,7 +92,7 @@ gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
|
||||
if (ddc->date)
|
||||
{
|
||||
if (ddc->terms)
|
||||
*(ddc->ts) = gncBillTermComputeDueDate (ddc->terms, *(ddc->ts2));
|
||||
ddc->ts->tv_sec = gncBillTermComputeDueDate (ddc->terms, ddc->ts2->tv_sec);
|
||||
else
|
||||
*(ddc->ts) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->date));
|
||||
}
|
||||
@ -185,10 +185,10 @@ post_date_changed_cb (GNCDateEdit *gde, gpointer d)
|
||||
{
|
||||
DialogDateClose *ddc = d;
|
||||
Timespec post_date;
|
||||
Timespec due_date;
|
||||
Timespec due_date = {0,0};
|
||||
|
||||
post_date = gnc_date_edit_get_date_ts (gde);
|
||||
due_date = gncBillTermComputeDueDate (ddc->terms, post_date);
|
||||
due_date.tv_sec = gncBillTermComputeDueDate (ddc->terms, post_date.tv_sec);
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), due_date);
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
|
||||
GtkTextBuffer* text_buffer;
|
||||
GtkTextIter start, end;
|
||||
gchar *text;
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
gboolean is_credit_note = gncInvoiceGetIsCreditNote (invoice);
|
||||
|
||||
if (iw->dialog_type == VIEW_INVOICE)
|
||||
@ -341,8 +341,8 @@ static void gnc_ui_to_invoice (InvoiceWindow *iw, GncInvoice *invoice)
|
||||
(GTK_EDITABLE (iw->billing_id_entry), 0, -1));
|
||||
gncInvoiceSetTerms (invoice, iw->terms);
|
||||
|
||||
ts = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (iw->opened_date));
|
||||
gncInvoiceSetDateOpened (invoice, ts);
|
||||
time = gnc_date_edit_get_date (GNC_DATE_EDIT (iw->opened_date));
|
||||
gncInvoiceSetDateOpened (invoice, time);
|
||||
|
||||
gnc_owner_get_owner (iw->owner_choice, &(iw->owner));
|
||||
if (iw->job_choice)
|
||||
@ -724,14 +724,12 @@ gnc_dialog_post_invoice(InvoiceWindow *iw, char *message,
|
||||
if (entries && ((gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR) ||
|
||||
(gncInvoiceGetOwnerType (invoice) == GNC_OWNER_EMPLOYEE)))
|
||||
{
|
||||
*postdate = gncEntryGetDate ((GncEntry*)entries->data);
|
||||
postdate->tv_sec = gncEntryGetDate ((GncEntry*)entries->data);
|
||||
for (entries_iter = entries; entries_iter != NULL; entries_iter = g_list_next(entries_iter))
|
||||
{
|
||||
Timespec entrydate;
|
||||
|
||||
entrydate = gncEntryGetDate ((GncEntry*)entries_iter->data);
|
||||
if (timespec_cmp(&entrydate, postdate) > 0)
|
||||
*postdate = entrydate;
|
||||
time64 entrydate = gncEntryGetDate ((GncEntry*)entries_iter->data);
|
||||
if (entrydate > postdate->tv_sec)
|
||||
postdate->tv_sec = entrydate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -950,7 +948,7 @@ gnc_invoice_post(InvoiceWindow *iw, struct post_invoice_params *post_params)
|
||||
else
|
||||
auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY);
|
||||
|
||||
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, accumulate, auto_pay);
|
||||
gncInvoicePostToAccount (invoice, acc, postdate.tv_sec, ddue.tv_sec, memo, accumulate, auto_pay);
|
||||
|
||||
cleanup:
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
@ -1749,8 +1747,8 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
|
||||
GtkTextBuffer* text_buffer;
|
||||
const char *string;
|
||||
gchar * tmp_string;
|
||||
Timespec ts, ts_zero = {0, 0};
|
||||
Account *acct;
|
||||
time64 time;
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (iw->id_entry), gncInvoiceGetID (invoice));
|
||||
|
||||
@ -1765,15 +1763,15 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (iw->active_check),
|
||||
gncInvoiceGetActive (invoice));
|
||||
|
||||
ts = gncInvoiceGetDateOpened (invoice);
|
||||
if (timespec_equal (&ts, &ts_zero))
|
||||
time = gncInvoiceGetDateOpened (invoice);
|
||||
if (!time)
|
||||
{
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date),
|
||||
gnc_time (NULL));
|
||||
}
|
||||
else
|
||||
{
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->opened_date), ts);
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT (iw->opened_date), time);
|
||||
}
|
||||
|
||||
/* fill in the terms text */
|
||||
@ -1818,8 +1816,8 @@ gnc_invoice_update_window (InvoiceWindow *iw, GtkWidget *widget)
|
||||
*/
|
||||
can_unpost = TRUE;
|
||||
|
||||
ts = gncInvoiceGetDatePosted (invoice);
|
||||
gnc_date_edit_set_time_ts (GNC_DATE_EDIT (iw->posted_date), ts);
|
||||
time = gncInvoiceGetDatePosted (invoice);
|
||||
gnc_date_edit_set_time (GNC_DATE_EDIT (iw->posted_date), time);
|
||||
|
||||
tmp_string = gnc_account_get_full_name (acct);
|
||||
gtk_entry_set_text (GTK_ENTRY (acct_entry), tmp_string);
|
||||
|
@ -485,7 +485,6 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
|
||||
const gchar *doc_deb_str = NULL;
|
||||
const gchar *doc_cred_str = NULL;
|
||||
GtkTreeIter iter;
|
||||
Timespec doc_date;
|
||||
GncInvoice *document;
|
||||
gnc_numeric value = gnc_numeric_zero();
|
||||
gnc_numeric debit = gnc_numeric_zero();
|
||||
@ -497,17 +496,16 @@ gnc_payment_window_fill_docs_list (PaymentWindow *pw)
|
||||
|
||||
/* Find the document's date or pre-payment date */
|
||||
if (document)
|
||||
doc_date = gncInvoiceGetDatePosted (document);
|
||||
doc_date_time = gncInvoiceGetDatePosted (document);
|
||||
else
|
||||
{
|
||||
/* Calculate the payment date based on the lot splits */
|
||||
Transaction *trans = xaccSplitGetParent (gnc_lot_get_latest_split (lot));
|
||||
if (trans)
|
||||
doc_date = xaccTransRetDatePostedTS (trans);
|
||||
doc_date_time = xaccTransRetDatePosted (trans);
|
||||
else
|
||||
continue; /* No valid split in this lot, skip it */
|
||||
}
|
||||
doc_date_time = timespecToTime64 (doc_date);
|
||||
|
||||
/* Find the document type. No type means pre-payment in this case */
|
||||
if (document)
|
||||
|
@ -344,8 +344,7 @@ get_trans_info (AssocDialog *assoc_dialog)
|
||||
{
|
||||
gchar *uri_u;
|
||||
gboolean rel = FALSE;
|
||||
Timespec ts = {0,0};
|
||||
xaccTransGetDatePostedTS (trans, &ts);
|
||||
Timespec ts = {xaccTransRetDatePosted (trans),0};
|
||||
|
||||
if (ts.tv_sec == 0)
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
|
@ -957,18 +957,17 @@ static void
|
||||
gnc_plugin_business_cmd_test_init_data (GtkAction *action,
|
||||
GncMainWindowActionData *data)
|
||||
{
|
||||
QofBook *book = gnc_get_current_book();
|
||||
QofBook *book = gnc_get_current_book();
|
||||
GncCustomer *customer = gncCustomerCreate(book);
|
||||
GncAddress *address = gncCustomerGetAddr(customer);
|
||||
GncInvoice *invoice = gncInvoiceCreate(book);
|
||||
GncOwner *owner = gncOwnerNew();
|
||||
GncJob *job = gncJobCreate(book);
|
||||
Account *root = gnc_book_get_root_account(book);
|
||||
Account *inc_acct = xaccMallocAccount(book);
|
||||
Account *bank_acct = xaccMallocAccount(book);
|
||||
Account *tax_acct = xaccMallocAccount(book);
|
||||
Account *ar_acct = xaccMallocAccount(book);
|
||||
Timespec now;
|
||||
GncAddress *address = gncCustomerGetAddr(customer);
|
||||
GncInvoice *invoice = gncInvoiceCreate(book);
|
||||
GncOwner *owner = gncOwnerNew();
|
||||
GncJob *job = gncJobCreate(book);
|
||||
Account *root = gnc_book_get_root_account(book);
|
||||
Account *inc_acct = xaccMallocAccount(book);
|
||||
Account *bank_acct = xaccMallocAccount(book);
|
||||
Account *tax_acct = xaccMallocAccount(book);
|
||||
Account *ar_acct = xaccMallocAccount(book);
|
||||
|
||||
// Create Customer
|
||||
gncCustomerSetID(customer, "000001");
|
||||
@ -983,10 +982,9 @@ gnc_plugin_business_cmd_test_init_data (GtkAction *action,
|
||||
gncOwnerInitCustomer(owner, customer);
|
||||
|
||||
// Create the Invoice
|
||||
timespecFromTime64(&now, time(NULL));
|
||||
gncInvoiceSetID(invoice, "000012");
|
||||
gncInvoiceSetOwner(invoice, owner);
|
||||
gncInvoiceSetDateOpened(invoice, now);
|
||||
gncInvoiceSetDateOpened(invoice, gnc_time (NULL));
|
||||
gncInvoiceSetCurrency(invoice, gnc_default_currency());
|
||||
|
||||
// Create the Job
|
||||
|
@ -524,7 +524,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
|
||||
Account *acc = NULL;
|
||||
enum update {YES = GTK_RESPONSE_YES, NO = GTK_RESPONSE_NO} update;
|
||||
GtkWidget *dialog;
|
||||
Timespec today;
|
||||
time64 today;
|
||||
InvoiceWindow *iw;
|
||||
gchar *new_id = NULL;
|
||||
gint64 denom = 0;
|
||||
@ -612,14 +612,12 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
|
||||
// FIXME: Must check for the return value of qof_scan_date!
|
||||
qof_scan_date (date_opened, &day, &month, &year);
|
||||
gncInvoiceSetDateOpened (invoice,
|
||||
gnc_dmy2timespec (day, month, year));
|
||||
gnc_dmy2time64 (day, month, year));
|
||||
}
|
||||
else // If no date in CSV
|
||||
{
|
||||
time64 now = gnc_time (NULL);
|
||||
Timespec now_timespec;
|
||||
timespecFromTime64 (&now_timespec, now);
|
||||
gncInvoiceSetDateOpened (invoice, now_timespec);
|
||||
gncInvoiceSetDateOpened (invoice, now);
|
||||
}
|
||||
gncInvoiceSetBillingID (invoice, billing_id ? billing_id : "");
|
||||
notes = un_escape(notes);
|
||||
@ -697,17 +695,17 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
|
||||
gncEntrySetDateGDate (entry, date);
|
||||
g_date_free (date);
|
||||
}
|
||||
timespecFromTime64 (&today, gnc_time (NULL)); // set today to the current date
|
||||
today = gnc_time (NULL); // set today to the current date
|
||||
if (strlen (date) != 0) // If a date is specified in CSV
|
||||
{
|
||||
GDate *date = g_date_new_dmy(day, month, year);
|
||||
gncEntrySetDateGDate(entry, date);
|
||||
gncEntrySetDateEntered(entry, gnc_dmy2timespec (day, month, year));
|
||||
gncEntrySetDateEntered(entry, gnc_dmy2time64 (day, month, year));
|
||||
}
|
||||
else
|
||||
{
|
||||
GDate *date = gnc_g_date_new_today();
|
||||
gncEntrySetDateGDate(entry, date); // TODO: DEPRECATED - use gncEntrySetDateGDate() instead!
|
||||
gncEntrySetDateGDate(entry, date);
|
||||
gncEntrySetDateEntered(entry, today);
|
||||
}
|
||||
// Remove escaped quotes
|
||||
@ -772,7 +770,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
|
||||
// autopost this invoice
|
||||
GHashTable *foreign_currs;
|
||||
gboolean auto_pay;
|
||||
Timespec p_date, d_date;
|
||||
time64 p_date, d_date;
|
||||
guint curr_count;
|
||||
gboolean scan_date_r;
|
||||
scan_date_r = qof_scan_date (date_posted, &day, &month, &year);
|
||||
@ -789,11 +787,11 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
|
||||
// Only auto-post if there's a single currency involved
|
||||
if(curr_count == 0)
|
||||
{
|
||||
p_date = gnc_dmy2timespec (day, month, year);
|
||||
p_date = gnc_dmy2time64 (day, month, year);
|
||||
// Check for the return value of qof_scan_date
|
||||
if(qof_scan_date (due_date, &day, &month, &year)) // obtains the due date, or leaves it at date_posted
|
||||
{
|
||||
d_date = gnc_dmy2timespec (day, month, year);
|
||||
d_date = gnc_dmy2time64 (day, month, year);
|
||||
}
|
||||
else
|
||||
d_date = p_date;
|
||||
@ -804,7 +802,7 @@ gnc_bi_import_create_bis (GtkListStore * store, QofBook * book,
|
||||
// Check if the currencies match
|
||||
if(gncInvoiceGetCurrency(invoice) == gnc_account_get_currency_or_parent(acc))
|
||||
{
|
||||
gncInvoicePostToAccount (invoice, acc, &p_date, &d_date,
|
||||
gncInvoicePostToAccount (invoice, acc, p_date, d_date,
|
||||
memo_posted,
|
||||
text2bool (accumulatesplits),
|
||||
auto_pay);
|
||||
|
@ -552,10 +552,10 @@ static void trans_add_split (Transaction* trans, Account* account, GncNumeric am
|
||||
value = amount * *price;
|
||||
else
|
||||
{
|
||||
auto tts = xaccTransRetDatePostedTS (trans);
|
||||
Timespec ts = {xaccTransRetDatePosted (trans), 0};
|
||||
/* 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),
|
||||
acct_comm, trans_curr, tts);
|
||||
acct_comm, trans_curr, ts);
|
||||
if (nprice)
|
||||
{
|
||||
/* Found a usable price. Let's check if the conversion direction is right */
|
||||
|
@ -181,17 +181,20 @@ static split_record interpret_split_record( char *record_line)
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
{
|
||||
record.log_date = gnc_iso8601_to_timespec_gmt(tok_ptr);
|
||||
time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
|
||||
record.log_date.tv_sec = secs;
|
||||
record.log_date_present = TRUE;
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
{
|
||||
record.date_entered = gnc_iso8601_to_timespec_gmt(tok_ptr);
|
||||
time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
|
||||
record.date_entered.tv_sec = secs;
|
||||
record.date_entered_present = TRUE;
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
{
|
||||
record.date_posted = gnc_iso8601_to_timespec_gmt(tok_ptr);
|
||||
time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
|
||||
record.date_posted.tv_sec = secs;
|
||||
record.date_posted_present = TRUE;
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
@ -246,7 +249,8 @@ static split_record interpret_split_record( char *record_line)
|
||||
}
|
||||
if (strlen(tok_ptr = my_strtok(NULL, "\t")) != 0)
|
||||
{
|
||||
record.date_reconciled = gnc_iso8601_to_timespec_gmt(tok_ptr);
|
||||
time64 secs = gnc_iso8601_to_time64_gmt(tok_ptr);
|
||||
record.date_reconciled.tv_sec = secs;
|
||||
record.date_reconciled_present = TRUE;
|
||||
}
|
||||
|
||||
@ -446,11 +450,11 @@ static void process_trans_record( FILE *log_file)
|
||||
/*Fill the transaction info*/
|
||||
if (record.date_entered_present)
|
||||
{
|
||||
xaccTransSetDateEnteredTS(trans, &(record.date_entered));
|
||||
xaccTransSetDateEnteredSecs(trans, record.date_entered.tv_sec);
|
||||
}
|
||||
if (record.date_posted_present)
|
||||
{
|
||||
xaccTransSetDatePostedTS(trans, &(record.date_posted));
|
||||
xaccTransSetDatePostedSecs(trans, record.date_posted.tv_sec);
|
||||
}
|
||||
if (record.trans_num_present)
|
||||
{
|
||||
|
@ -1131,6 +1131,7 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
|
||||
|
||||
while (!scm_is_null(possible_matches))
|
||||
{
|
||||
Timespec ts_send = {0,0};
|
||||
current_xtn = SCM_CAR(possible_matches);
|
||||
#define FUNC_NAME "xaccTransCountSplits"
|
||||
gnc_xtn = SWIG_MustGetPtr(SCM_CAR(current_xtn),
|
||||
@ -1152,10 +1153,11 @@ refresh_old_transactions(QIFImportWindow * wind, int selection)
|
||||
}
|
||||
|
||||
gtk_list_store_append(store, &iter);
|
||||
ts_send.tv_sec = xaccTransRetDatePosted(gnc_xtn);
|
||||
gtk_list_store_set
|
||||
(store, &iter,
|
||||
QIF_TRANS_COL_INDEX, rownum++,
|
||||
QIF_TRANS_COL_DATE, gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
|
||||
QIF_TRANS_COL_DATE, gnc_print_date(ts_send),
|
||||
QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
|
||||
QIF_TRANS_COL_AMOUNT, amount_str,
|
||||
QIF_TRANS_COL_CHECKED, selected != SCM_BOOL_F,
|
||||
@ -3122,6 +3124,7 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
|
||||
duplicates = wind->match_transactions;
|
||||
while (!scm_is_null(duplicates))
|
||||
{
|
||||
Timespec send_ts = {0,0};
|
||||
current_xtn = SCM_CAAR(duplicates);
|
||||
#define FUNC_NAME "xaccTransCountSplits"
|
||||
gnc_xtn = SWIG_MustGetPtr(current_xtn,
|
||||
@ -3138,11 +3141,12 @@ gnc_ui_qif_import_duplicates_match_prepare (GtkAssistant *assistant,
|
||||
(xaccSplitGetAccount(gnc_split), TRUE));
|
||||
}
|
||||
gtk_list_store_append(store, &iter);
|
||||
send_ts.tv_sec = xaccTransRetDatePosted(gnc_xtn);
|
||||
gtk_list_store_set
|
||||
(store, &iter,
|
||||
QIF_TRANS_COL_INDEX, rownum++,
|
||||
QIF_TRANS_COL_DATE,
|
||||
gnc_print_date(xaccTransRetDatePostedTS(gnc_xtn)),
|
||||
gnc_print_date(send_ts),
|
||||
QIF_TRANS_COL_DESCRIPTION, xaccTransGetDescription(gnc_xtn),
|
||||
QIF_TRANS_COL_AMOUNT, amount_str,
|
||||
-1);
|
||||
|
@ -127,10 +127,10 @@
|
||||
QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
|
||||
;; The date should be close to the same.. +/- a week.
|
||||
(let ((date (gnc-transaction-get-date-posted xtn)))
|
||||
(xaccQueryAddDateMatchTS query #t
|
||||
(decdate date WeekDelta) #t
|
||||
(incdate date WeekDelta)
|
||||
(let ((date (xaccTransGetDate xtn)))
|
||||
(xaccQueryAddDateMatchTT query
|
||||
#t (decdate date WeekDelta)
|
||||
#t (incdate date WeekDelta)
|
||||
QOF-QUERY-AND))
|
||||
|
||||
;; For each split in the new transaction, add a
|
||||
|
@ -566,7 +566,7 @@ void gnc_entry_ledger_set_default_invoice (GncEntryLedger *ledger,
|
||||
* to understand why.
|
||||
*/
|
||||
if (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_VENDOR)
|
||||
ledger->last_date_entered = timespec_to_gdate(gncInvoiceGetDateOpened (invoice));
|
||||
ledger->last_date_entered = time64_to_gdate(gncInvoiceGetDateOpened (invoice));
|
||||
|
||||
if (!ledger->query && invoice)
|
||||
create_invoice_query (ledger);
|
||||
@ -944,7 +944,7 @@ gnc_entry_ledger_duplicate_current_entry (GncEntryLedger *ledger)
|
||||
|
||||
/* We also must set a new DateEntered on the new entry
|
||||
* because otherwise the ordering is not deterministic */
|
||||
gncEntrySetDateEntered (new_entry, timespec_now());
|
||||
gncEntrySetDateEntered (new_entry, gnc_time (NULL));
|
||||
|
||||
/* Set the hint for where to display on the refresh */
|
||||
ledger->hint_entry = new_entry;
|
||||
@ -1017,7 +1017,7 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
|
||||
* up the current sort ordering from here, so I cowardly refuse to
|
||||
* tweak the EntryDate in this case. */
|
||||
{
|
||||
Timespec t1, t2;
|
||||
time64 t1, t2;
|
||||
GDate d1 = gncEntryGetDateGDate(current),
|
||||
d2 = gncEntryGetDateGDate(target);
|
||||
if (g_date_compare(&d1, &d2) != 0)
|
||||
@ -1029,7 +1029,7 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
|
||||
code used the timespec at the start of day. */
|
||||
t1 = gncEntryGetDate(current);
|
||||
t2 = gncEntryGetDate(target);
|
||||
if (!timespec_equal(&t1, &t2))
|
||||
if (t1 != t2)
|
||||
{
|
||||
/* Timespecs are not equal, even though the GDates were equal? Then
|
||||
we set the GDates again. This will force the timespecs to be equal
|
||||
@ -1048,12 +1048,12 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
|
||||
/* Swap the date-entered of both entries. That's already
|
||||
* sufficient! */
|
||||
{
|
||||
Timespec time_current = gncEntryGetDateEntered(current);
|
||||
Timespec time_target = gncEntryGetDateEntered(target);
|
||||
time64 time_current = gncEntryGetDateEntered(current);
|
||||
time64 time_target = gncEntryGetDateEntered(target);
|
||||
|
||||
/* Special treatment for identical times (potentially caused
|
||||
* by the "duplicate entry" command) */
|
||||
if (timespec_equal(&time_current, &time_target))
|
||||
if (time_current == time_target)
|
||||
{
|
||||
/*g_warning("Surprise - both DateEntered are equal.");*/
|
||||
/* We just increment the DateEntered of the previously
|
||||
@ -1061,9 +1061,9 @@ void gnc_entry_ledger_move_current_entry_updown (GncEntryLedger *ledger,
|
||||
* issues if multiple entries had this problem, but
|
||||
* whatever. */
|
||||
if (move_up)
|
||||
time_current.tv_sec++;
|
||||
++time_current;
|
||||
else
|
||||
time_target.tv_sec++;
|
||||
++time_target;
|
||||
}
|
||||
|
||||
/* Write the new DateEntered. */
|
||||
|
@ -90,10 +90,8 @@ gnc_entry_ledger_save (GncEntryLedger *ledger, gboolean do_commit)
|
||||
|
||||
if (entry == blank_entry)
|
||||
{
|
||||
Timespec ts;
|
||||
ts.tv_sec = gnc_time (NULL);
|
||||
ts.tv_nsec = 0;
|
||||
gncEntrySetDateEntered (blank_entry, ts);
|
||||
time64 time = gnc_time (NULL);
|
||||
gncEntrySetDateEntered (blank_entry, time);
|
||||
|
||||
switch (ledger->type)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
* gncEntryLedgerModel.c -- Model for GncEntry ledger
|
||||
* Copyright (C) 2001, 2002, 2003 Derek Atkins
|
||||
* Author: Derek Atkins <warlord@MIT.EDU>
|
||||
* Copyright (C) 2017 Aaron Laws
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
@ -186,11 +187,11 @@ static const char * get_date_entry (VirtualLocation virt_loc,
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
GncEntry *entry;
|
||||
Timespec ts;
|
||||
Timespec ts = {0,0};
|
||||
|
||||
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
|
||||
|
||||
ts = gncEntryGetDate (entry);
|
||||
ts.tv_sec = gncEntryGetDate (entry);
|
||||
return gnc_print_date (ts);
|
||||
}
|
||||
|
||||
@ -569,7 +570,6 @@ static char * get_date_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
BasicCell *cell;
|
||||
char string[1024];
|
||||
struct tm tm;
|
||||
Timespec ts;
|
||||
time64 tt;
|
||||
|
||||
cell = gnc_table_get_cell (ledger->table, virt_loc);
|
||||
@ -579,8 +579,7 @@ static char * get_date_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
if (!cell->value || *cell->value == '\0')
|
||||
return NULL;
|
||||
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &ts);
|
||||
tt = ts.tv_sec;
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &tt);
|
||||
gnc_localtime_r (&tt, &tm);
|
||||
qof_strftime (string, sizeof(string), _("%A %d %B %Y"), &tm);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
/********************************************************************\
|
||||
* split-register-control.c -- split register control object *
|
||||
* Copyright (C) 2017 Aaron Laws *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -1285,9 +1286,9 @@ gnc_split_register_xfer_dialog(SplitRegister *reg, Transaction *txn,
|
||||
cell = gnc_cellblock_get_cell_by_name(cur, DATE_CELL, NULL, NULL);
|
||||
if (cell)
|
||||
{
|
||||
Timespec ts;
|
||||
gnc_date_cell_get_date((DateCell*) cell, &ts);
|
||||
gnc_xfer_dialog_set_date(xfer, timespecToTime64(ts));
|
||||
time64 time;
|
||||
gnc_date_cell_get_date((DateCell*) cell, &time);
|
||||
gnc_xfer_dialog_set_date(xfer, time);
|
||||
}
|
||||
else
|
||||
gnc_xfer_dialog_set_date(xfer, xaccTransGetDate(txn));
|
||||
|
@ -1,5 +1,6 @@
|
||||
/********************************************************************\
|
||||
* split-register-model-save.c -- split register model object *
|
||||
* Copyright (C) 2017 Aaron Laws *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -96,20 +97,14 @@ gnc_split_register_save_due_date_cell (BasicCell * cell,
|
||||
{
|
||||
SRSaveData *sd = save_data;
|
||||
const char *value;
|
||||
Timespec ts;
|
||||
|
||||
time64 time;
|
||||
g_return_if_fail (gnc_basic_cell_has_name (cell, DDUE_CELL));
|
||||
|
||||
value = gnc_basic_cell_get_value (cell);
|
||||
|
||||
/* commit any pending changes */
|
||||
gnc_date_cell_commit ((DateCell *) cell);
|
||||
|
||||
DEBUG ("DATE: %s", value ? value : "(null)");
|
||||
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &ts);
|
||||
|
||||
xaccTransSetDateDueTS (sd->trans, &ts);
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &time);
|
||||
xaccTransSetDateDue (sd->trans, time);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -830,7 +830,7 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
|
||||
SplitRegister *reg = user_data;
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
Timespec ts;
|
||||
Timespec ts = {0, 0};
|
||||
gboolean is_current;
|
||||
char type;
|
||||
|
||||
@ -867,7 +867,7 @@ gnc_split_register_get_due_date_entry (VirtualLocation virt_loc,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xaccTransGetDateDueTS (trans, &ts);
|
||||
ts.tv_sec = xaccTransRetDateDue (trans);
|
||||
//PWARN ("returning valid due_date entry");
|
||||
|
||||
return gnc_print_date (ts);
|
||||
@ -882,14 +882,14 @@ gnc_split_register_get_date_entry (VirtualLocation virt_loc,
|
||||
SplitRegister *reg = user_data;
|
||||
Transaction *trans;
|
||||
Split *split;
|
||||
Timespec ts;
|
||||
Timespec ts = {0, 0};
|
||||
|
||||
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
|
||||
trans = xaccSplitGetParent (split);
|
||||
if (!trans)
|
||||
return NULL;
|
||||
|
||||
xaccTransGetDatePostedTS (trans, &ts);
|
||||
ts.tv_sec = xaccTransRetDatePosted (trans);
|
||||
|
||||
return gnc_print_date (ts);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
* split-register.c
|
||||
* author Copyright (c) 1998-2000 Linas Vepstas <linas@linas.org>
|
||||
* author Copyright (c) 2000-2001 Dave Peticolas <dave@krondo.com>
|
||||
* author Copyright (c) 2017 Aaron Laws
|
||||
*/
|
||||
#include <config.h>
|
||||
|
||||
@ -1382,12 +1383,10 @@ gnc_split_register_save_to_scm (SplitRegister *reg,
|
||||
if (gnc_table_layout_get_cell_changed (reg->table->layout, DATE_CELL, TRUE))
|
||||
{
|
||||
BasicCell *cell;
|
||||
Timespec ts;
|
||||
|
||||
time64 time;
|
||||
cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &ts);
|
||||
|
||||
gnc_trans_scm_set_date(trans_scm, &ts);
|
||||
gnc_date_cell_get_date ((DateCell *) cell, &time);
|
||||
gnc_trans_scm_set_date(trans_scm, time);
|
||||
}
|
||||
|
||||
if (gnc_table_layout_get_cell_changed (reg->table->layout, NUM_CELL, TRUE))
|
||||
@ -2076,9 +2075,10 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
|
||||
GNCPrice *price;
|
||||
gnc_numeric price_value;
|
||||
int scu = gnc_commodity_get_fraction(curr);
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
BasicCell *cell = gnc_table_layout_get_cell (reg->table->layout, DATE_CELL);
|
||||
gboolean swap = FALSE;
|
||||
Timespec ts;
|
||||
|
||||
/* Only record the price for account types that don't have a
|
||||
* "rate" cell. They'll get handled later by
|
||||
@ -2086,7 +2086,9 @@ record_price (SplitRegister *reg, Account *account, gnc_numeric value,
|
||||
*/
|
||||
if (gnc_split_reg_has_rate_cell (reg->type))
|
||||
return;
|
||||
gnc_date_cell_get_date ((DateCell*)cell, &ts);
|
||||
gnc_date_cell_get_date ((DateCell*)cell, &time);
|
||||
ts.tv_sec = time;
|
||||
ts.tv_nsec = 0;
|
||||
price = gnc_pricedb_lookup_day (pricedb, comm, curr, ts);
|
||||
if (gnc_commodity_equiv (comm, gnc_price_get_currency (price)))
|
||||
swap = TRUE;
|
||||
|
@ -72,6 +72,7 @@
|
||||
* HISTORY:
|
||||
* Copyright (c) 1998, 1999, 2000 Linas Vepstas <linas@linas.org>
|
||||
* Copyright (c) 2000 Dave Peticolas
|
||||
* Copyright (c) 2017 Aaron Laws
|
||||
*/
|
||||
|
||||
#ifndef DATE_CELL_H
|
||||
@ -121,9 +122,9 @@ void gnc_date_cell_commit (DateCell *cell);
|
||||
|
||||
/** Set a Timespec to the value in the DateCell.
|
||||
* @param cell The DateCell
|
||||
* @param ts A Timespec* to which the function will write the date.
|
||||
* @param time A time64* to which the function will write the time.
|
||||
*/
|
||||
void gnc_date_cell_get_date (DateCell *cell, Timespec *ts);
|
||||
void gnc_date_cell_get_date (DateCell *cell, time64 *time);
|
||||
|
||||
/** Timespec to the value in the DateCell.
|
||||
* @param cell The DateCell
|
||||
|
@ -28,6 +28,7 @@
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 2000 Dave Peticolas <dave@krondo.com>
|
||||
* Copyright (c) 2017 Aaron Laws
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
@ -686,7 +687,7 @@ gnc_date_cell_enter (BasicCell *bcell,
|
||||
static void
|
||||
gnc_date_cell_leave (BasicCell *bcell)
|
||||
{
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
PopBox *box = bcell->gui_private;
|
||||
|
||||
date_picker_disconnect_signals ((DateCell *) bcell);
|
||||
@ -697,8 +698,8 @@ gnc_date_cell_leave (BasicCell *bcell)
|
||||
box->calendar_popped = FALSE;
|
||||
|
||||
/* Refresh the date to expand any shortcuts. */
|
||||
gnc_date_cell_get_date ((DateCell *)bcell, &ts);
|
||||
gnc_date_cell_set_value_secs ((DateCell *)bcell, ts.tv_sec);
|
||||
gnc_date_cell_get_date ((DateCell *)bcell, &time);
|
||||
gnc_date_cell_set_value_secs ((DateCell *)bcell, time);
|
||||
}
|
||||
|
||||
void
|
||||
@ -718,17 +719,13 @@ gnc_date_cell_get_date_gdate (DateCell *cell, GDate *date)
|
||||
}
|
||||
|
||||
void
|
||||
gnc_date_cell_get_date (DateCell *cell, Timespec *ts)
|
||||
gnc_date_cell_get_date (DateCell *cell, time64 *time)
|
||||
{
|
||||
PopBox *box = cell->cell.gui_private;
|
||||
|
||||
if (!cell || !ts)
|
||||
if (!cell || !time)
|
||||
return;
|
||||
|
||||
gnc_parse_date (&(box->date), cell->cell.value);
|
||||
|
||||
ts->tv_sec = gnc_mktime (&box->date);
|
||||
ts->tv_nsec = 0;
|
||||
*time = gnc_mktime (&box->date);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -112,7 +112,7 @@
|
||||
|
||||
(define (process-invoice company amount bucket-intervals date)
|
||||
(define (in-interval this-date current-bucket)
|
||||
(gnc:timepair-lt this-date current-bucket))
|
||||
(< this-date current-bucket))
|
||||
|
||||
(define (find-bucket current-bucket bucket-intervals date)
|
||||
(gnc:debug "looking for bucket for date: " date)
|
||||
@ -183,8 +183,8 @@
|
||||
;; determine date function to use
|
||||
(define (get-selected-date-from-txn transaction date-type)
|
||||
(if (eq? date-type 'postdate)
|
||||
(gnc-transaction-get-date-posted transaction)
|
||||
(xaccTransRetDateDueTS transaction)))
|
||||
(xaccTransGetDate transaction)
|
||||
(xaccTransRetDateDue transaction)))
|
||||
|
||||
;; deal with a transaction - figure out if we've seen the company before
|
||||
;; if so, either process it as a bill or a payment, if not, create
|
||||
@ -315,16 +315,14 @@ more than one currency. This report is not designed to cope with this possibilit
|
||||
;; set up the query to get the splits in the chosen account
|
||||
;; XXX: FIXME: begindate is a hack -- we currently only go back a year
|
||||
(define (setup-query query account date)
|
||||
(define (date-copy date)
|
||||
(cons (car date) (cdr date)))
|
||||
(let ((begindate (make-zdate))) ;Set begindate to the start of the Epoch
|
||||
(let ((begindate (gnc-mktime (make-zdate)))) ;Set begindate to the start of the Epoch
|
||||
; (gnc:debug "Account: " account)
|
||||
(gnc:debug "begindate" begindate)
|
||||
(gnc:debug "date" date)
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
(gnc:query-set-match-non-voids-only! query (gnc-get-current-book))
|
||||
(xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS query #t begindate #t date QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT query #t begindate #t date QOF-QUERY-AND)
|
||||
(qof-query-set-sort-order query
|
||||
(list SPLIT-TRANS TRANS-DATE-POSTED)
|
||||
'() '())
|
||||
@ -657,7 +655,7 @@ copying this report to a spreadsheet for use in a mail merge.")
|
||||
(let* ((companys (make-hash-table 23))
|
||||
(report-title (op-value gnc:pagename-general gnc:optname-reportname))
|
||||
;; document will be the HTML document that we return.
|
||||
(report-date (gnc:timepair-end-day-time
|
||||
(report-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(op-value gnc:pagename-general optname-to-date))))
|
||||
(interval-vec (list->vector (make-extended-interval-list report-date)))
|
||||
|
@ -128,7 +128,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text-html; charset=utf-8">
|
||||
<title><?scm:d coyname ?> <?scm:d reportname ?> <?scm:d (gnc-print-date opt-date-tp) ?></title>
|
||||
<title><?scm:d coyname ?> <?scm:d reportname ?> <?scm:d (qof-print-date opt-date) ?></title>
|
||||
|
||||
<?scm (if css? (begin ?>
|
||||
<link rel="stylesheet" href="<?scm:d opt-css-file ?>" type="text/css">
|
||||
@ -157,7 +157,7 @@
|
||||
<table border="0" cellpadding="16"><tr><td> <!-- hack for GTKHTML -->
|
||||
<?scm )) ?>
|
||||
<h3><?scm:d coyname ?></h3>
|
||||
<h2><?scm:d reportname ?> <?scm:d (gnc-print-date opt-date-tp) ?></h2>
|
||||
<h2><?scm:d reportname ?> <?scm:d (qof-print-date opt-date) ?></h2>
|
||||
|
||||
<?scm
|
||||
;; This is where the work is done.
|
||||
|
@ -381,10 +381,9 @@
|
||||
(opt-price-source (get-option commodities-page optname-price-source))
|
||||
(opt-show-foreign? (get-option commodities-page optname-show-foreign))
|
||||
(opt-report-title (get-option general-page optname-report-title))
|
||||
(opt-date-tp (gnc:timepair-end-day-time
|
||||
(opt-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option general-page optname-date))))
|
||||
(opt-date-secs (gnc:timepair->secs opt-date-tp))
|
||||
(opt-columns (get-option display-page optname-columns))
|
||||
(opt-font-family (get-option display-page optname-font-family))
|
||||
(opt-font-size (get-option display-page optname-font-size))
|
||||
@ -424,7 +423,7 @@
|
||||
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn opt-price-source opt-report-commodity opt-date-tp))
|
||||
(gnc:case-exchange-fn opt-price-source opt-report-commodity opt-date))
|
||||
; List of commodities (other than the local one) used
|
||||
; so that exchange rate table can be displayed.
|
||||
; xlist will become an association list of (comm . #t) pairs
|
||||
@ -527,7 +526,7 @@
|
||||
(>= (gnc-account-get-current-depth (car account-list)) curr-depth))
|
||||
(let* ((account (car account-list))
|
||||
(comm (xaccAccountGetCommodity account))
|
||||
(bal (xaccAccountGetBalanceAsOfDate account opt-date-secs))
|
||||
(bal (xaccAccountGetBalanceAsOfDate account opt-date))
|
||||
(depth (flattened-acc-depth account))
|
||||
(treedepth 1)
|
||||
; Next account only qualifies as 'deeper' if we're not flattening
|
||||
|
@ -165,7 +165,7 @@
|
||||
(define (make-row column-vector date due-date num type-str memo monetary)
|
||||
(let ((row-contents '()))
|
||||
(if (date-col column-vector)
|
||||
(addto! row-contents (gnc-print-date date)))
|
||||
(addto! row-contents (qof-print-date date)))
|
||||
(if (num-col column-vector)
|
||||
(addto! row-contents num))
|
||||
(if (type-col column-vector)
|
||||
@ -206,7 +206,7 @@
|
||||
(define (add-txn-row table txn acc column-vector odd-row? printed?
|
||||
inv-str reverse? start-date total)
|
||||
(let* ((type (xaccTransGetTxnType txn))
|
||||
(date (gnc-transaction-get-date-posted txn))
|
||||
(date (xaccTransGetDate txn))
|
||||
(due-date #f)
|
||||
(value (xaccTransGetAccountValue txn acc))
|
||||
(split (xaccTransGetSplit txn 0))
|
||||
@ -234,7 +234,7 @@
|
||||
(if reverse?
|
||||
(set! value (gnc-numeric-neg value)))
|
||||
|
||||
(if (gnc:timepair-later start-date date)
|
||||
(if (< start-date date)
|
||||
(begin
|
||||
|
||||
;; Adds 'balance' row if needed
|
||||
@ -242,7 +242,7 @@
|
||||
|
||||
;; Now print out the invoice row
|
||||
(if (not (null? invoice))
|
||||
(set! due-date (gncInvoiceGetDateDue invoice)))
|
||||
(set! due-date (gncInvoiceGetDateDueTT invoice)))
|
||||
|
||||
(let ((row (make-row column-vector date due-date (gnc-get-num-action txn split)
|
||||
type-str (xaccSplitGetMemo split)
|
||||
@ -545,7 +545,7 @@
|
||||
|
||||
(define (query-toplevel-setup query account-list start-date end-date)
|
||||
(xaccQueryAddAccountMatch query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS query #t start-date #t end-date QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT query #t start-date #t end-date QOF-QUERY-AND)
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
query)
|
||||
|
||||
@ -605,7 +605,7 @@
|
||||
table
|
||||
(list
|
||||
(string-append label ": ")
|
||||
(string-expand (gnc-print-date date) #\space " "))))
|
||||
(string-expand (qof-print-date date) #\space " "))))
|
||||
|
||||
(define (make-date-table)
|
||||
(let ((table (gnc:make-html-table)))
|
||||
@ -640,7 +640,7 @@
|
||||
(gnc:html-table-append-row! table (list
|
||||
(strftime
|
||||
date-format
|
||||
(localtime (car (gnc:get-today))))))
|
||||
(localtime (gnc:get-today)))))
|
||||
|
||||
(gnc:html-table-set-style!
|
||||
table-outer "table"
|
||||
@ -695,10 +695,10 @@
|
||||
|
||||
(let* ((document (gnc:make-html-document))
|
||||
(report-title (opt-val gnc:pagename-general gnc:optname-reportname))
|
||||
(start-date (gnc:timepair-start-day-time
|
||||
(start-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general optname-from-date))))
|
||||
(end-date (gnc:timepair-end-day-time
|
||||
(end-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general optname-to-date))))
|
||||
(print-invoices? #t);;(opt-val gnc:pagename-general optname-invoicelines))
|
||||
@ -1003,8 +1003,8 @@
|
||||
(sprintf
|
||||
#f (_ "%s %s - %s")
|
||||
report-title
|
||||
(gnc-print-date start-date)
|
||||
(gnc-print-date end-date))))
|
||||
(qof-print-date start-date)
|
||||
(qof-print-date end-date))))
|
||||
(gnc:html-document-set-title!
|
||||
document headline)
|
||||
|
||||
|
@ -166,7 +166,7 @@
|
||||
|
||||
(if (date-col column-vector)
|
||||
(addto! row-contents
|
||||
(gnc-print-date (gncEntryGetDate entry))))
|
||||
(qof-print-date (gncEntryGetDate entry))))
|
||||
|
||||
(if (description-col column-vector)
|
||||
(addto! row-contents
|
||||
@ -426,7 +426,7 @@
|
||||
|
||||
(if (date-col used-columns)
|
||||
(addto! row
|
||||
(gnc-print-date (gnc-transaction-get-date-posted t))))
|
||||
(qof-print-date (xaccTransGetDate t))))
|
||||
|
||||
(if (description-col used-columns)
|
||||
(addto! row (_ "Payment, thank you")))
|
||||
@ -611,7 +611,7 @@
|
||||
(list
|
||||
(string-append label ": ")
|
||||
(string-expand (strftime date-format
|
||||
(localtime (car date)))
|
||||
(localtime date))
|
||||
#\space " "))))
|
||||
|
||||
(define (make-date-table)
|
||||
@ -780,7 +780,7 @@
|
||||
(let ((date-table #f)
|
||||
(post-date (gncInvoiceGetDatePosted invoice))
|
||||
(due-date (gncInvoiceGetDateDue invoice)))
|
||||
(if (not (equal? post-date (cons 0 0)))
|
||||
(if (not (zero? post-date))
|
||||
(begin
|
||||
(set! date-table (make-date-table))
|
||||
(make-date-row! date-table (_ "Date") post-date date-format)
|
||||
|
@ -174,7 +174,7 @@
|
||||
|
||||
(if (date-col column-vector)
|
||||
(addto! row-contents
|
||||
(gnc-print-date (gncEntryGetDate entry))))
|
||||
(qof-print-date (gncEntryGetDate entry))))
|
||||
|
||||
(if (description-col column-vector)
|
||||
(addto! row-contents
|
||||
@ -455,7 +455,7 @@
|
||||
|
||||
(if (date-col used-columns)
|
||||
(addto! row
|
||||
(gnc-print-date (gnc-transaction-get-date-posted t))))
|
||||
(qof-print-date (xaccTransGetDate t))))
|
||||
|
||||
(if (description-col used-columns)
|
||||
(addto! row (_ "Payment, thank you")))
|
||||
@ -663,9 +663,9 @@
|
||||
;; for the invoice date/due date fields
|
||||
;; I could have taken the format from the report options, but... ;)
|
||||
(string-expand (strftime (gnc-default-strftime-date-format)
|
||||
(gnc-localtime (car date)))
|
||||
(gnc-localtime date))
|
||||
#\space " ")
|
||||
;;(string-expand (gnc-print-date date) #\space " ")
|
||||
;;(string-expand (qof-print-date date) #\space " ")
|
||||
)))
|
||||
|
||||
(define (make-date-table)
|
||||
@ -740,7 +740,7 @@
|
||||
;; (gnc:html-table-append-row! table (list
|
||||
;; (strftime
|
||||
;; date-format
|
||||
;; (gnc-localtime (car (gnc:get-today))))))
|
||||
;; (gnc-localtime (gnc:get-today)))))
|
||||
table))
|
||||
|
||||
(define (make-break! document)
|
||||
@ -861,7 +861,7 @@
|
||||
(post-date (gncInvoiceGetDatePosted invoice))
|
||||
(due-date (gncInvoiceGetDateDue invoice)))
|
||||
|
||||
(if (not (equal? post-date (cons 0 0)))
|
||||
(if (not (zero? post-date))
|
||||
(begin
|
||||
(set! date-table (make-date-table))
|
||||
;; oli-custom - moved invoice number here
|
||||
|
@ -161,7 +161,7 @@
|
||||
|
||||
(if (date-col column-vector)
|
||||
(addto! row-contents
|
||||
(gnc-print-date (gncEntryGetDate entry))))
|
||||
(qof-print-date (gncEntryGetDate entry))))
|
||||
|
||||
(if (description-col column-vector)
|
||||
(addto! row-contents
|
||||
@ -404,7 +404,7 @@
|
||||
|
||||
(if (date-col used-columns)
|
||||
(addto! row
|
||||
(gnc-print-date (gnc-transaction-get-date-posted t))))
|
||||
(qof-print-date (xaccTransGetDate t))))
|
||||
|
||||
(if (description-col used-columns)
|
||||
(addto! row (_ "Payment, thank you")))
|
||||
@ -587,7 +587,7 @@
|
||||
(list
|
||||
(string-append label ": ")
|
||||
(string-expand (strftime date-format
|
||||
(localtime (car date)))
|
||||
(localtime date))
|
||||
#\space " ")
|
||||
)))
|
||||
|
||||
@ -621,7 +621,7 @@
|
||||
(gnc:html-table-append-row! table (list
|
||||
(strftime
|
||||
date-format
|
||||
(gnc-localtime (car (gnc:get-today))))))
|
||||
(gnc-localtime (gnc:get-today)))))
|
||||
table))
|
||||
|
||||
(define (make-break! document)
|
||||
@ -712,7 +712,7 @@
|
||||
(post-date (gncInvoiceGetDatePosted invoice))
|
||||
(due-date (gncInvoiceGetDateDue invoice)))
|
||||
|
||||
(if (not (equal? post-date (cons 0 0)))
|
||||
(if (not (zero? post-date))
|
||||
(begin
|
||||
(set! date-table (make-date-table))
|
||||
(make-date-row! date-table (string-append title " " (_ "Date")) post-date date-format)
|
||||
|
@ -132,7 +132,7 @@
|
||||
(table (gnc:make-html-table)))
|
||||
|
||||
(define (in-interval this-date current-bucket)
|
||||
(gnc:timepair-lt this-date current-bucket))
|
||||
(< this-date current-bucket))
|
||||
|
||||
(define (find-bucket current-bucket bucket-intervals date)
|
||||
(begin
|
||||
@ -189,12 +189,12 @@
|
||||
(define (make-row column-vector date due-date num type-str memo monetary)
|
||||
(let ((row-contents '()))
|
||||
(if (date-col column-vector)
|
||||
(addto! row-contents (gnc-print-date date)))
|
||||
(addto! row-contents (qof-print-date date)))
|
||||
(if (date-due-col column-vector)
|
||||
(addto! row-contents
|
||||
(if (and due-date
|
||||
(not (equal? due-date (cons 0 0))))
|
||||
(gnc-print-date due-date)
|
||||
(not (zero? due-date)))
|
||||
(qof-print-date due-date)
|
||||
"")))
|
||||
(if (num-col column-vector)
|
||||
(addto! row-contents num))
|
||||
@ -236,7 +236,7 @@
|
||||
(define (add-txn-row table txn acc column-vector odd-row? printed?
|
||||
inv-str reverse? start-date total)
|
||||
(let* ((type (xaccTransGetTxnType txn))
|
||||
(date (gnc-transaction-get-date-posted txn))
|
||||
(date (xaccTransGetDate txn))
|
||||
(due-date #f)
|
||||
(value (xaccTransGetAccountValue txn acc))
|
||||
(split (xaccTransGetSplit txn 0))
|
||||
@ -258,7 +258,7 @@
|
||||
(if reverse?
|
||||
(set! value (gnc-numeric-neg value)))
|
||||
|
||||
(if (gnc:timepair-later start-date date)
|
||||
(if (< start-date date)
|
||||
(begin
|
||||
|
||||
; Adds 'balance' row if needed
|
||||
@ -465,7 +465,7 @@
|
||||
guid QOF-QUERY-OR)
|
||||
|
||||
(xaccQueryAddSingleAccountMatch q account QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS q #f end-date #t end-date QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT q #f end-date #t end-date QOF-QUERY-AND)
|
||||
(qof-query-set-book q (gnc-get-current-book))
|
||||
q))
|
||||
|
||||
@ -493,7 +493,7 @@
|
||||
table
|
||||
(list
|
||||
(string-append label ": ")
|
||||
(string-expand (gnc-print-date date) #\space " "))))
|
||||
(string-expand (qof-print-date date) #\space " "))))
|
||||
|
||||
(define (make-date-table)
|
||||
(let ((table (gnc:make-html-table)))
|
||||
@ -526,7 +526,7 @@
|
||||
(gnc:html-table-append-row! table (list
|
||||
(strftime
|
||||
date-format
|
||||
(gnc-localtime (car (gnc:get-today))))))
|
||||
(gnc-localtime (current-time)))))
|
||||
table))
|
||||
|
||||
(define (make-break! document)
|
||||
@ -546,10 +546,10 @@
|
||||
(query (qof-query-create-for-splits))
|
||||
(account (opt-val owner-page acct-string))
|
||||
(owner (opt-val owner-page owner-string))
|
||||
(start-date (gnc:timepair-start-day-time
|
||||
(start-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general (N_ "From")))))
|
||||
(end-date (gnc:timepair-end-day-time
|
||||
(end-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general (N_ "To")))))
|
||||
(book (gnc-account-get-book account))
|
||||
@ -620,9 +620,9 @@
|
||||
(string-append
|
||||
(_ "Date Range")
|
||||
": "
|
||||
(gnc-print-date start-date)
|
||||
(qof-print-date start-date)
|
||||
" - "
|
||||
(gnc-print-date end-date))))
|
||||
(qof-print-date end-date))))
|
||||
|
||||
(make-break! document)
|
||||
|
||||
|
@ -226,7 +226,7 @@
|
||||
(table (gnc:make-html-table)))
|
||||
|
||||
(define (in-interval this-date current-bucket)
|
||||
(gnc:timepair-lt this-date current-bucket))
|
||||
(< this-date current-bucket))
|
||||
|
||||
(define (find-bucket current-bucket bucket-intervals date)
|
||||
(begin
|
||||
@ -251,7 +251,7 @@
|
||||
(let* ((bal (gnc-lot-get-balance lot))
|
||||
(invoice (gncInvoiceGetInvoiceFromLot lot))
|
||||
(date (if (eq? date-type 'postdate)
|
||||
(gncInvoiceGetDatePosted invoice)
|
||||
(gncInvoiceGetDatePostedTT invoice)
|
||||
(gncInvoiceGetDateDue invoice)))
|
||||
)
|
||||
|
||||
@ -287,12 +287,12 @@
|
||||
(define (make-row column-vector date due-date num type-str memo monetary credit debit sale tax)
|
||||
(let ((row-contents '()))
|
||||
(if (date-col column-vector)
|
||||
(addto! row-contents (gnc-print-date date)))
|
||||
(addto! row-contents (qof-print-date date)))
|
||||
(if (date-due-col column-vector)
|
||||
(addto! row-contents
|
||||
(if (and due-date
|
||||
(not (equal? due-date (cons 0 0))))
|
||||
(gnc-print-date due-date)
|
||||
(not (zero? due-date)))
|
||||
(qof-print-date due-date)
|
||||
"")))
|
||||
(if (num-col column-vector)
|
||||
(addto! row-contents num))
|
||||
@ -346,7 +346,7 @@
|
||||
(define (add-txn-row table txn acc column-vector odd-row? printed?
|
||||
reverse? start-date total)
|
||||
(let* ((type (xaccTransGetTxnType txn))
|
||||
(date (gnc-transaction-get-date-posted txn))
|
||||
(date (xaccTransGetDate txn))
|
||||
(due-date #f)
|
||||
(value (xaccTransGetAccountValue txn acc))
|
||||
(sale (gnc-numeric-zero))
|
||||
@ -373,7 +373,7 @@
|
||||
(if reverse?
|
||||
(set! value (gnc-numeric-neg value)))
|
||||
|
||||
(if (gnc:timepair-le start-date date)
|
||||
(if (<= start-date date)
|
||||
(begin
|
||||
|
||||
; Adds 'balance' row if needed
|
||||
@ -674,7 +674,7 @@
|
||||
guid QOF-QUERY-OR)
|
||||
|
||||
(xaccQueryAddSingleAccountMatch q account QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS q #f end-date #t end-date QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT q #f end-date #t end-date QOF-QUERY-AND)
|
||||
(qof-query-set-book q (gnc-get-current-book))
|
||||
q))
|
||||
|
||||
@ -702,7 +702,7 @@
|
||||
table
|
||||
(list
|
||||
(string-append label ": ")
|
||||
(string-expand (gnc-print-date date) #\space " "))))
|
||||
(string-expand (qof-print-date date) #\space " "))))
|
||||
|
||||
(define (make-date-table)
|
||||
(let ((table (gnc:make-html-table)))
|
||||
@ -735,7 +735,7 @@
|
||||
(gnc:html-table-append-row! table (list
|
||||
(strftime
|
||||
date-format
|
||||
(gnc-localtime (car (gnc:get-today))))))
|
||||
(gnc-localtime (gnc:get-today)))))
|
||||
table))
|
||||
|
||||
(define (make-break! document)
|
||||
@ -754,10 +754,10 @@
|
||||
(orders '())
|
||||
(query (qof-query-create-for-splits))
|
||||
(account (opt-val owner-page acct-string))
|
||||
(start-date (gnc:timepair-start-day-time
|
||||
(start-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general optname-from-date))))
|
||||
(end-date (gnc:timepair-end-day-time
|
||||
(end-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general optname-to-date))))
|
||||
(book (gnc-account-get-book account))
|
||||
@ -820,9 +820,9 @@
|
||||
(string-append
|
||||
(_ "Date Range")
|
||||
": "
|
||||
(gnc-print-date start-date)
|
||||
(qof-print-date start-date)
|
||||
" - "
|
||||
(gnc-print-date end-date))))
|
||||
(qof-print-date end-date))))
|
||||
|
||||
(make-break! document)
|
||||
|
||||
|
@ -68,8 +68,8 @@
|
||||
(lambda (s1 s2)
|
||||
(let ((t1 (xaccSplitGetParent s1))
|
||||
(t2 (xaccSplitGetParent s2)))
|
||||
(< (car (gnc-transaction-get-date-posted t1))
|
||||
(car (gnc-transaction-get-date-posted t2))))))))
|
||||
(< (xaccTransGetDate t1)
|
||||
(xaccTransGetDate t2)))))))
|
||||
|
||||
; pre-scan invoice entries to look for discounts and taxes
|
||||
(for entry in entries do
|
||||
@ -142,7 +142,7 @@
|
||||
<!-- header texts -->
|
||||
|
||||
<h1><?scm:d (nbsp (_ "Invoice No.")) ?> <?scm:d invoiceid ?></h1>
|
||||
<h2><?scm:d (strftime opt-date-format (localtime (car (gnc:get-today)))) ?></h2>
|
||||
<h2><?scm:d (strftime opt-date-format (localtime (gnc:get-today))) ?></h2>
|
||||
<p> </p>
|
||||
<?scm (if (not (string=? billcontact "")) (begin ?>
|
||||
<p>Attn: <?scm:d billcontact ?></p><br>
|
||||
@ -193,7 +193,7 @@
|
||||
(dsc-total 'add currency rdiscval)
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="left"><?scm:d (gnc-print-date (gncEntryGetDate entry)) ?></td>
|
||||
<td align="left"><?scm:d (qof-print-date (gncEntryGetDate entry)) ?></td>
|
||||
<td align="left" ><?scm:d (gncEntryGetDescription entry) ?></td>
|
||||
<td align="right"><?scm:d (fmtnumeric qty) ?></td>
|
||||
<td align="right"><?scm:d (format #f "~4,2,,,'0f" (gnc-numeric-to-double each)) ?></td>
|
||||
@ -254,7 +254,7 @@
|
||||
(inv-total 'add c a)
|
||||
?>
|
||||
<tr valign="top">
|
||||
<td align="center"><?scm:d (gnc-print-date (gnc-transaction-get-date-posted t)) ?></td>
|
||||
<td align="center"><?scm:d (qof-print-date (xaccTransGetDate t)) ?></td>
|
||||
<td align="left" colspan="<?scm:d (- maxcols 3) ?>"><?scm:d opt-payment-recd-heading ?></td>
|
||||
<td align="right" colspan="2"><?scm:d (fmtmoney c a) ?></td>
|
||||
</tr>
|
||||
|
@ -79,8 +79,8 @@
|
||||
(lambda (s1 s2)
|
||||
(let ((t1 (xaccSplitGetParent s1))
|
||||
(t2 (xaccSplitGetParent s2)))
|
||||
(< (car (gnc-transaction-get-date-posted t1))
|
||||
(car (gnc-transaction-get-date-posted t2))))))))
|
||||
(< (xaccTransGetDate t1)
|
||||
(xaccTransGetDate t2)))))))
|
||||
|
||||
|
||||
;; Is this an invoice or something else
|
||||
@ -246,7 +246,7 @@
|
||||
<td align="right" class="invnum"><big><strong><?scm:d invoiceid ?></strong></big></td>
|
||||
</tr>
|
||||
<?scm )) ?>
|
||||
<?scm (if (equal? postdate (cons 0 0)) (begin ?>
|
||||
<?scm (if (zero? postdate) (begin ?>
|
||||
<tr>
|
||||
<td colspan="2" align="right"><?scm:d (_ "Invoice in progress...") ?></td>
|
||||
</tr>
|
||||
@ -254,12 +254,12 @@
|
||||
<tr>
|
||||
<td align="right"><?scm:d (nbsp (_ "Invoice Date")) ?>: </td>
|
||||
<td align="right"><?scm:d (nbsp (strftime dateformat
|
||||
(localtime (car postdate)))) ?></td>
|
||||
(localtime postdate))) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><?scm:d (nbsp (_ "Due Date")) ?>: </td>
|
||||
<td align="right"><?scm:d (nbsp (strftime dateformat
|
||||
(localtime (car duedate)))) ?></td>
|
||||
(localtime duedate))) ?></td>
|
||||
</tr> <?scm )) ?>
|
||||
<?scm (if (not (string=? billingid "")) (begin ?>
|
||||
<tr>
|
||||
@ -347,7 +347,7 @@
|
||||
?>
|
||||
<tr valign="top">
|
||||
<?scm (if opt-col-date (begin ?>
|
||||
<td align="center" ><nobr><?scm:d (nbsp (gnc-print-date (gncEntryGetDate entry))) ?></nobr></td>
|
||||
<td align="center" ><nobr><?scm:d (nbsp (qof-print-date (gncEntryGetDate entry))) ?></nobr></td>
|
||||
<?scm )) ?>
|
||||
<td align="left"><?scm:d (gncEntryGetDescription entry) ?></td>
|
||||
<!-- td align="left">< ?scm:d (gncEntryGetNotes entry) ?></td -->
|
||||
@ -419,7 +419,7 @@
|
||||
?>
|
||||
<tr valign="top">
|
||||
<?scm (if opt-col-date (begin ?>
|
||||
<td align="center"><?scm:d (gnc-print-date (gnc-transaction-get-date-posted t)) ?></td>
|
||||
<td align="center"><?scm:d (qof-print-date (xaccTransGetDate t)) ?></td>
|
||||
<?scm )) ?>
|
||||
<td align="left" colspan="<?scm:d (+ tbl_cols (if opt-col-date 0 1)) ?>"><?scm:d opt-payment-recd-heading ?></td>
|
||||
<td align="right"><?scm:d (fmtmoney c a) ?></td>
|
||||
|
@ -91,19 +91,18 @@
|
||||
|
||||
(define levelx-collector (make-level-collector MAX-LEVELS))
|
||||
|
||||
(define today (timespecCanonicalDayTime
|
||||
(cons (current-time) 0)))
|
||||
(define today (time64CanonicalDayTime (current-time)))
|
||||
|
||||
(define bdtm
|
||||
(let ((result (gnc:timepair->date today)))
|
||||
(let ((result (gnc-localtime today)))
|
||||
(set-tm:mday result 16) ; 16
|
||||
(set-tm:mon result 3) ; Apr
|
||||
(set-tm:isdst result -1)
|
||||
result))
|
||||
|
||||
(define tax-day (cons (gnc-mktime bdtm) 0))
|
||||
(define tax-day (gnc-mktime bdtm))
|
||||
|
||||
(define after-tax-day (gnc:timepair-later tax-day today))
|
||||
(define after-tax-day (< tax-day today))
|
||||
|
||||
(define (make-split-list account split-filter-pred)
|
||||
(reverse (filter split-filter-pred
|
||||
@ -111,14 +110,14 @@
|
||||
|
||||
;; returns a predicate that returns true only if a split is
|
||||
;; between early-date and late-date
|
||||
(define (split-report-make-date-filter-predicate begin-date-tp
|
||||
end-date-tp)
|
||||
(define (split-report-make-date-filter-predicate begin-date
|
||||
end-date)
|
||||
(lambda (split)
|
||||
(let ((tp
|
||||
(gnc-transaction-get-date-posted
|
||||
(let ((t
|
||||
(xaccTransGetDate
|
||||
(xaccSplitGetParent split))))
|
||||
(and (gnc:timepair-ge-date tp begin-date-tp)
|
||||
(gnc:timepair-le-date tp end-date-tp)))))
|
||||
(and (>= t begin-date)
|
||||
(<= t end-date)))))
|
||||
|
||||
;; This is nearly identical to, and could be shared with
|
||||
;; display-report-list-item in report.scm. This adds warn-msg parameter
|
||||
@ -322,10 +321,10 @@
|
||||
(let* ((type (xaccAccountGetType account))
|
||||
(code (gnc:account-get-txf-code account))
|
||||
(date-str (if date
|
||||
(strftime "%d.%m.%Y" (gnc-localtime (car date)))
|
||||
(strftime "%d.%m.%Y" (gnc-localtime date))
|
||||
#f))
|
||||
(x-date-str (if x-date
|
||||
(strftime "%d.%m.%Y" (gnc-localtime (car x-date)))
|
||||
(strftime "%d.%m.%Y" (gnc-localtime x-date))
|
||||
#f))
|
||||
;; Only formats 1,3 implemented now! Others are treated as 1.
|
||||
(format (gnc:get-txf-format code (eq? type ACCT-TYPE-INCOME)))
|
||||
@ -410,7 +409,7 @@
|
||||
(define (render-level-x-account table level max-level account lx-value
|
||||
suppress-0 full-names txf-date)
|
||||
(let* ((account-name (if txf-date ; special split
|
||||
(strftime "%d.%m.%Y" (gnc-localtime (car txf-date)))
|
||||
(strftime "%d.%m.%Y" (gnc-localtime txf-date))
|
||||
(if (or full-names (equal? level 1))
|
||||
(gnc-account-get-full-name account)
|
||||
(xaccAccountGetName account))))
|
||||
@ -490,7 +489,7 @@
|
||||
(gnc:report-starting reportname)
|
||||
(let* ((from-value (gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general "From")))
|
||||
(to-value (gnc:timepair-end-day-time
|
||||
(to-value (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general "To"))))
|
||||
(alt-period (get-option gnc:pagename-general "Alternate Period"))
|
||||
@ -517,8 +516,8 @@
|
||||
(work-done 0)
|
||||
|
||||
;; Alternate dates are relative to from-date
|
||||
(from-date (gnc:timepair->date from-value))
|
||||
(from-value (gnc:timepair-start-day-time
|
||||
(from-date (gnc-localtime from-value))
|
||||
(from-value (gnc:time64-start-day-time
|
||||
(let ((bdtm from-date))
|
||||
(if (member alt-period
|
||||
'(last-year 1st-last 2nd-last
|
||||
@ -547,9 +546,9 @@
|
||||
((4th-est 4th-last) ; Oct 1
|
||||
(set-tm:mon bdtm 9))))
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))))
|
||||
(gnc-mktime bdtm))))
|
||||
|
||||
(to-value (gnc:timepair-end-day-time
|
||||
(to-value (gnc:time64-end-day-time
|
||||
(let ((bdtm from-date))
|
||||
(if (member alt-period
|
||||
'(last-year 1st-last 2nd-last
|
||||
@ -573,8 +572,8 @@
|
||||
((3rd-est 3rd-last) ; Aug 31
|
||||
(set-tm:mon bdtm 7))
|
||||
((4th-est 4th-last last-year) ; Dec 31
|
||||
(set-tm:mon bdtm 11))
|
||||
(else (set! bdtm (gnc:timepair->date to-value))))
|
||||
(set-tm:mon bdtm 11))
|
||||
(else (set! bdtm (gnc-mktime to-value))))
|
||||
;; Tax quaters equal Real quarters
|
||||
(case alt-period
|
||||
((1st-est 1st-last) ; Mar 31
|
||||
@ -588,9 +587,9 @@
|
||||
((4th-est 4th-last last-year) ; Dec 31
|
||||
(set-tm:mon bdtm 11))
|
||||
(else
|
||||
(set! bdtm (gnc:timepair->date to-value)))))
|
||||
(set! bdtm (gnc-mktime to-value)))))
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))))
|
||||
(gnc-mktime bdtm))))
|
||||
|
||||
(txf-feedback-str-lst '())
|
||||
(doc (gnc:make-html-document))
|
||||
@ -603,8 +602,8 @@
|
||||
(txf-special-split? (gnc:account-get-txf-code account)))
|
||||
(let*
|
||||
((full-year?
|
||||
(let ((bdto (gnc-localtime (car to-value)))
|
||||
(bdfrom (gnc-localtime (car from-value))))
|
||||
(let ((bdto (gnc-localtime to-value))
|
||||
(bdfrom (gnc-localtime from-value)))
|
||||
(and (equal? (tm:year bdto) (tm:year bdfrom))
|
||||
(equal? (tm:mon bdfrom) 0)
|
||||
(equal? (tm:mday bdfrom) 1)
|
||||
@ -613,23 +612,23 @@
|
||||
;; Adjust dates so we get the final Estimated Tax
|
||||
;; paymnent from the right year
|
||||
(from-est (if full-year?
|
||||
(let ((bdtm (gnc:timepair->date
|
||||
(timespecCanonicalDayTime
|
||||
(let ((bdtm (gnc-localtime
|
||||
(time64CanonicalDayTime
|
||||
from-value))))
|
||||
(set-tm:mday bdtm 1) ; 01
|
||||
(set-tm:mon bdtm 2) ; Mar
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))
|
||||
(gnc-mktime bdtm))
|
||||
from-value))
|
||||
(to-est (if full-year?
|
||||
(let* ((bdtm (gnc:timepair->date
|
||||
(timespecCanonicalDayTime
|
||||
(let* ((bdtm (gnc-localtime
|
||||
(time64CanonicalDayTime
|
||||
from-value))))
|
||||
(set-tm:mday bdtm 28) ; 28
|
||||
(set-tm:mon bdtm 1) ; Feb
|
||||
(set-tm:year bdtm (+ (tm:year bdtm) 1))
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))
|
||||
(gnc-mktime bdtm))
|
||||
to-value)))
|
||||
(list from-est to-est full-year?))
|
||||
#f))
|
||||
@ -646,12 +645,12 @@
|
||||
(+ 1 level)
|
||||
level)))
|
||||
(map (lambda (spl)
|
||||
(let* ((date (gnc-transaction-get-date-posted
|
||||
(let* ((date (xaccTransGetDate
|
||||
(xaccSplitGetParent spl)))
|
||||
(amount (xaccSplitGetAmount spl))
|
||||
;; TurboTax 1999 and 2000 ignore dates after Dec 31
|
||||
(fudge-date (if (and full-year?
|
||||
(gnc:timepair-lt to-value date))
|
||||
(< to-value date))
|
||||
to-value
|
||||
date)))
|
||||
(if tax-mode?
|
||||
@ -765,13 +764,13 @@
|
||||
;; Ignore
|
||||
'())))
|
||||
|
||||
(let ((from-date (strftime "%d.%m.%Y" (gnc-localtime (car from-value))))
|
||||
(to-date (strftime "%d.%m.%Y" (gnc-localtime (car to-value))))
|
||||
(to-year (strftime "%Y" (gnc-localtime (car to-value))))
|
||||
(let ((from-date (strftime "%d.%m.%Y" (gnc-localtime from-value)))
|
||||
(to-date (strftime "%d.%m.%Y" (gnc-localtime to-value)))
|
||||
(to-year (strftime "%Y" (gnc-localtime to-value)))
|
||||
(today-date (strftime "%d.%m.%Y"
|
||||
(gnc-localtime
|
||||
(car (timespecCanonicalDayTime
|
||||
(cons (current-time) 0))))))
|
||||
(time64CanonicalDayTime
|
||||
(current-time)))))
|
||||
(tax-nr (or
|
||||
(gnc:option-get-value book gnc:*tax-label* gnc:*tax-nr-label*)
|
||||
""))
|
||||
|
@ -120,31 +120,29 @@
|
||||
|
||||
(define selected-accounts-sorted-by-form-line-acct (list))
|
||||
|
||||
(define today (timespecCanonicalDayTime (cons (current-time) 0)))
|
||||
(define today (time64CanonicalDayTime (current-time)))
|
||||
|
||||
(define bdtm
|
||||
(let ((result (gnc:timepair->date today)))
|
||||
(let ((result (gnc-localtime today)))
|
||||
(set-tm:mday result 16) ; 16
|
||||
(set-tm:mon result 3) ; Apr
|
||||
(set-tm:isdst result -1)
|
||||
result))
|
||||
|
||||
(define tax-day (cons (gnc-mktime bdtm) 0))
|
||||
(define tax-day (gnc-mktime bdtm))
|
||||
|
||||
(define after-tax-day (gnc:timepair-later tax-day today))
|
||||
(define after-tax-day (< tax-day today))
|
||||
|
||||
(define (make-split-list account split-filter-pred)
|
||||
(filter split-filter-pred (xaccAccountGetSplitList account)))
|
||||
|
||||
;; returns a predicate that returns true only if a split is
|
||||
;; between early-date and late-date
|
||||
(define (split-report-make-date-filter-predicate begin-date-tp end-date-tp)
|
||||
(define (split-report-make-date-filter-predicate begin-date-t64 end-date-t64)
|
||||
(lambda (split)
|
||||
(let ((tp
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccSplitGetParent split))))
|
||||
(and (gnc:timepair-ge-date tp begin-date-tp)
|
||||
(gnc:timepair-le-date tp end-date-tp)))))
|
||||
(let ((t64 (xaccTransGetDate (xaccSplitGetParent split))))
|
||||
(and (>= t64 begin-date-t64)
|
||||
(<= t64 end-date-t64)))))
|
||||
|
||||
;; This is nearly identical to, and could be shared with
|
||||
;; display-report-list-item in report.scm. This adds warn-msg parameter
|
||||
@ -549,10 +547,10 @@
|
||||
(if (and txf?
|
||||
(not (gnc-numeric-zero-p account-value)))
|
||||
(let* ((date-str (if date
|
||||
(strftime "%m/%d/%Y" (gnc-localtime (car date)))
|
||||
(strftime "%m/%d/%Y" (gnc-localtime date))
|
||||
#f))
|
||||
(x-date-str (if x-date
|
||||
(strftime "%m/%d/%Y" (gnc-localtime (car x-date)))
|
||||
(strftime "%m/%d/%Y" (gnc-localtime x-date))
|
||||
#f))
|
||||
;; Only formats 1,3,4,6 implemented now! Others are treated as 1.
|
||||
(format (get-acct-txf-info 'format type code))
|
||||
@ -721,11 +719,11 @@
|
||||
(begin ;; do so
|
||||
(set! missing-pricedb-entry? #f)
|
||||
(set! pricedb-lookup-price
|
||||
(let ((price (gnc-pricedb-lookup-nearest-in-time
|
||||
(let ((price (gnc-pricedb-lookup-nearest-in-time64
|
||||
pricedb
|
||||
account-commodity
|
||||
USD-currency
|
||||
(timespecCanonicalDayTime
|
||||
(time64CanonicalDayTime
|
||||
lookup-date))))
|
||||
(if (gnc-commodity-equiv account-commodity (gnc-price-get-currency price))
|
||||
(set! price (gnc-price-invert price)))
|
||||
@ -734,7 +732,7 @@
|
||||
(gnc-price-get-value
|
||||
pricedb-lookup-price))
|
||||
(set! pricedb-lookup-price-time
|
||||
(gnc-price-get-time
|
||||
(gnc-price-get-time64
|
||||
pricedb-lookup-price))
|
||||
(gnc-pricedb-convert-balance-nearest-price
|
||||
pricedb
|
||||
@ -746,7 +744,7 @@
|
||||
;; Use midday as the transaction time so it matches a price
|
||||
;; on the same day. Otherwise it uses midnight which will
|
||||
;; likely match a price on the previous day
|
||||
(timespecCanonicalDayTime lookup-date))
|
||||
(time64CanonicalDayTime lookup-date))
|
||||
)
|
||||
(begin ;; otherwise set flag and set to zero
|
||||
(set! missing-pricedb-entry? #t)
|
||||
@ -822,7 +820,7 @@
|
||||
(string-append
|
||||
" on "
|
||||
(strftime "%Y-%b-%d"
|
||||
(gnc-localtime (car pricedb-lookup-price-time)))
|
||||
(gnc-localtime pricedb-lookup-price-time))
|
||||
")"
|
||||
)
|
||||
""))
|
||||
@ -1231,7 +1229,7 @@
|
||||
account-commodity
|
||||
(if (equal? currency-conversion-date
|
||||
'conv-to-tran-date)
|
||||
(gnc:timepair-previous-day
|
||||
(gnc:time64-previous-day
|
||||
from-value)
|
||||
to-value)
|
||||
account-commodity ;; force price lookup
|
||||
@ -1261,9 +1259,8 @@
|
||||
""
|
||||
(string-append "Balance on "
|
||||
(strftime "%Y-%b-%d"
|
||||
(gnc-localtime (car
|
||||
(gnc:timepair-previous-day
|
||||
from-value))))
|
||||
(gnc-localtime (gnc:time64-previous-day
|
||||
from-value)))
|
||||
(if (string=? curr-conv-note "")
|
||||
":"
|
||||
(string-append " " curr-conv-note)
|
||||
@ -1345,11 +1342,11 @@
|
||||
(set! output
|
||||
(map (lambda (split)
|
||||
(let* ((parent (xaccSplitGetParent split))
|
||||
(trans-date (gnc-transaction-get-date-posted parent))
|
||||
(trans-date (xaccTransGetDate parent))
|
||||
;; TurboTax 1999 and 2000 ignore dates after Dec 31
|
||||
(fudge-date (if splits-period
|
||||
(if (and full-year?
|
||||
(gnc:timepair-lt to-value trans-date))
|
||||
(< to-value trans-date))
|
||||
to-value
|
||||
trans-date)
|
||||
trans-date))
|
||||
@ -1495,7 +1492,7 @@
|
||||
(gnc:make-html-table-cell/markup
|
||||
"date-cell"
|
||||
(strftime "%Y-%b-%d"
|
||||
(gnc-localtime (car trans-date)))))
|
||||
(gnc-localtime trans-date))))
|
||||
(gnc:html-table-set-style! num-table "table"
|
||||
'attribute (list "border" "0")
|
||||
'attribute (list "cellspacing" "0")
|
||||
@ -1686,14 +1683,14 @@
|
||||
#f
|
||||
(if (txf-beg-bal-only? tax-code)
|
||||
(string-append "Balance on "
|
||||
(strftime "%Y-%b-%d" (gnc-localtime (car
|
||||
(gnc:timepair-previous-day
|
||||
from-value))))
|
||||
(strftime "%Y-%b-%d" (gnc-localtime
|
||||
(gnc:time64-previous-day
|
||||
from-value)))
|
||||
" For "
|
||||
)
|
||||
(string-append "Balance on "
|
||||
(strftime "%Y-%b-%d"
|
||||
(gnc-localtime (car to-value)))
|
||||
(gnc-localtime to-value))
|
||||
" For "
|
||||
)
|
||||
)
|
||||
@ -2042,7 +2039,7 @@
|
||||
(gnc:report-starting reportname)
|
||||
(let* ((from-value (gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general "From")))
|
||||
(to-value (gnc:timepair-end-day-time
|
||||
(to-value (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general "To"))))
|
||||
(alt-period (get-option gnc:pagename-general "Alternate Period"))
|
||||
@ -2087,8 +2084,8 @@
|
||||
(work-done 0)
|
||||
|
||||
;; Alternate dates are relative to from-date
|
||||
(from-date (gnc:timepair->date from-value))
|
||||
(from-value (gnc:timepair-start-day-time
|
||||
(from-date (gnc-localtime from-value))
|
||||
(from-value (gnc:time64-start-day-time
|
||||
(let ((bdtm from-date))
|
||||
(if (member alt-period
|
||||
'(last-year 1st-last 2nd-last
|
||||
@ -2118,9 +2115,9 @@
|
||||
((4th-est 4th-last) ; Oct 1
|
||||
(set-tm:mon bdtm 9))))
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))))
|
||||
(gnc-mktime bdtm))))
|
||||
|
||||
(to-value (gnc:timepair-end-day-time
|
||||
(to-value (gnc:time64-end-day-time
|
||||
(let ((bdtm from-date))
|
||||
(if (member alt-period
|
||||
'(last-year 1st-last 2nd-last
|
||||
@ -2146,7 +2143,7 @@
|
||||
(set-tm:mon bdtm 7))
|
||||
((4th-est 4th-last last-year) ; Dec 31
|
||||
(set-tm:mon bdtm 11))
|
||||
(else (set! bdtm (gnc:timepair->date to-value))))
|
||||
(else (set! bdtm (gnc-localtime to-value))))
|
||||
;; Tax quaters equal Real quarters
|
||||
(case alt-period
|
||||
((1st-est 1st-last) ; Mar 31
|
||||
@ -2160,9 +2157,9 @@
|
||||
((4th-est 4th-last last-year) ; Dec 31
|
||||
(set-tm:mon bdtm 11))
|
||||
(else
|
||||
(set! bdtm (gnc:timepair->date to-value)))))
|
||||
(set! bdtm (gnc-localtime to-value)))))
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))))
|
||||
(gnc-mktime bdtm))))
|
||||
|
||||
(form-line-acct-header-printed? #f)
|
||||
(form-schedule-header-printed? #f)
|
||||
@ -2179,8 +2176,8 @@
|
||||
(txf-special-date? (gnc:account-get-txf-code account)))
|
||||
(let*
|
||||
((full-year?
|
||||
(let ((bdto (gnc-localtime (car to-value)))
|
||||
(bdfrom (gnc-localtime (car from-value))))
|
||||
(let ((bdto (gnc-localtime to-value))
|
||||
(bdfrom (gnc-localtime from-value)))
|
||||
(and (equal? (tm:year bdto) (tm:year bdfrom))
|
||||
(equal? (tm:mon bdfrom) 0)
|
||||
(equal? (tm:mday bdfrom) 1)
|
||||
@ -2189,23 +2186,23 @@
|
||||
;; Adjust dates so we get the final Estimated Tax
|
||||
;; paymnent from the right year
|
||||
(from-est (if full-year?
|
||||
(let ((bdtm (gnc:timepair->date
|
||||
(timespecCanonicalDayTime
|
||||
(let ((bdtm (gnc-localtime
|
||||
(time64CanonicalDayTime
|
||||
from-value))))
|
||||
(set-tm:mday bdtm 1) ; 01
|
||||
(set-tm:mon bdtm 2) ; Mar
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))
|
||||
(gnc-mktime bdtm))
|
||||
from-value))
|
||||
(to-est (if full-year?
|
||||
(let* ((bdtm (gnc:timepair->date
|
||||
(timespecCanonicalDayTime
|
||||
(let* ((bdtm (gnc-localtime
|
||||
(time64CanonicalDayTime
|
||||
from-value))))
|
||||
(set-tm:mday bdtm 28) ; 28
|
||||
(set-tm:mon bdtm 1) ; Feb
|
||||
(set-tm:year bdtm (+ (tm:year bdtm) 1))
|
||||
(set-tm:isdst bdtm -1)
|
||||
(cons (gnc-mktime bdtm) 0))
|
||||
(gnc-mktime bdtm))
|
||||
to-value)))
|
||||
(list from-est to-est full-year?))
|
||||
#f))
|
||||
@ -2253,7 +2250,7 @@
|
||||
(or (eq? account-type ACCT-TYPE-INCOME)
|
||||
(eq? account-type ACCT-TYPE-EXPENSE)))
|
||||
(gnc:account-get-comm-balance-at-date account
|
||||
(gnc:timepair-previous-day from-value) #f)
|
||||
(gnc:time64-previous-day from-value) #f)
|
||||
#f))
|
||||
(acct-end-bal-collector (if (not
|
||||
(or (eq? account-type ACCT-TYPE-INCOME)
|
||||
@ -2393,13 +2390,13 @@
|
||||
) ;; end of let*
|
||||
)
|
||||
|
||||
(let ((from-date (strftime "%Y-%b-%d" (gnc-localtime (car from-value))))
|
||||
(to-date (strftime "%Y-%b-%d" (gnc-localtime (car to-value))))
|
||||
(let ((from-date (strftime "%Y-%b-%d" (gnc-localtime from-value)))
|
||||
(to-date (strftime "%Y-%b-%d" (gnc-localtime to-value)))
|
||||
(today-date (strftime "D%m/%d/%Y"
|
||||
(gnc-localtime
|
||||
(car (timespecCanonicalDayTime
|
||||
(cons (current-time) 0))))))
|
||||
(tax-year (strftime "%Y" (gnc-localtime (car from-value))))
|
||||
(time64CanonicalDayTime
|
||||
(current-time)))))
|
||||
(tax-year (strftime "%Y" (gnc-localtime from-value)))
|
||||
(tax-entity-type (gnc-get-current-book-tax-type))
|
||||
(tax-entity-type-valid? #f)
|
||||
(prior-form-schedule "")
|
||||
|
@ -59,10 +59,6 @@
|
||||
(export slotset-check)
|
||||
(export slotset-map-input)
|
||||
|
||||
(export predicate-and)
|
||||
(export predicate-or)
|
||||
(export predicate-not)
|
||||
|
||||
(export binary-search-lt)
|
||||
|
||||
;; Filters
|
||||
@ -333,25 +329,6 @@
|
||||
(car final))
|
||||
(make-list-collector (cons collector other-collectors))))
|
||||
|
||||
;;
|
||||
;; Predicates
|
||||
;;
|
||||
;; Was thinking about turning these into a real type (just to get a
|
||||
;; decent predicate-name function). Probably not required.
|
||||
|
||||
(define (predicate-not p)
|
||||
(lambda (x) (not (p x))))
|
||||
|
||||
(define (predicate-and p1 p2)
|
||||
(lambda (x) (and (p1 x) (p2 x))))
|
||||
|
||||
(define (predicate-or p1 p2)
|
||||
(lambda (x) (or (p1 x) (p2 x))))
|
||||
|
||||
(define (make-predicate fn) fn)
|
||||
|
||||
(define (predicate-test p value)
|
||||
(p value))
|
||||
|
||||
;; Binary search. Returns highest index with content less than or
|
||||
;; equal to the supplied value.
|
||||
|
@ -35,11 +35,11 @@
|
||||
|
||||
|
||||
;; Returns a list of all splits in the 'currency-accounts' up to
|
||||
;; 'end-date-tp' which have two different commodities involved, one of
|
||||
;; 'end-date' which have two different commodities involved, one of
|
||||
;; which is equivalent to 'commodity' (the latter constraint only if
|
||||
;; 'commodity' != #f ).
|
||||
(define (gnc:get-match-commodity-splits
|
||||
currency-accounts end-date-tp commodity)
|
||||
currency-accounts end-date commodity)
|
||||
(let ((query (qof-query-create-for-splits))
|
||||
(splits #f))
|
||||
|
||||
@ -48,8 +48,8 @@
|
||||
(xaccQueryAddAccountMatch query
|
||||
currency-accounts
|
||||
QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS
|
||||
query #f end-date-tp #t end-date-tp QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT
|
||||
query #f end-date #t end-date QOF-QUERY-AND)
|
||||
|
||||
;; Get the query result, i.e. all splits in currency
|
||||
;; accounts.
|
||||
@ -89,23 +89,22 @@
|
||||
splits))
|
||||
|
||||
;; Returns a sorted list of all splits in the 'currency-accounts' up
|
||||
;; to 'end-date-tp' which have the 'commodity' and one other commodity
|
||||
;; to 'end-date' which have the 'commodity' and one other commodity
|
||||
;; involved. The splits are sorted by date.
|
||||
(define (gnc:get-match-commodity-splits-sorted currency-accounts
|
||||
end-date-tp
|
||||
end-date
|
||||
commodity)
|
||||
(sort (gnc:get-match-commodity-splits currency-accounts
|
||||
end-date-tp commodity)
|
||||
end-date commodity)
|
||||
(lambda (a b)
|
||||
(gnc:timepair-lt
|
||||
(gnc-transaction-get-date-posted (xaccSplitGetParent a))
|
||||
(gnc-transaction-get-date-posted (xaccSplitGetParent b))))))
|
||||
(< (xaccTransGetDate (xaccSplitGetParent a))
|
||||
(xaccTransGetDate (xaccSplitGetParent b))))))
|
||||
|
||||
|
||||
;; Returns a list of all splits in the currency-accounts up to
|
||||
;; end-date which have two *different* commodities involved.
|
||||
(define (gnc:get-all-commodity-splits currency-accounts end-date-tp)
|
||||
(gnc:get-match-commodity-splits currency-accounts end-date-tp #f))
|
||||
(define (gnc:get-all-commodity-splits currency-accounts end-date)
|
||||
(gnc:get-match-commodity-splits currency-accounts end-date #f))
|
||||
|
||||
|
||||
|
||||
@ -131,11 +130,11 @@
|
||||
|
||||
;; Create a list of all prices of 'price-commodity' measured in the
|
||||
;; currency 'report-currency'. The prices are taken from all splits in
|
||||
;; 'currency-accounts' up until the date 'end-date-tp'. Returns a list
|
||||
;; 'currency-accounts' up until the date 'end-date'. Returns a list
|
||||
;; of lists. Each listelement looks like the list (time price), where
|
||||
;; 'time' is the timepair when the <gnc:numeric*> 'price' was valid.
|
||||
;; 'time' is the time64 when the <gnc:numeric*> 'price' was valid.
|
||||
(define (gnc:get-commodity-totalavg-prices
|
||||
currency-accounts end-date-tp price-commodity report-currency)
|
||||
currency-accounts end-date price-commodity report-currency)
|
||||
(let ((total-foreign (gnc-numeric-zero))
|
||||
(total-domestic (gnc-numeric-zero)))
|
||||
(filter
|
||||
@ -150,7 +149,7 @@
|
||||
(xaccSplitGetAmount a)))
|
||||
(value-amount (gnc-numeric-abs
|
||||
(xaccSplitGetValue a)))
|
||||
(transaction-date (gnc-transaction-get-date-posted
|
||||
(transaction-date (xaccTransGetDate
|
||||
(xaccSplitGetParent a)))
|
||||
(foreignlist
|
||||
(if (gnc-commodity-equiv transaction-comm
|
||||
@ -213,7 +212,7 @@
|
||||
;; date.
|
||||
(gnc:get-match-commodity-splits-sorted
|
||||
currency-accounts
|
||||
end-date-tp price-commodity)))))
|
||||
end-date price-commodity)))))
|
||||
|
||||
;; Create a list of prices for all commodities in 'commodity-list',
|
||||
;; i.e. the same thing as in get-commodity-totalavg-prices but
|
||||
@ -221,7 +220,7 @@
|
||||
;; of the foreign-currency and the appropriate list from
|
||||
;; gnc:get-commodity-totalavg-prices, see there.
|
||||
(define (gnc:get-commoditylist-totalavg-prices
|
||||
commodity-list report-currency end-date-tp
|
||||
commodity-list report-currency end-date
|
||||
start-percent delta-percent)
|
||||
(let ((currency-accounts
|
||||
;;(filter gnc:account-has-shares?
|
||||
@ -238,17 +237,17 @@
|
||||
(+ start-percent (* delta-percent (/ work-done work-to-do)))))
|
||||
(cons c
|
||||
(gnc:get-commodity-totalavg-prices
|
||||
currency-accounts end-date-tp c report-currency))))
|
||||
currency-accounts end-date c report-currency))))
|
||||
commodity-list)))
|
||||
|
||||
;; Get the instantaneous prices for the 'price-commodity', measured in
|
||||
;; amounts of the 'report-currency'. The prices are taken from all
|
||||
;; splits in 'currency-accounts' up until the date
|
||||
;; 'end-date-tp'. Returns a list of lists. Each listelement looks like
|
||||
;; the list (time price), where 'time' is the timepair when the
|
||||
;; 'end-date'. Returns a list of lists. Each listelement looks like
|
||||
;; the list (time price), where 'time' is the time64 when the
|
||||
;; <gnc:numeric*> 'price' was valid.
|
||||
(define (gnc:get-commodity-inst-prices
|
||||
currency-accounts end-date-tp price-commodity report-currency)
|
||||
currency-accounts end-date price-commodity report-currency)
|
||||
;; go through all splits; convert all splits into a price.
|
||||
(filter
|
||||
gnc:price-is-not-zero?
|
||||
@ -262,7 +261,7 @@
|
||||
(xaccSplitGetAmount a)))
|
||||
(value-amount (gnc-numeric-abs
|
||||
(xaccSplitGetValue a)))
|
||||
(transaction-date (gnc-transaction-get-date-posted
|
||||
(transaction-date (xaccTransGetDate
|
||||
(xaccSplitGetParent a)))
|
||||
(foreignlist
|
||||
(if (gnc-commodity-equiv transaction-comm price-commodity)
|
||||
@ -314,7 +313,7 @@
|
||||
;; Get all the interesting splits, sorted by date.
|
||||
(gnc:get-match-commodity-splits-sorted
|
||||
currency-accounts
|
||||
end-date-tp price-commodity))))
|
||||
end-date price-commodity))))
|
||||
|
||||
;; Get the instantaneous prices for all commodities in
|
||||
;; 'commodity-list', i.e. the same thing as get-commodity-inst-prices
|
||||
@ -322,7 +321,7 @@
|
||||
;; consists of the foreign-currency and the appropriate list from
|
||||
;; gnc:get-commodity-inst-prices, see there.
|
||||
(define (gnc:get-commoditylist-inst-prices
|
||||
commodity-list report-currency end-date-tp
|
||||
commodity-list report-currency end-date
|
||||
start-percent delta-percent)
|
||||
(let ((currency-accounts
|
||||
;;(filter gnc:account-has-shares?
|
||||
@ -339,7 +338,7 @@
|
||||
(+ start-percent (* delta-percent (/ work-done work-to-do)))))
|
||||
(cons c
|
||||
(gnc:get-commodity-inst-prices
|
||||
currency-accounts end-date-tp c report-currency))))
|
||||
currency-accounts end-date c report-currency))))
|
||||
commodity-list)))
|
||||
|
||||
|
||||
@ -350,26 +349,26 @@
|
||||
(define (gnc:pricelist-price-find-nearest
|
||||
pricelist date)
|
||||
(let* ((later (find (lambda (p)
|
||||
(gnc:timepair-lt date (first p)))
|
||||
(< date (first p)))
|
||||
pricelist))
|
||||
(earlierlist (take-while
|
||||
(lambda (p)
|
||||
(gnc:timepair-ge date (first p)))
|
||||
(>= date (first p)))
|
||||
pricelist))
|
||||
(earlier (and (not (null? earlierlist))
|
||||
(last earlierlist))))
|
||||
;; (if earlier
|
||||
;; (warn "earlier"
|
||||
;; (gnc-print-date (first earlier))
|
||||
;; (qof-print-date (first earlier))
|
||||
;; (gnc-numeric-to-double (second earlier))))
|
||||
;; (if later
|
||||
;; (warn "later"
|
||||
;; (gnc-print-date (first later))
|
||||
;; (qof-print-date (first later))
|
||||
;; (gnc-numeric-to-double (second later))))
|
||||
|
||||
(if (and earlier later)
|
||||
(if (< (abs (gnc:timepair-delta date (first earlier)))
|
||||
(abs (gnc:timepair-delta date (first later))))
|
||||
(if (< (abs (- (first earlier) date))
|
||||
(abs (- (first later) date)))
|
||||
(second earlier)
|
||||
(second later))
|
||||
(or
|
||||
@ -827,7 +826,7 @@
|
||||
(gnc-pricedb-get-db (gnc-get-current-book))
|
||||
(gnc:gnc-monetary-amount foreign)
|
||||
(gnc:gnc-monetary-commodity foreign)
|
||||
domestic (timespecCanonicalDayTime date))))
|
||||
domestic (time64CanonicalDayTime date))))
|
||||
#f))
|
||||
|
||||
;; Exchange by the nearest price from pricelist. This function takes
|
||||
@ -868,18 +867,18 @@
|
||||
;; the value of 'source-option', whose possible values are set in
|
||||
;; gnc:options-add-price-source!.
|
||||
(define (gnc:case-exchange-fn
|
||||
source-option report-currency to-date-tp)
|
||||
source-option report-currency to-date)
|
||||
(case source-option
|
||||
((average-cost) (gnc:make-exchange-function
|
||||
(gnc:make-exchange-alist
|
||||
report-currency to-date-tp #t)))
|
||||
report-currency to-date #t)))
|
||||
((weighted-average) (gnc:make-exchange-function
|
||||
(gnc:make-exchange-alist
|
||||
report-currency to-date-tp #f)))
|
||||
report-currency to-date #f)))
|
||||
((pricedb-latest) gnc:exchange-by-pricedb-latest)
|
||||
((pricedb-nearest) (lambda (foreign domestic)
|
||||
(gnc:exchange-by-pricedb-nearest
|
||||
foreign domestic to-date-tp)))
|
||||
foreign domestic to-date)))
|
||||
(else
|
||||
(begin
|
||||
;; FIX-ME
|
||||
@ -892,7 +891,7 @@
|
||||
source-option " using pricedb-nearest.")
|
||||
(lambda (foreign domestic)
|
||||
(gnc:exchange-by-pricedb-nearest
|
||||
foreign domestic to-date-tp))))))
|
||||
foreign domestic to-date))))))
|
||||
|
||||
;; Return a ready-to-use function. Which one to use is determined by
|
||||
;; the value of 'source-option', whose possible values are set in
|
||||
@ -902,25 +901,25 @@
|
||||
;; section of the progress bar while running this function.
|
||||
;;
|
||||
(define (gnc:case-exchange-time-fn
|
||||
source-option report-currency commodity-list to-date-tp
|
||||
source-option report-currency commodity-list to-date
|
||||
start-percent delta-percent)
|
||||
(case source-option
|
||||
;; Make this the same as gnc:case-exchange-fn
|
||||
((average-cost) (let* ((exchange-fn (gnc:make-exchange-function
|
||||
(gnc:make-exchange-alist
|
||||
report-currency to-date-tp #t))))
|
||||
report-currency to-date #t))))
|
||||
(lambda (foreign domestic date)
|
||||
(exchange-fn foreign domestic))))
|
||||
((weighted-average) (let ((pricealist
|
||||
(gnc:get-commoditylist-totalavg-prices
|
||||
commodity-list report-currency to-date-tp
|
||||
commodity-list report-currency to-date
|
||||
start-percent delta-percent)))
|
||||
(lambda (foreign domestic date)
|
||||
(gnc:exchange-by-pricealist-nearest
|
||||
pricealist foreign domestic date))))
|
||||
((actual-transactions) (let ((pricealist
|
||||
(gnc:get-commoditylist-inst-prices
|
||||
commodity-list report-currency to-date-tp)))
|
||||
commodity-list report-currency to-date)))
|
||||
(lambda (foreign domestic date)
|
||||
(gnc:exchange-by-pricealist-nearest
|
||||
pricealist foreign domestic date))))
|
||||
@ -933,8 +932,7 @@
|
||||
source-option ". Using pricedb-nearest.")
|
||||
;; FIX-ME another hack to prevent report crashing when an
|
||||
;; unimplemented source-option comes through
|
||||
gnc:exchange-by-pricedb-nearest
|
||||
))))
|
||||
gnc:exchange-by-pricedb-nearest))))
|
||||
|
||||
|
||||
|
||||
@ -972,15 +970,10 @@
|
||||
;; returns #f instead of an actual
|
||||
;; <gnc:monetary>. Better to just return #f.
|
||||
(exchange-fn (gnc:make-gnc-monetary curr val)
|
||||
domestic))
|
||||
)
|
||||
)
|
||||
)
|
||||
domestic)))))
|
||||
#f)
|
||||
(balance 'getmonetary domestic #f)))
|
||||
(else #f)
|
||||
)
|
||||
)
|
||||
(else #f)))
|
||||
|
||||
;; As above, but adds only the commodities of other stocks and
|
||||
;; mutual-funds. Returns a commodity-collector, (not a <gnc:monetary>)
|
||||
@ -1019,13 +1012,8 @@
|
||||
(define (gnc:uniform-commodity? amt report-commodity)
|
||||
;; function to see if the commodity-collector amt
|
||||
;; contains any foreign commodities
|
||||
(let ((elts (gnc-commodity-collector-commodity-count amt))
|
||||
)
|
||||
(let ((elts (gnc-commodity-collector-commodity-count amt)))
|
||||
(or (equal? elts 0)
|
||||
(and (equal? elts 1)
|
||||
(gnc-commodity-collector-contains-commodity?
|
||||
amt report-commodity)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
amt report-commodity)))))
|
||||
|
@ -129,14 +129,14 @@
|
||||
;; sorting function. #f means to preform no sorting. the
|
||||
;; default sorting function is gnc:account-code-less-p.
|
||||
;;
|
||||
;; start-date: timepair
|
||||
;; start-date: time64
|
||||
;;
|
||||
;; the starting date of the reporting period over which to
|
||||
;; report balances for this account. if start-date is #f,
|
||||
;; will be no limit on how early a counted transaction may
|
||||
;; ocurr.
|
||||
;;
|
||||
;; end-date: timepair
|
||||
;; end-date: time64
|
||||
;;
|
||||
;; the ending date of the reporting period over which to
|
||||
;; report balances for this account. if end-date is #f, there
|
||||
@ -1164,8 +1164,7 @@
|
||||
)
|
||||
)))
|
||||
(gnc:html-table-set-style! table "table" 'attribute(list "style" "width:100%; max-width:20em") 'attribute (list "cellpadding" "0"))
|
||||
table)
|
||||
)
|
||||
table))
|
||||
|
||||
;;
|
||||
;; This function adds all the lines from a gnc:html-acct-table to a
|
||||
|
@ -90,15 +90,15 @@
|
||||
|
||||
(define (build-date-collector dates per-date-collector)
|
||||
(let* ((date-vector (list->vector dates))
|
||||
(slotset (make-slotset (lambda (split)
|
||||
(let* ((date (split->date split))
|
||||
(interval-index (binary-search-lt (lambda (pair date)
|
||||
(gnc:timepair-le (car pair) date))
|
||||
(cons date 0)
|
||||
date-vector))
|
||||
(interval (vector-ref date-vector interval-index)))
|
||||
interval))
|
||||
dates)))
|
||||
(slotset (make-slotset (lambda (split)
|
||||
(let* ((date (split->date split))
|
||||
(interval-index (binary-search-lt (lambda (pair date)
|
||||
(<= (car pair) date))
|
||||
date
|
||||
date-vector))
|
||||
(interval (vector-ref date-vector interval-index)))
|
||||
interval))
|
||||
dates)))
|
||||
(collector-from-slotset slotset per-date-collector)))
|
||||
|
||||
(define (build-category-by-account-collector account-destination-alist dates cell-accumulator result-collector)
|
||||
@ -131,16 +131,17 @@
|
||||
|
||||
;; Decide how to run the given report (but don't actually do any work)
|
||||
|
||||
(define (category-by-account-report-work do-intervals? datepairs account-alist
|
||||
split-collector result-collector)
|
||||
(let* ((dateinfo (if do-intervals? (category-report-dates-intervals datepairs)
|
||||
(category-report-dates-accumulate datepairs)))
|
||||
(processed-datepairs (third dateinfo))
|
||||
(splits-fn (lambda () (category-report-splits dateinfo account-alist)))
|
||||
(collector (collector-where (predicate-not split-closing?)
|
||||
(build-category-by-account-collector account-alist
|
||||
processed-datepairs split-collector
|
||||
result-collector))))
|
||||
(define (category-by-account-report-work do-intervals? dates account-alist
|
||||
split-collector result-collector)
|
||||
(let* ((dateinfo (if do-intervals?
|
||||
(category-report-dates-intervals dates)
|
||||
(category-report-dates-accumulate dates)))
|
||||
(processed-dates (third dateinfo))
|
||||
(splits-fn (lambda () (category-report-splits dateinfo account-alist)))
|
||||
(collector (collector-where (lambda (split) (not (split-closing? split)))
|
||||
(build-category-by-account-collector account-alist
|
||||
processed-dates split-collector
|
||||
result-collector))))
|
||||
(cons splits-fn collector)))
|
||||
|
||||
(define (category-report-splits dateinfo account-alist)
|
||||
@ -148,19 +149,19 @@
|
||||
(max-date (second dateinfo)))
|
||||
(splits-up-to (map car account-alist) min-date max-date)))
|
||||
|
||||
(define (category-report-dates-intervals datepairs)
|
||||
(let* ((min-date (car (list-min-max (map first datepairs) gnc:timepair-lt)))
|
||||
(max-date (cdr (list-min-max (map second datepairs) gnc:timepair-lt))))
|
||||
(list min-date max-date datepairs)))
|
||||
(define (category-report-dates-intervals dates)
|
||||
(let* ((min-date (car (list-min-max (map first dates) <)))
|
||||
(max-date (cdr (list-min-max (map second dates) <))))
|
||||
(list min-date max-date dates)))
|
||||
|
||||
(define (category-report-dates-accumulate dates)
|
||||
(let* ((min-date (decdate (car (list-min-max dates gnc:timepair-lt)) DayDelta))
|
||||
(max-date (cdr (list-min-max dates gnc:timepair-lt)))
|
||||
(datepairs (reverse! (cdr (fold (lambda (next acc)
|
||||
(let ((prev (car acc))
|
||||
(pairs-so-far (cdr acc)))
|
||||
(cons next (cons (list prev next) pairs-so-far))))
|
||||
(cons min-date '()) dates)))))
|
||||
(let* ((min-date (decdate (car (list-min-max dates <)) DayDelta))
|
||||
(max-date (cdr (list-min-max dates <)))
|
||||
(datepairs (reverse! (cdr (fold (lambda (next acc)
|
||||
(let ((prev (car acc))
|
||||
(pairs-so-far (cdr acc)))
|
||||
(cons next (cons (list prev next) pairs-so-far))))
|
||||
(cons min-date '()) dates)))))
|
||||
(list min-date max-date datepairs)))
|
||||
|
||||
|
||||
|
@ -489,7 +489,7 @@
|
||||
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
(xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS query #f date #t date QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT query #f date #t date QOF-QUERY-AND)
|
||||
(qof-query-set-sort-order query
|
||||
(list SPLIT-TRANS TRANS-DATE-POSTED)
|
||||
(list QUERY-DEFAULT-SORT)
|
||||
@ -529,9 +529,9 @@
|
||||
;; Build a query to find all splits between the indicated dates.
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
(xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS query
|
||||
(and start-date #t) start-date
|
||||
(and end-date #t) end-date
|
||||
(xaccQueryAddDateMatchTT query
|
||||
(and start-date #t) (if start-date start-date 0)
|
||||
(and end-date #t) (if end-date end-date 0)
|
||||
QOF-QUERY-AND)
|
||||
|
||||
;; Get the query results.
|
||||
@ -718,14 +718,13 @@
|
||||
;; the type is an alist '((str "match me") (cased #f) (regexp #f))
|
||||
;; If type is #f, sums all non-closing splits in the interval
|
||||
(define (gnc:account-get-trans-type-balance-interval
|
||||
account-list type start-date-tp end-date-tp)
|
||||
account-list type start-date end-date)
|
||||
(let* ((total (gnc:make-commodity-collector)))
|
||||
(map (lambda (split)
|
||||
(let* ((shares (xaccSplitGetAmount split))
|
||||
(acct-comm (xaccAccountGetCommodity
|
||||
(xaccSplitGetAccount split)))
|
||||
(txn (xaccSplitGetParent split))
|
||||
)
|
||||
(txn (xaccSplitGetParent split)))
|
||||
(if type
|
||||
(gnc-commodity-collector-add total acct-comm shares)
|
||||
(if (not (xaccTransGetIsClosingTxn txn))
|
||||
@ -733,7 +732,7 @@
|
||||
)))
|
||||
)
|
||||
(gnc:account-get-trans-type-splits-interval
|
||||
account-list type start-date-tp end-date-tp)
|
||||
account-list type start-date end-date)
|
||||
)
|
||||
total
|
||||
)
|
||||
@ -743,7 +742,7 @@
|
||||
;; the type is an alist '((str "match me") (cased #f) (regexp #f))
|
||||
;; If type is #f, sums all splits in the interval (even closing splits)
|
||||
(define (gnc:account-get-trans-type-balance-interval-with-closing
|
||||
account-list type start-date-tp end-date-tp)
|
||||
account-list type start-date end-date)
|
||||
(let* ((total (gnc:make-commodity-collector)))
|
||||
(map (lambda (split)
|
||||
(let* ((shares (xaccSplitGetAmount split))
|
||||
@ -754,7 +753,7 @@
|
||||
)
|
||||
)
|
||||
(gnc:account-get-trans-type-splits-interval
|
||||
account-list type start-date-tp end-date-tp)
|
||||
account-list type start-date end-date)
|
||||
)
|
||||
total
|
||||
)
|
||||
@ -763,7 +762,7 @@
|
||||
;; Filters the splits from the source to the target accounts
|
||||
;; returns a commodity collector
|
||||
;; does NOT do currency exchanges
|
||||
(define (gnc:account-get-total-flow direction target-account-list from-date-tp to-date-tp)
|
||||
(define (gnc:account-get-total-flow direction target-account-list from-date to-date)
|
||||
|
||||
(let* (
|
||||
(total-flow (gnc:make-commodity-collector))
|
||||
@ -784,11 +783,11 @@
|
||||
;; ----------------------------------------------------
|
||||
(let* (
|
||||
(transaction (xaccSplitGetParent target-account-split))
|
||||
(transaction-date-posted (gnc-transaction-get-date-posted transaction))
|
||||
(transaction-date-posted (xaccTransGetDate transaction))
|
||||
)
|
||||
(if (and
|
||||
(gnc:timepair-le transaction-date-posted to-date-tp)
|
||||
(gnc:timepair-ge transaction-date-posted from-date-tp)
|
||||
(<= transaction-date-posted to-date)
|
||||
(>= transaction-date-posted from-date)
|
||||
)
|
||||
;; -------------------------------------------------------------
|
||||
;; get the split information
|
||||
@ -830,7 +829,7 @@
|
||||
;; similar, but only counts transactions with non-negative shares and
|
||||
;; *ignores* any closing entries
|
||||
(define (gnc:account-get-pos-trans-total-interval
|
||||
account-list type start-date-tp end-date-tp)
|
||||
account-list type start-date end-date)
|
||||
(let* ((str-query (qof-query-create-for-splits))
|
||||
(sign-query (qof-query-create-for-splits))
|
||||
(total-query #f)
|
||||
@ -850,14 +849,16 @@
|
||||
(gnc:query-set-match-non-voids-only! sign-query (gnc-get-current-book))
|
||||
(xaccQueryAddAccountMatch str-query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddAccountMatch sign-query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS
|
||||
(xaccQueryAddDateMatchTT
|
||||
str-query
|
||||
(and start-date-tp #t) start-date-tp
|
||||
(and end-date-tp #t) end-date-tp QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS
|
||||
(and start-date #t) (if start-date start-date 0)
|
||||
(and end-date #t) (if end-date end-date 0)
|
||||
QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT
|
||||
sign-query
|
||||
(and start-date-tp #t) start-date-tp
|
||||
(and end-date-tp #t) end-date-tp QOF-QUERY-AND)
|
||||
(and start-date #t) (if start-date start-date 0)
|
||||
(and end-date #t) (if end-date end-date 0)
|
||||
QOF-QUERY-AND)
|
||||
(xaccQueryAddDescriptionMatch
|
||||
str-query matchstr case-sens regexp QOF-COMPARE-CONTAINS QOF-QUERY-AND)
|
||||
(set! total-query
|
||||
@ -885,9 +886,7 @@
|
||||
splits
|
||||
)
|
||||
(qof-query-destroy total-query)
|
||||
total
|
||||
)
|
||||
)
|
||||
total))
|
||||
|
||||
;; Return the splits that match an account list, date range, and (optionally) type
|
||||
;; where type is defined as an alist like:
|
||||
@ -898,7 +897,7 @@
|
||||
;; only non-closing transactions will be returned, and if it is omitted then both
|
||||
;; kinds of transactions will be returned.
|
||||
(define (gnc:account-get-trans-type-splits-interval
|
||||
account-list type start-date-tp end-date-tp)
|
||||
account-list type start-date end-date)
|
||||
(if (null? account-list)
|
||||
;; No accounts given. Return empty list.
|
||||
'()
|
||||
@ -917,10 +916,11 @@
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
(gnc:query-set-match-non-voids-only! query (gnc-get-current-book))
|
||||
(xaccQueryAddAccountMatch query account-list QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS
|
||||
(xaccQueryAddDateMatchTT
|
||||
query
|
||||
(and start-date-tp #t) start-date-tp
|
||||
(and end-date-tp #t) end-date-tp QOF-QUERY-AND)
|
||||
(and start-date #t) (if start-date start-date 0)
|
||||
(and end-date #t) (if end-date end-date 0)
|
||||
QOF-QUERY-AND)
|
||||
(if (or matchstr closing)
|
||||
(begin
|
||||
(set! query2 (qof-query-create-for-splits))
|
||||
|
@ -11,11 +11,10 @@
|
||||
(define (run-test)
|
||||
(test-account-get-trans-type-splits-interval))
|
||||
|
||||
(define (NDayDelta tp n)
|
||||
(define (NDayDelta t64 n)
|
||||
(let* ((day-secs (* 60 60 24 n)) ; n days in seconds is n times 60 sec/min * 60 min/h * 24 h/day
|
||||
(new-secs (- (car tp) day-secs))
|
||||
(new-tp (cons new-secs 0)))
|
||||
new-tp))
|
||||
(new-secs (- t64 day-secs)))
|
||||
new-secs))
|
||||
|
||||
(define (test-account-get-trans-type-splits-interval)
|
||||
(let* ((env (create-test-env))
|
||||
@ -23,11 +22,11 @@
|
||||
(test-day (tm:mday ts-now))
|
||||
(test-month (+ 1 (tm:mon ts-now)))
|
||||
(test-year (+ 1900 (tm:year ts-now)))
|
||||
(end-date-tp (gnc-dmy2timespec-neutral test-day test-month test-year))
|
||||
(start-date-tp (NDayDelta end-date-tp 10))
|
||||
(q-end-date-tp (gnc-dmy2timespec-end test-day test-month test-year))
|
||||
(q-start-date-tp (gnc-dmy2timespec test-day test-month test-year))
|
||||
(q-start-date-tp (NDayDelta q-start-date-tp 5)))
|
||||
(end-date (gnc-dmy2time64-neutral test-day test-month test-year))
|
||||
(start-date (NDayDelta end-date 10))
|
||||
(q-end-date (gnc-dmy2time64-end test-day test-month test-year))
|
||||
(q-start-date (gnc-dmy2time64 test-day test-month test-year))
|
||||
(q-start-date (NDayDelta q-start-date 5)))
|
||||
|
||||
(let* ((accounts (env-create-account-structure-alist env (list "Assets"
|
||||
(list (cons 'type ACCT-TYPE-ASSET))
|
||||
@ -36,10 +35,10 @@
|
||||
(bank-account (cdr (assoc "Bank Account" accounts)))
|
||||
(wallet (cdr (assoc "Wallet" accounts))))
|
||||
|
||||
(env-create-daily-transactions env start-date-tp end-date-tp bank-account wallet)
|
||||
(format #t "Created transactions for each day from ~a to ~a~%" (gnc-ctime (gnc:timepair->secs start-date-tp)) (gnc-ctime (gnc:timepair->secs end-date-tp)))
|
||||
(env-create-daily-transactions env start-date end-date bank-account wallet)
|
||||
(format #t "Created transactions for each day from ~a to ~a~%" (gnc-ctime start-date) (gnc-ctime end-date))
|
||||
(let ((splits (gnc:account-get-trans-type-splits-interval (list bank-account wallet)
|
||||
ACCT-TYPE-ASSET
|
||||
q-start-date-tp q-end-date-tp)))
|
||||
q-start-date q-end-date)))
|
||||
;; 10 is the right number (5 days, two splits per tx)
|
||||
(or (equal? 10 (length splits)) (begin (format #t "Fail, ~d splits, expected 10~%" (length splits)) #f))))))
|
||||
|
@ -367,11 +367,11 @@ balance at a given time"))
|
||||
(gnc:report-starting reportname)
|
||||
|
||||
;; Get all options
|
||||
(let ((to-date-tp (gnc:timepair-end-day-time
|
||||
(let ((to-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general optname-to-date))))
|
||||
(from-date-tp (if do-intervals?
|
||||
(gnc:timepair-start-day-time
|
||||
(from-date (if do-intervals?
|
||||
(gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date)))
|
||||
@ -421,13 +421,13 @@ balance at a given time"))
|
||||
(define (profit-fn account subaccts?)
|
||||
(if do-intervals?
|
||||
(gnc:account-get-comm-balance-interval
|
||||
account from-date-tp to-date-tp subaccts?)
|
||||
account from-date to-date subaccts?)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account to-date-tp subaccts?)))
|
||||
account to-date subaccts?)))
|
||||
|
||||
;; Define more helper variables.
|
||||
(let* ((exchange-fn (gnc:case-exchange-fn
|
||||
price-source report-currency to-date-tp))
|
||||
price-source report-currency to-date))
|
||||
(tree-depth (if (equal? account-levels 'all)
|
||||
(gnc:get-current-account-tree-depth)
|
||||
account-levels))
|
||||
@ -436,10 +436,9 @@ balance at a given time"))
|
||||
(if averaging-fraction-func
|
||||
;; Calculate the divisor of the amounts so that an
|
||||
;; average is shown
|
||||
(let* ((start-frac (averaging-fraction-func (gnc:timepair->secs from-date-tp)))
|
||||
(end-frac (averaging-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
|
||||
(diff (- end-frac start-frac))
|
||||
)
|
||||
(let* ((start-frac (averaging-fraction-func from-date))
|
||||
(end-frac (averaging-fraction-func (+ 1 to-date)))
|
||||
(diff (- end-frac start-frac)))
|
||||
;; Extra sanity check to ensure a positive number
|
||||
(if (> diff 0)
|
||||
(/ 1 diff)
|
||||
@ -567,11 +566,11 @@ balance at a given time"))
|
||||
(if do-intervals?
|
||||
(sprintf #f
|
||||
(_ "%s to %s")
|
||||
(gnc-print-date from-date-tp)
|
||||
(gnc-print-date to-date-tp))
|
||||
(qof-print-date from-date)
|
||||
(qof-print-date to-date))
|
||||
(sprintf #f
|
||||
(_ "Balance at %s")
|
||||
(gnc-print-date to-date-tp)))
|
||||
(qof-print-date to-date)))
|
||||
(if show-total?
|
||||
(let ((total (apply + (unzip1 combined))))
|
||||
(sprintf
|
||||
|
@ -161,9 +161,11 @@
|
||||
ACCT-TYPE-EQUITY ACCT-TYPE-INCOME ACCT-TYPE-EXPENSE)
|
||||
(gnc-account-get-descendants-sorted (gnc-get-current-root-account))))
|
||||
#f #t))
|
||||
|
||||
(gnc:options-add-account-levels!
|
||||
options gnc:pagename-accounts optname-depth-limit
|
||||
"b" opthelp-depth-limit 3)
|
||||
|
||||
(add-option
|
||||
(gnc:make-multichoice-option
|
||||
gnc:pagename-accounts optname-bottom-behavior
|
||||
@ -267,7 +269,7 @@
|
||||
(let* (
|
||||
(report-title (get-option gnc:pagename-general optname-report-title))
|
||||
(company-name (get-option gnc:pagename-general optname-party-name))
|
||||
(date-tp (gnc:timepair-end-day-time
|
||||
(report-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-date))))
|
||||
@ -320,12 +322,12 @@
|
||||
depth-limit))
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity date-tp))
|
||||
(gnc:case-exchange-fn price-source report-commodity report-date))
|
||||
)
|
||||
|
||||
(gnc:html-document-set-title!
|
||||
doc (string-append company-name " " report-title " "
|
||||
(gnc-print-date date-tp))
|
||||
(qof-print-date report-date))
|
||||
)
|
||||
|
||||
(if (null? accounts)
|
||||
@ -346,11 +348,11 @@
|
||||
(get-total-balance-fn
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account date-tp #f)))
|
||||
account report-date #f)))
|
||||
(table-env ;; parameters for :make-
|
||||
(list
|
||||
(list 'start-date #f)
|
||||
(list 'end-date date-tp)
|
||||
(list 'end-date report-date)
|
||||
(list 'display-tree-depth tree-depth)
|
||||
(list 'depth-limit-behavior bottom-behavior)
|
||||
(list 'report-commodity report-commodity)
|
||||
@ -501,8 +503,7 @@
|
||||
)
|
||||
|
||||
(gnc:report-finished)
|
||||
doc)
|
||||
)
|
||||
doc))
|
||||
|
||||
(gnc:define-report
|
||||
'version 1
|
||||
|
@ -535,11 +535,11 @@
|
||||
(gnc:report-percent-done (* 100 (/ work-done work-to-do)))
|
||||
|
||||
(let* ((parent (xaccSplitGetParent split))
|
||||
(txn-date (gnc-transaction-get-date-posted parent))
|
||||
(txn-date (xaccTransGetDate parent))
|
||||
(commod-currency (xaccTransGetCurrency parent))
|
||||
(commod-currency-frac (gnc-commodity-get-fraction commod-currency)))
|
||||
|
||||
(if (and (gnc:timepair-le txn-date to-date)
|
||||
(if (and (<= txn-date to-date)
|
||||
(not (assoc-ref seen_trans (gncTransGetGUID parent))))
|
||||
(let ((trans-income (gnc-numeric-zero))
|
||||
(trans-brokerage (gnc-numeric-zero))
|
||||
@ -828,9 +828,9 @@
|
||||
;; This is safe because xaccSplitGetAccount returns null for a null split
|
||||
(other-acct (xaccSplitGetAccount other-split))
|
||||
(parent (xaccSplitGetParent split))
|
||||
(txn-date (gnc-transaction-get-date-posted parent)))
|
||||
(txn-date (xaccTransGetDate parent)))
|
||||
(if (and (not (null? other-acct))
|
||||
(gnc:timepair-le txn-date to-date)
|
||||
(<= txn-date to-date)
|
||||
(string=? (xaccAccountGetName other-acct) account-name)
|
||||
(gnc-commodity-is-currency (xaccAccountGetCommodity other-acct)))
|
||||
;; This is a two split transaction where the other split is to an
|
||||
@ -1025,7 +1025,7 @@
|
||||
(gnc:html-document-set-title!
|
||||
document (string-append
|
||||
report-title
|
||||
(sprintf #f " %s" (gnc-print-date to-date))))
|
||||
(sprintf #f " %s" (qof-print-date to-date))))
|
||||
|
||||
(if (not (null? accounts))
|
||||
; at least 1 account selected
|
||||
@ -1039,8 +1039,8 @@
|
||||
domestic)))
|
||||
((pricedb-nearest)
|
||||
(lambda (foreign domestic date)
|
||||
(find-price (gnc-pricedb-lookup-nearest-in-time-any-currency
|
||||
pricedb foreign (timespecCanonicalDayTime date)) domestic)))))
|
||||
(find-price (gnc-pricedb-lookup-nearest-in-time-any-currency-t64
|
||||
pricedb foreign (time64CanonicalDayTime date)) domestic)))))
|
||||
(headercols (list (_ "Account")))
|
||||
(totalscols (list (gnc:make-html-table-cell/markup "total-label-cell" (_ "Total"))))
|
||||
(sum-total-moneyin (gnc-numeric-zero))
|
||||
|
@ -169,11 +169,11 @@
|
||||
gain-loss-accum)
|
||||
(set! data-rows
|
||||
(cons
|
||||
(list (gnc-print-date interval-start)
|
||||
(gnc-print-date interval-end)
|
||||
(list (qof-print-date interval-start)
|
||||
(qof-print-date interval-end)
|
||||
(/ (stats-accum 'total #f)
|
||||
(gnc:timepair-delta interval-start
|
||||
interval-end))
|
||||
(- interval-end
|
||||
interval-start))
|
||||
(minmax-accum 'getmax #f)
|
||||
(minmax-accum 'getmin #f)
|
||||
(gain-loss-accum 'debits #f)
|
||||
@ -213,9 +213,8 @@
|
||||
|
||||
|
||||
(define (update-stats split-amt split-time)
|
||||
(let ((time-difference (gnc:timepair-delta
|
||||
last-balance-time
|
||||
split-time)))
|
||||
(let ((time-difference (- split-time
|
||||
last-balance-time)))
|
||||
(stats-accum 'add (* last-balance time-difference))
|
||||
(set! last-balance (+ last-balance split-amt))
|
||||
(set! last-balance-time split-time)
|
||||
@ -223,15 +222,13 @@
|
||||
(gain-loss-accum 'add split-amt)))
|
||||
|
||||
(define (split-recurse)
|
||||
(if (or (null? splits) (gnc:timepair-gt
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccSplitGetParent
|
||||
(car splits))) to))
|
||||
(if (or (null? splits)
|
||||
(> (xaccTransGetDate (xaccSplitGetParent (car splits)))
|
||||
to))
|
||||
#f
|
||||
(let*
|
||||
((split (car splits))
|
||||
(split-time (gnc-transaction-get-date-posted
|
||||
(xaccSplitGetParent split)))
|
||||
(split-time (xaccTransGetDate (xaccSplitGetParent split)))
|
||||
;; FIXME: Which date should we use here? The 'to'
|
||||
;; date? the 'split-time'?
|
||||
(split-amt (get-split-value split split-time))
|
||||
@ -323,10 +320,10 @@
|
||||
(gnc:report-starting reportname)
|
||||
(let* ((report-title (get-option gnc:pagename-general
|
||||
gnc:optname-reportname))
|
||||
(begindate (gnc:timepair-start-day-time
|
||||
(begindate (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general optname-from-date))))
|
||||
(enddate (gnc:timepair-end-day-time
|
||||
(enddate (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general optname-to-date))))
|
||||
(stepsize (gnc:deltasym-to-delta (get-option gnc:pagename-general optname-stepsize)))
|
||||
@ -348,8 +345,8 @@
|
||||
(commodity-list #f)
|
||||
(exchange-fn #f)
|
||||
|
||||
(beforebegindate (gnc:timepair-end-day-time
|
||||
(gnc:timepair-previous-day begindate)))
|
||||
(beforebegindate (gnc:time64-end-day-time
|
||||
(gnc:time64-previous-day begindate)))
|
||||
(all-zeros? #t)
|
||||
;; startbal will be a commodity-collector
|
||||
(startbal '()))
|
||||
@ -423,7 +420,7 @@
|
||||
(xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
|
||||
;; match splits between start and end dates
|
||||
(xaccQueryAddDateMatchTS
|
||||
(xaccQueryAddDateMatchTT
|
||||
query #t begindate #t enddate QOF-QUERY-AND)
|
||||
(qof-query-set-sort-order query
|
||||
(list SPLIT-TRANS TRANS-DATE-POSTED)
|
||||
|
@ -294,11 +294,11 @@
|
||||
(let* (
|
||||
(report-title (get-option gnc:pagename-general optname-report-title))
|
||||
(company-name (get-option gnc:pagename-general optname-party-name))
|
||||
(date-tp (gnc:timepair-end-day-time
|
||||
(reportdate (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-date))))
|
||||
(date-secs (gnc:timepair->secs date-tp))
|
||||
(date-secs reportdate)
|
||||
(report-form? (get-option gnc:pagename-general
|
||||
optname-report-form))
|
||||
(standard-order? (get-option gnc:pagename-general
|
||||
@ -373,9 +373,8 @@
|
||||
(gnc:get-current-account-tree-depth)
|
||||
depth-limit))
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity date-tp))
|
||||
)
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity reportdate)))
|
||||
|
||||
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
|
||||
;; with the proper arguments.
|
||||
@ -452,7 +451,7 @@
|
||||
;;(gnc:warn "account names" liability-account-names)
|
||||
(gnc:html-document-set-title!
|
||||
doc (string-append company-name " " report-title " "
|
||||
(gnc-print-date date-tp))
|
||||
(qof-print-date reportdate))
|
||||
)
|
||||
|
||||
(if (null? accounts)
|
||||
@ -492,10 +491,10 @@
|
||||
(get-total-balance-fn
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account date-tp #f)))
|
||||
account reportdate #f)))
|
||||
(get-total-value-fn
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-value-at-date account date-tp #f)))
|
||||
(gnc:account-get-comm-value-at-date account reportdate #f)))
|
||||
)
|
||||
|
||||
;; If you ask me, any outstanding(TM) retained earnings and
|
||||
@ -544,12 +543,12 @@
|
||||
;; commodity trading accounts they will automatically accumulate the gains.
|
||||
(set! unrealized-gain-collector (gnc:make-commodity-collector))
|
||||
(if compute-unrealized-gains?
|
||||
(let ((asset-basis
|
||||
(gnc:accounts-get-comm-total-assets asset-accounts
|
||||
get-total-value-fn))
|
||||
(neg-liability-basis
|
||||
(gnc:accounts-get-comm-total-assets liability-accounts
|
||||
get-total-value-fn)))
|
||||
(let ((asset-basis (gnc:accounts-get-comm-total-assets
|
||||
asset-accounts
|
||||
get-total-value-fn))
|
||||
(neg-liability-basis (gnc:accounts-get-comm-total-assets
|
||||
liability-accounts
|
||||
get-total-value-fn)))
|
||||
;; Calculate unrealized gains from assets.
|
||||
(unrealized-gain-collector 'merge asset-balance #f)
|
||||
(unrealized-gain-collector 'minusmerge asset-basis #f)
|
||||
@ -590,7 +589,7 @@
|
||||
(set! table-env
|
||||
(list
|
||||
(list 'start-date #f)
|
||||
(list 'end-date date-tp)
|
||||
(list 'end-date reportdate)
|
||||
(list 'display-tree-depth tree-depth)
|
||||
(list 'depth-limit-behavior (if bottom-behavior
|
||||
'flatten
|
||||
@ -743,9 +742,7 @@
|
||||
|
||||
(gnc:report-finished)
|
||||
|
||||
doc
|
||||
)
|
||||
)
|
||||
doc))
|
||||
|
||||
(gnc:define-report
|
||||
'version 1
|
||||
|
@ -310,7 +310,7 @@
|
||||
(company-name (get-option gnc:pagename-general optname-party-name))
|
||||
(budget (get-option gnc:pagename-general optname-budget))
|
||||
(budget-valid? (and budget (not (null? budget))))
|
||||
(date-tp (if budget-valid? (gnc:budget-get-start-date budget) #f))
|
||||
(date-t64 (if budget-valid? (gnc:budget-get-start-date budget) #f))
|
||||
(report-form? (get-option gnc:pagename-general
|
||||
optname-report-form))
|
||||
(accounts (get-option gnc:pagename-accounts
|
||||
@ -379,7 +379,7 @@
|
||||
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity date-tp))
|
||||
(gnc:case-exchange-fn price-source report-commodity date-t64))
|
||||
)
|
||||
|
||||
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
|
||||
@ -652,7 +652,7 @@
|
||||
(
|
||||
(get-total-value-fn
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-value-at-date account date-tp #f)))
|
||||
(gnc:account-get-comm-value-at-date account date-t64 #f)))
|
||||
(asset-basis
|
||||
(gnc:accounts-get-comm-total-assets
|
||||
asset-accounts get-total-value-fn))
|
||||
|
@ -142,11 +142,9 @@
|
||||
;;
|
||||
;; Create bar and and values
|
||||
;;
|
||||
(define (gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-tp to-tp)
|
||||
(define (gnc:chart-create-budget-actual budget acct running-sum chart-type width height report-start-time report-end-time)
|
||||
(let* (
|
||||
(chart #f)
|
||||
(report-start-time (car from-tp))
|
||||
(report-end-time (car to-tp))
|
||||
)
|
||||
|
||||
(if (eqv? chart-type 'bars)
|
||||
@ -184,7 +182,6 @@
|
||||
(bgt-sum 0)
|
||||
(act-sum 0)
|
||||
(date (gnc-budget-get-period-start-date budget period))
|
||||
(period-start-time (car date))
|
||||
(bgt-vals '())
|
||||
(act-vals '())
|
||||
(date-iso-string-list '())
|
||||
@ -207,7 +204,7 @@
|
||||
(gnc-budget-get-account-period-actual-value budget acct period))))
|
||||
)
|
||||
)
|
||||
(if (<= report-start-time period-start-time)
|
||||
(if (<= report-start-time date)
|
||||
;; within reporting period, update the display lists
|
||||
(begin
|
||||
(if (not running-sum)
|
||||
@ -222,14 +219,13 @@
|
||||
)
|
||||
(set! bgt-vals (append bgt-vals (list bgt-sum)))
|
||||
(set! act-vals (append act-vals (list act-sum)))
|
||||
(set! date-iso-string-list (append date-iso-string-list (list (gnc-print-date date))))
|
||||
(set! date-iso-string-list (append date-iso-string-list (list (qof-print-date date))))
|
||||
)
|
||||
)
|
||||
;; prepare data for next loop repetition
|
||||
(set! period (+ period 1))
|
||||
(set! date (gnc-budget-get-period-start-date budget period))
|
||||
(set! period-start-time (car date))
|
||||
(if (< report-end-time period-start-time)
|
||||
(if (< report-end-time date)
|
||||
(set! period num-periods) ;; reporting period has ended, break the loop
|
||||
)
|
||||
)
|
||||
@ -320,10 +316,10 @@
|
||||
(report-title (get-option gnc:pagename-general
|
||||
gnc:optname-reportname))
|
||||
(document (gnc:make-html-document))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(from-date-t64 (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general optname-from-date))))
|
||||
(to-date-tp (gnc:timepair-end-day-time
|
||||
(to-date-t64 (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general optname-to-date))))
|
||||
)
|
||||
@ -358,7 +354,7 @@
|
||||
)
|
||||
(gnc:html-document-add-object!
|
||||
document
|
||||
(gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-date-tp to-date-tp)
|
||||
(gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-date-t64 to-date-t64)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -320,7 +320,7 @@
|
||||
(gnc:html-document-set-title!
|
||||
doc (sprintf #f (_ "%s: %s - %s")
|
||||
report-name (gnc-budget-get-name budget)
|
||||
(gnc-print-date (gnc-budget-get-period-start-date budget (- period 1)))))
|
||||
(qof-print-date (gnc-budget-get-period-start-date budget (- period 1)))))
|
||||
|
||||
;; Display accounts and totals
|
||||
(set! accounts-totals (gnc:html-table-add-budget-types! html-table split-up-accounts budget period exchange-fn report-currency))
|
||||
|
@ -350,7 +350,7 @@
|
||||
(if use-budget-period-range? (- user-budget-period-start 1) #f))
|
||||
(period-end
|
||||
(if use-budget-period-range? user-budget-period-end #f))
|
||||
(date-tp
|
||||
(date-t64
|
||||
(if budget-valid?
|
||||
(gnc-budget-get-period-start-date
|
||||
budget
|
||||
@ -416,7 +416,7 @@
|
||||
depth-limit))
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity date-tp))
|
||||
(gnc:case-exchange-fn price-source report-commodity date-t64))
|
||||
)
|
||||
|
||||
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
|
||||
|
@ -554,7 +554,7 @@
|
||||
(let* (
|
||||
(col-info (car col-list))
|
||||
(tc #f)
|
||||
(period-to-date-string (lambda (p) (gnc-print-date (gnc-budget-get-period-start-date budget p))))
|
||||
(period-to-date-string (lambda (p) (qof-print-date (gnc-budget-get-period-start-date budget p))))
|
||||
)
|
||||
(cond
|
||||
((equal? col-info 'total)
|
||||
@ -632,8 +632,8 @@
|
||||
(let* ((now (current-time))
|
||||
(total-periods (gnc-budget-get-num-periods budget) )
|
||||
(last-period (- total-periods 1))
|
||||
(period-start (lambda (x) (car (gnc-budget-get-period-start-date budget x))))
|
||||
(period-end (lambda (x) (car (gnc-budget-get-period-end-date budget x))))
|
||||
(period-start (lambda (x) (gnc-budget-get-period-start-date budget x)))
|
||||
(period-end (lambda (x) (gnc-budget-get-period-end-date budget x)))
|
||||
)
|
||||
(cond ((< now (period-start 0)) 1)
|
||||
((> now (period-end last-period)) total-periods)
|
||||
|
@ -143,18 +143,18 @@
|
||||
optname-show-rates))
|
||||
(show-full-names? (get-option gnc:pagename-general
|
||||
optname-show-full-names))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(from-date-t64 (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(to-date-tp (gnc:timepair-end-day-time
|
||||
(to-date-t64 (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
|
||||
;; calculate the exchange rates
|
||||
(exchange-fn (gnc:case-exchange-fn
|
||||
price-source report-currency to-date-tp))
|
||||
price-source report-currency to-date-t64))
|
||||
|
||||
(doc (gnc:make-html-document))
|
||||
(table (gnc:make-html-table))
|
||||
@ -162,10 +162,10 @@
|
||||
|
||||
(gnc:html-document-set-title!
|
||||
doc (string-append
|
||||
(get-option gnc:pagename-general gnc:optname-reportname)
|
||||
" - "
|
||||
(sprintf #f (_ "%s to %s")
|
||||
(gnc-print-date from-date-tp) (gnc-print-date to-date-tp))))
|
||||
(get-option gnc:pagename-general gnc:optname-reportname)
|
||||
" - "
|
||||
(sprintf #f (_ "%s to %s")
|
||||
(qof-print-date from-date-t64) (qof-print-date to-date-t64))))
|
||||
|
||||
|
||||
;; add subaccounts if requested
|
||||
@ -195,7 +195,7 @@
|
||||
;; nearest available exchange rate if that is what is specified
|
||||
(time-exchange-fn (gnc:case-exchange-time-fn
|
||||
price-source report-currency
|
||||
commodity-list to-date-tp
|
||||
commodity-list to-date-t64
|
||||
0 0)))
|
||||
|
||||
;; Helper function to convert currencies
|
||||
@ -208,8 +208,8 @@
|
||||
|
||||
(let ((result (cash-flow-calc-money-in-out
|
||||
(list (cons 'accounts accounts)
|
||||
(cons 'to-date-tp to-date-tp)
|
||||
(cons 'from-date-tp from-date-tp)
|
||||
(cons 'to-date-t64 to-date-t64)
|
||||
(cons 'from-date-t64 from-date-t64)
|
||||
(cons 'report-currency report-currency)
|
||||
(cons 'include-trading-accounts include-trading-accounts)
|
||||
(cons 'to-report-currency to-report-currency)))))
|
||||
@ -391,8 +391,8 @@
|
||||
;; function to add inflow and outflow of money
|
||||
(define (cash-flow-calc-money-in-out settings)
|
||||
(let* ((accounts (cdr (assq 'accounts settings)))
|
||||
(to-date-tp (cdr (assq 'to-date-tp settings)))
|
||||
(from-date-tp (cdr (assq 'from-date-tp settings)))
|
||||
(to-date-t64 (cdr (assq 'to-date-t64 settings)))
|
||||
(from-date-t64 (cdr (assq 'from-date-t64 settings)))
|
||||
(report-currency (cdr (assq 'report-currency settings)))
|
||||
(include-trading-accounts (cdr (assq 'include-trading-accounts settings)))
|
||||
(to-report-currency (cdr (assq 'to-report-currency settings)))
|
||||
@ -407,7 +407,7 @@
|
||||
(money-out-hash (make-hash-table))
|
||||
(money-out-collector (gnc:make-commodity-collector))
|
||||
|
||||
(all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-tp to-date-tp))
|
||||
(all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-t64 to-date-t64))
|
||||
(splits-to-do (length all-splits))
|
||||
(splits-seen-table (make-hash-table))
|
||||
(work-done 0))
|
||||
@ -423,8 +423,8 @@
|
||||
(if (= (modulo work-done 100) 0)
|
||||
(gnc:report-percent-done (* 85 (/ work-done splits-to-do))))
|
||||
(let ((parent (xaccSplitGetParent split)))
|
||||
(if (and (gnc:timepair-le (gnc-transaction-get-date-posted parent) to-date-tp)
|
||||
(gnc:timepair-ge (gnc-transaction-get-date-posted parent) from-date-tp))
|
||||
(if (and (<= (xaccTransGetDate parent) to-date-t64)
|
||||
(>= (xaccTransGetDate parent) from-date-t64))
|
||||
(let* ((parent-description (xaccTransGetDescription parent))
|
||||
(parent-currency (xaccTransGetCurrency parent)))
|
||||
(gnc:debug parent-description
|
||||
@ -467,7 +467,7 @@
|
||||
)
|
||||
(let ((s-report-value (to-report-currency parent-currency
|
||||
(gnc-numeric-neg s-value)
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccTransGetDate
|
||||
parent))))
|
||||
(money-in-collector 'add report-currency s-report-value)
|
||||
(s-account-in-collector 'add report-currency s-report-value))
|
||||
@ -487,7 +487,7 @@
|
||||
)
|
||||
(let ((s-report-value (to-report-currency parent-currency
|
||||
s-value
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccTransGetDate
|
||||
parent))))
|
||||
(money-out-collector 'add report-currency s-report-value)
|
||||
(s-account-out-collector 'add report-currency s-report-value))
|
||||
|
@ -163,18 +163,18 @@
|
||||
optname-report-currency))
|
||||
(price-source (get-option gnc:pagename-general
|
||||
optname-price-source))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(to-date-tp (gnc:timepair-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
(from-date-t64 (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(to-date-t64 (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
|
||||
;; calculate the exchange rates
|
||||
(exchange-fn (gnc:case-exchange-fn
|
||||
price-source report-currency to-date-tp))
|
||||
price-source report-currency to-date-t64))
|
||||
|
||||
(interval (get-option gnc:pagename-general optname-stepsize))
|
||||
(show-in? (get-option gnc:pagename-display optname-show-in))
|
||||
@ -185,8 +185,8 @@
|
||||
(width (get-option gnc:pagename-display optname-plot-width))
|
||||
|
||||
(dates-list (gnc:make-date-interval-list
|
||||
(gnc:timepair-start-day-time from-date-tp)
|
||||
(gnc:timepair-end-day-time to-date-tp)
|
||||
(gnc:time64-start-day-time from-date-t64)
|
||||
(gnc:time64-end-day-time to-date-t64)
|
||||
(gnc:deltasym-to-delta interval)))
|
||||
(report-title (get-option gnc:pagename-general
|
||||
gnc:optname-reportname))
|
||||
@ -216,10 +216,10 @@
|
||||
;; nearest available exchange rate if that is what is specified
|
||||
(time-exchange-fn (gnc:case-exchange-time-fn
|
||||
price-source report-currency
|
||||
commodity-list to-date-tp
|
||||
commodity-list to-date-t64
|
||||
0 0))
|
||||
(date-string-list (map (lambda (date-list-item) ; date-list-item is (start . end)
|
||||
(gnc-print-date (car date-list-item)))
|
||||
(qof-print-date (car date-list-item)))
|
||||
dates-list))
|
||||
(results-by-date '())
|
||||
(in-list '())
|
||||
@ -270,8 +270,8 @@
|
||||
(set! work-done (+ 1 work-done))
|
||||
(gnc:report-percent-done (* 80 (/ work-done work-to-do)))
|
||||
(let* ((settings (list (cons 'accounts accounts)
|
||||
(cons 'to-date-tp (second date-pair))
|
||||
(cons 'from-date-tp (first date-pair))
|
||||
(cons 'to-date-t64 (second date-pair))
|
||||
(cons 'from-date-t64 (first date-pair))
|
||||
(cons 'report-currency report-currency)
|
||||
(cons 'include-trading-accounts include-trading-accounts)
|
||||
(cons 'to-report-currency to-report-currency)))
|
||||
@ -311,8 +311,8 @@
|
||||
(gnc:html-barchart-set-subtitle!
|
||||
chart (sprintf #f
|
||||
(_ "%s to %s")
|
||||
(gnc-print-date from-date-tp)
|
||||
(gnc-print-date to-date-tp)))
|
||||
(qof-print-date from-date-t64)
|
||||
(qof-print-date to-date-t64)))
|
||||
(gnc:html-barchart-set-width! chart width)
|
||||
(gnc:html-barchart-set-height! chart height)
|
||||
(gnc:html-barchart-set-row-labels! chart date-string-list)
|
||||
@ -398,8 +398,8 @@
|
||||
;; function to add inflow and outflow of money
|
||||
(define (cashflow-barchart-calc-money-in-out settings)
|
||||
(let* ((accounts (cdr (assq 'accounts settings)))
|
||||
(to-date-tp (cdr (assq 'to-date-tp settings)))
|
||||
(from-date-tp (cdr (assq 'from-date-tp settings)))
|
||||
(to-date-t64 (cdr (assq 'to-date-t64 settings)))
|
||||
(from-date-t64 (cdr (assq 'from-date-t64 settings)))
|
||||
(report-currency (cdr (assq 'report-currency settings)))
|
||||
(include-trading-accounts (cdr (assq 'include-trading-accounts settings)))
|
||||
(to-report-currency (cdr (assq 'to-report-currency settings)))
|
||||
@ -414,7 +414,7 @@
|
||||
(money-out-hash (make-hash-table))
|
||||
(money-out-collector (gnc:make-commodity-collector))
|
||||
|
||||
(all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-tp to-date-tp))
|
||||
(all-splits (gnc:account-get-trans-type-splits-interval accounts '() from-date-t64 to-date-t64))
|
||||
(splits-seen-table (make-hash-table)))
|
||||
|
||||
(define (split-seen? split)
|
||||
@ -425,8 +425,8 @@
|
||||
|
||||
(define (work-per-split split)
|
||||
(let ((parent (xaccSplitGetParent split)))
|
||||
(if (and (gnc:timepair-le (gnc-transaction-get-date-posted parent) to-date-tp)
|
||||
(gnc:timepair-ge (gnc-transaction-get-date-posted parent) from-date-tp))
|
||||
(if (and (<= (xaccTransGetDate parent) to-date-t64)
|
||||
(>= (xaccTransGetDate parent) from-date-t64))
|
||||
(let* ((parent-description (xaccTransGetDescription parent))
|
||||
(parent-currency (xaccTransGetCurrency parent)))
|
||||
;(gnc:debug parent-description
|
||||
@ -469,7 +469,7 @@
|
||||
)
|
||||
(let ((s-report-value (to-report-currency parent-currency
|
||||
(gnc-numeric-neg s-value)
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccTransGetDate
|
||||
parent))))
|
||||
(money-in-collector 'add report-currency s-report-value)
|
||||
(s-account-in-collector 'add report-currency s-report-value))
|
||||
@ -489,7 +489,7 @@
|
||||
)
|
||||
(let ((s-report-value (to-report-currency parent-currency
|
||||
s-value
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccTransGetDate
|
||||
parent))))
|
||||
(money-out-collector 'add report-currency s-report-value)
|
||||
(s-account-out-collector 'add report-currency s-report-value))
|
||||
|
@ -237,14 +237,14 @@ developing over time"))
|
||||
(gnc:report-options report-obj) section name)))
|
||||
|
||||
(gnc:report-starting reportname)
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(let* ((to-date-t64 (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
optname-to-date))))
|
||||
(from-date-t64 (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(interval (get-option gnc:pagename-general optname-stepsize))
|
||||
(report-currency (get-option gnc:pagename-general
|
||||
optname-report-currency))
|
||||
@ -312,14 +312,14 @@ developing over time"))
|
||||
(if averaging-fraction-func
|
||||
;; Calculate the divisor of the amounts so that an
|
||||
;; average is shown. Multiplier factor is a gnc-numeric
|
||||
(let* ((start-frac-avg (averaging-fraction-func (gnc:timepair->secs from-date-tp)))
|
||||
(end-frac-avg (averaging-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
|
||||
(let* ((start-frac-avg (averaging-fraction-func from-date-t64))
|
||||
(end-frac-avg (averaging-fraction-func (+ 1 to-date-t64)))
|
||||
(diff-avg (- end-frac-avg start-frac-avg))
|
||||
(diff-avg-numeric (/
|
||||
(inexact->exact (round (* diff-avg 1000000))) ; 6 decimals precision
|
||||
1000000))
|
||||
(start-frac-int (interval-fraction-func (gnc:timepair->secs from-date-tp)))
|
||||
(end-frac-int (interval-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
|
||||
(start-frac-int (interval-fraction-func from-date-t64))
|
||||
(end-frac-int (interval-fraction-func (+ 1 to-date-t64)))
|
||||
(diff-int (- end-frac-int start-frac-int))
|
||||
(diff-int-numeric (/
|
||||
(inexact->exact diff-int) 1))
|
||||
@ -341,12 +341,12 @@ developing over time"))
|
||||
;; This is the list of date intervals to calculate.
|
||||
(dates-list (if do-intervals?
|
||||
(gnc:make-date-interval-list
|
||||
(gnc:timepair-start-day-time from-date-tp)
|
||||
(gnc:timepair-end-day-time to-date-tp)
|
||||
(gnc:time64-start-day-time from-date-t64)
|
||||
(gnc:time64-end-day-time to-date-t64)
|
||||
(gnc:deltasym-to-delta interval))
|
||||
(gnc:make-date-list
|
||||
(gnc:timepair-end-day-time from-date-tp)
|
||||
(gnc:timepair-end-day-time to-date-tp)
|
||||
(gnc:time64-end-day-time from-date-t64)
|
||||
(gnc:time64-end-day-time to-date-t64)
|
||||
(gnc:deltasym-to-delta interval))))
|
||||
;; Here the date strings for the x-axis labels are
|
||||
;; created.
|
||||
@ -358,7 +358,7 @@ developing over time"))
|
||||
|
||||
(define (datelist->stringlist dates-list)
|
||||
(map (lambda (date-list-item)
|
||||
(gnc-print-date
|
||||
(qof-print-date
|
||||
(if do-intervals?
|
||||
(car date-list-item)
|
||||
date-list-item)))
|
||||
@ -370,7 +370,7 @@ developing over time"))
|
||||
;; instead of division to avoid division-by-zero issues) in case
|
||||
;; the user wants to see the amounts averaged over some value.
|
||||
(define (collector->monetary c date)
|
||||
(if (not (gnc:timepair? date))
|
||||
(if (not (number? date))
|
||||
(throw 'wrong))
|
||||
(gnc:make-gnc-monetary
|
||||
report-currency
|
||||
@ -480,7 +480,7 @@ developing over time"))
|
||||
report-currency))
|
||||
(set! exchange-fn (gnc:case-exchange-time-fn
|
||||
price-source report-currency
|
||||
commodity-list to-date-tp
|
||||
commodity-list to-date-t64
|
||||
5 15))
|
||||
|
||||
;; Sort the account list according to the account code field.
|
||||
@ -536,8 +536,8 @@ developing over time"))
|
||||
(if do-intervals?
|
||||
(_ "%s to %s")
|
||||
(_ "Balances %s to %s"))
|
||||
(jqplot-escape-string (gnc-print-date from-date-tp))
|
||||
(jqplot-escape-string (gnc-print-date to-date-tp))))
|
||||
(jqplot-escape-string (qof-print-date from-date-t64))
|
||||
(jqplot-escape-string (qof-print-date to-date-t64))))
|
||||
|
||||
(gnc:html-barchart-set-width! chart width)
|
||||
(gnc:html-barchart-set-height! chart height)
|
||||
@ -562,8 +562,8 @@ developing over time"))
|
||||
(if do-intervals?
|
||||
(_ "%s to %s")
|
||||
(_ "Balances %s to %s"))
|
||||
(jqplot-escape-string (gnc-print-date from-date-tp))
|
||||
(jqplot-escape-string (gnc-print-date to-date-tp))))
|
||||
(jqplot-escape-string (qof-print-date from-date-t64))
|
||||
(jqplot-escape-string (qof-print-date to-date-t64))))
|
||||
|
||||
(gnc:html-linechart-set-width! chart width)
|
||||
(gnc:html-linechart-set-height! chart height)
|
||||
|
@ -2,6 +2,7 @@
|
||||
;; daily-reports.scm: reports based on the day of the week
|
||||
;;
|
||||
;; Copyright (C) 2003, Andy Wingo <wingo at pobox dot com>
|
||||
;; Christopher Lam upgrade to time64 (2017)
|
||||
;;
|
||||
;; based on account-piecharts.scm by Robert Merkel (rgmerk@mira.net)
|
||||
;; and Christian Stimming <stimming@tu-harburg.de> with
|
||||
@ -154,8 +155,8 @@
|
||||
(list interval-start
|
||||
interval-end
|
||||
(/ (stats-accum 'total #f)
|
||||
(gnc:timepair-delta interval-start
|
||||
interval-end))
|
||||
(- interval-end
|
||||
interval-start))
|
||||
(minmax-accum 'getmax #f)
|
||||
(minmax-accum 'getmin #f)
|
||||
(gain-loss-accum 'debits #f)
|
||||
@ -195,9 +196,8 @@
|
||||
|
||||
|
||||
(define (update-stats split-amt split-time)
|
||||
(let ((time-difference (gnc:timepair-delta
|
||||
last-balance-time
|
||||
split-time)))
|
||||
(let ((time-difference (- split-time
|
||||
last-balance-time)))
|
||||
(stats-accum 'add (* last-balance time-difference))
|
||||
(set! last-balance (+ last-balance split-amt))
|
||||
(set! last-balance-time split-time)
|
||||
@ -205,15 +205,13 @@
|
||||
(gain-loss-accum 'add split-amt)))
|
||||
|
||||
(define (split-recurse)
|
||||
(if (or (null? splits) (gnc:timepair-gt
|
||||
(gnc-transaction-get-date-posted
|
||||
(xaccSplitGetParent
|
||||
(car splits))) to))
|
||||
(if (or (null? splits)
|
||||
(> (xaccTransGetDate (xaccSplitGetParent (car splits)))
|
||||
to))
|
||||
#f
|
||||
(let*
|
||||
((split (car splits))
|
||||
(split-time (gnc-transaction-get-date-posted
|
||||
(xaccSplitGetParent split)))
|
||||
(split-time (xaccTransGetDate (xaccSplitGetParent split)))
|
||||
;; FIXME: Which date should we use here? The 'to'
|
||||
;; date? the 'split-time'?
|
||||
(split-amt (get-split-value split split-time)))
|
||||
@ -225,7 +223,7 @@
|
||||
; (gnc:debug "splits " splits)
|
||||
(update-stats split-amt split-time)
|
||||
(set! splits (cdr splits))
|
||||
(split-recurse))))
|
||||
(split-recurse))))
|
||||
|
||||
; the minmax accumulator
|
||||
|
||||
@ -237,16 +235,14 @@
|
||||
;; insert a null transaction at the end of the interval
|
||||
(update-stats 0.0 to)
|
||||
(list minmax-accum stats-accum gain-loss-accum last-balance splits)))
|
||||
|
||||
|
||||
|
||||
(for-each
|
||||
(lambda (interval)
|
||||
(let*
|
||||
|
||||
((interval-results
|
||||
(process-interval
|
||||
splits
|
||||
(car interval)
|
||||
(let*
|
||||
((interval-results
|
||||
(process-interval
|
||||
splits
|
||||
(car interval)
|
||||
(cadr interval)
|
||||
start-bal-double))
|
||||
(min-max-accum (car interval-results))
|
||||
@ -261,8 +257,7 @@
|
||||
(cadr interval)
|
||||
stats-accum
|
||||
min-max-accum gain-loss-accum)))
|
||||
interval-list)
|
||||
|
||||
interval-list)
|
||||
|
||||
(reverse data-rows)))
|
||||
|
||||
@ -283,10 +278,10 @@
|
||||
(gnc:report-starting reportname)
|
||||
|
||||
;; Get all options
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(let* ((to-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general optname-to-date))))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(from-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
@ -308,8 +303,8 @@
|
||||
(exchange-fn #f)
|
||||
(print-info (gnc-commodity-print-info report-currency #t))
|
||||
|
||||
(beforebegindate (gnc:timepair-end-day-time
|
||||
(gnc:timepair-previous-day from-date-tp)))
|
||||
(beforebegindate (gnc:time64-end-day-time
|
||||
(gnc:time64-previous-day from-date)))
|
||||
(document (gnc:make-html-document))
|
||||
(chart (gnc:make-html-piechart))
|
||||
(topl-accounts (gnc:filter-accountlist-type
|
||||
@ -372,7 +367,7 @@
|
||||
(gnc:report-percent-done 5)
|
||||
(set! exchange-fn (gnc:case-exchange-time-fn
|
||||
price-source report-currency
|
||||
commodity-list to-date-tp
|
||||
commodity-list to-date
|
||||
5 20))
|
||||
(gnc:report-percent-done 20)
|
||||
|
||||
@ -406,8 +401,8 @@
|
||||
(xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
|
||||
;; match splits between start and end dates
|
||||
(xaccQueryAddDateMatchTS
|
||||
query #t from-date-tp #t to-date-tp QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT
|
||||
query #t from-date #t to-date QOF-QUERY-AND)
|
||||
(qof-query-set-sort-order query
|
||||
(list SPLIT-TRANS TRANS-DATE-POSTED)
|
||||
(list QUERY-DEFAULT-SORT)
|
||||
@ -438,7 +433,7 @@
|
||||
|
||||
;; and analyze the data
|
||||
(set! data (analyze-splits splits startbal
|
||||
from-date-tp to-date-tp
|
||||
from-date to-date
|
||||
DayDelta monetary->double))
|
||||
(gnc:report-percent-done 70)
|
||||
|
||||
@ -448,7 +443,7 @@
|
||||
|
||||
(for-each
|
||||
(lambda (split)
|
||||
(let ((k (modulo (- (gnc:timepair-get-week-day
|
||||
(let ((k (modulo (- (gnc:time64-get-week-day
|
||||
(list-ref split 1)) 1) 7))) ; end-date
|
||||
(list-set! daily-totals k
|
||||
(+ (list-ref daily-totals k)
|
||||
@ -482,8 +477,8 @@
|
||||
chart (string-append
|
||||
(sprintf #f
|
||||
(_ "%s to %s")
|
||||
(gnc-print-date from-date-tp)
|
||||
(gnc-print-date to-date-tp))
|
||||
(qof-print-date from-date)
|
||||
(qof-print-date to-date))
|
||||
(if show-total?
|
||||
(let ((total (apply + daily-totals)))
|
||||
(sprintf
|
||||
|
@ -207,9 +207,9 @@
|
||||
(start-date-printable (gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-start-date)))
|
||||
(start-date-tp (gnc:timepair-end-day-time
|
||||
(gnc:timepair-previous-day start-date-printable)))
|
||||
(end-date-tp (gnc:timepair-end-day-time
|
||||
(start-date (gnc:time64-end-day-time
|
||||
(gnc:time64-previous-day start-date-printable)))
|
||||
(end-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-end-date))))
|
||||
@ -270,10 +270,10 @@
|
||||
;; exchange rates calculation parameters
|
||||
(start-exchange-fn
|
||||
(gnc:case-exchange-fn
|
||||
price-source report-commodity start-date-tp))
|
||||
price-source report-commodity start-date))
|
||||
(end-exchange-fn
|
||||
(gnc:case-exchange-fn
|
||||
price-source report-commodity end-date-tp))
|
||||
price-source report-commodity end-date))
|
||||
)
|
||||
|
||||
(gnc:html-document-set-title!
|
||||
@ -281,8 +281,8 @@
|
||||
(string-append "%s %s "
|
||||
(_ "For Period Covering %s to %s"))
|
||||
company-name report-title
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp)))
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date)))
|
||||
|
||||
(if (null? accounts)
|
||||
|
||||
@ -336,17 +336,17 @@
|
||||
(get-start-balance-fn
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account start-date-tp #f)))
|
||||
account start-date #f)))
|
||||
(get-end-balance-fn
|
||||
(lambda (account)
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
account end-date-tp #f)))
|
||||
account end-date #f)))
|
||||
(terse-period? #t)
|
||||
(period-for (if terse-period?
|
||||
(string-append " " (_ "for Period"))
|
||||
(sprintf #f (string-append ", " (_ "%s to %s"))
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp))
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date))
|
||||
))
|
||||
)
|
||||
|
||||
@ -396,11 +396,11 @@
|
||||
;; equity constitutes an unrealized loss. I'm unsure about
|
||||
;; that though....
|
||||
;;
|
||||
(define (unrealized-gains-at-date book-balance exchange-fn date-tp)
|
||||
(define (unrealized-gains-at-date book-balance exchange-fn date)
|
||||
(let* ((unrealized-gain-collector (gnc:make-commodity-collector))
|
||||
(weighted-fn
|
||||
(gnc:case-exchange-fn 'weighted-average
|
||||
report-commodity date-tp))
|
||||
report-commodity date))
|
||||
|
||||
(value
|
||||
(gnc:gnc-monetary-amount
|
||||
@ -445,10 +445,10 @@
|
||||
;; start and end retained earnings (income - expenses)
|
||||
(set! neg-pre-start-retained-earnings
|
||||
(gnc:accountlist-get-comm-balance-at-date-with-closing
|
||||
income-expense-accounts start-date-tp)) ; OK
|
||||
income-expense-accounts start-date)) ; OK
|
||||
(set! neg-pre-end-retained-earnings
|
||||
(gnc:accountlist-get-comm-balance-at-date-with-closing
|
||||
income-expense-accounts end-date-tp)) ; OK
|
||||
income-expense-accounts end-date)) ; OK
|
||||
;; neg-pre-end-retained-earnings is not used to calculate
|
||||
;; profit but is used to calculate unrealized gains
|
||||
|
||||
@ -457,13 +457,13 @@
|
||||
(set! income-expense-closing
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
income-expense-accounts closing-pattern
|
||||
start-date-tp end-date-tp)
|
||||
start-date end-date)
|
||||
)
|
||||
;; find retained earnings for the period
|
||||
(set! neg-net-income
|
||||
(gnc:accountlist-get-comm-balance-interval-with-closing
|
||||
income-expense-accounts
|
||||
start-date-tp end-date-tp)) ; OK
|
||||
start-date end-date)) ; OK
|
||||
;; revert the income/expense to its pre-closing balance
|
||||
(neg-net-income 'minusmerge income-expense-closing #f)
|
||||
(set! net-income (gnc:make-commodity-collector))
|
||||
@ -502,7 +502,7 @@
|
||||
(set! start-unrealized-gains
|
||||
(unrealized-gains-at-date start-book-balance
|
||||
start-exchange-fn
|
||||
start-date-tp)) ; OK
|
||||
start-date)) ; OK
|
||||
;; I suspect that unrealized gains (since never realized)
|
||||
;; must be counted from forever-ago....
|
||||
;; ...yep, this appears to be correct.
|
||||
@ -510,7 +510,7 @@
|
||||
(set! end-unrealized-gains
|
||||
(unrealized-gains-at-date end-book-balance
|
||||
end-exchange-fn
|
||||
end-date-tp)) ; OK
|
||||
end-date)) ; OK
|
||||
|
||||
;; unrealized gains accrued during the reporting period...
|
||||
(set! net-unrealized-gains (gnc:make-commodity-collector))
|
||||
@ -534,7 +534,7 @@
|
||||
(set! equity-closing
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
equity-accounts closing-pattern
|
||||
start-date-tp end-date-tp)
|
||||
start-date end-date)
|
||||
)
|
||||
(set! neg-pre-closing-equity (gnc:make-commodity-collector))
|
||||
(neg-pre-closing-equity 'merge neg-end-equity-balance #f)
|
||||
@ -544,7 +544,7 @@
|
||||
(net-investment 'minusmerge neg-pre-closing-equity #f);; > 0
|
||||
(net-investment 'merge neg-start-equity-balance #f) ;; net increase
|
||||
|
||||
(set! withdrawals (gnc:account-get-total-flow 'in equity-accounts start-date-tp end-date-tp))
|
||||
(set! withdrawals (gnc:account-get-total-flow 'in equity-accounts start-date end-date))
|
||||
|
||||
(set! investments (gnc:make-commodity-collector))
|
||||
(investments 'merge net-investment #f)
|
||||
@ -584,7 +584,7 @@
|
||||
(report-line
|
||||
build-table
|
||||
(string-append (_ "Capital") ", "
|
||||
(gnc-print-date start-date-printable))
|
||||
(qof-print-date start-date-printable))
|
||||
#f start-total-equity
|
||||
1 start-exchange-fn #f "primary-subheading"
|
||||
)
|
||||
@ -628,7 +628,7 @@
|
||||
(report-line
|
||||
build-table
|
||||
(string-append (_ "Capital") ", "
|
||||
(gnc-print-date end-date-tp))
|
||||
(qof-print-date end-date))
|
||||
#f
|
||||
end-total-equity
|
||||
1 end-exchange-fn #f "primary-subheading"
|
||||
@ -641,8 +641,8 @@
|
||||
(and show-rates?
|
||||
(let* ((curr-tbl (gnc:make-html-table))
|
||||
(headers (list
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp)
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date)
|
||||
)
|
||||
)
|
||||
(then (gnc:html-make-exchangerates
|
||||
|
@ -96,44 +96,44 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
(define (split-same-corr-account-code-p a b)
|
||||
(= (xaccSplitCompareOtherAccountCodes a b) 0))
|
||||
|
||||
(define (timepair-same-year tp-a tp-b)
|
||||
(= (gnc:timepair-get-year tp-a)
|
||||
(gnc:timepair-get-year tp-b)))
|
||||
(define (time64-same-year tp-a tp-b)
|
||||
(= (gnc:time64-get-year tp-a)
|
||||
(gnc:time64-get-year tp-b)))
|
||||
|
||||
(define (timepair-same-quarter tp-a tp-b)
|
||||
(and (timepair-same-year tp-a tp-b)
|
||||
(= (gnc:timepair-get-quarter tp-a)
|
||||
(gnc:timepair-get-quarter tp-b))))
|
||||
(define (time64-same-quarter tp-a tp-b)
|
||||
(and (time64-same-year tp-a tp-b)
|
||||
(= (gnc:time64-get-quarter tp-a)
|
||||
(gnc:time64-get-quarter tp-b))))
|
||||
|
||||
(define (timepair-same-month tp-a tp-b)
|
||||
(and (timepair-same-year tp-a tp-b)
|
||||
(= (gnc:timepair-get-month tp-a)
|
||||
(gnc:timepair-get-month tp-b))))
|
||||
(define (time64-same-month tp-a tp-b)
|
||||
(and (time64-same-year tp-a tp-b)
|
||||
(= (gnc:time64-get-month tp-a)
|
||||
(gnc:time64-get-month tp-b))))
|
||||
|
||||
(define (timepair-same-week tp-a tp-b)
|
||||
(and (timepair-same-year tp-a tp-b)
|
||||
(= (gnc:timepair-get-week tp-a)
|
||||
(gnc:timepair-get-week tp-b))))
|
||||
(define (time64-same-week tp-a tp-b)
|
||||
(and (time64-same-year tp-a tp-b)
|
||||
(= (gnc:time64-get-week tp-a)
|
||||
(gnc:time64-get-week tp-b))))
|
||||
|
||||
(define (split-same-week-p a b)
|
||||
(let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
|
||||
(tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
|
||||
(timepair-same-week tp-a tp-b)))
|
||||
(let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
|
||||
(tp-b (xaccTransGetDate (xaccSplitGetParent b))))
|
||||
(time64-same-week tp-a tp-b)))
|
||||
|
||||
(define (split-same-month-p a b)
|
||||
(let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
|
||||
(tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
|
||||
(timepair-same-month tp-a tp-b)))
|
||||
(let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
|
||||
(tp-b (xaccTransGetDate (xaccSplitGetParent b))))
|
||||
(time64-same-month tp-a tp-b)))
|
||||
|
||||
(define (split-same-quarter-p a b)
|
||||
(let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
|
||||
(tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
|
||||
(timepair-same-quarter tp-a tp-b)))
|
||||
(let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
|
||||
(tp-b (xaccTransGetDate (xaccSplitGetParent b))))
|
||||
(time64-same-quarter tp-a tp-b)))
|
||||
|
||||
(define (split-same-year-p a b)
|
||||
(let ((tp-a (gnc-transaction-get-date-posted (xaccSplitGetParent a)))
|
||||
(tp-b (gnc-transaction-get-date-posted (xaccSplitGetParent b))))
|
||||
(timepair-same-year tp-a tp-b)))
|
||||
(let ((tp-a (xaccTransGetDate (xaccSplitGetParent a)))
|
||||
(tp-b (xaccTransGetDate (xaccSplitGetParent b))))
|
||||
(time64-same-year tp-a tp-b)))
|
||||
|
||||
(define (set-last-row-style! table tag . rest)
|
||||
(let ((arg-list
|
||||
@ -197,29 +197,29 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
|
||||
(define (render-week-subheading split table width subheading-style column-vector)
|
||||
(add-subheading-row (gnc:date-get-week-year-string
|
||||
(gnc:timepair->date
|
||||
(gnc-transaction-get-date-posted
|
||||
(gnc-localtime
|
||||
(xaccTransGetDate
|
||||
(xaccSplitGetParent split))))
|
||||
table width subheading-style))
|
||||
|
||||
(define (render-month-subheading split table width subheading-style column-vector)
|
||||
(add-subheading-row (gnc:date-get-month-year-string
|
||||
(gnc:timepair->date
|
||||
(gnc-transaction-get-date-posted
|
||||
(gnc-localtime
|
||||
(xaccTransGetDate
|
||||
(xaccSplitGetParent split))))
|
||||
table width subheading-style))
|
||||
|
||||
(define (render-quarter-subheading split table width subheading-style column-vector)
|
||||
(add-subheading-row (gnc:date-get-quarter-year-string
|
||||
(gnc:timepair->date
|
||||
(gnc-transaction-get-date-posted
|
||||
(gnc-localtime
|
||||
(xaccTransGetDate
|
||||
(xaccSplitGetParent split))))
|
||||
table width subheading-style))
|
||||
|
||||
(define (render-year-subheading split table width subheading-style column-vector)
|
||||
(add-subheading-row (gnc:date-get-year-string
|
||||
(gnc:timepair->date
|
||||
(gnc-transaction-get-date-posted
|
||||
(gnc-localtime
|
||||
(xaccTransGetDate
|
||||
(xaccSplitGetParent split))))
|
||||
table width subheading-style))
|
||||
|
||||
@ -293,7 +293,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
|
||||
(define (render-week-subtotal
|
||||
table width split total-collector subtotal-style column-vector export?)
|
||||
(let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
|
||||
(let ((tm (gnc-localtime (xaccTransGetDate
|
||||
(xaccSplitGetParent split)))))
|
||||
(add-subtotal-row table width
|
||||
(total-string (gnc:date-get-week-year-string tm))
|
||||
@ -301,7 +301,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
|
||||
(define (render-month-subtotal
|
||||
table width split total-collector subtotal-style column-vector export?)
|
||||
(let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
|
||||
(let ((tm (gnc-localtime (xaccTransGetDate
|
||||
(xaccSplitGetParent split)))))
|
||||
(add-subtotal-row table width
|
||||
(total-string (gnc:date-get-month-year-string tm))
|
||||
@ -310,7 +310,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
|
||||
(define (render-quarter-subtotal
|
||||
table width split total-collector subtotal-style column-vector export?)
|
||||
(let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
|
||||
(let ((tm (gnc-localtime (xaccTransGetDate
|
||||
(xaccSplitGetParent split)))))
|
||||
(add-subtotal-row table width
|
||||
(total-string (gnc:date-get-quarter-year-string tm))
|
||||
@ -318,7 +318,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
|
||||
(define (render-year-subtotal
|
||||
table width split total-collector subtotal-style column-vector export?)
|
||||
(let ((tm (gnc:timepair->date (gnc-transaction-get-date-posted
|
||||
(let ((tm (gnc-localtime (xaccTransGetDate
|
||||
(xaccSplitGetParent split)))))
|
||||
(add-subtotal-row table width
|
||||
(total-string (strftime "%Y" tm))
|
||||
@ -518,7 +518,7 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
(opt-val gnc:pagename-general optname-currency)
|
||||
currency))
|
||||
(sign-reverses? (opt-val gnc:pagename-display (N_ "Sign Reverses")))
|
||||
(trans-date (gnc-transaction-get-date-posted parent))
|
||||
(trans-date (xaccTransGetDate parent))
|
||||
(converted (lambda (num)
|
||||
(gnc:exchange-by-pricedb-nearest
|
||||
(gnc:make-gnc-monetary currency num)
|
||||
@ -540,15 +540,15 @@ accounts must be of type ASSET for taxes paid on expenses, and type LIABILITY fo
|
||||
(addto! row-contents
|
||||
(if transaction-row?
|
||||
(gnc:make-html-table-cell/markup "date-cell"
|
||||
(gnc-print-date (gnc-transaction-get-date-posted parent)))
|
||||
(qof-print-date (xaccTransGetDate parent)))
|
||||
" ")))
|
||||
(if (used-reconciled-date column-vector)
|
||||
(addto! row-contents
|
||||
(gnc:make-html-table-cell/markup "date-cell"
|
||||
(let ((date (gnc-split-get-date-reconciled split)))
|
||||
(if (equal? date (cons 0 0))
|
||||
(let ((date (xaccSplitGetDateReconciled split)))
|
||||
(if (zero? date)
|
||||
" "
|
||||
(gnc-print-date date))))))
|
||||
(qof-print-date date))))))
|
||||
(if (used-num column-vector)
|
||||
(addto! row-contents
|
||||
(if transaction-row?
|
||||
@ -1148,8 +1148,8 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
|
||||
|
||||
|
||||
(define (display-date-interval begin end)
|
||||
(let ((begin-string (gnc-print-date begin))
|
||||
(end-string (gnc-print-date end)))
|
||||
(let ((begin-string (qof-print-date begin))
|
||||
(end-string (qof-print-date end)))
|
||||
(sprintf #f (_ "From %s To %s") begin-string end-string)))
|
||||
|
||||
(define (get-primary-subtotal-style options)
|
||||
@ -1616,10 +1616,10 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
|
||||
(accounts-sales (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-INCOME)) c_account_1))
|
||||
(accounts-purchases (filter (lambda (acc) (eq? (xaccAccountGetType acc) ACCT-TYPE-EXPENSE)) c_account_1))
|
||||
(filter-mode (opt-val gnc:pagename-accounts "Filter Type"))
|
||||
(begindate (gnc:timepair-start-day-time
|
||||
(begindate (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general "Start Date"))))
|
||||
(enddate (gnc:timepair-end-day-time
|
||||
(enddate (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general "End Date"))))
|
||||
(transaction-matcher (opt-val gnc:pagename-general optname-transaction-matcher))
|
||||
@ -1648,7 +1648,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
|
||||
(xaccQueryAddAccountMatch query
|
||||
c_account_1
|
||||
QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS
|
||||
(xaccQueryAddDateMatchTT
|
||||
query #t begindate #t enddate QOF-QUERY-AND)
|
||||
(qof-query-set-sort-order query
|
||||
(get-query-sortkey primary-key)
|
||||
|
@ -302,11 +302,11 @@
|
||||
(start-date-printable (gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-start-date)))
|
||||
(start-date-tp (gnc:timepair-start-day-time
|
||||
(start-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-start-date))))
|
||||
(end-date-tp (gnc:timepair-end-day-time
|
||||
(end-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-end-date))))
|
||||
@ -388,7 +388,7 @@
|
||||
depth-limit))
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity end-date-tp))
|
||||
(gnc:case-exchange-fn price-source report-commodity end-date))
|
||||
)
|
||||
|
||||
;; Wrapper to call gnc:html-table-add-labeled-amount-line!
|
||||
@ -434,8 +434,8 @@
|
||||
(string-append "%s %s "
|
||||
(_ "For Period Covering %s to %s"))
|
||||
company-name report-title
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp)))
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date)))
|
||||
|
||||
(if (null? accounts)
|
||||
|
||||
@ -473,8 +473,8 @@
|
||||
(period-for (if terse-period?
|
||||
(string-append " " (_ "for Period"))
|
||||
(sprintf #f (string-append ", " (_ "%s to %s"))
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp))
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date))
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -518,29 +518,29 @@
|
||||
(set! revenue-closing
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
revenue-accounts closing-pattern
|
||||
start-date-tp end-date-tp)
|
||||
start-date end-date)
|
||||
) ;; this is norm positive (debit)
|
||||
(set! expense-closing
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
expense-accounts closing-pattern
|
||||
start-date-tp end-date-tp)
|
||||
start-date end-date)
|
||||
) ;; this is norm negative (credit)
|
||||
(set! expense-total
|
||||
(gnc:accountlist-get-comm-balance-interval-with-closing
|
||||
expense-accounts
|
||||
start-date-tp end-date-tp))
|
||||
start-date end-date))
|
||||
(expense-total 'minusmerge expense-closing #f)
|
||||
(set! neg-revenue-total
|
||||
(gnc:accountlist-get-comm-balance-interval-with-closing
|
||||
revenue-accounts
|
||||
start-date-tp end-date-tp))
|
||||
start-date end-date))
|
||||
(neg-revenue-total 'minusmerge revenue-closing #f)
|
||||
(set! revenue-total (gnc:make-commodity-collector))
|
||||
(revenue-total 'minusmerge neg-revenue-total #f)
|
||||
(set! trading-total
|
||||
(gnc:accountlist-get-comm-balance-interval-with-closing
|
||||
trading-accounts
|
||||
start-date-tp end-date-tp))
|
||||
start-date end-date))
|
||||
;; calculate net income
|
||||
(set! net-income (gnc:make-commodity-collector))
|
||||
(net-income 'merge revenue-total #f)
|
||||
@ -549,8 +549,8 @@
|
||||
|
||||
(set! table-env
|
||||
(list
|
||||
(list 'start-date start-date-tp)
|
||||
(list 'end-date end-date-tp)
|
||||
(list 'start-date start-date)
|
||||
(list 'end-date end-date)
|
||||
(list 'display-tree-depth tree-depth)
|
||||
(list 'depth-limit-behavior (if bottom-behavior
|
||||
'flatten
|
||||
@ -714,9 +714,7 @@
|
||||
|
||||
(gnc:report-finished)
|
||||
|
||||
doc
|
||||
)
|
||||
)
|
||||
doc))
|
||||
|
||||
(define is-reportname (N_ "Income Statement"))
|
||||
(define pnl-reportname (N_ "Profit & Loss"))
|
||||
@ -738,8 +736,7 @@
|
||||
'report-guid "0b81a3bdfd504aff849ec2e8630524bc"
|
||||
'menu-path (list gnc:menuname-income-expense)
|
||||
'options-generator income-statement-options-generator
|
||||
'renderer income-statement-renderer
|
||||
)
|
||||
'renderer income-statement-renderer)
|
||||
|
||||
;; Also make a "Profit & Loss" report, even if it's the exact same one,
|
||||
;; just relabeled.
|
||||
@ -749,7 +746,6 @@
|
||||
'report-guid "8758ba23984c40dea5527f5f0ca2779e"
|
||||
'menu-path (list gnc:menuname-income-expense)
|
||||
'options-generator profit-and-loss-options-generator
|
||||
'renderer profit-and-loss-renderer
|
||||
)
|
||||
'renderer profit-and-loss-renderer)
|
||||
|
||||
;; END
|
||||
|
@ -156,11 +156,11 @@
|
||||
(gnc:lookup-option (gnc:report-options report-obj) section name)))
|
||||
|
||||
(gnc:report-starting reportname)
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(let* ((to-date-t64 (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(from-date-t64 (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
@ -184,11 +184,14 @@
|
||||
(commodity-list #f)
|
||||
(exchange-fn #f)
|
||||
|
||||
(dates-list ((if inc-exp? gnc:make-date-interval-list
|
||||
(dates-list ((if inc-exp?
|
||||
gnc:make-date-interval-list
|
||||
gnc:make-date-list)
|
||||
((if inc-exp? gnc:timepair-start-day-time
|
||||
gnc:timepair-end-day-time) from-date-tp)
|
||||
(gnc:timepair-end-day-time to-date-tp)
|
||||
((if inc-exp?
|
||||
gnc:time64-start-day-time
|
||||
gnc:time64-end-day-time)
|
||||
from-date-t64)
|
||||
(gnc:time64-end-day-time to-date-t64)
|
||||
(gnc:deltasym-to-delta interval)))
|
||||
(report-title (get-option gnc:pagename-general
|
||||
gnc:optname-reportname))
|
||||
@ -207,7 +210,7 @@
|
||||
;; This exchanges the commodity-collector 'c' to one single
|
||||
;; 'report-currency' according to the exchange-fn. Returns a gnc:monetary
|
||||
(define (collector->monetary c date)
|
||||
(if (not (gnc:timepair? date))
|
||||
(if (not (number? date))
|
||||
(throw 'wrong))
|
||||
(gnc:sum-collector-commodity
|
||||
c report-currency
|
||||
@ -261,7 +264,7 @@
|
||||
(gnc:report-percent-done 10)
|
||||
(set! exchange-fn (gnc:case-exchange-time-fn
|
||||
price-source report-currency
|
||||
commodity-list to-date-tp
|
||||
commodity-list to-date-t64
|
||||
10 40))
|
||||
(gnc:report-percent-done 50)
|
||||
|
||||
@ -274,9 +277,9 @@
|
||||
(date-string-list (map
|
||||
(if inc-exp?
|
||||
(lambda (date-list-item)
|
||||
(gnc-print-date
|
||||
(qof-print-date
|
||||
(car date-list-item)))
|
||||
gnc-print-date)
|
||||
qof-print-date)
|
||||
dates-list)))
|
||||
(let* ((the-acount-destination-alist
|
||||
(if inc-exp?
|
||||
@ -332,8 +335,8 @@
|
||||
(gnc:html-barchart-set-subtitle!
|
||||
chart (sprintf #f
|
||||
(_ "%s to %s")
|
||||
(jqplot-escape-string (gnc-print-date from-date-tp))
|
||||
(jqplot-escape-string (gnc-print-date to-date-tp))))
|
||||
(jqplot-escape-string (qof-print-date from-date-t64))
|
||||
(jqplot-escape-string (qof-print-date to-date-t64))))
|
||||
(gnc:html-barchart-set-width! chart width)
|
||||
(gnc:html-barchart-set-height! chart height)
|
||||
(gnc:html-barchart-set-row-labels! chart date-string-list)
|
||||
|
@ -188,11 +188,11 @@
|
||||
(gnc:lookup-option (gnc:report-options report-obj) section name)))
|
||||
|
||||
(gnc:report-starting reportname)
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(let* ((to-date-t64 (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(from-date-t64 (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
@ -221,11 +221,13 @@
|
||||
(commodity-list #f)
|
||||
(exchange-fn #f)
|
||||
|
||||
(dates-list ((if inc-exp? gnc:make-date-interval-list
|
||||
(dates-list ((if inc-exp?
|
||||
gnc:make-date-interval-list
|
||||
gnc:make-date-list)
|
||||
((if inc-exp? gnc:timepair-start-day-time
|
||||
gnc:timepair-end-day-time) from-date-tp)
|
||||
(gnc:timepair-end-day-time to-date-tp)
|
||||
((if inc-exp?
|
||||
gnc:time64-start-day-time
|
||||
gnc:time64-end-day-time) from-date-t64)
|
||||
(gnc:time64-end-day-time to-date-t64)
|
||||
(gnc:deltasym-to-delta interval)))
|
||||
(report-title (get-option gnc:pagename-general
|
||||
gnc:optname-reportname))
|
||||
@ -244,7 +246,7 @@
|
||||
;; This exchanges the commodity-collector 'c' to one single
|
||||
;; 'report-currency' according to the exchange-fn. Returns a gnc:monetary
|
||||
(define (collector->monetary c date)
|
||||
(if (not (gnc:timepair? date))
|
||||
(if (not (number? date))
|
||||
(throw 'wrong))
|
||||
(gnc:sum-collector-commodity
|
||||
c report-currency
|
||||
@ -298,7 +300,7 @@
|
||||
(gnc:report-percent-done 10)
|
||||
(set! exchange-fn (gnc:case-exchange-time-fn
|
||||
price-source report-currency
|
||||
commodity-list to-date-tp
|
||||
commodity-list to-date-t64
|
||||
10 40))
|
||||
(gnc:report-percent-done 50)
|
||||
|
||||
@ -316,7 +318,7 @@
|
||||
|
||||
(define (datelist->stringlist dates-list)
|
||||
(map (lambda (date-list-item)
|
||||
(gnc-print-date
|
||||
(qof-print-date
|
||||
(if inc-exp?
|
||||
(car date-list-item)
|
||||
date-list-item)))
|
||||
@ -376,8 +378,8 @@
|
||||
(gnc:html-linechart-set-subtitle!
|
||||
chart (sprintf #f
|
||||
(_ "%s to %s")
|
||||
(gnc-print-date from-date-tp)
|
||||
(gnc-print-date to-date-tp)))
|
||||
(qof-print-date from-date-t64)
|
||||
(qof-print-date to-date-t64)))
|
||||
(gnc:html-linechart-set-width! chart width)
|
||||
(gnc:html-linechart-set-height! chart height)
|
||||
|
||||
|
@ -191,7 +191,7 @@
|
||||
(gnc:html-document-set-title!
|
||||
document (string-append
|
||||
report-title
|
||||
(sprintf #f " %s" (gnc-print-date to-date))))
|
||||
(sprintf #f " %s" (qof-print-date to-date))))
|
||||
|
||||
;(gnc:debug "accounts" accounts)
|
||||
(if (not (null? accounts))
|
||||
@ -235,7 +235,7 @@
|
||||
(lambda (foreign date)
|
||||
(let* ((price
|
||||
(gnc-pricedb-lookup-nearest-in-time-any-currency
|
||||
pricedb foreign (timespecCanonicalDayTime date)))
|
||||
pricedb foreign (time64CanonicalDayTime date)))
|
||||
(fn (if (and price (> (length price) 0))
|
||||
(let* ((the_price
|
||||
(if (gnc-commodity-equiv
|
||||
|
@ -142,14 +142,14 @@
|
||||
(gnc:make-gnc-monetary c n)))
|
||||
|
||||
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(let* ((to-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
(from-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(interval (get-option gnc:pagename-general optname-stepsize))
|
||||
(report-title (get-option gnc:pagename-general
|
||||
gnc:optname-reportname))
|
||||
@ -170,9 +170,9 @@
|
||||
optname-price-source))
|
||||
|
||||
(dates-list (gnc:make-date-list
|
||||
(gnc:timepair-end-day-time from-date-tp)
|
||||
(gnc:timepair-end-day-time to-date-tp)
|
||||
(gnc:deltasym-to-delta interval)))
|
||||
(gnc:time64-end-day-time from-date)
|
||||
(gnc:time64-end-day-time to-date)
|
||||
(gnc:deltasym-to-delta interval)))
|
||||
|
||||
(document (gnc:make-html-document))
|
||||
(chart (gnc:make-html-scatter))
|
||||
@ -202,8 +202,8 @@
|
||||
" - "
|
||||
(sprintf #f
|
||||
(_ "%s to %s")
|
||||
(gnc-print-date from-date-tp)
|
||||
(gnc-print-date to-date-tp))))
|
||||
(qof-print-date from-date)
|
||||
(qof-print-date to-date))))
|
||||
(gnc:html-scatter-set-width! chart width)
|
||||
(gnc:html-scatter-set-height! chart height)
|
||||
(gnc:html-scatter-set-marker! chart
|
||||
@ -243,15 +243,15 @@
|
||||
(case price-source
|
||||
((actual-transactions)
|
||||
(gnc:get-commodity-inst-prices
|
||||
currency-accounts to-date-tp
|
||||
currency-accounts to-date
|
||||
price-commodity report-currency))
|
||||
((weighted-average)
|
||||
(gnc:get-commodity-totalavg-prices
|
||||
currency-accounts to-date-tp
|
||||
currency-accounts to-date
|
||||
price-commodity report-currency))
|
||||
((pricedb)
|
||||
(map (lambda (p)
|
||||
(list (gnc-price-get-time p)
|
||||
(list (gnc-price-get-time64 p)
|
||||
(gnc-price-get-value p)))
|
||||
(gnc-pricedb-get-prices
|
||||
(gnc-pricedb-get-db (gnc-get-current-book))
|
||||
@ -259,15 +259,15 @@
|
||||
)))
|
||||
|
||||
(set! data (filter
|
||||
(lambda (x)
|
||||
(lambda (x)
|
||||
(and
|
||||
(gnc:timepair-ge to-date-tp (first x))
|
||||
(gnc:timepair-ge (first x) from-date-tp)))
|
||||
(>= to-date (first x))
|
||||
(>= (first x) from-date)))
|
||||
data))
|
||||
|
||||
;; some output
|
||||
;;(warn "data" (map (lambda (x) (list
|
||||
;; (gnc-print-date (car x))
|
||||
;; (qof-print-date x)
|
||||
;; (gnc-numeric-to-double (second x))))
|
||||
;; data))
|
||||
|
||||
@ -287,8 +287,8 @@
|
||||
(set! data
|
||||
(map (lambda (x)
|
||||
(list
|
||||
(/ (- (car (first x))
|
||||
(car from-date-tp))
|
||||
(/ (- (first x)
|
||||
from-date)
|
||||
;; FIXME: These hard-coded values are more
|
||||
;; or less totally bogus. OTOH this whole
|
||||
;; scaling thing is totally bogus as well,
|
||||
|
@ -203,8 +203,8 @@
|
||||
(if transaction-info?
|
||||
(gnc:make-html-table-cell/markup
|
||||
"date-cell"
|
||||
(gnc-print-date
|
||||
(gnc-transaction-get-date-posted parent)))
|
||||
(qof-print-date
|
||||
(xaccTransGetDate parent)))
|
||||
" ")))
|
||||
(if (num-col column-vector)
|
||||
(addto! row-contents
|
||||
@ -810,7 +810,7 @@
|
||||
(list
|
||||
(string-append
|
||||
(_ "Date") ": "
|
||||
(string-expand (gnc-print-date (cons (current-time) 0))
|
||||
(string-expand (qof-print-date (current-time))
|
||||
#\space " "))
|
||||
(make-client-table address)))
|
||||
(set-last-row-style!
|
||||
|
@ -5,6 +5,7 @@
|
||||
;; Copyright 2004 David Montenegro <sunrise2000@comcast.net>
|
||||
;; Copyright 2001 Christian Stimming <stimming@tu-harburg.de>
|
||||
;; Copyright 2000-2001 Bill Gribble <grib@gnumatic.com>
|
||||
;; Copyright 2017 Christopher Lam upgrade to time64
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
@ -41,7 +42,6 @@
|
||||
|
||||
(gnc:module-load "gnucash/report/report-system" 0)
|
||||
|
||||
|
||||
(define reportname (N_ "Future Scheduled Transactions Summary"))
|
||||
|
||||
(define optname-report-title (N_ "Report Title"))
|
||||
@ -249,11 +249,11 @@
|
||||
(let* (
|
||||
(report-title (get-option gnc:pagename-general optname-report-title))
|
||||
(company-name (get-option gnc:pagename-general optname-party-name))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(from-date (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-from-date))))
|
||||
(to-date-tp (gnc:timepair-end-day-time
|
||||
(to-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-to-date))))
|
||||
@ -306,7 +306,7 @@
|
||||
depth-limit))
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity to-date-tp))
|
||||
(gnc:case-exchange-fn price-source report-commodity to-date))
|
||||
)
|
||||
|
||||
(gnc:html-document-set-title!
|
||||
@ -314,8 +314,8 @@
|
||||
(string-append "%s %s "
|
||||
(_ "For Period Covering %s to %s"))
|
||||
company-name report-title
|
||||
(gnc-print-date from-date-tp)
|
||||
(gnc-print-date to-date-tp))
|
||||
(qof-print-date from-date)
|
||||
(qof-print-date to-date))
|
||||
)
|
||||
|
||||
(if (null? accounts)
|
||||
@ -330,14 +330,14 @@
|
||||
|
||||
;; otherwise, generate the report...
|
||||
(let* (
|
||||
(sx-value-hash (gnc-sx-all-instantiate-cashflow-all from-date-tp to-date-tp))
|
||||
(sx-value-hash (gnc-sx-all-instantiate-cashflow-all from-date to-date))
|
||||
(chart-table #f) ;; gnc:html-acct-table
|
||||
(hold-table (gnc:make-html-table)) ;; temporary gnc:html-table
|
||||
(build-table (gnc:make-html-table)) ;; gnc:html-table reported
|
||||
(table-env ;; parameters for :make-
|
||||
(list
|
||||
(list 'start-date from-date-tp)
|
||||
(list 'end-date to-date-tp)
|
||||
(list 'start-date from-date)
|
||||
(list 'end-date to-date)
|
||||
(list 'display-tree-depth tree-depth)
|
||||
(list 'depth-limit-behavior bottom-behavior)
|
||||
(list 'report-commodity report-commodity)
|
||||
@ -506,8 +506,7 @@
|
||||
)
|
||||
|
||||
(gnc:report-finished)
|
||||
doc)
|
||||
)
|
||||
doc))
|
||||
|
||||
(gnc:define-report
|
||||
'version 1
|
||||
|
@ -18,11 +18,10 @@
|
||||
(list "Wallet"))
|
||||
(list "Expenses" (list (cons 'type ACCT-TYPE-EXPENSE)))))
|
||||
|
||||
(define (NDayDelta tp n)
|
||||
(define (NDayDelta t64 n)
|
||||
(let* ((day-secs (* 60 60 24 n)) ; n days in seconds is n times 60 sec/min * 60 min/h * 24 h/day
|
||||
(new-secs (- (car tp) day-secs))
|
||||
(new-tp (cons new-secs 0)))
|
||||
new-tp))
|
||||
(new-secs (- t64 day-secs)))
|
||||
new-secs))
|
||||
|
||||
(define (test-one-tx-in-cash-flow)
|
||||
(let* ((env (create-test-env))
|
||||
@ -31,15 +30,15 @@
|
||||
(wallet-account (cdr (assoc "Wallet" account-alist)))
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(today (gnc-localtime (current-time)))
|
||||
(to-date-tp (gnc-dmy2timespec-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
|
||||
(from-date-tp (NDayDelta to-date-tp 1))
|
||||
(to-date-t64 (gnc-dmy2time64-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
|
||||
(from-date-t64 (NDayDelta to-date-t64 1))
|
||||
(exchange-fn (lambda (currency amount date) amount))
|
||||
(report-currency (gnc-default-report-currency))
|
||||
)
|
||||
(env-create-transaction env to-date-tp bank-account expense-account 100/1)
|
||||
(env-create-transaction env to-date-t64 bank-account expense-account 100/1)
|
||||
(let ((result (cash-flow-calc-money-in-out (list (cons 'accounts (list bank-account))
|
||||
(cons 'to-date-tp to-date-tp)
|
||||
(cons 'from-date-tp from-date-tp)
|
||||
(cons 'to-date-t64 to-date-t64)
|
||||
(cons 'from-date-t64 from-date-t64)
|
||||
(cons 'report-currency report-currency)
|
||||
(cons 'include-trading-accounts #f)
|
||||
(cons 'to-report-currency exchange-fn)))))
|
||||
@ -75,15 +74,15 @@
|
||||
(wallet-account (cdr (assoc "Wallet" account-alist)))
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(today (gnc-localtime (current-time)))
|
||||
(to-date-tp (gnc-dmy2timespec-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
|
||||
(from-date-tp (NDayDelta to-date-tp 1))
|
||||
(to-date-t64 (gnc-dmy2time64-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
|
||||
(from-date-t64 (NDayDelta to-date-t64 1))
|
||||
(exchange-fn (lambda (currency amount date) amount))
|
||||
(report-currency (gnc-default-report-currency))
|
||||
)
|
||||
(env-create-transaction env to-date-tp bank-account wallet-account 100/1)
|
||||
(env-create-transaction env to-date-t64 bank-account wallet-account 100/1)
|
||||
(let ((result (cash-flow-calc-money-in-out (list (cons 'accounts (list wallet-account bank-account))
|
||||
(cons 'to-date-tp to-date-tp)
|
||||
(cons 'from-date-tp from-date-tp)
|
||||
(cons 'to-date-t64 to-date-t64)
|
||||
(cons 'from-date-t64 from-date-t64)
|
||||
(cons 'report-currency report-currency)
|
||||
(cons 'include-trading-accounts #f)
|
||||
(cons 'to-report-currency exchange-fn)))))
|
||||
@ -109,16 +108,16 @@
|
||||
(wallet-account (cdr (assoc "Wallet" account-alist)))
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(today (gnc-localtime (current-time)))
|
||||
(to-date-tp (gnc-dmy2timespec-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
|
||||
(from-date-tp (NDayDelta to-date-tp 1))
|
||||
(to-date-t64 (gnc-dmy2time64-end (tm:mday today) (+ 1 (tm:mon today)) (+ 1900 (tm:year today))))
|
||||
(from-date-t64 (NDayDelta to-date-t64 1))
|
||||
(exchange-fn (lambda (currency amount date) amount))
|
||||
(report-currency (gnc-default-report-currency))
|
||||
)
|
||||
(env-create-transaction env to-date-tp bank-account expense-account 100/1)
|
||||
(env-create-transaction env to-date-tp expense-account bank-account 50/1)
|
||||
(env-create-transaction env to-date-t64 bank-account expense-account 100/1)
|
||||
(env-create-transaction env to-date-t64 expense-account bank-account 50/1)
|
||||
(let ((result (cash-flow-calc-money-in-out (list (cons 'accounts (list wallet-account bank-account))
|
||||
(cons 'to-date-tp to-date-tp)
|
||||
(cons 'from-date-tp from-date-tp)
|
||||
(cons 'to-date-t64 to-date-t64)
|
||||
(cons 'from-date-t64 from-date-t64)
|
||||
(cons 'report-currency report-currency)
|
||||
(cons 'include-trading-accounts #f)
|
||||
(cons 'to-report-currency exchange-fn)))))
|
||||
|
@ -73,8 +73,8 @@
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(income-account (cdr (assoc "Income" account-alist)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env
|
||||
date-1
|
||||
bank-account
|
||||
@ -93,8 +93,8 @@
|
||||
(set-option report gnc:pagename-general "Price Source" 'pricedb-nearest)
|
||||
(set-option report gnc:pagename-general "Report's currency" (gnc-default-report-currency))
|
||||
(set-option report gnc:pagename-accounts "Accounts" (list wallet-account bank-account))
|
||||
(format #t "Create first transaction on ~a~%" (gnc-ctime (gnc:timepair->secs date-1)))
|
||||
(format #t "Create second transaction on ~a~%" (gnc-ctime (gnc:timepair->secs date-2)))
|
||||
(format #t "Create first transaction on ~a~%" (gnc-ctime date-1))
|
||||
(format #t "Create second transaction on ~a~%" (gnc-ctime date-2))
|
||||
(let ((doc (renderer report)))
|
||||
(gnc:html-document-set-style-sheet! doc (gnc:report-stylesheet report))
|
||||
(let* ((result (gnc:html-document-render doc #f))
|
||||
@ -147,8 +147,8 @@
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(income-account (cdr (assoc "Income" account-alist)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env
|
||||
date-1
|
||||
bank-account
|
||||
@ -230,8 +230,8 @@
|
||||
(expense-account (cdr (assoc "Expenses" account-alist)))
|
||||
(income-account (cdr (assoc "Income" account-alist)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env
|
||||
date-1
|
||||
bank-account
|
||||
|
@ -129,8 +129,8 @@
|
||||
(my-income-account (env-create-root-account env ACCT-TYPE-INCOME
|
||||
(gnc-default-report-currency)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env
|
||||
date-1
|
||||
my-income-account
|
||||
@ -198,8 +198,8 @@
|
||||
(my-income-account (env-create-root-account env ACCT-TYPE-INCOME
|
||||
(gnc-default-report-currency)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env date-1 my-income-account my-asset-account -1/1)
|
||||
(env-create-transaction env date-1 my-expense-account my-liability-account -1/1)
|
||||
(env-create-transaction env date-2 my-income-account my-asset-account -5/1)
|
||||
@ -256,8 +256,8 @@
|
||||
(my-income-account (env-create-root-account env ACCT-TYPE-INCOME
|
||||
(gnc-default-report-currency)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env date-1 my-income-account my-asset-account -1/1)
|
||||
(env-create-transaction env date-1 my-expense-account my-liability-account -1/1)
|
||||
(env-create-transaction env date-2 my-income-account my-asset-account -5/1)
|
||||
@ -317,9 +317,9 @@
|
||||
(my-equity-account (env-create-root-account env ACCT-TYPE-EQUITY
|
||||
(gnc-default-report-currency)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1))
|
||||
(date-3 (gnc:timepair-next-day date-2)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1))
|
||||
(date-3 (gnc:time64-next-day date-2)))
|
||||
|
||||
(env-create-transaction env date-1 my-income-account my-asset-account -1/1)
|
||||
(env-create-transaction env date-2 my-income-account my-asset-account -2/1)
|
||||
|
@ -125,8 +125,8 @@
|
||||
(my-income-account (env-create-root-account env ACCT-TYPE-INCOME
|
||||
(gnc-default-report-currency)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env
|
||||
date-1
|
||||
my-income-account
|
||||
@ -185,8 +185,8 @@
|
||||
(my-income-account (env-create-root-account env ACCT-TYPE-INCOME
|
||||
(gnc-default-report-currency)))
|
||||
(date-0 (gnc:get-start-this-month))
|
||||
(date-1 (gnc:timepair-next-day date-0))
|
||||
(date-2 (gnc:timepair-next-day date-1)))
|
||||
(date-1 (gnc:time64-next-day date-0))
|
||||
(date-2 (gnc:time64-next-day date-1)))
|
||||
(env-create-transaction env date-1 my-income-account my-asset-account -1/1)
|
||||
(env-create-transaction env date-1 my-expense-account my-liability-account -1/1)
|
||||
(env-create-transaction env date-2 my-income-account my-asset-account -5/1)
|
||||
|
@ -1640,10 +1640,10 @@ tags within description, notes or memo. ")
|
||||
c_account_0))
|
||||
(c_account_2 (opt-val gnc:pagename-accounts optname-filterby))
|
||||
(filter-mode (opt-val gnc:pagename-accounts optname-filtertype))
|
||||
(begindate (gnc:timepair-start-day-time
|
||||
(begindate (gnc:time64-start-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general optname-startdate))))
|
||||
(enddate (gnc:timepair-end-day-time
|
||||
(enddate (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(opt-val gnc:pagename-general optname-enddate))))
|
||||
(transaction-matcher (opt-val pagename-filter optname-transaction-matcher))
|
||||
@ -1822,7 +1822,7 @@ tags within description, notes or memo. ")
|
||||
|
||||
(qof-query-set-book query (gnc-get-current-book))
|
||||
(xaccQueryAddAccountMatch query c_account_1 QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTS query #t begindate #t enddate QOF-QUERY-AND)
|
||||
(xaccQueryAddDateMatchTT query #t begindate #t enddate QOF-QUERY-AND)
|
||||
(case void-status
|
||||
((non-void-only) (gnc:query-set-match-non-voids-only! query (gnc-get-current-book)))
|
||||
((void-only) (gnc:query-set-match-voids-only! query (gnc-get-current-book)))
|
||||
@ -1895,8 +1895,8 @@ tags within description, notes or memo. ")
|
||||
(gnc:html-markup-h3
|
||||
(sprintf #f
|
||||
(_ "From %s to %s")
|
||||
(gnc-print-date begindate)
|
||||
(gnc-print-date enddate)))))
|
||||
(qof-print-date begindate)
|
||||
(qof-print-date enddate)))))
|
||||
|
||||
(if (member 'match infobox-display)
|
||||
(gnc:html-document-add-object!
|
||||
|
@ -302,9 +302,9 @@
|
||||
(start-date-printable (gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-start-date)))
|
||||
(start-date-tp (gnc:timepair-end-day-time
|
||||
(gnc:timepair-previous-day start-date-printable)))
|
||||
(end-date-tp (gnc:timepair-end-day-time
|
||||
(start-date (gnc:time64-end-day-time
|
||||
(gnc:time64-previous-day start-date-printable)))
|
||||
(end-date (gnc:time64-end-day-time
|
||||
(gnc:date-option-absolute-time
|
||||
(get-option gnc:pagename-general
|
||||
optname-end-date))))
|
||||
@ -384,13 +384,13 @@
|
||||
(doc (gnc:make-html-document))
|
||||
;; exchange rates calculation parameters
|
||||
(exchange-fn
|
||||
(gnc:case-exchange-fn price-source report-commodity end-date-tp))
|
||||
(gnc:case-exchange-fn price-source report-commodity end-date))
|
||||
(terse-period? #t)
|
||||
(period-for (if terse-period?
|
||||
(string-append " " (_ "for Period"))
|
||||
(sprintf #f (string-append ", " (_ "%s to %s"))
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp))
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date))
|
||||
))
|
||||
)
|
||||
|
||||
@ -398,12 +398,12 @@
|
||||
doc (if (equal? report-variant 'current)
|
||||
(sprintf #f (string-append "%s %s %s")
|
||||
company-name report-title
|
||||
(gnc-print-date end-date-tp))
|
||||
(qof-print-date end-date))
|
||||
(sprintf #f (string-append "%s %s "
|
||||
(_ "For Period Covering %s to %s"))
|
||||
company-name report-title
|
||||
(gnc-print-date start-date-printable)
|
||||
(gnc-print-date end-date-tp))
|
||||
(qof-print-date start-date-printable)
|
||||
(qof-print-date end-date))
|
||||
)
|
||||
)
|
||||
|
||||
@ -523,7 +523,7 @@
|
||||
(unrealized-gain-collector (gnc:make-commodity-collector))
|
||||
(cost-fn (gnc:case-exchange-fn 'average-cost
|
||||
report-commodity
|
||||
end-date-tp))
|
||||
end-date))
|
||||
(value #f)
|
||||
(cost #f))
|
||||
|
||||
@ -533,7 +533,7 @@
|
||||
(lambda (acct)
|
||||
(book-balance 'merge
|
||||
(gnc:account-get-comm-balance-at-date
|
||||
acct end-date-tp #f)
|
||||
acct end-date #f)
|
||||
#f))
|
||||
all-accounts)
|
||||
|
||||
@ -573,7 +573,7 @@
|
||||
(set! table-env
|
||||
(list
|
||||
(list 'start-date #f)
|
||||
(list 'end-date end-date-tp)
|
||||
(list 'end-date end-date)
|
||||
(list 'display-tree-depth
|
||||
(if (integer? depth-limit) depth-limit #f))
|
||||
(list 'depth-limit-behavior 'flatten)
|
||||
@ -710,7 +710,7 @@
|
||||
(list 'regexp closing-regexp)
|
||||
(list 'closing #t)
|
||||
)
|
||||
start-date-tp end-date-tp
|
||||
start-date end-date
|
||||
))
|
||||
(adjusting
|
||||
(gnc:account-get-trans-type-balance-interval-with-closing
|
||||
@ -719,7 +719,7 @@
|
||||
(list 'cased adjusting-cased)
|
||||
(list 'regexp adjusting-regexp)
|
||||
)
|
||||
start-date-tp end-date-tp
|
||||
start-date end-date
|
||||
))
|
||||
(is? (member acct all-is-accounts))
|
||||
(ga-or-is? (or (member acct all-ga-accounts) is?))
|
||||
@ -733,7 +733,7 @@
|
||||
(list 'regexp adjusting-regexp)
|
||||
(list 'positive #t)
|
||||
)
|
||||
start-date-tp end-date-tp
|
||||
start-date end-date
|
||||
)
|
||||
))
|
||||
(neg-adjusting
|
||||
@ -1136,9 +1136,7 @@
|
||||
|
||||
(gnc:report-finished)
|
||||
|
||||
doc
|
||||
)
|
||||
)
|
||||
doc))
|
||||
|
||||
(gnc:define-report
|
||||
'version 1
|
||||
@ -1153,4 +1151,3 @@
|
||||
(trial-balance-renderer report-obj #f filename)))
|
||||
|
||||
;; END
|
||||
|
||||
|
@ -437,8 +437,8 @@
|
||||
(gnc:html-markup-b prepared-for)
|
||||
(gnc:html-markup-br)
|
||||
(_ "Date: ")
|
||||
(gnc-print-date
|
||||
(cons (current-time) 0)))
|
||||
(qof-print-date
|
||||
(current-time)))
|
||||
|
||||
;; title only
|
||||
(gnc:make-html-text
|
||||
|
@ -432,8 +432,8 @@
|
||||
(gnc:html-markup-b prepared-for)
|
||||
(gnc:html-markup-br)
|
||||
(_ "Date: ")
|
||||
(gnc-print-date
|
||||
(cons (current-time) 0)))
|
||||
(qof-print-date
|
||||
(current-time)))
|
||||
|
||||
;; title only
|
||||
(gnc:make-html-text
|
||||
|
@ -450,8 +450,8 @@
|
||||
(gnc:html-markup-b prepared-for)
|
||||
(gnc:html-markup-br)
|
||||
(_ "Date: ")
|
||||
(gnc-print-date
|
||||
(cons (current-time) 0)))
|
||||
(qof-print-date
|
||||
(current-time)))
|
||||
|
||||
;; title only
|
||||
(gnc:make-html-text
|
||||
|
@ -534,7 +534,7 @@
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-i
|
||||
(_ "Report Creation Date: ")
|
||||
(gnc-print-date (gnc:get-today))
|
||||
(qof-print-date (gnc:get-today))
|
||||
" "
|
||||
(strftime "%X %Z" (localtime (current-time)))
|
||||
)
|
||||
@ -543,7 +543,7 @@
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-i
|
||||
(_ "Report Creation Date: ")
|
||||
(gnc-print-date (gnc:get-today))
|
||||
(qof-print-date (gnc:get-today))
|
||||
)
|
||||
(gnc:html-markup-br)
|
||||
)
|
||||
@ -659,7 +659,7 @@
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-i
|
||||
(_ "Report Creation Date: ")
|
||||
(gnc-print-date (gnc:get-today))
|
||||
(qof-print-date (gnc:get-today))
|
||||
" "
|
||||
(strftime "%X %Z" (localtime (current-time)))
|
||||
)
|
||||
@ -668,7 +668,7 @@
|
||||
(gnc:make-html-text
|
||||
(gnc:html-markup-i
|
||||
(_ "Report Creation Date: ")
|
||||
(gnc-print-date (gnc:get-today))
|
||||
(qof-print-date (gnc:get-today))
|
||||
(gnc:html-markup-br)
|
||||
)
|
||||
)
|
||||
|
@ -102,7 +102,7 @@
|
||||
(gnc:make-date-option
|
||||
(N_ "Hello, World!") (N_ "Just a Date Option")
|
||||
"d" (N_ "This is a date option.")
|
||||
(lambda () (cons 'absolute (cons (current-time) 0)))
|
||||
(lambda () (cons 'absolute (current-time)))
|
||||
#f 'absolute #f ))
|
||||
|
||||
;; This is another date option, but the user can also select
|
||||
@ -111,7 +111,7 @@
|
||||
(gnc:make-date-option
|
||||
(N_ "Hello, World!") (N_ "Time and Date Option")
|
||||
"e" (N_ "This is a date option with time.")
|
||||
(lambda () (cons 'absolute (cons (current-time) 0)))
|
||||
(lambda () (cons 'absolute (current-time)))
|
||||
#t 'absolute #f ))
|
||||
|
||||
(add-option
|
||||
@ -267,13 +267,13 @@ option like this.")
|
||||
|
||||
;; these are samples of different date options. for a simple
|
||||
;; date with day, month, and year but no time you should use
|
||||
;; gnc-print-date
|
||||
;; qof-print-date
|
||||
(let ((time-string (strftime "%X" (gnc-localtime (current-time))))
|
||||
(date-string (strftime "%x" (gnc-localtime (car date-val))))
|
||||
(date-string2 (strftime "%x %X" (gnc-localtime (car date2-val))))
|
||||
(rel-date-string (strftime "%x" (gnc-localtime (car rel-date-val))))
|
||||
(date-string (strftime "%x" (gnc-localtime date-val)))
|
||||
(date-string2 (strftime "%x %X" (gnc-localtime date2-val)))
|
||||
(rel-date-string (strftime "%x" (gnc-localtime rel-date-val)))
|
||||
(combo-date-string
|
||||
(strftime "%x" (gnc-localtime (car combo-date-val)))))
|
||||
(strftime "%x" (gnc-localtime combo-date-val))))
|
||||
|
||||
;; Here's where we fill the report document with content. We
|
||||
;; do this by adding 'html objects' such as text, tables, and
|
||||
|
@ -180,11 +180,6 @@
|
||||
;; date-utilities.scm
|
||||
|
||||
(export gnc:reldate-list)
|
||||
(export gnc:timepair->secs)
|
||||
(export gnc:secs->timepair)
|
||||
(export gnc:timepair->date)
|
||||
(export gnc:date->timepair)
|
||||
(export gnc:timepair?)
|
||||
(export gnc:date-get-year)
|
||||
(export gnc:date-get-quarter)
|
||||
(export gnc:date-get-month-day)
|
||||
@ -192,13 +187,13 @@
|
||||
(export gnc:date-get-week-day)
|
||||
(export gnc:date-get-week)
|
||||
(export gnc:date-get-year-day)
|
||||
(export gnc:timepair-get-year)
|
||||
(export gnc:timepair-get-quarter)
|
||||
(export gnc:timepair-get-month-day)
|
||||
(export gnc:timepair-get-month)
|
||||
(export gnc:timepair-get-week-day)
|
||||
(export gnc:timepair-get-week)
|
||||
(export gnc:timepair-get-year-day)
|
||||
(export gnc:time64-get-year)
|
||||
(export gnc:time64-get-quarter)
|
||||
(export gnc:time64-get-month-day)
|
||||
(export gnc:time64-get-month)
|
||||
(export gnc:time64-get-week-day)
|
||||
(export gnc:time64-get-week)
|
||||
(export gnc:time64-get-year-day)
|
||||
(export gnc:date-get-year-string)
|
||||
(export gnc:date-get-quarter-string)
|
||||
(export gnc:date-get-quarter-year-string)
|
||||
@ -218,18 +213,10 @@
|
||||
(export moddatek)
|
||||
(export decdate)
|
||||
(export incdate)
|
||||
(export gnc:timepair-later)
|
||||
(export gnc:timepair-lt)
|
||||
(export gnc:timepair-earlier)
|
||||
(export gnc:timepair-gt)
|
||||
(export gnc:timepair-le)
|
||||
(export gnc:timepair-ge)
|
||||
(export gnc:timepair-eq)
|
||||
(export gnc:timepair-earlier-date)
|
||||
(export gnc:timepair-later-date)
|
||||
(export gnc:timepair-le-date)
|
||||
(export gnc:timepair-ge-date)
|
||||
(export gnc:timepair-eq-date)
|
||||
(export decdate)
|
||||
(export incdate)
|
||||
(export gnc:time64-le-date)
|
||||
(export gnc:time64-ge-date)
|
||||
(export gnc:make-date-interval-list)
|
||||
(export gnc:make-date-list)
|
||||
(export make-zdate)
|
||||
@ -244,12 +231,10 @@
|
||||
(export ThirtyDayDelta)
|
||||
(export NinetyDayDelta)
|
||||
(export gnc:deltasym-to-delta)
|
||||
(export gnc:timepair-delta)
|
||||
(export gnc:time-elapsed)
|
||||
(export gnc:timepair-start-day-time)
|
||||
(export gnc:timepair-end-day-time)
|
||||
(export gnc:timepair-previous-day)
|
||||
(export gnc:timepair-next-day)
|
||||
(export gnc:time64-start-day-time)
|
||||
(export gnc:time64-end-day-time)
|
||||
(export gnc:time64-previous-day)
|
||||
(export gnc:time64-next-day)
|
||||
(export gnc:reldate-get-symbol)
|
||||
(export gnc:reldate-get-string)
|
||||
(export gnc:reldate-get-desc)
|
||||
|
@ -20,30 +20,13 @@
|
||||
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
;; Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
|
||||
|
||||
(use-modules (gnucash core-utils)
|
||||
(gnucash printf)
|
||||
(gnucash gettext))
|
||||
|
||||
(define gnc:reldate-list '())
|
||||
|
||||
(define (gnc:timepair->secs tp)
|
||||
(inexact->exact
|
||||
(+ (car tp)
|
||||
(/ (cdr tp) 1000000000))))
|
||||
|
||||
(define (gnc:secs->timepair secs)
|
||||
(cons secs 0))
|
||||
|
||||
(define (gnc:timepair->date tp)
|
||||
(gnc-localtime (gnc:timepair->secs tp)))
|
||||
|
||||
(define (gnc:date->timepair date)
|
||||
(gnc:secs->timepair (gnc-mktime date)))
|
||||
|
||||
(define (gnc:timepair? date)
|
||||
(and (number? (car date))
|
||||
(number? (cdr date))))
|
||||
|
||||
;; get stuff from localtime date vector
|
||||
(define (gnc:date-get-year datevec)
|
||||
(+ 1900 (tm:year datevec)))
|
||||
@ -58,33 +41,32 @@
|
||||
(+ (tm:wday datevec) 1))
|
||||
;; jan 1 == 1
|
||||
(define (gnc:date-get-week datevec)
|
||||
(gnc:date-to-week (gnc:timepair->secs
|
||||
(gnc:timepair-start-day-time
|
||||
(gnc:date->timepair datevec)))))
|
||||
(gnc:date-to-week (gnc:time64-start-day-time
|
||||
(gnc-mktime datevec))))
|
||||
|
||||
(define (gnc:date-get-year-day datevec)
|
||||
(+ (tm:yday datevec) 1))
|
||||
|
||||
(define (gnc:timepair-get-year tp)
|
||||
(gnc:date-get-year (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-year t64)
|
||||
(gnc:date-get-year (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:timepair-get-quarter tp)
|
||||
(gnc:date-get-quarter (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-quarter t64)
|
||||
(gnc:date-get-quarter (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:timepair-get-month-day tp)
|
||||
(gnc:date-get-month-day (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-month-day t64)
|
||||
(gnc:date-get-month-day (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:timepair-get-month tp)
|
||||
(gnc:date-get-month (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-month t64)
|
||||
(gnc:date-get-month (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:timepair-get-week-day tp)
|
||||
(gnc:date-get-week-day (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-week-day t64)
|
||||
(gnc:date-get-week-day (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:timepair-get-week tp)
|
||||
(gnc:date-get-week (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-week t64)
|
||||
(gnc:date-get-week (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:timepair-get-year-day tp)
|
||||
(gnc:date-get-year-day (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-get-year-day t64)
|
||||
(gnc:date-get-year-day (gnc-localtime t64)))
|
||||
|
||||
(define (gnc:date-get-year-string datevec)
|
||||
(gnc-locale-to-utf8 (strftime "%Y" datevec)))
|
||||
@ -105,29 +87,30 @@
|
||||
(gnc-locale-to-utf8 (strftime "%B %Y" datevec)))
|
||||
|
||||
(define (gnc:date-get-week-year-string datevec)
|
||||
(let ((begin-string (gnc-print-date
|
||||
(gnc:secs->timepair
|
||||
(+ (* (gnc:date-to-week
|
||||
(gnc:timepair->secs
|
||||
(gnc:timepair-start-day-time
|
||||
(gnc:date->timepair datevec))))
|
||||
604800 ) 345600))))
|
||||
(end-string (gnc-print-date
|
||||
(gnc:secs->timepair
|
||||
(+ (* (gnc:date-to-week
|
||||
(gnc:timepair->secs
|
||||
(gnc:timepair-start-day-time
|
||||
(gnc:date->timepair datevec))))
|
||||
604800 ) 864000)))))
|
||||
(sprintf #f (_ "%s to %s") begin-string end-string)))
|
||||
(let* ((beginweekt64 (* (gnc:time64-get-week
|
||||
(gnc-mktime datevec))
|
||||
604800))
|
||||
(begin-string (qof-print-date (+ beginweekt64 345600)))
|
||||
(end-string (qof-print-date (+ beginweekt64 864000))))
|
||||
(sprintf #f (_ "%s to %s") begin-string end-string)))
|
||||
|
||||
; (let ((begin-string (qof-print-date
|
||||
; (+ (* (gnc:date-get-week
|
||||
; (gnc:time64-start-day-time
|
||||
; (gnc-mktime datevec)))
|
||||
; 604800) 345600)))
|
||||
; (end-string (qof-print-date
|
||||
; (+ (* (gnc:date-get-week
|
||||
; (gnc:time64-start-day-time
|
||||
; (gnc-mktime datevec)))
|
||||
; 604800) 864000))))
|
||||
; (sprintf #f (_ "%s to %s") begin-string end-string)))
|
||||
|
||||
;; is leap year?
|
||||
(define (gnc:leap-year? year)
|
||||
(if (= (remainder year 4) 0)
|
||||
(if (= (remainder year 100) 0)
|
||||
(if (= (remainder year 400) 0) #t #f)
|
||||
#t)
|
||||
#f))
|
||||
(or (and (zero? (remainder year 4))
|
||||
(not (zero? (remainder year 100))))
|
||||
(zero? (remainder year 400))))
|
||||
|
||||
;; number of days in year
|
||||
(define (gnc:days-in-year year)
|
||||
@ -198,7 +181,7 @@
|
||||
(/ (- (/ (/ caltime 3600.0) 24) 3) 7))
|
||||
|
||||
(define (gnc:date-to-week caltime)
|
||||
(quotient (- (quotient caltime 86400) 3) 7))
|
||||
(floor (/ (- (/ caltime 86400) 3) 7)))
|
||||
|
||||
;; convert a date in seconds since 1970 into # of days since Feb 28, 1970
|
||||
;; ignoring leap-seconds
|
||||
@ -221,7 +204,7 @@
|
||||
|
||||
;; Modify a date
|
||||
(define (moddate op adate delta)
|
||||
(let ((newtm (gnc:timepair->date adate)))
|
||||
(let ((newtm (gnc-localtime adate)))
|
||||
(begin
|
||||
(set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
|
||||
(set-tm:min newtm (op (tm:min newtm) (tm:min delta)))
|
||||
@ -229,87 +212,48 @@
|
||||
(set-tm:mday newtm (op (tm:mday newtm) (tm:mday delta)))
|
||||
(set-tm:mon newtm (op (tm:mon newtm) (tm:mon delta)))
|
||||
(set-tm:year newtm (op (tm:year newtm) (tm:year delta)))
|
||||
(set-tm:isdst newtm 0)
|
||||
(gnc:date->timepair newtm))))
|
||||
(set-tm:isdst newtm -1)
|
||||
(gnc-mktime newtm))))
|
||||
|
||||
;; Add or subtract time from a date
|
||||
(define (decdate adate delta)(moddate - adate delta ))
|
||||
(define (incdate adate delta)(moddate + adate delta ))
|
||||
|
||||
;; Time comparison, true if t2 is later than t1
|
||||
;; FIXME: RENAME THIS FUNCTION!!!!
|
||||
|
||||
(define (gnc:timepair-later t1 t2)
|
||||
(cond ((< (car t1) (car t2)) #t)
|
||||
((= (car t1) (car t2)) (< (cdr t2) (cdr t2)))
|
||||
(else #f)))
|
||||
|
||||
(define gnc:timepair-lt gnc:timepair-later)
|
||||
|
||||
(define (gnc:timepair-earlier t1 t2)
|
||||
(gnc:timepair-later t2 t1))
|
||||
|
||||
(define (gnc:timepair-gt t1 t2)
|
||||
(gnc:timepair-earlier t1 t2))
|
||||
|
||||
;; t1 <= t2
|
||||
(define (gnc:timepair-le t1 t2)
|
||||
(cond ((< (car t1) (car t2)) #t)
|
||||
((= (car t1) (car t2)) (<= (cdr t2) (cdr t2)))
|
||||
(else #f)))
|
||||
|
||||
(define (gnc:timepair-ge t1 t2)
|
||||
(gnc:timepair-le t2 t1))
|
||||
|
||||
(define (gnc:timepair-eq t1 t2)
|
||||
(and (= (car t1) (car t2)) (= (cdr t1) (cdr t2))))
|
||||
(define (decdate adate delta) (moddate - adate delta ))
|
||||
(define (incdate adate delta) (moddate + adate delta ))
|
||||
|
||||
;; date-granularity comparison functions.
|
||||
|
||||
(define (gnc:timepair-earlier-date t1 t2)
|
||||
(gnc:timepair-earlier (timespecCanonicalDayTime t1)
|
||||
(timespecCanonicalDayTime t2)))
|
||||
(define (gnc:time64-le-date t1 t2)
|
||||
(<= (time64CanonicalDayTime t1)
|
||||
(time64CanonicalDayTime t2)))
|
||||
|
||||
(define (gnc:timepair-later-date t1 t2)
|
||||
(gnc:timepair-earlier-date t2 t1))
|
||||
|
||||
(define (gnc:timepair-le-date t1 t2)
|
||||
(gnc:timepair-le (timespecCanonicalDayTime t1)
|
||||
(timespecCanonicalDayTime t2)))
|
||||
|
||||
(define (gnc:timepair-ge-date t1 t2)
|
||||
(gnc:timepair-le t2 t1))
|
||||
|
||||
(define (gnc:timepair-eq-date t1 t2)
|
||||
(gnc:timepair-eq (timespecCanonicalDayTime t1)
|
||||
(timespecCanonicalDayTime t2)))
|
||||
(define (gnc:time64-ge-date t1 t2)
|
||||
(gnc:time64-le-date t2 t1))
|
||||
|
||||
;; Build a list of time intervals.
|
||||
;;
|
||||
;; Note that the last interval will be shorter than <incr> if
|
||||
;; (<curd>-<endd>) is not an integer multiple of <incr>. If you don't
|
||||
;; want that you'll have to write another function.
|
||||
(define (gnc:make-date-interval-list curd endd incr)
|
||||
(cond ((gnc:timepair-later curd endd)
|
||||
(let ((nextd (incdate curd incr)))
|
||||
(cond ((gnc:timepair-later nextd endd)
|
||||
(cons (list curd (decdate nextd SecDelta) '())
|
||||
(gnc:make-date-interval-list nextd endd incr)))
|
||||
(else (cons (list curd endd '()) '())))))
|
||||
(else '())))
|
||||
|
||||
(define (gnc:make-date-interval-list current-date end-date increment)
|
||||
(if (< current-date end-date)
|
||||
(let ((next-date (incdate current-date increment)))
|
||||
(if (< next-date end-date)
|
||||
(cons (list current-date (decdate next-date SecDelta) '())
|
||||
(gnc:make-date-interval-list next-date end-date increment))
|
||||
(cons (list current-date end-date '())
|
||||
'())))
|
||||
'()))
|
||||
|
||||
;; Build a list of times. The dates are evenly spaced with the
|
||||
;; stepsize 'incr'. If the difference of 'startdate' and 'enddate' is
|
||||
;; not an integer multiple of 'incr', 'enddate' will be added as the
|
||||
;; last element of the list, thus making the last interval smaller
|
||||
;; than 'incr'.
|
||||
(define (gnc:make-date-list startdate enddate incr)
|
||||
(cond ((gnc:timepair-later startdate enddate)
|
||||
(cons startdate
|
||||
(gnc:make-date-list (incdate startdate incr)
|
||||
enddate incr)))
|
||||
(else (list enddate))))
|
||||
|
||||
(define (gnc:make-date-list startdate enddate incr)
|
||||
(if (< startdate enddate)
|
||||
(cons startdate
|
||||
(gnc:make-date-list (incdate startdate incr)
|
||||
enddate incr))
|
||||
(list enddate)))
|
||||
|
||||
; A reference zero date - the Beginning Of The Epoch
|
||||
; Note: use of eval is evil... by making this a generator function,
|
||||
@ -399,46 +343,31 @@
|
||||
(cdr retval)
|
||||
#f)))
|
||||
|
||||
;; Find difference in seconds time 1 and time2
|
||||
(define (gnc:timepair-delta t1 t2)
|
||||
(- (gnc:timepair->secs t2) (gnc:timepair->secs t1)))
|
||||
|
||||
;; find float difference between times
|
||||
(define (gnc:time-elapsed t1 t2)
|
||||
(+ (- (car t2)
|
||||
(car t1))
|
||||
(/ (- (cdr t2)
|
||||
(cdr t1)) 1000000.0)))
|
||||
|
||||
;; timepair manipulation functions
|
||||
;; hack alert - these should probably be put somewhere else
|
||||
;; and be implemented PROPERLY rather than hackily
|
||||
;;; Added from transaction-report.scm
|
||||
|
||||
;; given a timepair contains any time on a certain day (local time)
|
||||
;; given a time64 time on a certain day (local time)
|
||||
;; converts it to be midday that day.
|
||||
|
||||
(define (gnc:timepair-start-day-time tp)
|
||||
(let ((bdt (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-start-day-time t64)
|
||||
(let ((bdt (gnc-localtime t64)))
|
||||
(set-tm:sec bdt 0)
|
||||
(set-tm:min bdt 0)
|
||||
(set-tm:hour bdt 0)
|
||||
(set-tm:isdst bdt -1)
|
||||
(gnc:date->timepair bdt)))
|
||||
(gnc-mktime bdt)))
|
||||
|
||||
(define (gnc:timepair-end-day-time tp)
|
||||
(let ((bdt (gnc:timepair->date tp)))
|
||||
(define (gnc:time64-end-day-time t64)
|
||||
(let ((bdt (gnc-localtime t64)))
|
||||
(set-tm:sec bdt 59)
|
||||
(set-tm:min bdt 59)
|
||||
(set-tm:hour bdt 23)
|
||||
(set-tm:isdst bdt -1)
|
||||
(gnc:date->timepair bdt)))
|
||||
(gnc-mktime bdt)))
|
||||
|
||||
(define (gnc:timepair-previous-day tp)
|
||||
(decdate tp DayDelta))
|
||||
(define (gnc:time64-previous-day t64)
|
||||
(decdate t64 DayDelta))
|
||||
|
||||
(define (gnc:time64-next-day t64)
|
||||
(incdate t64 DayDelta))
|
||||
|
||||
(define (gnc:timepair-next-day tp)
|
||||
(incdate tp DayDelta))
|
||||
|
||||
(define (gnc:reldate-get-symbol x) (vector-ref x 0))
|
||||
(define (gnc:reldate-get-string x) (vector-ref x 1))
|
||||
@ -486,7 +415,7 @@
|
||||
(set-tm:mday now 1)
|
||||
(set-tm:mon now 0)
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-cal-year)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -496,7 +425,7 @@
|
||||
(set-tm:mday now 31)
|
||||
(set-tm:mon now 11)
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-prev-year)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -507,7 +436,7 @@
|
||||
(set-tm:mon now 0)
|
||||
(set-tm:year now (- (tm:year now) 1))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-prev-year)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -518,7 +447,7 @@
|
||||
(set-tm:mon now 11)
|
||||
(set-tm:year now (- (tm:year now) 1))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-next-year)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -529,7 +458,7 @@
|
||||
(set-tm:mon now 0)
|
||||
(set-tm:year now (+ (tm:year now) 1))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-next-year)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -540,13 +469,13 @@
|
||||
(set-tm:mon now 11)
|
||||
(set-tm:year now (+ (tm:year now) 1))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-accounting-period)
|
||||
(gnc:secs->timepair (gnc-accounting-period-fiscal-start)))
|
||||
(gnc-accounting-period-fiscal-start))
|
||||
|
||||
(define (gnc:get-end-accounting-period)
|
||||
(gnc:secs->timepair (gnc-accounting-period-fiscal-end)))
|
||||
(gnc-accounting-period-fiscal-end))
|
||||
|
||||
(define (gnc:get-start-this-month)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -555,7 +484,7 @@
|
||||
(set-tm:hour now 0)
|
||||
(set-tm:mday now 1)
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-this-month)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -565,7 +494,7 @@
|
||||
(set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
|
||||
(+ (tm:year now) 1900)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-prev-month)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -579,7 +508,7 @@
|
||||
(set-tm:year now (- (tm:year now) 1)))
|
||||
(set-tm:mon now (- (tm:mon now) 1)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-prev-month)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -594,7 +523,7 @@
|
||||
(set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
|
||||
(+ (tm:year now) 1900)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-next-month)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -608,7 +537,7 @@
|
||||
(set-tm:year now (+ (tm:year now) 1)))
|
||||
(set-tm:mon now (+ (tm:mon now) 1)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-next-month)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -623,7 +552,7 @@
|
||||
(set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
|
||||
(+ (tm:year now) 1900)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-current-quarter)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -633,7 +562,7 @@
|
||||
(set-tm:mday now 1)
|
||||
(set-tm:mon now (- (tm:mon now) (modulo (tm:mon now) 3)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-current-quarter)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -645,7 +574,7 @@
|
||||
(set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
|
||||
(+ (tm:year now) 1900)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-prev-quarter)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -660,7 +589,7 @@
|
||||
(set-tm:year now (- (tm:year now) 1)))
|
||||
(set-tm:mon now (- (tm:mon now) 3)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-prev-quarter)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -676,7 +605,7 @@
|
||||
(set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
|
||||
(+ (tm:year now) 1900)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-start-next-quarter)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -690,7 +619,7 @@
|
||||
(set-tm:year now (+ (tm:year now) 1)))
|
||||
(set-tm:mon now (+ (tm:mon now) (- 3 (modulo (tm:mon now) 3)))))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-end-next-quarter)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -706,10 +635,10 @@
|
||||
(set-tm:mday now (gnc:days-in-month (+ (tm:mon now) 1)
|
||||
(+ (tm:year now) 1900)))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now)))
|
||||
(gnc-mktime now)))
|
||||
|
||||
(define (gnc:get-today)
|
||||
(cons (current-time) 0))
|
||||
(current-time))
|
||||
|
||||
(define (gnc:get-one-month-ago)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -723,7 +652,7 @@
|
||||
(if (> month-length (tm:mday now))
|
||||
(set-tm:mday now month-length))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-three-months-ago)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -737,7 +666,7 @@
|
||||
(if (> month-days (tm:mday now))
|
||||
(set-tm:mday now month-days))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-six-months-ago)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -751,7 +680,7 @@
|
||||
(if (> month-days (tm:mday now))
|
||||
(set-tm:mday now month-days))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-one-year-ago)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -761,7 +690,7 @@
|
||||
(if (> month-days (tm:mday now))
|
||||
(set-tm:mday now month-days))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-one-month-ahead)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -775,7 +704,7 @@
|
||||
(if (> month-length (tm:mday now))
|
||||
(set-tm:mday now month-length))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-three-months-ahead)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -789,7 +718,7 @@
|
||||
(if (> month-days (tm:mday now))
|
||||
(set-tm:mday now month-days))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-six-months-ahead)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -803,7 +732,7 @@
|
||||
(if (> month-days (tm:mday now))
|
||||
(set-tm:mday now month-days))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
(define (gnc:get-one-year-ahead)
|
||||
(let ((now (gnc-localtime (current-time))))
|
||||
@ -813,7 +742,7 @@
|
||||
(if (> month-days (tm:mday now))
|
||||
(set-tm:mday now month-days))
|
||||
(set-tm:isdst now -1)
|
||||
(gnc:date->timepair now))))
|
||||
(gnc-mktime now))))
|
||||
|
||||
;; There is no GNC:RELATIVE-DATES list like the one mentioned in
|
||||
;; gnucash-design.info, is there? Here are the currently defined
|
||||
|
@ -2,6 +2,7 @@
|
||||
* guile-util.c -- utility functions for using guile for GnuCash *
|
||||
* Copyright (C) 1999 Linas Vepstas *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* Copyright (C) 2017 Aaron Laws *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -707,19 +708,14 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
|
||||
* Returns: Nothing *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_trans_scm_set_date(SCM trans_scm, Timespec *ts)
|
||||
gnc_trans_scm_set_date(SCM trans_scm, time64 time)
|
||||
{
|
||||
SCM arg;
|
||||
|
||||
Timespec ts = {time, 0};
|
||||
initialize_scm_functions();
|
||||
|
||||
if (!gnc_is_trans_scm(trans_scm))
|
||||
return;
|
||||
if (ts == NULL)
|
||||
return;
|
||||
|
||||
arg = gnc_timespec2timepair(*ts);
|
||||
|
||||
arg = gnc_timespec2timepair(ts);
|
||||
scm_call_2(setters.trans_scm_date, trans_scm, arg);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* guile-util.h -- utility functions for using guile for GnuCash *
|
||||
* Copyright (C) 1999 Linas Vepstas *
|
||||
* Copyright (C) 2017 Aaron Laws *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -67,7 +68,7 @@ void gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
|
||||
gboolean do_commit,
|
||||
QofBook *book);
|
||||
|
||||
void gnc_trans_scm_set_date(SCM trans_scm, Timespec *ts);
|
||||
void gnc_trans_scm_set_date(SCM trans_scm, time64 time);
|
||||
void gnc_trans_scm_set_num(SCM trans_scm, const char *num);
|
||||
void gnc_trans_scm_set_description(SCM trans_scm, const char *description);
|
||||
void gnc_trans_scm_set_notes(SCM trans_scm, const char *notes);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* option-util.c -- GNOME<->guile option interface *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* Copyright (C) 2017 Aaron Laws *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -2085,112 +2086,6 @@ gnc_option_db_lookup_multichoice_option(GNCOptionDB *odb,
|
||||
return strdup(default_value);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_option_db_lookup_date_option *
|
||||
* looks up a date option. If present, returns the absolute date *
|
||||
* represented in the set_ab_value argument provided, otherwise *
|
||||
* copies the default_value argument (if non-NULL) to the *
|
||||
* set_ab_value argument. If the default_value argument is NULL, *
|
||||
* copies the current date to set_ab_value. Whatever value is *
|
||||
* stored in set_ab_value is returned as an approximate (no *
|
||||
* nanoseconds) time64 value. set_ab_value may be NULL, in which *
|
||||
* case only the return value can be used. If is_relative is *
|
||||
* non-NULL, it is set to whether the date option is currently *
|
||||
* storing a relative date. If it is, and set_rel_value *
|
||||
* is non-NULL, it returns a newly allocated string *
|
||||
* representing the scheme symbol for that relative date *
|
||||
* *
|
||||
* Args: odb - option database to search in *
|
||||
* section - section name of option *
|
||||
* name - name of option *
|
||||
* is_relative - location to store boolean value *
|
||||
* set_ab_value - location to store absolute option value *
|
||||
* set_rel_value - location to store relative option value *
|
||||
* default - default value if not found *
|
||||
* Return: time64 approximation of set_value *
|
||||
\********************************************************************/
|
||||
time64
|
||||
gnc_option_db_lookup_date_option(GNCOptionDB *odb,
|
||||
const char *section,
|
||||
const char *name,
|
||||
gboolean *is_relative,
|
||||
Timespec *set_ab_value,
|
||||
char **set_rel_value,
|
||||
Timespec *default_value)
|
||||
{
|
||||
GNCOption *option;
|
||||
Timespec temp = {0, 0};
|
||||
char *symbol;
|
||||
SCM getter;
|
||||
SCM value;
|
||||
|
||||
initialize_getters();
|
||||
|
||||
if (set_ab_value == NULL)
|
||||
{
|
||||
set_ab_value = &temp;
|
||||
}
|
||||
|
||||
if (set_rel_value != NULL)
|
||||
{
|
||||
*set_rel_value = NULL;
|
||||
}
|
||||
|
||||
if (is_relative != NULL)
|
||||
{
|
||||
*is_relative = FALSE;
|
||||
}
|
||||
|
||||
option = gnc_option_db_get_option_by_name(odb, section, name);
|
||||
|
||||
if (option != NULL)
|
||||
{
|
||||
getter = gnc_option_getter(option);
|
||||
if (getter != SCM_UNDEFINED)
|
||||
{
|
||||
value = scm_call_0(getter);
|
||||
|
||||
if (scm_is_pair(value))
|
||||
{
|
||||
Timespec absolute;
|
||||
|
||||
absolute = gnc_date_option_value_get_absolute (value);
|
||||
|
||||
*set_ab_value = absolute;
|
||||
|
||||
symbol = gnc_date_option_value_get_type (value);
|
||||
|
||||
if (g_strcmp0(symbol, "relative") == 0)
|
||||
{
|
||||
SCM relative = gnc_date_option_value_get_relative (value);
|
||||
|
||||
if (is_relative != NULL)
|
||||
*is_relative = TRUE;
|
||||
|
||||
if (set_rel_value != NULL)
|
||||
*set_rel_value = gnc_scm_symbol_to_locale_string (relative);
|
||||
}
|
||||
|
||||
g_free (symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (default_value == NULL)
|
||||
{
|
||||
set_ab_value->tv_sec = gnc_time (NULL);
|
||||
set_ab_value->tv_nsec = 0;
|
||||
}
|
||||
else
|
||||
*set_ab_value = *default_value;
|
||||
}
|
||||
|
||||
return set_ab_value->tv_sec;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_option_db_lookup_number_option *
|
||||
* looks up a number option. If present, returns its value *
|
||||
@ -2609,18 +2504,15 @@ gnc_date_option_value_get_type (SCM option_value)
|
||||
* get the absolute time of a date option value *
|
||||
* *
|
||||
* Args: option_value - option value to get absolute time of *
|
||||
* Return: Timespec value *
|
||||
* Return: time64 value *
|
||||
\*******************************************************************/
|
||||
Timespec
|
||||
time64
|
||||
gnc_date_option_value_get_absolute (SCM option_value)
|
||||
{
|
||||
SCM value;
|
||||
|
||||
initialize_getters();
|
||||
|
||||
value = scm_call_1 (getters.date_option_value_absolute, option_value);
|
||||
|
||||
return gnc_timepair2timespec (value);
|
||||
return scm_to_int64 (value);
|
||||
}
|
||||
|
||||
/*******************************************************************\
|
||||
|
@ -2,6 +2,7 @@
|
||||
* option-util.h -- GNOME<->guile option interface *
|
||||
* Copyright (C) 1998,1999 Linas Vepstas *
|
||||
* Copyright (C) 2000 Dave Peticolas *
|
||||
* Copyright (C) 2017 Aaron Laws *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -182,14 +183,6 @@ char * gnc_option_db_lookup_multichoice_option(GNCOptionDB *odb,
|
||||
const char *name,
|
||||
const char *default_value);
|
||||
|
||||
time64 gnc_option_db_lookup_date_option(GNCOptionDB *odb,
|
||||
const char *section,
|
||||
const char *name,
|
||||
gboolean *is_relative,
|
||||
Timespec *set_ab_value,
|
||||
char **set_rel_value,
|
||||
Timespec *default_value);
|
||||
|
||||
gdouble gnc_option_db_lookup_number_option(GNCOptionDB *odb,
|
||||
const char *section,
|
||||
const char *name,
|
||||
@ -248,7 +241,7 @@ gboolean gnc_option_db_set_string_option(GNCOptionDB *odb,
|
||||
char * gnc_option_date_option_get_subtype(GNCOption *option);
|
||||
|
||||
char * gnc_date_option_value_get_type (SCM option_value);
|
||||
Timespec gnc_date_option_value_get_absolute (SCM option_value);
|
||||
time64 gnc_date_option_value_get_absolute (SCM option_value);
|
||||
SCM gnc_date_option_value_get_relative (SCM option_value);
|
||||
|
||||
char * gnc_plot_size_option_value_get_type (SCM option_value);
|
||||
|
@ -562,13 +562,24 @@
|
||||
subtype
|
||||
relative-date-list)
|
||||
(define (date-legal date)
|
||||
(and (pair? date)
|
||||
(or
|
||||
(and (pair? date)
|
||||
(or
|
||||
(and (eq? 'relative (car date)) (symbol? (cdr date)))
|
||||
(and (eq? 'absolute (car date))
|
||||
(pair? (cdr date))
|
||||
(exact? (cadr date))
|
||||
(exact? (cddr date))))))
|
||||
(and (eq? 'absolute (car date))
|
||||
(or (and (pair? (cdr date)) ; we can still accept
|
||||
(exact? (cadr date)) ; old-style timepairs
|
||||
(exact? (cddr date)))
|
||||
(and (number? (cdr date))
|
||||
(exact? (cdr date))))))))
|
||||
(define (maybe-convert-to-time64 date)
|
||||
;; compatibility shim. this is triggered only when date is type
|
||||
;; (cons 'absolute (cons sec nsec)) - we'll convert to
|
||||
;; (cons 'absolute sec). this shim must always be kept for gnucash
|
||||
;; to reload saved reports, or reload reports launched at startup,
|
||||
;; which had been saved as timepairs.
|
||||
(if (pair? (cdr date))
|
||||
(cons (car date) (cadr date))
|
||||
date))
|
||||
(define (list-lookup list item)
|
||||
(cond
|
||||
((null? list) #f)
|
||||
@ -582,7 +593,7 @@
|
||||
(lambda () value)
|
||||
(lambda (date)
|
||||
(if (date-legal date)
|
||||
(set! value date)
|
||||
(set! value (maybe-convert-to-time64 date))
|
||||
(gnc:error "Illegal date value set:" date)))
|
||||
default-getter
|
||||
(gnc:restore-form-generator value->string)
|
||||
|
@ -111,7 +111,6 @@ static xmlNodePtr
|
||||
entry_dom_tree_create (GncEntry* entry)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
Timespec ts;
|
||||
Account* acc;
|
||||
GncTaxTable* taxtable;
|
||||
GncOrder* order;
|
||||
@ -123,11 +122,11 @@ entry_dom_tree_create (GncEntry* entry)
|
||||
xmlAddChild (ret, guid_to_dom_tree (entry_guid_string,
|
||||
qof_instance_get_guid (QOF_INSTANCE (entry))));
|
||||
|
||||
ts = gncEntryGetDate (entry);
|
||||
xmlAddChild (ret, timespec_to_dom_tree (entry_date_string, &ts));
|
||||
auto time = gncEntryGetDate (entry);
|
||||
xmlAddChild (ret, time64_to_dom_tree (entry_date_string, time));
|
||||
|
||||
ts = gncEntryGetDateEntered (entry);
|
||||
xmlAddChild (ret, timespec_to_dom_tree (entry_dateentered_string, &ts));
|
||||
time = gncEntryGetDateEntered (entry);
|
||||
xmlAddChild (ret, time64_to_dom_tree (entry_dateentered_string, time));
|
||||
|
||||
maybe_add_string (ret, entry_description_string,
|
||||
gncEntryGetDescription (entry));
|
||||
@ -241,13 +240,12 @@ set_string (xmlNodePtr node, GncEntry* entry,
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
set_timespec (xmlNodePtr node, GncEntry* entry,
|
||||
void (*func) (GncEntry* entry, Timespec ts))
|
||||
set_time64 (xmlNodePtr node, GncEntry* entry,
|
||||
void (*func) (GncEntry* entry, time64 ts))
|
||||
{
|
||||
Timespec ts = dom_tree_to_timespec (node);
|
||||
if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
|
||||
|
||||
func (entry, ts);
|
||||
time64 time = dom_tree_to_time64 (node);
|
||||
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||
func (entry, time);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -350,16 +348,14 @@ static gboolean
|
||||
entry_date_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata* pdata = static_cast<decltype (pdata)> (entry_pdata);
|
||||
|
||||
return set_timespec (node, pdata->entry, gncEntrySetDate);
|
||||
return set_time64 (node, pdata->entry, gncEntrySetDate);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
entry_dateentered_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata* pdata = static_cast<decltype (pdata)> (entry_pdata);
|
||||
|
||||
return set_timespec (node, pdata->entry, gncEntrySetDateEntered);
|
||||
return set_time64 (node, pdata->entry, gncEntrySetDateEntered);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -81,17 +81,17 @@ maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
}
|
||||
|
||||
static void
|
||||
maybe_add_timespec (xmlNodePtr ptr, const char* tag, Timespec ts)
|
||||
maybe_add_time64 (xmlNodePtr ptr, const char* tag, time64 time)
|
||||
{
|
||||
if (ts.tv_sec || ts.tv_nsec)
|
||||
xmlAddChild (ptr, timespec_to_dom_tree (tag, &ts));
|
||||
if (time)
|
||||
xmlAddChild (ptr, time64_to_dom_tree (tag, time));
|
||||
}
|
||||
|
||||
static xmlNodePtr
|
||||
invoice_dom_tree_create (GncInvoice* invoice)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
Timespec ts;
|
||||
time64 time;
|
||||
Transaction* txn;
|
||||
GNCLot* lot;
|
||||
Account* acc;
|
||||
@ -111,11 +111,10 @@ invoice_dom_tree_create (GncInvoice* invoice)
|
||||
xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string,
|
||||
gncInvoiceGetOwner (invoice)));
|
||||
|
||||
ts = gncInvoiceGetDateOpened (invoice);
|
||||
xmlAddChild (ret, timespec_to_dom_tree (invoice_opened_string, &ts));
|
||||
time = gncInvoiceGetDateOpened (invoice);
|
||||
xmlAddChild (ret, time64_to_dom_tree (invoice_opened_string, time));
|
||||
|
||||
maybe_add_timespec (ret, invoice_posted_string,
|
||||
gncInvoiceGetDatePosted (invoice));
|
||||
maybe_add_time64 (ret, invoice_posted_string, gncInvoiceGetDatePosted (invoice));
|
||||
|
||||
term = gncInvoiceGetTerms (invoice);
|
||||
if (term)
|
||||
@ -185,13 +184,12 @@ set_string (xmlNodePtr node, GncInvoice* invoice,
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
set_timespec (xmlNodePtr node, GncInvoice* invoice,
|
||||
void (*func) (GncInvoice* invoice, Timespec ts))
|
||||
set_time64 (xmlNodePtr node, GncInvoice* invoice,
|
||||
void (*func) (GncInvoice* invoice, time64 time))
|
||||
{
|
||||
Timespec ts = dom_tree_to_timespec (node);
|
||||
if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
|
||||
|
||||
func (invoice, ts);
|
||||
time64 time = dom_tree_to_time64 (node);
|
||||
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||
func (invoice, time);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -247,16 +245,14 @@ static gboolean
|
||||
invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata)
|
||||
{
|
||||
struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
|
||||
|
||||
return set_timespec (node, pdata->invoice, gncInvoiceSetDateOpened);
|
||||
return set_time64 (node, pdata->invoice, gncInvoiceSetDateOpened);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata)
|
||||
{
|
||||
struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
|
||||
|
||||
return set_timespec (node, pdata->invoice, gncInvoiceSetDatePosted);
|
||||
return set_time64 (node, pdata->invoice, gncInvoiceSetDatePosted);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -90,11 +90,11 @@ order_dom_tree_create (GncOrder* order)
|
||||
gncOrderGetOwner (order)));
|
||||
|
||||
ts = gncOrderGetDateOpened (order);
|
||||
xmlAddChild (ret, timespec_to_dom_tree (order_opened_string, &ts));
|
||||
xmlAddChild (ret, time64_to_dom_tree (order_opened_string, ts.tv_sec));
|
||||
|
||||
ts = gncOrderGetDateClosed (order);
|
||||
if (ts.tv_sec || ts.tv_nsec)
|
||||
xmlAddChild (ret, timespec_to_dom_tree (order_closed_string, &ts));
|
||||
if (ts.tv_sec)
|
||||
xmlAddChild (ret, time64_to_dom_tree (order_closed_string, ts.tv_sec));
|
||||
|
||||
maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
|
||||
maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));
|
||||
@ -134,9 +134,9 @@ static inline gboolean
|
||||
set_timespec (xmlNodePtr node, GncOrder* order,
|
||||
void (*func) (GncOrder* order, Timespec ts))
|
||||
{
|
||||
Timespec ts = dom_tree_to_timespec (node);
|
||||
if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
|
||||
|
||||
time64 time = dom_tree_to_time64 (node);
|
||||
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||
Timespec ts {time, 0};
|
||||
func (order, ts);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -113,9 +113,10 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
|
||||
}
|
||||
else if (g_strcmp0 ("price:time", (char*)sub_node->name) == 0)
|
||||
{
|
||||
Timespec t = dom_tree_to_timespec (sub_node);
|
||||
if (!dom_tree_valid_timespec (&t, sub_node->name)) return FALSE;
|
||||
gnc_price_set_time (p, t);
|
||||
time64 time = dom_tree_to_time64 (sub_node);
|
||||
if (!dom_tree_valid_time64 (time, sub_node->name)) return FALSE;
|
||||
Timespec ts {time, 0};
|
||||
gnc_price_set_time (p, ts);
|
||||
}
|
||||
else if (g_strcmp0 ("price:source", (char*)sub_node->name) == 0)
|
||||
{
|
||||
@ -438,7 +439,7 @@ gnc_price_to_dom_tree (const xmlChar* tag, GNCPrice* price)
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
|
||||
timesp = gnc_price_get_time (price);
|
||||
tmpnode = timespec_to_dom_tree ("price:time", ×p);
|
||||
tmpnode = time64_to_dom_tree ("price:time", timesp.tv_sec);
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
|
||||
sourcestr = gnc_price_get_source_string (price);
|
||||
|
@ -56,12 +56,19 @@ add_gnc_num (xmlNodePtr node, const gchar* tag, gnc_numeric 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
|
||||
add_timespec (xmlNodePtr node, const gchar* tag, Timespec tms, gboolean always)
|
||||
{
|
||||
if (always || ! ((tms.tv_sec == 0) && (tms.tv_nsec == 0)))
|
||||
if (always || tms.tv_sec)
|
||||
{
|
||||
xmlAddChild (node, timespec_to_dom_tree (tag, &tms));
|
||||
xmlAddChild (node, time64_to_dom_tree (tag, tms.tv_sec));
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,10 +179,10 @@ gnc_transaction_dom_tree_create (Transaction* trn)
|
||||
}
|
||||
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",
|
||||
xaccTransRetDateEnteredTS (trn), TRUE);
|
||||
add_time64 (ret, "trn:date-entered",
|
||||
xaccTransRetDateEntered (trn), TRUE);
|
||||
|
||||
str = g_strdup (xaccTransGetDescription (trn));
|
||||
if (str)
|
||||
@ -275,13 +282,9 @@ static gboolean
|
||||
spl_reconcile_date_handler (xmlNodePtr node, gpointer data)
|
||||
{
|
||||
struct split_pdata* pdata = static_cast<decltype (pdata)> (data);
|
||||
Timespec ts;
|
||||
|
||||
ts = dom_tree_to_timespec (node);
|
||||
if (!dom_tree_valid_timespec (&ts, node->name)) return FALSE;
|
||||
|
||||
xaccSplitSetDateReconciledTS (pdata->split, &ts);
|
||||
|
||||
time64 time = dom_tree_to_time64 (node);
|
||||
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||
xaccSplitSetDateReconciledSecs (pdata->split, time);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -430,18 +433,24 @@ set_tran_string (xmlNodePtr node, Transaction* trn,
|
||||
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
|
||||
set_tran_date (xmlNodePtr node, Transaction* trn,
|
||||
void (*func) (Transaction* trn, const Timespec* tm))
|
||||
{
|
||||
Timespec tm;
|
||||
|
||||
tm = dom_tree_to_timespec (node);
|
||||
|
||||
if (!dom_tree_valid_timespec (&tm, node->name)) return FALSE;
|
||||
|
||||
func (trn, &tm);
|
||||
|
||||
time64 time = dom_tree_to_time64 (node);
|
||||
if (!dom_tree_valid_time64 (time, node->name)) return FALSE;
|
||||
Timespec ts {time, 0};
|
||||
func (trn, &ts);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -489,7 +498,7 @@ trn_date_posted_handler (xmlNodePtr node, gpointer trans_pdata)
|
||||
struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
|
||||
Transaction* trn = pdata->trans;
|
||||
|
||||
return set_tran_date (node, trn, xaccTransSetDatePostedTS);
|
||||
return set_tran_time64 (node, trn, xaccTransSetDatePostedSecs);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -498,7 +507,7 @@ trn_date_entered_handler (xmlNodePtr node, gpointer trans_pdata)
|
||||
struct trans_pdata* pdata = static_cast<decltype (pdata)> (trans_pdata);
|
||||
Transaction* trn = pdata->trans;
|
||||
|
||||
return set_tran_date (node, trn, xaccTransSetDateEnteredTS);
|
||||
return set_tran_time64 (node, trn, xaccTransSetDateEnteredSecs);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -2350,7 +2350,7 @@ txn_rest_date_posted_end_handler (gpointer data_for_children,
|
||||
gpointer* result, const gchar* tag)
|
||||
{
|
||||
Transaction* t = (Transaction*) parent_data;
|
||||
TimespecParseInfo* info = (TimespecParseInfo*) data_for_children;
|
||||
Time64ParseInfo* info = (Time64ParseInfo*) data_for_children;
|
||||
|
||||
g_return_val_if_fail (info, FALSE);
|
||||
if (!t || !timespec_parse_ok (info))
|
||||
@ -2359,7 +2359,7 @@ txn_rest_date_posted_end_handler (gpointer data_for_children,
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
xaccTransSetDatePostedTS (t, & (info->ts));
|
||||
xaccTransSetDatePostedSecs (t, info->time);
|
||||
g_free (info);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -2382,7 +2382,7 @@ txn_rest_date_entered_end_handler (gpointer data_for_children,
|
||||
gpointer* result, const gchar* tag)
|
||||
{
|
||||
Transaction* t = (Transaction*) parent_data;
|
||||
TimespecParseInfo* info = (TimespecParseInfo*) data_for_children;
|
||||
Time64ParseInfo* info = (Time64ParseInfo*) data_for_children;
|
||||
|
||||
g_return_val_if_fail (info, FALSE);
|
||||
if (!t || !timespec_parse_ok (info))
|
||||
@ -2391,7 +2391,7 @@ txn_rest_date_entered_end_handler (gpointer data_for_children,
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
xaccTransSetDateEnteredTS (t, & (info->ts));
|
||||
xaccTransSetDateEnteredSecs (t, info->time);
|
||||
g_free (info);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -2713,7 +2713,7 @@ txn_restore_split_reconcile_date_end_handler (gpointer data_for_children,
|
||||
gpointer* result, const gchar* tag)
|
||||
{
|
||||
Split* s = (Split*) parent_data;
|
||||
TimespecParseInfo* info = (TimespecParseInfo*) data_for_children;
|
||||
Time64ParseInfo* info = (Time64ParseInfo*) data_for_children;
|
||||
|
||||
g_return_val_if_fail (info, FALSE);
|
||||
if (!s || !timespec_parse_ok (info))
|
||||
@ -2722,7 +2722,7 @@ txn_restore_split_reconcile_date_end_handler (gpointer data_for_children,
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
xaccSplitSetDateReconciledTS (s, & (info->ts));
|
||||
xaccSplitSetDateReconciledSecs (s, info->time);
|
||||
g_free (info);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -2959,9 +2959,10 @@ price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
|
||||
}
|
||||
else if (g_strcmp0 ("price:time", (char*)sub_node->name) == 0)
|
||||
{
|
||||
Timespec t = dom_tree_to_timespec (sub_node);
|
||||
if (!dom_tree_valid_timespec (&t, sub_node->name)) return FALSE;
|
||||
gnc_price_set_time (p, t);
|
||||
time64 time = dom_tree_to_time64 (sub_node);
|
||||
if (!dom_tree_valid_time64 (time, sub_node->name)) return FALSE;
|
||||
Timespec ts = {time, 0};
|
||||
gnc_price_set_time (p, ts);
|
||||
}
|
||||
else if (g_strcmp0 ("price:source", (char*)sub_node->name) == 0)
|
||||
{
|
||||
|
@ -132,54 +132,23 @@ commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c)
|
||||
}
|
||||
|
||||
char*
|
||||
timespec_sec_to_string (const Timespec* ts)
|
||||
time64_to_string (time64 time)
|
||||
{
|
||||
return gnc_print_time64 (ts->tv_sec, "%Y-%m-%d %H:%M:%S %q");
|
||||
}
|
||||
|
||||
gchar*
|
||||
timespec_nsec_to_string (const Timespec* ts)
|
||||
{
|
||||
return g_strdup_printf ("%ld", ts->tv_nsec);
|
||||
return gnc_print_time64 (time, TIMESPEC_TIME_FORMAT " %q");
|
||||
}
|
||||
|
||||
xmlNodePtr
|
||||
timespec_to_dom_tree (const char* tag, const Timespec* spec)
|
||||
time64_to_dom_tree (const char* tag, const time64 time)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
gchar* date_str = NULL;
|
||||
gchar* ns_str = NULL;
|
||||
|
||||
g_return_val_if_fail (spec, NULL);
|
||||
|
||||
date_str = timespec_sec_to_string (spec);
|
||||
|
||||
g_return_val_if_fail (time, NULL);
|
||||
auto date_str = time64_to_string (time);
|
||||
if (!date_str)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = xmlNewNode (NULL, BAD_CAST tag);
|
||||
|
||||
xmlNewTextChild (ret, NULL, BAD_CAST "ts:date",
|
||||
checked_char_cast (date_str));
|
||||
|
||||
if (spec->tv_nsec > 0)
|
||||
{
|
||||
ns_str = timespec_nsec_to_string (spec);
|
||||
if (ns_str)
|
||||
{
|
||||
xmlNewTextChild (ret, NULL, BAD_CAST "ts:ns",
|
||||
checked_char_cast (ns_str));
|
||||
}
|
||||
}
|
||||
|
||||
g_free (date_str);
|
||||
if (ns_str)
|
||||
{
|
||||
g_free (ns_str);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -311,7 +280,7 @@ add_kvp_value_node (xmlNodePtr node, const gchar* tag, KvpValue* val)
|
||||
case KvpValue::Type::TIMESPEC:
|
||||
{
|
||||
auto ts = val->get<Timespec> ();
|
||||
val_node = timespec_to_dom_tree (tag, &ts);
|
||||
val_node = time64_to_dom_tree (tag, ts.tv_sec);
|
||||
xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
|
||||
xmlAddChild (node, val_node);
|
||||
break;
|
||||
|
@ -40,9 +40,8 @@ xmlNodePtr int_to_dom_tree (const char* tag, gint64 val);
|
||||
xmlNodePtr boolean_to_dom_tree (const char* tag, gboolean val);
|
||||
xmlNodePtr guid_to_dom_tree (const char* tag, const GncGUID* gid);
|
||||
xmlNodePtr commodity_ref_to_dom_tree (const char* tag, const gnc_commodity* c);
|
||||
xmlNodePtr timespec_to_dom_tree (const char* tag, const Timespec* spec);
|
||||
gchar* timespec_nsec_to_string (const Timespec* ts);
|
||||
gchar* timespec_sec_to_string (const Timespec* ts);
|
||||
xmlNodePtr time64_to_dom_tree (const char* tag, time64);
|
||||
gchar* time64_to_string (time64);
|
||||
xmlNodePtr gdate_to_dom_tree (const char* tag, const GDate* spec);
|
||||
xmlNodePtr gnc_numeric_to_dom_tree (const char* tag, const gnc_numeric* num);
|
||||
xmlNodePtr qof_instance_slots_to_dom_tree (const char* tag,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user