Commit Graph

735 Commits

Author SHA1 Message Date
Christopher Lam
d9623b0ad1 [test-utilities] initial commit
Add tests for libgnucash/scm/utilities.scm functions

- tests for list<->vec
- tests for gnc:substring-replace
- tests for gnc:substring-replace-from-to

  The latter confirms that the comment before the function definition
  is *incorrect* - it describes that substring-replace-from-to will
  start from the 2nd substring for the first substitution, and
  performs 2 substitutions. However the comment illustrates only 1
  substitution. The test suite performs the test according to code
  behaviour, rather than the comment. This issue is moot in practice
  because the end-after is always called with negative in the code
  base.

  original comment:

;;  gnc:substring-replace-from-to
;;  same as gnc:substring-replace extended by:
;;  start: from which occurrence onwards the replacement shall start
;;  end-after: max. number times the replacement should executed
;;
;;  Example: (gnc:substring-replace-from-to "foobarfoobarfoobar" "bar" "xyz" 2 2)
;;           returns "foobarfooxyzfoobar".
2019-04-23 18:52:36 +08:00
John Ralls
fc0a729253 Merge Christoph Holtermann's 'PR-python-bindings-update-source-doc' into maint 2019-04-20 12:55:41 -07:00
John Ralls
aa53c23239 Merge T Edmunds's 'amortization-rounding' into maint. 2019-04-20 12:36:51 -07:00
John Ralls
3c946a8449 Merge T Edmunds's 'computeInterestIncrement' to maint. 2019-04-20 12:32:17 -07:00
c-holtermann
ba8a9c8478 update python source doc 2019-04-20 15:12:20 +02:00
Robert Fewell
20e2b6b5de Bug 797175 - Opening a file from a gvfs mount point fails
When testing for a MS Windows path which has a ":", a gvfs path with the
format '/run/user/1000/gvfs/smb-share:server=192.168.1.11,share=public/
test-xml-file.gnucash' is recognised as a Windows path. To avoid this
expand the test to ":/" and also ":\"
2019-04-19 15:51:29 +01:00
thetedmunds
9afc856c20 Changed gnc:computeInterestIncrement to directly calculate the amount of interest accrued in the specified compounding period. Bug 797195. 2019-04-17 12:11:29 -07:00
thetedmunds
5f9020016a Amended commit to address pull-request comments. 2019-04-17 11:52:24 -07:00
Robert Fewell
0f6465ca6d Bug 797175 - Gnucash will not open from UNC paths.
UNC paths were overlooked in a change I made, corrected and added some
notes to source file for reminder.
2019-04-12 11:53:29 +01:00
John Ralls
c091197f57 Provide static strings for gnc_userdata_home and gnc_userconfig_home.
On Windows boost::filesystem::path's string() produces a string
that goes out of scope with the function in which it's called, so
returning its c_str() ptr yields freed memory, usually full of garbage.

This has an interesting side effect in gnc-file.c's check_file_path():
Since the memory is freed, g_path_get_dirname() reuses it after an
iteration or two, writing its result into the same address. The
following strcmp naturally returns 0 because it's comparing two
instances of the same ptr, so check_file_path falsely reports that
the proposed save path is in GNC_USERDATA_DIR.
2019-04-11 17:38:01 -07:00
Frank H. Ellenberger
833decc03e I18N: Review of price-quotes.scm
Mark "Found FQ version" translatable, but remove translation from log
file entries.
2019-04-08 17:37:33 +02:00
Christopher Lam
d64fb74b9e [utilities] add supporting functions for guile-json use
converts nested-list to nested-vector, and vice-versa
2019-04-04 19:44:00 +08:00
Christopher Lam
3923dfa19a [business-prefs] tidy counter definitions
(for-each) is more appropriate here because the (map) output is
unused...
2019-04-04 19:43:44 +08:00
Robert Fewell
5eb6f76e63 Change uri functions to work with valid Windows file uri's
Windows file uri's can be of the form 'file:///N:/bob.txt' so change
the gnc_uri_get_components to remove a left over '/' at the start so
gnc_resolve_file_path gets the absolute path correctly. Also change
gnc_uri_create_uri to add an extra '/' for Windows file uri's.
2019-03-29 20:43:00 +00:00
Robert Fewell
89d2cde979 Remove some white space/tabs from gnc-filepath-utils.cpp 2019-03-29 20:43:00 +00:00
Robert Fewell
22a7a05d50 Add function to create an absolute file path
Add function to create an absolute file path from a prefix path and a
relative one. If the prefix is null, then the root directory of the
current path is used.
2019-03-29 20:43:00 +00:00
Christopher Lam
a4eb5b1a59 [options] compact book-currency-acounting functions 2019-03-30 01:39:55 +08:00
Christopher Lam
faf1b08cec [options] compact valid-gains-loss-account? 2019-03-30 00:59:24 +08:00
Christopher Lam
0b8ff4b5d6 [options] deprecate gnc:save-options
this is unused.
2019-03-25 17:38:50 +08:00
Christopher Lam
4f6344963d [options] simplify gnc:value->string 2019-03-25 17:38:50 +08:00
christopherlam
d711cc35f8 Bug 639049 - Asset Barchart Report includes also the first day of next month transactions
If the original date is an end-of-month date, we take it as an
indicator they always want monthdelta dates to be end-of-months.

This works for monthly/quarterly/halfyearly/annual.

Addendum to commit 65bfeaf5de which was
deemed to be an incomplete fix.

