Commit Graph

213 Commits

Author SHA1 Message Date
John Ralls
b60aef9d2a Remove timespec2dmy.
It had only two uses and one was in a test. Replace those calls with
gnc_localtime_r.
2018-08-12 16:12:19 -07:00
John Ralls
6f89bd62b3 Remove timespec from gnucash/gnome.
With a little API bleed into engine.
2018-08-12 16:12:19 -07:00
John Ralls
2f861bc2a4 Ensure all C++ class member raw pointers are default-initialized to nullptr. 2018-08-10 12:21:28 -07:00
Christopher Lam
47ba21b8dc [test-extras] export gnc-pricedb-create 2018-08-07 13:26:09 +08:00
John Ralls
78ab26cc2b Fix gncInvoice test failure.
test_suite_gncInvoice sets up the test suite. It's not part of the test
runtime, so stack variables in it have gone out of scope by the time the
tests are actually run. Making invoiceData static makes it permanent so
it exists at runtime.
2018-08-06 14:49:07 -07:00
Geert Janssens
d87fa3a5be Bug 796766 - Credit note creating 'imbalance' with wrong entries
Add fix and regression test.
2018-08-06 13:29:12 +02:00
John Ralls
6d605762dd Delete the last vestiges of timepair. 2018-07-23 12:00:54 -07:00
John Ralls
43af50bd8a Bug 796759 - --add-price-quotes <sql file> leaves a lock on the file.
First, save isn't necessary if the book is dirty, so don't... but that
means that the book has to be marked dirty after a session swap. No more
laziness.

Second, regardless of the outcome of inner_main_add_price_quotes the
session must be destroyed to remove the lock.

A couple of cleanups in QofSessionImpl::save as well: Rewrote the
descriptive comment to reflect how it really works when the backend has
gotten disconnected and removed the superfluous qof_book_set_backend
with the backend that we'd *just gotten from the book*.
2018-07-14 17:09:22 -07:00
John Ralls
756f444ac3 Update bug tracker URL
Change all instances of bugzilla.gnome.org to bugs.gnucash.org, reflecting
our migration to a self-hosted bug tracker.

Inform the Translation Project Coordinator at release that this affects
translatable strings and that all message catalogs have been updated.
2018-07-13 09:49:33 -07:00
Christopher Lam
582265d0c6 [job-report] Prevent Crash if there is no AR account
I think this crash is triggered because the 'account' variable
defaults to the first available AR account. If there's no AR account
it becomes null, and querying null's default book leads to segfault.

