Merge branch 'maint'

This commit is contained in:
Christopher Lam 2020-05-04 23:31:21 +08:00
commit 14ea5d9751
12 changed files with 40 additions and 141 deletions

View File

@ -1,6 +1,6 @@
from unittest import main
from datetime import datetime, timedelta
from datetime import datetime, timezone, timedelta
from gnucash import Account, \
ACCT_TYPE_RECEIVABLE, ACCT_TYPE_INCOME, ACCT_TYPE_BANK, \
@ -56,8 +56,15 @@ 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())
utc_offset = datetime.now().astimezone().utcoffset()
now = datetime.now().astimezone()
neutral_time = (now + utc_offset).astimezone(timezone.utc).replace(hour=10, minute=59, second=0, microsecond=0)
if utc_offset > timedelta(hours=13):
neutral_time -= utc_offset - timedelta(hours=13);
if utc_offset < timedelta(hours=-10):
neutral_time += timedelta(hours=-10) - utc_offset
self.assertEqual(neutral_time,
self.invoice.GetDatePosted().astimezone(timezone.utc))
self.assertTrue( self.invoice.IsPosted() )
def test_owner(self):

View File

@ -237,10 +237,10 @@ function(gnc_add_scheme_targets _TARGET)
file(TO_CMAKE_PATH "$ENV{PATH}" fpath)
set(LIBRARY_PATH "PATH=${BINDIR_BUILD};${fpath}")
else()
set (LIBRARY_PATH "LD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash")
set (LIBRARY_PATH "LD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:$ENV{LD_LIBRARY_PATH}")
endif()
if (APPLE)
set (LIBRARY_PATH "DYLD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash")
set (LIBRARY_PATH "DYLD_LIBRARY_PATH=${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:$ENV{DYLD_LIBRARY_PATH}")
endif()
set(_GNC_MODULE_PATH "")
if(MINGW64)

View File

@ -9,10 +9,10 @@ function(get_guile_env)
list(APPEND env "GNC_UNINSTALLED=yes")
list(APPEND env "GNC_BUILDDIR=${CMAKE_BINARY_DIR}")
if (APPLE)
list(APPEND env "DYLD_LIBRARY_PATH=${_GNC_MODULE_PATH}")
list(APPEND env "DYLD_LIBRARY_PATH=${_GNC_MODULE_PATH}:$ENV{LD_LIBRARY_PATH}")
endif()
if (UNIX)
list(APPEND env LD_LIBRARY_PATH=${_GNC_MODULE_PATH})
list(APPEND env "LD_LIBRARY_PATH=${_GNC_MODULE_PATH}:$ENV{DYLD_LIBRARY_PATH}")
endif()
if (MINGW64)
set(fpath "")

View File

@ -1,6 +1,11 @@
N_( "1The GnuCash online manual has lots of helpful information. \
You can access the manual under the Help menu.")
/* Translators: You can replace the link, if a transated page exists. */
N_( "Mailing lists are the preferred form of communication in the \
GnuCash community. For announcements of new releases, user groups etc. \
see the table at https://wiki.gnucash.org/wiki/Mailing_Lists")
N_( "The GnuCash developers are easy to contact. As well \
as several mailing lists, you can chat to them live on IRC! \
Join them on #gnucash at irc.gnome.org")

View File

@ -1514,7 +1514,7 @@ create_transaction(XferDialog *xferData, time64 time,
xaccTransBeginEdit(trans);
xaccTransSetCurrency(trans, xferData->from_commodity);
xaccTransSetDatePostedSecs(trans, time);
xaccTransSetDatePostedSecsNormalized(trans, time);
/* Trans-Num or Split-Action set with gnc_set_num_action below per book
* option */

View File

@ -2450,7 +2450,7 @@ gtv_sr_begin_edit (GncTreeViewSplitReg *view, Transaction *trans)
//is a new transaction and set the time to current time to show current
//date on new transactions
time = gnc_time (NULL);
xaccTransSetDatePostedSecs (trans, time);
xaccTransSetDatePostedSecsNormalized (trans, time);
}
}
LEAVE(" ");

View File