Also I'd forgotten to activate a test in test-date-utilities. Enable it.
2019-03-21 19:44:33 +08:00
John Ralls
bc9d83c90f Merge Christoph Holterman's 'PR-G_ADD_PRIVATE-clean' into maint. 2019-03-19 09:12:48 -07:00
loftx
d5297a46bf Resolve 'basic_string::_M_construct null not valid' error when no database is provided in connection string 2019-02-26 15:37:01 +01:00
Christopher Lam
09e0e02a75 [test-extras] abstract test-data skeleton 2019-02-22 23:36:15 +08:00
Geert Janssens
fce75ea748 Add dedicated api to query build-time, version related compile constants
And use it in several location in the code for consistent behaviour
2019-02-21 17:00:15 +01:00
Christopher Lam
fe6cc534a0 [engine-utilities] deprecate account utility functions
These functions are obsolete with SRFI-1
2019-02-20 22:47:03 +08:00
Christopher Lam
972562421e [engine-utilities] deprecate split utility functions
These functions are obsolete with srfi-1
2019-02-20 22:47:01 +08:00
Christopher Lam
9ba0d9658d [test-extras] (create-transaction) adds price trading commodities/currency
this will modify a test which was calibrated to record purchase price
only. fix transaction creation to add prices for both purchase and
sales, and also fix test which was assuming no sale price was bring
recorded.
2019-02-20 21:41:49 +08:00
Christopher Lam
918321aafa [test-extras] for tests: (env-create-multisplit-transaction)
This is the general case for any transaction creation.  Rewrite other
transaction creation routines to use it.  All tests still work
unchanged, which confirms this function works well.

This will allow tests to create multisplit transactions, of an
arbitrary number of splits. If the list-of-split's values are not
balanced (i.e. total 0), the engine will create an Imbalance-CUR
split.

The motivation is to allow creation of complex multisplit
multicommodity transactions eg USD50 + GBP20 (USD25) = EUR66 (USD75)
as well as their prices GBP/USD = 25/20 and EUR/USD = 75/66.

* USD -50
* USD -25 = GBP -20
* USD +75 = EUR +66

This will be useful in creating tests for stock-based reports, whereby
stock sales need splits in STOCK/ASSET/INCOME accounts.
2019-02-20 21:41:49 +08:00
Christopher Lam
4a2b5e9641 [hooks.scm] deprecate hooks.scm
this module has a single function which is used only once. inline it.
2019-02-20 21:09:22 +08:00
Christopher Lam
f64586b873 [app-utils] remove config-var.scm
unused since 1999?
2019-02-20 21:04:23 +08:00
John Ralls
11083d6052 Bug 796989 - some date/time does not honor user locale (bis).
Set the locale for C so that it matches what's set for C++.
2019-02-19 09:49:56 -08:00
Christopher Lam
4f0e9a5168 [options] gnc:warn when looking up old option names
the option lookup mechanism will dynamically translate option
names. warn the user if this takes place so that the report writer may
use new option names.
2019-02-19 22:28:12 +08:00
Frank H. Ellenberger
d7190c0fac Merge branch 'patch-1' of https://github.com/sicelo/Gnucash into maint
Bug 797105 - Incorrect local-symbol for SZL currency
PR #461
2019-02-18 14:09:54 +01:00
Sicelo
07fbb46398
Update SZL section header
Clarify the reason for changing the symbol
2019-02-17 08:10:55 +02:00
Mike Alexander
d4af5244d0 Bug 797106: Do a better job of converting decimal prices to rationals.
Use the Scheme rationalize method to convert the decimal numbers
from Finance::Quote to ratinal numbers.  This avoids rediculous
precision like 8515625000000001/3906250000000000 for 2.18.
2019-02-17 11:58:15 +08:00
Christopher Lam
a4789fcac5 bugfix: fix crasher when loading saved-report with unknown choices.
If a saved-report with e.g. relative date, multichoice option is
unknown, the report would crash, and the Report-Options would
segfault. This commit fixes both: report-date defaults to 'today',
multichoice-options defaults to default-value.

Following this commit, if a report loads a saved-report or .gcm from a
future version, a gnc:warn will be emitted and the report will not
crash; it will use relative-date today. Multichoice will remain the
default value. Report Options will not segfault.

The user will be notified via a gnc:gui-warn dialog
2019-02-17 11:25:06 +08:00
Christopher Lam
a731c9ed9a [gnome-utils] add gnc:gui-warn/error/msg global functions
gnc:gui-[warn|error|msg] are new global functions.

By default they mirror gnc:warn/error/msg. However then gnome is
available, they will display appropriate warn/error/info dialog in
addition to outputting to console.
2019-02-17 11:24:57 +08:00
Sicelo
86be3b9247
Update iso-4217-currencies.xml 2019-02-16 18:08:45 +02:00
Sicelo
96577ff922
Update iso-4217-currencies.xml
Fixing the 'local-symbol' property for the SZL currency from "L" to "E." See Bug 797105.
2019-02-16 01:10:09 +02:00
Christopher Lam
65bfeaf5de [date-utilities] bugfix: date-intervals produces good month deltas
Instead of recursing the date, we calculate the next month using an
index-based multiplier, and apply modulo/remainder as appropriate to
determine the next month/year.

Then we attempt to create new mktime, and if the resulting mktime's
month is not as expected, reduce the mday by 1 until resulting month
is correct. This fixes monthly intervals for end-of-month days.

Test via monthly/quarterly deltas, and also includes leapyear
calculation.
2019-02-13 22:23:44 +08:00
John Ralls
140eb0b110 Log a warning in gnc_get_locale() instead of writing to stderr. 2019-02-12 12:58:42 -08:00
John Ralls
7d7da8e2c4 Bug 797067 - Date displayed incorrectly in register take two.
Revert using boost::locale to generate std::locales as boost::locale-
generated locales don't implement std::locale::facet and there was
a bug in the boost::locale ICU wrapper code that caused the wrong year
to be output for the last 3 days of December.

