Commit Graph

603 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