Commit Graph

703 Commits

Author SHA1 Message Date
John Ralls
8738644af0 Merge David Palma's fix-division into maint. 2019-05-13 15:15:36 -07:00
Geert Janssens
d4c524a9ef Fix test dependency issue 2019-05-13 20:14:58 +02:00
David Palma
aab89065da
Bug 796949 - Fix division and rounding of zero.
Fix division of 128-bit integers so that the remainder inherits the dividend's sign.
Fix rounding for truncated zero.
2019-05-11 23:23:59 +01:00
Christopher Lam
6e246ef8ad [options] compact option-setter in generator
slightly more compact, avoids confusing structure whereby 'option' is
both the lambda's argument and the definition of argument.
2019-05-04 06:19:59 +08:00
John Ralls
bfbb89f6e2 Rewire and corrected Doxygen comment for gnc_get_locale() c++ function.
There's no point in going through the cache dance on MinGW, that will
just throw.
2019-04-30 15:00:06 -07:00
John Ralls
529a6cb067 Call setlocale(LC_ALL, "") exactly once.
And in Windows only with the value from the environment if there is one.
Calling it with "" in Windows ignores the environment and sets it to the
system settings.
2019-04-30 14:56:43 -07:00
John Ralls
114efe5936 Transcode non-constant strings before passing them to scm_eval_string.
Instead of using scm_c_eval_string, which transcodes with
scm_from_locale_string. That doesn't work on Windows.
2019-04-29 15:00:54 -07:00
John Ralls
94bb28d9ab Bug 797127 - Company name and address in reports not display properly
Ensure that all includes of swig-runtime.h are *followed* by
including guile-mappings.h so that the defines masking
scm_to_utf8_string and scm_from_utf8_string are undone.
2019-04-27 13:39:27 -07:00
Christopher Lam
4d529c02cd [libgnucash-scm-utilities] remove unneeded section in CMakeLists 2019-04-27 17:04:02 +08:00
Robert Fewell
d1ee651bbc Modify the qof log format based on max logger name from log.conf
When you have multiple loggers enabled, the log file indentations are
partly based on logger name length and so you can have false
indentations which can cause confusion. This change gets the maximum
name logger length and uses this for all with a minimum default length
of 12 characters.
2019-04-26 12:09:05 +01:00
Robert Fewell
4368e18ac5 Bug 797165 - Crash on price deletion.
Caused by the introduction of caching used in gnc_pricedb_nth_price,
when prices were deleted, the cached list was never updated and so the
tree model could reference a deleted price and hence crash. This also
affected adding prices as the new prices would not show due to the
cache not being updated. To fix this a function was added to reset the
cache when prices are updated from the model.
2019-04-26 12:09:05 +01:00
Robert Fewell
9f0558ffb5 Add some missing log Macros for the price model
Add some missing LEAVE macro statements so the log entries do not get
longer and longer.
2019-04-26 12:09:05 +01:00
thetedmunds
483f9a4c83 Bug 797196 - Allow for per-payment rounding in amortization calculations
Provides functions gnc:amort_pmt, gnc:amort_ppmt, and gnc:amort_ipmt in
fin.scm.
2019-04-25 13:28:40 -07:00
John Ralls
5311e5a386 Revert "Merge T Edmunds's 'amortization-rounding' into maint."
This reverts commit aa53c23239, reversing
changes made to 3c946a8449, because
aa53c23 was based on master and so undid other changes made to maint
since the last merge-to-master.
2019-04-25 13:19:28 -07:00
Christopher Lam
0cf49f1244 [test-libgnucash-scm-utilities] amend info to explain comment fix 2019-04-25 11:20:34 +08:00
Christopher Lam
7d15e6e4e7 [utilities] create general string-replace-substring
copied function created by Mark Weaver, core guile dev and augmented
to selectively replace substring indices

This is a much more efficient function than the previous
gnc:substring-replace which will constantly split lists using
substring, and create new strings using string-append.

It also does tail call optimization properly, unlike the previous
functions.

https://lists.gnu.org/archive/html/guile-devel/2013-09/msg00029.html -
original

"Here's an implementation that does this benchmark about 80 times
faster on my machine: (20 milliseconds vs 1.69 seconds)

--8<---------------cut here---------------start------------->8---
(define* (string-replace-substring s substr replacement
                                   #:optional
                                   (start 0)
                                   (end (string-length s)))
  (let ((substr-length (string-length substr)))
    (if (zero? substr-length)
        (error "string-replace-substring: empty substr")
        (let loop ((start start)
                   (pieces (list (substring s 0 start))))
          (let ((idx (string-contains s substr start end)))
            (if idx
                (loop (+ idx substr-length)
                      (cons* replacement
                             (substring s start idx)
                             pieces))
                (string-concatenate-reverse (cons (substring s start)
                                                  pieces))))))))
--8<---------------cut here---------------end--------------->8---

The reason this is so much faster is because it avoids needless
generation of intermediate strings."
2019-04-25 10:52:45 +08:00
John Ralls
a12bbaccd3 Create CMakeLists.txt in libgnucash/scm/test.
Amended by chris to add a working scm/test/CMakeLists.txt.
2019-04-25 10:51:20 +08:00
Christopher Lam
92a920c4e0 [test-libgnucash-scm-utilities] renamed from test-utilities.scm 2019-04-25 10:51:20 +08:00
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