GCC's libstdc++ supports only the "C" locale on Windows and throws if
one attempts to create any other kind. For dates we work around this
by using wstrftime() to format according to locale and then convert
the UTF16 string to UTF8. wstrftime() interprets the time zone flags
%z, %Z, and %ZP differently so we process those first before calling
strftime. This will have the unfortunate effect of not localizing
timezone names but it's as close as we can get.
2019-02-08 11:56:32 -08:00
Mike Alexander
62a4e73f7f Don't use GNC-DENOM-SIGFIGS when converting prices
to gnc-numeric values.
2019-01-28 19:25:50 -05:00
Mike Alexander
5bd7875437 Revert the part of 923b01e2 which reverses currency quotes less than 1.
Now that GnuCash uses 64 bit numbers in numerics this is not necessary.
It can store a number as small as 1e-9 with 9 significant digits.
2019-01-28 19:25:34 -05:00
Mike Alexander
df19244792 Fix the comments on double_to_gnc_numeric. GNC_DENOM_AUTO is allowed.
GNC_DENOM_AUTO
2019-01-28 19:24:26 -05:00
Mike Alexander
2820af7166 Make test-backend-dbi-basic build and run with libdbi 8.
This may not be the correct fix, but it is plausible and it
makes the test build and run.
2019-01-28 19:23:35 -05:00
Alex Aycinena
7d0adfd0c6 remove unnecessary KVPs and frames related to US Income Tax name and type 2019-01-27 15:58:46 -08:00
Christoph Holtermann
2ab6650e9a Replace deprecated g_type_class_add_private
use G_DEFINE_TYPE_WITH_PRIVATE
and adapt name of private property to work with G_DEFINE_TYPE_WITH_PRIVATE
2019-01-26 08:15:02 +01:00
Christoph Holtermann
2cfc61182e directly use G_DEFINE_TYPE instead of QOF_GOBJECT_GET_TYPE 2019-01-26 08:15:02 +01:00
Christoph Holtermann
1bfcc95998 directly use G_DEFINE_TYPE_WITH_PRIVATE instead of QOF_GOBJECT_GET_TYPE 2019-01-26 08:15:02 +01:00
Christoph Holtermann
658da08008 replace deprecated g_type_class_add_private 2019-01-26 08:15:02 +01:00
John Ralls
84d1c3645d Use NULL, not '\0', to set a char* argument to NULL. 2019-01-25 12:52:14 -08:00
John Ralls
f9f714c78d gnc_pricedb_nth_price: Clarify code and cache results.
Use built-in glib functions to retrieve the list of per-currency price
lists, concatenate them into a single list, instead of doing it all in
hand-rolled loops.

Sorting is preformed by the calling GncTreeViewPrice so this removes
sorting from gnc_pricedb_nth_price.

There's no concurrency concern because gnc_pricedb_nth_price is a
GUI callback and so must run in the GUI thread.
2019-01-25 08:49:03 -08:00
Alex Aycinena
fc15364326 remove unnecesary 'home' level in path for US Income Tax book tax information 2019-01-24 18:36:13 -08:00
John Ralls
3a48672763 Complete reversion of e81bcf6 in gnc-pricedb.c. 2019-01-23 17:54:29 -08:00
John Ralls
020bc5371f Bug 797046 - Tools / Price Database / Currencies UI not working...
since 3.4.
2019-01-19 14:31:10 -08:00
John Ralls
e31f4c3f95 Fix unlocalized date in status bar.
It seems that std::locales created by boost::locale::generator are
not entirely compatible: If used to create a new locale with a facet
for boost::date_time one ends up with the C locale and the facet.

For the time being avoid the problem by using boost::locale to format
dates and times. std::chrono gets calendar functions in C++20 so we
can switch date-time backends once we can adopt it.
2019-01-19 13:41:17 -08:00
Christian Stimming
75b6d14455 Speed-up of dealing with account_imap lists: Replace g_list_append with _prepend and subsequent _reverse.
This is glib's suggested way of dealing with GList in more optimized
way, as g_list_append will have to traverse the list until the end.
2019-01-18 23:52:51 +01:00
Alex Aycinena
46b3e31acf Updated to include codes for version 42, although new codes not implemented yet because data not reliably available 2019-01-17 18:19:26 -08:00
Alex Aycinena
217289d037 Bug #796687, Tax entity name and type don't get saved. Change frame->set to frame->set_path to create missing frames. 2019-01-17 12:32:33 -08:00
Alex Aycinena
8f4f8a1dc4 Update US Income Tax information for 2018. Two forms haven't yet been published. If changes needed, will do in subsequent commit. 2019-01-17 12:15:51 -08:00
Thomas Klausner
3ab5a2be52 Bug 797041 - enum confusion in qoflog. 2019-01-13 16:29:11 -08:00
John Ralls
b4fedff90e Provide a single static instance of C++ locale.
We can't use std::locale::global because all streams imbue it by
default and if it's not 'C' (aka std::locale::classic) then we
must imbue all the streams that we don't want localized, and that's
most of them.

Provides error checking for setting the C++ locale from the environment.
This is necessary both because the environment might have an invalid
locale, which would cause an unhandled exception crash.

