Commit Graph

615 Commits

Author SHA1 Message Date
Geert Janssens
4ffc4d046f GncEntry - Fix inverted comparison 2019-05-28 17:19:29 +02:00
John Ralls
957df9a32b Add a +0000 offset to ISO8601 timestamps in the XML backend.
Apparently GnuCash for Android hard-coded the offset spec into their
parser, so it can't import XML files without it.
2019-05-27 14:51:06 -07:00
Christopher Lam
ed42f8acb6 Bug 797197 - Transaction report: Error message when sorting on month
guile's strftime is/was buggy; cannot handle non-UTF8 locales. Use
gnc_print_time64 instead. see the following

http://lists.gnu.org/archive/html/bug-guile/2019-05/msg00003.html
2019-05-27 21:20:29 +08:00
Geert Janssens
b7479e8fb0 Bump minimum cmake version to 3.5
This version is available for all supported platforms and distros
(CentOS can have a version via EPEL, which is required anyway)

Advantages:
- one cmake version for all platforms
- we can drop all conditions based on cmake version
2019-05-25 12:04:51 +02:00
John Ralls
2d4f771bed Merge Adrién Panella's 'budget' into maint. 2019-05-23 09:50:20 -07:00
Adrian Panella
5bb54d073c [budget] Fix error in qof_book property path
The "Default budget" property had an erroneus path
and was not returning any value.
2019-05-17 23:12:19 -05:00
Robert Fewell
416b79d304 Reformat source files gnc-accounting-period.*
Change tabs to white space and some other white space changes.
2019-05-17 11:01:24 +01:00
Robert Fewell
037f5ed5be Bug 797089 - Wrong time for accounting period end date
In the Preferences/Accounting Period, there is an option to specify
absolute dates but the end date was being set to start of day instead
of end of day, changed this.
2019-05-17 11:01:24 +01:00
John Ralls
fc567208f3 Bug 797233 - Balance Sheet, Chart of Accounts, and other reports...
crash when involving foreign currency stocks.

Scheme's inexact->exact function just converts the floating-point
representation of a number into an exact rational (documented in the
API Reference, Simple Generic Data Types, Numerical data types, Exact
and Inexact Numbers), which isn't what we want.

We want the number converted to exact directly from the string and to do
that we have gnc-fq-helper preface it with #e.
2019-05-14 13:34:07 -07:00
John Ralls
217418bb8c Merge Adrián Panella's 'numeric' into maint. 2019-05-14 10:09:16 -07:00
Adrian Panella
f905467a44 [numeric] Fix constructor from strings in range (0 ,1)
Fix error that caused strings in the form 0.nnn to be
converted to negative numerics.
2019-05-13 23:05:11 -05:00
John Ralls
e6c50357bb Fix test error string to match actual error. 2019-05-13 15:19:19 -07:00
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