Commit Graph

330 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
John Ralls
bc9d83c90f Merge Christoph Holterman's 'PR-G_ADD_PRIVATE-clean' into maint. 2019-03-19 09:12:48 -07:00
Christopher Lam
09e0e02a75 [test-extras] abstract test-data skeleton 2019-02-22 23:36:15 +08: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
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
Sicelo
07fbb46398
Update SZL section header
Clarify the reason for changing the symbol
2019-02-17 08:10:55 +02: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
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
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
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
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
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
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
Christopher Lam
2423aeda42 [engine/test-test-extras] remove duplicated test file 2018-12-29 23:15:46 +08: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