On windows std::locale("") can't handle some Microsoft-style locale
strings (e.g. Spanish_Spain) so we use boost::locale's gen("") function
to set the locale--though even that can't handle a Microsoft-style
locale string with an appended charset (e.g. Spanish_Spain.1252) and
that's what glibc's setlocale(LC_ALL, NULL) emits.
2019-01-06 10:13:01 -08:00
John Ralls
cee97be8d4 Add GncDateTime::timestamp().
To provide a C++ implementation of gnc_date_timestamp and to avoid
using the expensive and localized GncDateTime::format().
2019-01-06 10:13:00 -08:00
John Ralls
cec3f6031e Fix broken compile of test-gnc-date.c on Ubuntu 14.04. 2019-01-04 17:01:38 -08:00
John Ralls
9fa7b7f940 Implement a faster date-time serialization function.
Has the side effect of recording all date-times in XML files in UTC
instead of local time with a timezone.
2019-01-04 16:34:33 -08:00
John Ralls
137c920d06 Merge Chris Carson's 'dateFormat' into maint. 2019-01-04 15:50:39 -08:00
John Ralls
a65dd6cc25 Merge Chris Carson's 'refactor-Scrub-c' into maint. 2019-01-04 15:49:42 -08:00
Christopher D. Carson
2b69278650 Re-coded for cached locale.
Testing notes:  Based on the averages of 3 runs, the net
user CPU to save the XML file I use is:
10.2 seconds without this change
7.6 seconds with this change

In my environment the first call to the format routine
in question, the call that sets the cache value, is at
the end of the XML load.
2019-01-01 20:08:47 -06:00
Christopher D. Carson
0e37e059d5 Fix XML load CPU hotspot: Scrub.c xaccTransScrubPostedDate
The refactoring provides roughly 10% reduction in user CPU
use for XML file load by moving an expensive function
to within an if-clause where the result is used.  The diff looks
like a full re-write but only the if statements, indenting,
and commentary changed.
2019-01-01 19:41:16 -06:00
Christian Stimming
eb9e45bc20 Sorting speed-up: Cache the bool value of Transaction's is_closing property.
This value is queried on each comparison of split or txn sort function,
which means it is called quite a lot. Avoiding the KVP lookup of this
property gains a lot in terms of CPU cycles.
2018-12-31 14:50:36 +01:00
Christian Stimming
1eed3db5e7 Some (very minor) translation string improvements.
Fix superfluous space.
Unify case sensitivity in string that appears multiple times.
2018-12-30 22:23:04 +01:00
Christopher Lam
2423aeda42 [engine/test-test-extras] remove duplicated test file 2018-12-29 23:15:46 +08:00
Christopher Lam
0d4575da6c [income-gst-statement] rename options
Further commit to fix 3466ce78b

Discussion as follows
https://code.gnucash.org/logs/2018/12/27.html#T12:31:58
https://code.gnucash.org/logs/2018/12/28.html#T19:12:18
2018-12-29 04:03:45 +01:00
John Ralls
9bfaada356 Bug 796961 - Can't overwrite existing MYSQL database, V3.3.
Because m_exists was left true after dropping it, so the new
database wasn't created.
2018-12-28 13:22:40 -08:00
John Ralls
1116ce909b Bug 796967 - gnclock table not removed when using PostgreSQL.
Because of https://sourceforge.net/p/libdbi-drivers/bugs/24.
This issue causes trouble in save_may_clobber_data() as well, so
work around it by using a SQL query instead of dbi_conn_get_table_list.
2018-12-28 13:22:40 -08:00
Geert Janssens
267852ba76 Add a note on cvt and imbuing locales in a boost::filesystem::path object 2018-12-28 18:47:06 +01:00
Geert Janssens
272ca421b7 Set up filepath utils to determine the GNC_CONFIG_HOME in the same way as GNC_DATA_HOME
Until now GNC_CONFIG_HOME was more or less hard-coded.
Now it can be set via environment variable GNC_CONFIG_HOME.
In addition it will automatically be created to avoid potential
user confusion.
2018-12-28 18:36:52 +01:00
Geert Janssens
ac2e0946ea Rewrite path scrubbing in a c++ way 2018-12-28 16:15:00 +01:00
Robert Fewell
2634f23f87 Bug 767772 - Associated file with transaction is lost
when moving entry between accounts

When using the cut transaction option the 'associated file' value was
not being pasted to the new transaction. Added scheme code to get this
value and save it to new transaction when using 'cut/copy' and then
'paste' operations. When using the duplicate option, a dialogue allows
you to keep the copied association or not. It does not get copied for
autocomplete.
2018-12-28 09:45:50 +01:00
Geert Janssens
d22e1db340 gnc-uri - refer to 'scheme' instead of 'protocol' as that's the more formal term used in uris
This involves renaming 3 functions:
gnc_uri_get_protocol -> gnc_uri_get_scheme
gnc_uri_is_known_protocol -> gnc_uri_is_known_scheme
gnc_uri_is_file_protocol -> gnc_uri_is_file_scheme

The *_protocol variants are marked as deprecated.
Additionally a number of local variables have been renamed from
protocol to scheme to support this change.
2018-12-27 22:33:17 +01:00
Geert Janssens
4b398325ea Redesign gnc-uri-utils
- gnc_uri_get_components will now return NULL as protocol if the input is a normal
  file system path instead of a uri (it used to return 'file')
- gnc_uri_get_protocol will now return NULL if the input is a normal
  file system path instead of a uri (it used to return 'file')
- gnc_uri_is_file_protocol now returns FALSE if protocol is NULL (it used to return TRUE)
- gnc_uri_is_file_uri now returns FALSE if input is a normal file
  system path instead of a uri (it used to return TRUE)
- a new function gnc_uri_targets_local_fs will return TRUE only if its input
  is either a file uri or a normal file system path. This function is now mostly
  used instead of gnc_uri_is_file_uri in the current code base
- a new function gnc_uri_is_uri is added to check whether its input
  is a valid uri (has protocol, path and hostname for non-file uris)