@ -483,42 +483,8 @@ gnc_reconcile_view_class_init (GNCReconcileViewClass *klass)
}
static gboolean
gnc_reconcile_view_toggle_split (GNCReconcileView *view, Split *split)
{
Split *current;
g_return_val_if_fail (GNC_IS_RECONCILE_VIEW (view), FALSE);
g_return_val_if_fail (view->reconciled != NULL, FALSE);
current = g_hash_table_lookup (view->reconciled, split);
if (current == NULL)
{
g_hash_table_insert (view->reconciled, split, split);
return TRUE;
}
else
{
g_hash_table_remove (view->reconciled, split);
return FALSE;
}
}
/** Insert or remove a split from the list of splits to be reconciled
* (view->reconciled) so that all other splits in the same transaction
* for the account being reconciled (including children), are the same
* reconciliation state as the split that has been toggled.
*
* @param view The view to use.
*
* @param split The split to be inserted or removed
*
* @param reconcile TRUE=insert, FALSE=remove
*/
static void
gnc_reconcile_view_rec_or_unrec_split (GNCReconcileView *view, Split *split, gboolean reconcile)
gnc_reconcile_view_toggle_split (GNCReconcileView *view, Split *split)
{
Split *current;
@ -527,103 +493,20 @@ gnc_reconcile_view_rec_or_unrec_split (GNCReconcileView *view, Split *split, gbo
current = g_hash_table_lookup (view->reconciled, split);
if (current == NULL && reconcile)
if (current == NULL)
g_hash_table_insert (view->reconciled, split, split);
if ((current != NULL) && (!reconcile))
else
g_hash_table_remove (view->reconciled, split);
}
static void
gnc_reconcile_view_toggle_children (Account *account, GNCReconcileView *view, Split *split, gboolean reconcile)
{
GList *child_accounts, *node;
Transaction *transaction;
/*
* Need to get all splits in this transaction and identify any that are
* in the same hierarchy as the account being reconciled (not necessarily
* the account this split is from.)
*
* For each of these splits set them to the same state as the split whose
* checkbox was toggled.
*/
child_accounts = gnc_account_get_descendants (account);
child_accounts = g_list_prepend (child_accounts, account);
transaction = xaccSplitGetParent (split);
for (node = xaccTransGetSplitList (transaction); node; node = node->next)
{
Split *other_split;
Account *other_account;
GNCReconcileView *current_view;
GtkTreeModel *model;
GtkTreeIter iter;
gboolean valid;
gpointer pointer;
other_split = node->data;
other_account = xaccSplitGetAccount (other_split);
if (other_split == split)
continue;
/* Check this 'other' account is in the same hierarchy */
if (!g_list_find (child_accounts, other_account))
continue;
/* Search our sibling view for this split first. We search the
* sibling list first because that it where it is most likely to be.
*/
current_view = view->sibling;
if (!gnc_query_view_item_in_view (GNC_QUERY_VIEW (current_view), other_split))
{
/* Not in the sibling view, try this view */
current_view = view;
if (!gnc_query_view_item_in_view (GNC_QUERY_VIEW (current_view), other_split))
/* We can't find it, nothing more I can do about it */
continue;
}
/* Found the other split. Toggle the reconciled check mark in the view... */
model = gtk_tree_view_get_model (GTK_TREE_VIEW (current_view));
valid = gtk_tree_model_get_iter_first (model, &iter);
while (valid)
{
// Walk through the list, reading each row
gtk_tree_model_get (model, &iter, REC_POINTER, &pointer, -1);
if(pointer == other_split)
{
gboolean toggled;
gtk_tree_model_get (model, &iter, REC_RECN, &toggled, -1);
if (toggled != reconcile)
gtk_list_store_set (GTK_LIST_STORE (model), &iter, REC_RECN, reconcile, -1);
break;
}
valid = gtk_tree_model_iter_next (model, &iter);
}
/* ...and toggle its reconciled state in the internal hash */
gnc_reconcile_view_rec_or_unrec_split (current_view, other_split, reconcile);
}
g_list_free (child_accounts);
}
static void
gnc_reconcile_view_toggle (GNCReconcileView *view, Split *split)
{
gboolean include_children;
gboolean is_reconciled;
g_return_if_fail (GNC_IS_RECONCILE_VIEW (view));
g_return_if_fail (view->reconciled != NULL);
is_reconciled = gnc_reconcile_view_toggle_split (view, split);
include_children = xaccAccountGetReconcileChildrenStatus (view->account);
if (include_children)
gnc_reconcile_view_toggle_children (view->account, view, split, is_reconciled);
gnc_reconcile_view_toggle_split (view, split);
g_signal_emit (G_OBJECT (view),
reconcile_view_signals[TOGGLE_RECONCILED], 0, split);

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkAdjustment" id="atm_fee_adj">
@ -94,7 +94,7 @@
<property name="default_height">400</property>
<property name="type_hint">normal</property>
<signal name="response" handler="gnc_preferences_response_cb" swapped="no"/>
<child>
<child type="titlebar">
<placeholder/>
</child>
<child internal-child="vbox">
@ -2985,6 +2985,7 @@ many months before the current month:</property>
<property name="text" translatable="yes">1</property>
<property name="adjustment">default_zoom_adj</property>
<property name="value">1</property>
<property name="digits">1</property>
</object>
<packing>
<property name="expand">False</property>

View File

@ -939,6 +939,7 @@ csv_export_assistant_create (CsvExportInfo *info)
/* Start date info */
info->csvd.start_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
gtk_widget_set_sensitive (info->csvd.start_date, FALSE);
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "start_date_hbox"));
gtk_box_pack_start (GTK_BOX(hbox), info->csvd.start_date, TRUE, TRUE, 0);
gtk_widget_show (info->csvd.start_date);
@ -948,6 +949,7 @@ csv_export_assistant_create (CsvExportInfo *info)
/* End date info */
info->csvd.end_date = gnc_date_edit_new (gnc_time (NULL), FALSE, FALSE);
gtk_widget_set_sensitive (info->csvd.end_date, FALSE);
hbox = GTK_WIDGET(gtk_builder_get_object (builder, "end_date_hbox"));
gtk_box_pack_start (GTK_BOX(hbox), info->csvd.end_date, TRUE, TRUE, 0);
gtk_widget_show (info->csvd.end_date);