I guess I can fix segfault too by fixing gnc_account_get_book.
2018-07-07 12:58:13 -07:00
Geert Janssens
f067e8328e Allow saving to xml over an existing sqlite3 file and the other way around
A type check on the pre-existing file was preventing this. The type check however
only makes sense when opening files, not when overwriting.
2018-07-06 22:00:08 +02:00
Christian Stimming
5f46553f1f Minor KVP performance cleanup
Change some plain string literals to std::string constants, which helps
avoiding typos and also saves some string constructors/destructors
in the KVP lookup. Nevertheless the functions in Account.cpp do not
contribute that much to the overall UI speed, but whatever.
2018-06-24 20:50:46 +02:00
Christian Stimming
92ea3ba8a6 Register speed-up for large files.
The function qof_book_use_split_action_for_num_field gets called quite a
lot in each register display refresh (due to sorting all splits from
Split.x's xaccSplitOrder function), but it always used to use a KVP
lookup, which is rather expensive compared to accessing a gboolean member
variable.

To get rid of this cost, I had to remove the KVP lookup in this
simple-looking function. The pattern is this: A gboolean cache variable is
introduced, along with an isvalid flag. The lookup makes the expensive
KVP lookup once, then caches the value. The GObject property mechanism
offers a callback for when the setter was called, which is used to mark
the cached value as invalid. A parallel setter method (here:
qof_book_set_option) also just marks the cache as invalid. This covers
all setters, and the getters will use the cached value except for their
first invocation.

The NUM_FIELD_SOURCE feature was introduced in 2012 by the very large
commit 7cdd7372 and apparently its costs never were a problem
until the KVP lookup became more costly due to the std::vector
construction and destruction.
2018-06-22 22:54:33 +02:00
John Ralls
a9f0fe2f93 Merge Chris Lam's 'maint-test-all-charts' into maint. 2018-06-17 14:06:38 -07:00
Christian Stimming
1e3a445007 Optimize calls to get_path_kvp so that std::strings are not always created and deleted immediately.
Turns out that the on-the-fly conversion from const char* (the KVP_OPTION_PATH
constants) to std::string with their immediate deletion afterwards is
a quite costly operation. Avoiding this is surprisingly easy: Just keep
local std::string objects at hand, and they don't have to be created
and deleted anymore.

The more optimized solution might be to turn the std::vector<std::string>
into a std::vector<GQuark>, but this commit at least improves the picture for now.
2018-06-17 22:51:16 +02:00
Christopher Lam
02bb981daa [test-extras] upgrade env-transfer-foreign to update pricedb 2018-06-16 14:18:30 +08:00
Robert Fewell
1f14d0f629 In qof_scan_date returns valid date when day and month are 0
If you start typing a date in the register with the enable autoreadonly
option starting with a 0, gdate complains when trying to create a valid
date.
2018-06-09 15:04:27 +01:00
John Ralls
cdcb230a31 Don't look for backend libraries in old autotools subdirs.
Partly addresses Bug 794526
2018-06-07 17:38:04 -07:00
John Ralls
74cbde2d4f normalize date formats the C++ way. 2018-05-28 08:56:01 -07:00
John Ralls
174752e28c Merge Bill Nottingham's 'bad-dates' into maint 2018-05-26 18:10:02 -07:00
John Ralls
aa08689371 Merge Paul Wassi's "Fix Permanent Storage" PR into maint. 2018-05-26 16:35:58 -07:00
John Ralls
5708707f6c Fix misplaced try block that caused unhandled exception if year out of range. 2018-05-25 09:19:12 -07:00
Paul Wassi
396c955fd5 Fix permanent storage of vendor details.
Since the data types did not match for the billterms and taxtable,
those references/guids were not saved to the database.
2018-05-25 01:56:14 +02:00
Geert Janssens
fcabf6bb96 A more detailed revision of gncEntry and gncInvoice related rounding
First change is to ensure gncEntry rounding is consistent. Internally
calculated values in the entry are never rounded. Consumers of
gncEntry's calculated values can request them either rounded or not.

Next use a pragmatical approach for calculating values on invoices based on
the entry values: do the rounding such that we never
create an unbalanced transaction while posting
That means
- round each entry's net value before summing them in net total
- accumulate all tax totals on invoice level per tax account before rounding
  and round before before summing them in a global tax total

Hopefully this will catch a few more rounding issues in this area.

A complete solution can only offered if we allow users to manually correct
tax entries. This requires changes to user interface and data format
so that's not going to happen in gnucash 3.x.
2018-05-24 18:53:15 +02:00
Bill Nottingham
8b1b25aee5 Modify date formatters to strip out certian specifiers.
strptime/strftime supports various modifiers to their parameters.

 'E' and 'O': alternate locale-specific formats
 (used in default format for Persian, Oriya, Azerbaijani)
 '-': padding
 (used in default format for Czech)

GnuCash passes dates as integer y/m/d without using locale-specific
formats, so we need to strip out 'E' and 'O' from the format when
scanning dates or determining separators in gnc-date.

None of '-', 'E', or 'O' are supported by boost (and '-' causes
errors), so strip them out from formatters in gnc-datetime as well.

See https://bugzilla.gnome.org/show_bug.cgi?id=795247.
2018-05-22 23:37:22 -04:00
Geert Janssens
2e8df1984a Improve rounding for invoice entry values
This will probably need more refinement because the multiplications
are still missing rounding methods, but the changes in this commit
will already allow guile code to correctly create entries.
2018-05-19 20:25:13 +02:00
Christopher Lam
13f31e0691 test-extras.scm: (logging-and) is obsolete
Use the much nicer SRFI-64 forms instead.
2018-05-10 22:21:55 +08:00
Christopher Lam
5e0fc04f7b test-extras.scm: remove dead code
These functions are never used through code.
2018-05-10 22:21:55 +08:00
Christopher Lam
c6032ac6ed srfi64-extras.scm: centralize (gnc:test-runner)
This is good enough to be used widely.
2018-05-10 13:19:03 +08:00
Geert Janssens
a9f35ed7ae Lowercase cmake commands
A huge bikeshed fest but it distracted me enough to do it anyway.
2018-05-03 23:18:15 +02:00
Geert Janssens
b761b5a0dc Bug 795377 - Reads and saves Gnucash 2.6.19 XML file, then can't reread it, due to bad date in old file
This commit contains another round of cleanups in the
timespec to time64 conversion. There were a number of
false assumptions that time64 = 0 would be a bad date
in the xml parser. This commit corrects enough of them to
eliminate the bug. Further cleanup is probably advised but
can be done at a later stage.
2018-04-28 12:19:28 +02:00
John Ralls
9c4469d039 Bug 795405 - All Dates in Price Database Off-By-One After 3.0 Upgrade
Also Bug 791825 - Accounting Period dates off by 1.
The DST start/end dates were reversed *and* the DST offset had the wrong
sign in Windows, resulting in the effective timezone always being one to
the west off (i.e. PDT was -9 and PST was -8).
2018-04-27 15:00:28 -07:00
John Ralls
83e993fb80 Add a TimeZoneProvider::dump().
Because gdb can't always see clearly inside m_zone_vector.
2018-04-27 14:16:49 -07:00
John Ralls
f6855bc0f8 Rename zone_vector to m_zone_vector.
To comply with coding spec.
2018-04-27 14:16:49 -07:00
Geert Janssens
d69cdaebf2 Add new test source to distribution list 2018-04-27 09:55:58 +02:00
Geert Janssens
74fd6e046b Add a few unit tests for qofquerycore 2018-04-26 23:06:36 +02:00
Geert Janssens
c71204628d Bug 795031 - 3.0 Crashes on loading when opening 2.6.19 file 2018-04-26 23:06:36 +02:00
Geert Janssens
4aadfbe636 Bug 795040 - GnuCash crashes when searching for a newly created bill 2018-04-26 23:06:35 +02:00
John Ralls
35cd165bec Bug 795134 - Improper handle of unicode character in username
Part 1: gnc-filename-utils didn't manage the encoding differences
between Windows (UTF16) and GLib (UTF-8).
2018-04-22 13:55:36 -07:00
Geert Janssens
451bbd53d9 Fix another date test
This may fix this crasher bug on windows:
https://bugzilla.gnome.org/show_bug.cgi?id=795040
However on linux it only fixes a warning so I can't be sure
until after the next nightly.
2018-04-18 19:07:30 +02:00
John Ralls
40a266fc62 One more catch-by-value error. 2018-04-14 16:03:04 -07:00
John Ralls
01420adb99 Bug 772776 - VERY large queries (over 11000 fields in IN clause) slow...
down GnuCash

Replace with joins or subqueries. Affords a 20% speedup on Windows.
2018-04-14 10:18:01 -07:00
Geert Janssens
dcfc1280bd Base invoice posted status on the presence of a posted transaction rather than a posted account
Bills and invoices that are posted and subsequently unposted again still store their
posted account internally as a convenience to the user (upon reposting the old
account will be offered by default) so it's not a reliable test for the posted state.
The posted transaction on the other hand is guaranteed to only exist when the invoice is
posted. This should fix a slew of small and perhaps larger side effects, such as
a posted bill still appearing as editable, critical warnings when creating new bills/invoices
and so on.
2018-04-14 18:46:26 +02:00
John Ralls
4a97269e4b Correct a g_log_level in test_gnc_pricedb_lookup_day. 2018-04-12 15:17:01 -07:00
John Ralls
85cc574d50 Prevent throw in gnc-pricedb.
If a price lookup is given an invalid time64/timespec (i.e. INT64_MAX)
then just return NULL instead of trying to find the nearest price.
2018-04-12 15:17:01 -07:00
John Ralls
16ba1e39b1 Bug 795080 - Some dates reset to 01/01/1970
An odd corner case: BST apparently came off of DST at 23:00 26 Oct 2014,
so midnight that day was ambiguous about being DST or not; that causes
the local_date_time constructor to throw in spite of the tm.is_dst element
being 0 (meaning pick standard time).

Instead of just failing in that case, try constructing a local_date_time
three hours later then adjust it back three hours. If *that* doesn't work
then throw a std::invalid argument.
2018-04-12 15:17:01 -07:00
John Ralls
c05aeb85ec Merge Bill Nottingham's exception type fix into unstable. 2018-04-09 15:12:56 -07:00
John Ralls
7a0f0d57c8 Bug 782144 - git-master - Save Corrupts Data File / Not Open Data File
After much thrashing this turned out to be caused by a date string
with a 3-digit year and that caused an unexpected boost::bad_cast
exception from boost::posix_time::time_from_string().

To prevent that and anything like it, pre-parse the string with
regular expressions to classify them and split out the timezone
if there is one. If neither (perhaps eventually none) of the
regexes match throw std::invalid_argument. The C function will
catch this and return 0.
2018-04-08 17:37:39 -07:00
Bill Nottingham
434dd9520c Adjust catch syntax to avoid GCC8 warnings. 2018-04-03 22:02:44 -04:00
John Ralls
f084fc67f7 Catch guid_syntax_exception in build_bayes. 2018-03-31 17:11:36 -07:00