2018-12-27 20:53:33 +01:00
Geert Janssens
06da9e9712 Enable gnc-uri test suite
It was there but never run :(
2018-12-27 20:53:33 +01:00
John Ralls
53680e6100 Merge Bob Fewell's 'fixes03' into maint. 2018-12-25 11:11:27 -08:00
Robert Fewell
5c524c31b2 Add routine to fix Account Color being set to "Not Set"
Previously the account color slot has been populated with "Not Set"
when any field for the account has been edited and saved. This routine
should run once and remove all such entries.
2018-12-24 13:00:07 +00:00
Christopher D. Carson
aaeb639d07 Performance fix in dom_chars_handler: use g_strndup instead of g_strdup
Because the origin string can be extraordinarly long, you get more
benefit from this than you would imagine
2018-12-24 13:46:48 +01:00
YOSHINO Yoshihito
7f1a711567 Bug 796989 - some date/time does not honor user locale
because now it looks for the user locale each time when it formats
datetime, I added Fixme comments.
2018-12-22 01:09:08 +01:00
John Ralls
f5be842c2e boost needs bcrypt.lib for all versions of Windows. 2018-12-16 16:31:06 -08:00
Christoph Holtermann
96e27a4199 typo 2018-12-04 12:05:59 +01:00
John Ralls
e81bcf6e33 Fix the remaining static analysis warnings.
Except two incorrect leak warnings and one about mktemp
 being insecure in the XML backend. See the respective
comments about those.
2018-11-30 15:08:41 +09:00
John Ralls
bf55c30aeb Fix most of the unused assignment errors from static analysis.
There are a very few left that need deeper study, but this gets
rid of most of the noise. For the most part it's just getting rid of
extra variables or removing an assignment that is always
replaced later but before any reads of the variable. A few are
discarded result variables.
2018-11-30 15:08:41 +09:00
John Ralls
876bfd19ad Protect against nullptr dereference, remove unused GError.
Found by clang static analyzer.
2018-11-30 15:08:41 +09:00
John Ralls
24ce92056d Protect from potential nullptr dereferences.
pmtsched is created in only one banch of the opening switch.
Found by clang static analyzer.
2018-11-30 15:08:41 +09:00
John Ralls
8f22c4bed4 Localize variables, ensure that val_imbalance is set, test txn_curr != commodity once.
Found by clang static analyzer.
2018-11-30 15:08:41 +09:00
John Ralls
4ffeb3efac Ensure that a dereferenced variable isn't NULL.
Found by clang static analyzer.
2018-11-30 15:08:41 +09:00
John Ralls
43a30e1c97 Silence clang static analyzer complaint about potential div by 0.
It can't, because if b is 0 the function would have
returned already; since b.m_hi is 0 b.m_lo can't be. The assert
reassures clang that this is the case.
2018-11-30 15:08:41 +09:00
John Ralls
3d1362757b Prevent potential undefined behavior by shifting by a wrapped uint.
Found by clang static analyzer.
2018-11-30 15:08:41 +09:00
John Ralls
606d9cfee6 Prevent potential nullptr dereference.
Found by clang static analyzer.
2018-11-30 15:08:41 +09:00
John Ralls
faba7975ac Fix a bunch of memory allocation errors found by clang static analysis. 2018-11-30 15:08:41 +09:00
John Ralls
61cd7999f3 Fix half-up, half-down, and banker's rounding for negative numbers.
We need to compare the magnitudes of the remainder and the denominator
in order to round negative numbers correctly. Note that while gnc_numeric
is constrained to a positive denominator the C++ rounding functions cannot
assume that constraint in all cases.

Combined with the previous commit, this fixes
Bug 796949 - Incorrect conversion of 0,01 USD to EUR
2018-11-27 22:17:22 +09:00
John Ralls
536606a89c Fix extract_common_prices logic.
So that the returned price tuple has the two commodities of interest
converted to a common currency. Before the first pair that that shared
any random currency would be returned, perhaps creating an absurd result.
2018-11-27 22:17:22 +09:00
Geert Janssens
13f6c4d6d7 Introduce and use gnc_time64_get_day_neutral
This function complements gnc_time64_get_day_begin/end. There was
time64CanonicalDayTime but this returned noon of the given day, where we
want 10:59am in most cases. I haven't changed time64CanonicalDayTime
directly as that may break assumptions in other parts of the code.
Instead I have created a new function that can be gradually introduced.
2018-11-20 21:12:32 +01:00
Geert Janssens
11af81b51b Bug 789674 - Close Book tool regression 2018-11-20 18:55:09 +01:00
Geert Janssens
cd04e805e3 Bug 796919 - Leading '+' character not accepted in amount when value surrounded by quotes
Use a variant of xaccParseAmount that allows to ignore the locale's positive_sign character
or the + sign if locale doesn't define a positive_sign character.

In a future redesign it would probably be better to replace use
of xaccParseAmount with some variant of the gnc-expression-parser
but that would require more that a few tweaks to get right.
2018-11-18 17:23:14 +01:00
Geert Janssens
f13d21b973 Bug 498072 - GnuCash show taxes on invoice when individual taxes is not checked
Use more descriptive option name and tool tip as proposed in the bug.
2018-11-18 15:38:59 +01:00
Robert Fewell
d458e13a7f Remove KVP for assoc_uri when passed an empty string
Change xaccTransSetAssociation so if an empty string is passed the KVP
entry is removed instead of leaving an empty stub.
2018-11-15 15:30:35 +00:00
John Ralls
284d6c1456 Fix travis failure try 2.
stdint.h for Transaction.c too.

Also get rid of unused timeval decl.
2018-11-11 17:43:24 +09:00
John Ralls
73d193606e Fix travis failure.
Linux needs stdint.h for INT64_MAX.
2018-11-11 17:29:06 +09:00
John Ralls
710b122b24 Bug 796940 - Invalid transaction date-posted KVP causes...
date-posted to not be saved.

Check the stored GDate for being in the GncDateTime range as well
as the GDate range before returning it and check trans->date-posted
against INT64_MAX instead of 0 before changing it.
2018-11-11 17:07:34 +09:00
John Ralls
4c1c485db6 Use split SCU when borking random split pairs.
Reduces likelihood of a zero value in the transaction currency.
2018-11-10 11:35:16 +09:00
John Ralls
4b5ee84575 Work around strange struct tm initializer failure. 2018-11-02 13:44:09 -07:00
John Ralls
0e723610f0 Bug 795080 - Some dates reset to 01/01/1970
The first fix for this bug handled structs tm with ambiguous times.
This one fixes the GncDate constructor when the time is ambiguous
because it's in the DST-change hour, using the same add 3 hours,
construct the LDT, and subtract the 3 hours from the result.

The string constructor handles only simple-offset HH:MM timezones and so
is immune to the bug.
2018-11-02 10:45:40 -07:00
Ruben Cheng
36e430c8ba
Update iso-4217-currencies.xml
*) Fix VEB and VEF local-symbol
*) Add new currency for Venezuela (VES - Bolivar Soberano) since August 20th 2018
This is related to Bug 796927
2018-10-31 23:23:02 -04:00
John Ralls
263c5a40ea Merge Chris Lam's 'maint-scheme-progress' into maint. 2018-10-29 13:06:25 -07:00
John Ralls
f6fb1101bd Add bcrypt.lib to engine build flags on Windows < 10.
Seems not to be required on Win10.
2018-10-29 11:27:16 -07:00
Christopher Lam
b59e209618 [test-extras] gnc-pricedb-create skips if commodity = currency 2018-10-28 09:09:03 +08:00
John Ralls
08e28bfc81 Merge Di Mang's Double-semicolon fix into maint. 2018-10-16 08:57:31 -07:00
John Ralls
7a4b06c442 Bug 796878 - test-qofsession fails on x86_32. 2018-10-04 15:44:32 -07:00
Di Mang
893383ce9b removing double semicolons at the end of lines 2018-09-30 19:10:50 +02:00
John Ralls
b7be8d59b7 Remove engine-deprecated.i from CMakeLists.txt.
It wasn't created in the timespec functions deprecation commit.
2018-09-29 13:01:29 -07:00
Geert Janssens
406953c2ae Bug 796820 - References to 'Gnome Bugzilla' should be changed to 'GnuCash Bugzilla'
Additionally use https everywhere to refer to bugs.gnucash.org or bugzilla.gnome.org
2018-09-28 15:00:43 +02:00
John Ralls
26714d2e17 Bug 792446 - Mixed languages in error dialog. 2018-09-27 18:05:42 -07:00
Geert Janssens
2094282790 Merge branch 'block-pref' of https://github.com/Bob-IT/gnucash into maint 2018-09-27 21:57:39 +02:00
Robert Fewell
b6f2b111bc Block registered prefs when preference dialogue loaded
When the preference dialogue is loaded and options are set, the ones
with registered callbacks fire causing parts of Gnucash to be updated.
This was observed with gnc_split_register_load being executed 5 times
for each open register when the preference dialogue was loaded.