View File

@ -70,6 +70,7 @@ struct _main_matcher_info
GtkWidget *show_account_column;
GtkWidget *show_matched_info;
gboolean add_toggled; // flag to indicate that add has been toggled to stop selection
gint id;
};
enum downloaded_cols
@ -174,6 +175,7 @@ void gnc_gen_trans_list_delete (GNCImportMainMatcher *info)
{
gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->main_widget));
gnc_import_Settings_delete (info->user_settings);
gnc_unregister_gui_component (info->id);
gtk_widget_destroy (GTK_WIDGET (info->main_widget));
}
else
@ -946,7 +948,6 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
GtkStyleContext *stylectxt;
GdkRGBA color;
GtkWidget *button;
gint id;
info = g_new0 (GNCImportMainMatcher, 1);
info->pending_matches = gnc_import_PendingMatches_new();
@ -1007,12 +1008,12 @@ GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent,
g_object_unref (G_OBJECT(builder));
// Register this UI, it needs to be closed when the session is closed.
id = gnc_register_gui_component (IMPORT_MAIN_MATCHER_CM_CLASS,
NULL, /* no refresh handler */
(GNCComponentCloseHandler)gnc_gen_trans_list_delete,
info);
info->id = gnc_register_gui_component (IMPORT_MAIN_MATCHER_CM_CLASS,
NULL, /* no refresh handler */
(GNCComponentCloseHandler)gnc_gen_trans_list_delete,
info);
// This ensure this dialog is closed when the session is closed.
gnc_gui_component_set_session (id, gnc_get_current_session());
gnc_gui_component_set_session (info->id, gnc_get_current_session());
return info;
}

View File

@ -314,7 +314,7 @@ GncDateTimeImpl::GncDateTimeImpl(const GncDateImpl& date, DayPart part) :
if (offset < hours(-10))
m_time -= hours(offset.hours() + 10);
if (offset > hours(13))
m_time -= hours(offset.hours() - 11);
m_time += hours(13 - offset.hours());
}
catch(boost::gregorian::bad_year&)
{

View File

@ -1506,8 +1506,8 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
/* Entered and Posted at date */
xaccTransSetDateEnteredSecs (txn, gnc_time (NULL));
xaccTransSetDatePostedSecs (txn, post_date);
gncInvoiceSetDatePosted (invoice, post_date);
xaccTransSetDatePostedSecsNormalized (txn, post_date);
gncInvoiceSetDatePosted (invoice, xaccTransRetDatePosted(txn));
xaccTransSetDateDue (txn, due_date);