Commit Graph

26258 Commits

Author SHA1 Message Date
Geert Janssens
585de5d134 GncQuotes - break actual interaction with Finance::Quote out into a separate function query_fq
That allows for later reuse and easier testing.
2022-10-02 11:50:26 -07:00
Geert Janssens
70ab8a8a46 GncQuotes - drop parameterized constructor
The book parameter is only needed while fetching quotes.
In case the user passes one or more commodities to process
the book can be readily derived from the commodity/commodities.
In the other case (fetch all quotes) the user now is
required to pass a book to the call.
2022-10-02 11:50:26 -07:00
Geert Janssens
4c2863966b GncQuotes - rename fetch_all to be an overload of fetch
And add a third overload to fetch only a single quote
2022-10-02 11:50:26 -07:00
Geert Janssens
7765e13704 Bindings - move log wrappers into the swig interface files
They are only used for guile (and possibly python, so there's
no need to carry them around in core-utils.
2022-10-02 11:50:26 -07:00
Geert Janssens
e5c6f6026b Remove support code that was only used by price-quotes.scm 2022-10-02 11:50:26 -07:00
Geert Janssens
e97fc3e408 Drop price-quotes.scm, gnc-fq-helper.in and gnc-fq-check.in - no longer used 2022-10-02 11:50:26 -07:00
Geert Janssens
bf357315fd finance-quote-wrapper - implement check and fetch in one file via command line switches
This obsoletes gnc-fq-check as the same function can now be
performed with 'finance-quote-wrapper -v'
2022-10-02 11:50:26 -07:00
Geert Janssens
8c08fedaa1 Use GncQuotes in price db window 2022-10-02 11:50:26 -07:00
Geert Janssens
8896d61c7a Build dialog-price-edit-db as C++ 2022-10-02 11:50:26 -07:00
Geert Janssens
fbf9aecd25 Use GncQuotes in transfer dialog 2022-10-02 11:50:26 -07:00
Geert Janssens
1a0be99bc6 Build dialog-transfer as C++
Preparation to use GncQuotes instead of price-quotes.scm
2022-10-02 11:50:26 -07:00
Geert Janssens
a00bce168c GncQuotes - cache default currency 2022-10-02 11:50:26 -07:00
Geert Janssens
fcbe6cf10c Add code to parse json data returned by our F::Q wrapper
This code will convert the json data into GncPrice objects and add them
to the pricedb, effectively doing what price-quotes.scm does.

A few notable remarks:
- still requires plenty of cleaning up. This is the first proof of concept
- like the original scm based code, this parser completely ignores  timezone
  information. As it wasn't used before and nobody complained, it may not
  be that important. Or it can be implemented later.
- price-quotes.scm would first check if a price already existed in the pricedb
  and try to update that one instead of adding one (only if the old price's
  type is inferior). However that is redundant as gnc_pricedb_add_price does
  the same check. So I have omitted this extra check from GncQuotes.
- currency quotes can be inverted. I have slightly changed the way to handle
  this. The perl wrapper code will simply set an "inverted" flag in that case,
  but will otherwise not swap currency and commodity as it used to be the case.
  On parsing, the inversion flag will cause the GncNumeric that's parsed from
  the price to be inverted. As it's still a GncNumeric that shouldn't result
  in any loss of precision, while keeping prices in the db always in the default
  currency.
2022-10-02 11:50:26 -07:00
Geert Janssens
5c13da0e59 Move fetching quotes info to gnc-commands
It needs gnc-prefs which I don't want to add by default to gnucash-cli.
2022-10-02 11:50:25 -07:00
Geert Janssens
6ecc1ef73f GncQuotes - switch to Pimpl idiom
That allows the private implementation to pass a number of variables
based on various boost libraries. It's better to not have them in
the public interface to keep compilation times down.
2022-10-02 11:50:25 -07:00
Geert Janssens
65ae46426b GncQuotes - add parameterized construction
For all but the basic check a book is required. Might
as well be able to pass it directly and store a reference
to it. That will simplify member function declarations.
2022-10-02 11:50:25 -07:00
Geert Janssens
3685e5de73 Factor out the async call to perl
This will allow us to reuse it for several F::Q commands, like
check, fetch,...
2022-10-02 11:50:25 -07:00
Geert Janssens
6ce91d7f49 Drop the single quotes instance code for now
I have been reading on singleton implementations and there appears
to be a lot of pushback against those.
We can revisit this if it turns out performance degrades
significantly by running the F::Q check multiple times.
2022-10-02 11:50:25 -07:00
Geert Janssens
616a672d52 Rewrite boost::process call to properly capture both stdout and stderr
The previous version of the code could only capture one
but not both at the same time.
2022-10-02 11:50:25 -07:00
Geert Janssens
a6771754d5 GncQuotes - start implementation of fetch/fetch_all 2022-10-02 11:50:25 -07:00
Geert Janssens
f3fdc5de12 Rewrite gnc-fq-helper as finance-quote-wrapper
This rewritten version takes JSON input and spits out JSON.
Additionally inverted currency quotes will only be flagged.
The old code also swapped currencies in the result.
GncQuotes will be written towards these new implementation
choices.
2022-10-02 11:50:25 -07:00
Geert Janssens
1d94887a0b Rewrite gnc_commodity_table_get_quotable_commodities as gnc_quotes_get_quotable_commodities
It only makes sense in that context.
2022-10-02 11:50:25 -07:00
Geert Janssens
466db526b2 Move source files for GncQuotes to app-utils
It will depend on functions in that library. This can probably be
fixed by cleaning up app-utils, but that's not the topic of
this feature.
2022-10-02 11:50:25 -07:00
Geert Janssens
8c4bd86c7b Fix memory leak as suggested by Christopher Lam 2022-10-02 11:50:25 -07:00
Geert Janssens
9d62755b4a Make GncQuotes::check() a private function, returning nothing
At the same time do an explicit reinstantiation of quotes_cached at first use
to work around what seems to be a race condition between static instantiation
and binreloc.
2022-10-02 11:50:25 -07:00
Geert Janssens
32df095d4f Catch potential boost::process exceptions
Could happen if the perl executable isn't found and perhaps also
if there's a stream exception.
2022-10-02 11:50:25 -07:00
Geert Janssens
d79306f7db Protect boost process output read loop from deadlock
As per the boost::process tutorials
2022-10-02 11:50:25 -07:00
Geert Janssens
f658ff409f Tweak line endings in output streams
Flush only at the very end.
2022-10-02 11:50:25 -07:00
Geert Janssens
8b772384cd Various performance fixes based on feedback
- const correctnes
- avoid unnecessary copying
- avoid need to reverse GList
2022-10-02 11:50:25 -07:00
Geert Janssens
2f7ed7f25d Initial version of libgnc-quotes
This library intends to wrap Finance::Quote the way price-quotes.scm currently does.
In this first commit the library replaces price-quotes.scm's library to install
quote sources. In addition it exposes a new command line parameter  in gnucash-cli
to show which version of Finance::Quote is installed on the system (if any) and
which quotes sources that verions exposes.
2022-10-02 11:50:25 -07:00
John Ralls
b0ae402c23 Limit instantiation of GncInt128 constructors to integral values.
Instead of using static_assert. This prevents the compiler from even
trying and avoids weird compilation errors when testing types for
instantiating other templates.
2022-10-02 10:15:15 -07:00
John Ralls
3c75d212ab Fix build on Apple Silicon or maybe Apple-clang-14.0
The compiler complains that there's no matching
gnc_register_number_range_option for GncOptionDB*, which without this
commit is true because the explicit templates are for GncOptionDBPtr&.
Note that the original template definition is for GncOptionDB* and
that the header-defined inlines that take GncOptionDBPtr& call the
GncOptionDB* version.
2022-10-02 10:15:01 -07:00
John Ralls
283a5b7ce9 Fix dist, files moved 2022-10-01 17:39:31 -07:00
Christopher Lam
c78bb3c22c [test-gnc-option-scheme-output.scm] more scheme typos
Addendum to 11d395185
2022-09-27 21:36:05 +08:00
John Ralls
11d395185c Fix spelling of xaccAccountGetType. 2022-09-26 09:31:47 -07:00
John Ralls
3949821da6 Merge branch 'maint' 2022-09-25 11:50:10 -07:00
John Ralls
ebd340674e Release GnuCash 4.12 2022-09-24 14:06:53 -07:00
Maxime Leroy
6f0d1fa60f
Translation update by Maxime Leroy <lisacintosh@gmail.com> using Weblate
po/fr.po: 99.9% (5399 of 5401 strings; 2 fuzzy)
3 failing checks (0.1%)
Translation: GnuCash/Program (French)
Translate-URL: https://hosted.weblate.org/projects/gnucash/gnucash/fr/

Co-authored-by: Maxime Leroy <lisacintosh@gmail.com>
2022-09-24 07:54:05 +02:00
Minjae Isaac Kwon
87c1e4752a
Translation update by Minjae Isaac Kwon <minjae.isaac.kwon@gmail.com> using Weblate
po/ko.po: 63.8% (3450 of 5401 strings; 1015 fuzzy)
263 failing checks (4.8%)
Translation: GnuCash/Program (Korean)
Translate-URL: https://hosted.weblate.org/projects/gnucash/gnucash/ko/

Co-authored-by: Minjae Isaac Kwon <minjae.isaac.kwon@gmail.com>
2022-09-24 07:54:05 +02:00
Eduardo Malaspina
9c4fac3da7
Translation update by Eduardo Malaspina <vaio0@swismail.com> using Weblate
po/es.po: 99.8% (5391 of 5401 strings; 10 fuzzy)
10 failing checks (0.1%)
Translation: GnuCash/Program (Spanish)
Translate-URL: https://hosted.weblate.org/projects/gnucash/gnucash/es/

Co-authored-by: Eduardo Malaspina <vaio0@swismail.com>
2022-09-24 07:54:05 +02:00
Christopher Lam
ae993503ee [assistant-stock-transaction] better punctuation for error messages. 2022-09-24 13:53:18 +08:00
Christopher Lam
1cac132214 [gnc-plugin-page-register] hide toolbar and menu in regular register
Instead of toggling sensitivity according to xaccAccountIsPriced,
toggle visibility instead.
2022-09-22 22:50:57 +08:00
Christopher Lam
05f952dbe8 [assistant-stock-transaction] use cpp form for struct
...and remove unused pointer in struct
2022-09-22 22:50:57 +08:00
Christopher Lam
788c3ee617 [import-main-matcher] setup_entry handles NULL and empty initial
gtk_entry_set_text throws a warning if initial is empty. Avoid calling
when initial==NULL.

Also, if the imported transaction has empty-string desc/notes/memo, we
don't want to populate the GtkEntryCompletion with it.
2022-09-21 00:11:55 +08:00
Christopher Lam
3e4a4dbfe1 [import-main-matcher] initialize hash tables in common setup
... otherwise the hash tables aren't initialized when the CSV importer
calls the import matcher.
2022-09-21 00:11:55 +08:00
John Ralls
2505955ab9 Fix test failure from Bug 798616 fix. 2022-09-20 09:09:34 -07:00
Arve Eriksson
43b6c17b92
Translation update by Arve Eriksson <031299870@telia.com> using Weblate
po/sv.po: 100.0% (5401 of 5401 strings; 0 fuzzy)
0 failing checks (0.0%)
Translation: GnuCash/Program (Swedish)
Translate-URL: https://hosted.weblate.org/projects/gnucash/gnucash/sv/

Co-authored-by: Arve Eriksson <031299870@telia.com>
2022-09-20 03:18:37 +02:00
John Ralls
7c350c3ae5 Bug 798616 - Can't register amount greater than 9,000,000,000
Because when loading the value the split in the xml backend doesn't yet
have a parent so the code tried to convert to GNC_COMMODITY_MAX_FRACTION
and if the numerator was larger than 10^10 that would overflow.

To fix it this changes the "don't know" response to get_currency_denom
and get_commodity_denom to GNC_DENOM_AUTO which will normally leave
the denominator alone.
2022-09-19 18:17:58 -07:00
Christopher Lam
1752f1d19d [assistant-stock-transaction] disallow stock split ratio of 0.
otherwise the reverse stock split would allow a new stock amount
balance of zero.
2022-09-20 08:45:07 +08:00
Christopher Lam
84f4f3b6f8 [assistant-stock-transaction] add to toolbar 2022-09-19 10:03:28 +08:00