To overcome this, a couple of functions have been created to block and
unblock all registered prefs and used while the preference dialogue is
loaded.
2018-09-27 15:57:34 +01:00
John Ralls
26a179872d Don't create 2 new books for every new session.
And don't ask to save a not-dirty or empty book, fixing
Bug 794870 - If no book is opened, gnucash still asks if the user wants
to save changes when opening a file
2018-09-23 16:42:11 -07:00
Geert Janssens
3991ccb9c2 Cache current owner balances
These are queried continuously by the owner tree view (on Customer/Vendor/Employee
Overview pages) and recalculating them is an expensive operation.
The cache will be invalidated each time a lot reated to the owner
changes (modify or delete). The net effect is a huge responsiveness
improvement of said overviews in case of a large book.
2018-09-23 16:00:41 +02:00
John Ralls
40bcd1e377 Bump the max_denom_mult to match the new GNC_COMMODITY_MAX_FRACTION. 2018-09-21 14:33:02 -07:00
John Ralls
4fe12f5422 Some more magic number replacements. 2018-09-21 14:32:03 -07:00
John Ralls
87533fe4bc Catch std::underflow_error as well as std::overflow_error.
Any operation that can overflow will throw an underflow if it's a
negative number. The C interface needs to catch both to prevent
unhandled exception crashes,
2018-09-21 14:28:49 -07:00
John Ralls
6d2ef90313 Fix a magic number. 2018-09-21 13:00:34 -07:00
John Ralls
dd10ac8bc7 Don't need NANOS_PER_SECOND anymore. 2018-09-21 13:00:19 -07:00
John Ralls
80a4591736 Bug 786708 - GnuCash won't load currency fractions larger than 1000000.
Also create larger fractions for the account dialog.
2018-09-21 12:59:50 -07:00
John Ralls
2d565215cd Fix localedir relocation.
Since LOCALEDIR is now always absolute we need to see if there's a
prefix and if LOCALEDIR is a subdir of PREFIX instead.
2018-09-18 16:08:48 -07:00
John Ralls
83b1b8adfc Fix typos. 2018-09-16 13:05:49 -07:00
John Ralls
162605f505 Fix Windows binreloc executable finding.
Taking into account the behavior of
g_win32_get_package_installation_directory_of_module when the last
directory element either is or isn't "bin".
2018-09-16 12:36:04 -07:00
Geert Janssens
5057703d30 Sql backend - show progress similar to how it's done for xml backend
That is let the percentage increase gradually. The current granularity is still
very rough, but at least it gives an indication of getting closer to fully
loading the data. The previous configuration on the other hand only suggested
something was happening but with no indication where in the load process
gnucash was.
2018-09-15 17:48:37 +02:00
Geert Janssens
5775662b52 Raise edit level of all accounts before loading transactions and splits
This prevents calling xaccAccountRecomputeBalanceInCurrency on each split that gets added,
which was exponentially increasing load times. On a huge test book the
load time dropped from 53 minutes to 1m20s.
2018-09-15 17:05:16 +02:00
Geert Janssens
221c46585c Sql backend - load transactions before business objects to reduce individual slot queries 2018-09-15 16:38:55 +02:00
Geert Janssens
62eb95c05c Fix memory leaks in gncOwnerGetBalanceInCurrency 2018-09-14 11:34:45 +02:00
Geert Janssens
4e71629966 Fix memory leak in xaccTransRetDateDue 2018-09-14 10:47:31 +02:00
John Ralls
10a21cbfac Merge branch 'Bug794526' into maint 2018-09-11 10:46:02 -07:00
Geert Janssens
48b29f5e91 Fix memory leak in char* type KvpValue and fix improper uses
The core issue was that the delete visitor was never called because its parameter
type (char *) didn't match the boost::variant type (const char *).
Fixing the visitor's parameter type also require a const_cast
back to char * because that's what g_free takes as argument.

The rest of this commit is merely fixing KvpValue instantiations that
tried to create a char* KvpValue from a stack based const string instead
of a heap allocated one. That would bomb out on calling the
delete visitor.
2018-09-10 19:49:43 +02:00
Geert Janssens
b866d7d955 Plug memory leak in xaccSplitDestroy
Splits were not marked for deletion if the transaction is read-only
and the account is not marked for deletion yet. The net result is
that split will not be freed later on.
However xaccSplitDestroy is also called from a Transaction's do_destroy.
At that point accounts are not necessarily marked for deletion yet (like
is the case when a datafile is closed). This turned out to be a problem
for invoice post transactions (which are also read only) and hence
would cause memory to leak.
2018-09-10 18:57:39 +02:00
Geert Janssens
1117027f72 An empty GValue is interpreted as NULL reason, which is still a valid cache
Ignoring this would make caching almost useless as there are typically
only very few read-only transactions.
2018-09-10 10:24:49 +02:00
John Ralls
f219bc45aa Bug 794526 - Python bindings can't find loadable modules.
Always use absolute paths for configured directories (BINDIR etc.)
Abstract out the guts of gnc_gbr_find_foo_dir for foo in lib, bin, and data.
etc requires special handling because of the way it's treated if prefix
begins with /opt.

Always fall back on the configured directory if binreloc is disabled and
no default is passed in.
2018-09-09 16:36:39 -07:00
John Ralls
a19dcc7bd4 Fix crash when there's no TRANS_READ_ONLY_REASON slot.
Unsetting an empty g_value raises a fatal error, causing tests to fail
in some environments.

g_free() handles NULLs itself, no need to protect it.
2018-09-09 15:02:53 -07:00
Geert Janssens
d069b67d48 Fix memory leak in xaccTransGetReadOnly
In addition implement a cache for this value as suggested in the comments
as this function is called on every transaction commit.
2018-09-09 22:50:05 +02:00
Geert Janssens
3634e8f59d Fix memory leak using qof_instance_get on a GncGUID
The underlying boxed type will return a copy so we should free this
when no longer needed.
2018-09-09 22:50:05 +02:00
Geert Janssens
4cc61463ab Remove unused variable 2018-09-09 22:50:05 +02:00
John Ralls
b05082a09d Merge Chris Lam's consolidated invoice report into maint. 2018-09-08 14:43:33 -07:00
Geert Janssens
705e866472 Bug 796054 follow up
Now that a separate wiki section has been written for the side effects of this bug
make the memo field of affected splits point to this wiki section.
2018-09-01 16:22:42 +02:00
Geert Janssens
d07f759ca3 Use alignment-safe buffer handling
Casting a char* to a struct containing a uint32_t is not universally safe
due to alignment constraints on reads on some platforms. Copy our possibly
unaligned source data into an aligned area of memory to avoid SIGBUS on
armhf.
Reported by vorlonofportland in PR#403. This commit the John's optimized
version of Vorlon's proposed fix.
2018-09-01 12:07:42 +02:00
Geert Janssens
4c87dd05ec Fix compiler warning issues
- add -Wno-deprecated-declarations to CXX_FLAGS as well. This was
  reported by vorlonofportland in PR#401 to become necessary for glib 2.58
  as that has deprecated g_type_class_add_private which appears in our
  c++ code.
- change -Wno-deprecated-register into -Wregister. The former appeared to
  be a clang dialect and alias for the latter (see
  https://github.com/Barro/compiler-warnings for an overview of clang
  and gcc warnings). It was moved to global CXX_FLAGS as it can only be
  added for g++.
2018-09-01 12:07:38 +02:00
Geert Janssens
131df82135 Merge branch 'date-bugs' of https://github.com/Bob-IT/gnucash into maint 2018-08-31 22:01:45 +02:00
Geert Janssens
baf933acf2 Bug 796054 - unposting and reposting invoice doubles amounts
Add scrub function to unblock the double post transaction
2018-08-31 20:24:39 +02:00
John Ralls
fc368b91d2 Restore the timespec_val column name in the slots table.
Renaming it would require a backwards-incompatible schema change,
something that shouldn't happen in the middle of a stable series.
2018-08-30 17:03:41 -07:00
Geert Janssens
c977c2350a Merge branch 'sort-filter' of https://github.com/Bob-IT/gnucash into maint 2018-08-30 12:18:15 +02:00
John Ralls
704afc6e02 Comment to explain structuring an (env-transfer-foreign). 2018-08-28 15:10:29 -07:00
John Ralls
fe73f52bdb Guard against divide-by-zero errors. 2018-08-28 15:10:29 -07:00
Robert Fewell
2dcb316280 White space removal and change tabs to spaces in qofbook.cpp/h 2018-08-25 11:10:32 +01:00
Robert Fewell
fd750a22eb Cache the number of days read only value
The KVP value for the qof_book_get_num_days_autoreadonly was being
called many times so it makes sense to cache it in the book to avoid
the KVP lookup.
2018-08-25 11:10:24 +01:00
Robert Fewell
a650693d07 New feature for register sort/filter settings move. 2018-08-17 11:31:25 +01:00
Robert Fewell
9423e0913b Remove white space and re-indent gnc-features.c 2018-08-17 11:31:25 +01:00
John Ralls
c08dee67ba Preserve timespec-using functions in Guile bindings.
There's an example of use in text-extras.scm, function
gnc-pricedb-create.

Unfortunately the deprecation messages issue no warnings.
2018-08-16 10:47:41 -07:00
John Ralls
e9098d08d2 Change ISO date format to remove fractional seconds. 2018-08-13 16:19:39 -07:00
John Ralls
35fabe2690 Remove Timespec from gnc-date. 2018-08-13 16:19:39 -07:00
John Ralls
20f6e4e690 Remove Timespec from the SQL backend. 2018-08-13 11:52:43 -07:00
John Ralls
755773ac4c Clean up timespec comments in the XML backend.
Noting where the word must stay; most significantly for KVP types and for
parsing Version 1 XML files.
2018-08-13 11:52:43 -07:00
John Ralls
b32a8a9390 Remove time64_to_string and string_to_time64 and their tests.
Each was used exactly once and simply wrapped a function call.
Also replace static function time_parse_failure that just returned a
constant with the constant.
2018-08-13 11:52:43 -07:00
John Ralls
62b17ca5db Timespec removal, engine odds-and-ends. 2018-08-13 11:52:43 -07:00
John Ralls
358cd979d9 Remove Timespec from the main engine classes (Transaction, Split, & Account. 2018-08-13 11:52:42 -07:00
John Ralls
fee589b28c Remove Timespec from pricedb.
Includes removing the time64 specialized functions because the regular ones
handle time64 now.
2018-08-13 11:52:42 -07:00
John Ralls
92a8cf330a Timespec->time64 in business code. 2018-08-13 11:52:42 -07:00
John Ralls
c8b372e390 Convert GNC_TYPE_TIMESPEC to GNC_TYPE_TIME64, Kvp::Type::Timespec to Kvp::Type::Time64
They have to go together because of using gvalues to hide KVP from most of
GnuCash.
2018-08-12 16:12:19 -07:00
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
Geert Janssens
1e87d069f6 Merge branch 'maint-upgrade-test-balsheet' of https://github.com/christopherlam/gnucash into maint 2018-08-08 16:26:35 +02:00
Geert Janssens
d69d1f6a32 Merge branch 'maint' of https://github.com/yurchor/gnucash into maint 2018-08-08 15:52:51 +02:00
Geert Janssens
239ee6797a Fix crash when cancelling a Save As... overwrite action
This was discovered while trying to fix bug 796792. However that bug itself
is totally unrelated.
2018-08-08 15:47:09 +02:00
Christopher Lam
7ef4c00579 [easy-invoice] Display/Charge Type rename back to Display/Action
This report had renamed "Action" to "Charge Type". For consistency,
let's rename it back, and add migration path in options.scm for
saved-options. 2 fewer strings for translation.
2018-08-07 20:59:35 +08: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
Geert Janssens
69fef8277f Revert "Add preference to control toolbar appearance"
This reverts commit 3b09313107.
2018-07-31 17:30:07 +02:00
Yuri Chornoivan
f9700ba98d Fix minor typos 2018-07-27 14:23:15 +03:00
John Ralls
216528c130 Merge Bob Fewell's 'fixes8' into maint. 2018-07-23 14:51:01 -07:00
John Ralls
6d605762dd Delete the last vestiges of timepair. 2018-07-23 12:00:54 -07:00
John Ralls
773b070345 Don't set transaction properties via scheme in C code. 2018-07-23 12:00:12 -07:00
Robert Fewell
64778fcad5 Fix error when options dialogue is open when app closed
With the options dialogue open when Gnucash is closed this error is
logged in the trace file, gnc_close_gui_component() component not found.

This is fixed by reversing the components list found for session so the
options dialogue is closed before the report window.
2018-07-22 13:07:57 +01:00
John Ralls
ff91056ab1 Resolve ubuntu 14.04 naming conflict. 2018-07-15 16:55:55 -07:00
John Ralls
a51be5157c Add preference for forcing prices to decimal display.
Anticipating that some users might prefer to see exact prices,
add a preference to General>Numbers to configure whether prices
are rounded to decimals or are displayed as exact fractions.
2018-07-15 14:18:01 -07:00
John Ralls
1fffbaf856 Bug 794755 - Commodity Register displays fractional prices
When printing numbers convert them to a new decimal denominator with
rounding if the passed-in print info specifies that they should be
forced and rounded.

Make the default price settings forced and rounded.

Pass the price currency to gnc_default_price_print_info and
use the currency's fraction * 100 to determine the round-to
denominator and the number of decimal places to display.
2018-07-15 13:20:21 -07:00
Robert Fewell
3b09313107 Add preference to control toolbar appearance
Add preferences to select icon size and item layout on the toolbar.
Fixes Bug 796739 - Toolbar buttons have no labels, part 1 of 3.
2018-07-15 10:40:41 -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
de927d535d Fix test-backend-dbi for Postgress and MySQL.
Pass MySQL database exists errors and skip creating the database
if it exists.
2018-07-13 16:34:42 -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
9d5712ef09 Use same 'force' logic sequence for sqlite and other dbs 2018-07-06 22:32:01 +02:00