Commit Graph

729 Commits

Author SHA1 Message Date
John Ralls
b8c0673526 Merge branch 'maint' 2022-12-19 12:11:32 -08:00
John Ralls
b4bab92da2 Bug 798664 - Result of 'gnucash --nofile' is marked dirty
Don't create a new book in the new-user dialog unless the user says to.
Don't automatically create a new book when retrieving default commodities
because the retrieve might be requested in a context like the Preferences
dialog when there is no book.

Some report tests relied on requesting the default commodity creating
the book, so in those tests ensure that the book is created first.
2022-12-12 11:30:59 -08:00
John Ralls
fae5de80d3 Undo unintended change in Bug 798679 commit. 2022-12-11 19:54:35 -08:00
John Ralls
fd2761bd68 Bug 798679 - Fullwidth characters cannot be pasted as-is in register fields
Control character check doesn't need normalization, the control character
codepoints aren't graphic and so can't be composed nor have compatible
equivalents.
2022-12-11 13:00:40 -08:00
Geert Janssens
98251d59a6 Bug 798672 - Preferences are not saved nor loaded, ERROR <GLib-GIO> g_settings_new_full: assertion 'schema != NULL' failed
Apparently it was a failure on our side to properly look up
requested gsettings schema.
2022-11-29 12:27:21 +01:00
Christopher Lam
fc94b41c81 Merge branch 'maint' 2022-10-29 21:53:57 +08:00
John Ralls
cf088f2a70 Merge John Ralls's 'Bug798614' into maint. 2022-10-28 15:27:28 -07:00
John Ralls
14a0ea4ed3 [price-quotes] Sort and format source list. 2022-10-17 11:13:55 -07:00
John Ralls
1a906b00aa [price-quotes] Enable gnucash-cli to retrieve preferences on macOS.
By embedding a minimal Info.plist with a bundle ID into the executable.
This necessitated a change to binreloc because the unix-style install
depended on there being a bundle ID only when the program was run from
an application bundle.
2022-10-17 10:06:21 -07:00
John Ralls
2767587874 [price-quotes] Fix setting alphavantage API key. 2022-10-14 15:47:07 -07:00
John Ralls
7f2a09a69f [price-quotes] Handle short error strings from finance-quote-wrapper.
This keeps the translation work in GnuCash and improves the error
signalling in gnc-quotes.
2022-10-14 10:26:51 -07:00
John Ralls
50c72b4f88 [price-quotes] Remove m_ready and usable() from GncQuoteSource.
GncQuoteSource ctor throws if something is wrong so usable is always true.
2022-10-13 14:28:17 -07:00
John Ralls
7d93774dd2 [price-quotes] Throw instead of returning if there aren't any commodities to quote.
So that the user gets sees an error instead of silent failure.
2022-10-13 13:51:37 -07:00
John Ralls
81d4ea9550 [price-quotes] Remove F::Q version format check.
We don't care what the version string looks like as long as there is one.
2022-10-13 12:58:09 -07:00
John Ralls
c78fe37ff7 [price-quotes] General typo fixes and code cleanup. 2022-10-13 12:52:36 -07:00
John Ralls
70c9d4c9e3 [price-quotes] Fix version retrieval.
Plus there's no need for a "not found" version string because GncQuotes
construction will throw if Finance::Quote isn't correctly installed. No
object, nothing to call version() on.
2022-10-13 12:20:59 -07:00
John Ralls
97e730b8d8 [price-quotes] Reformat test quote response strings to one line per quote. 2022-10-13 11:24:49 -07:00
Mike Alexander
2d3e80ea08 Compatibility with XCode's "new build system"
With XCode 14 or newer CMake tries to use the "new build system" which has a
requirement that if two targets depend on the same generated file one of them
must depend on the other.  This commit adds reduntant dependencies to satisfy
this requirement.
2022-10-09 01:10:06 -04:00
John Ralls
e817091de1 [price-quotes] Warn only once if the AlphaVantage Key isn't set.
And check the environment if it's not in preferences.
2022-10-02 11:50:26 -07:00
John Ralls
d97ea77762 [price quotes] Add report member function to display quote information to stdout.
Instead of creating price instances in the database.
2022-10-02 11:50:26 -07:00
John Ralls
6ffb0bb633 [price-quotes] Report quote fetch failures to the user. 2022-10-02 11:50:26 -07:00
John Ralls
4c47e91180 [price-quotes] Implement error codes for currency and quote failures. 2022-10-02 11:50:26 -07:00
John Ralls
6db7800ca5 [price-quotes] Doxygen docs. 2022-10-02 11:50:26 -07:00
John Ralls
29ce925646 [price-quotes] Test the other fetch overloads and quote values. 2022-10-02 11:50:26 -07:00
John Ralls
b5bc6463a3 [price-quotes] Rework date-time handling.
A check of the F::Q modules found that the only ones that return a quote
time return a bogus one and do so only to mollify GnuCash.

Since there's no good way to determine the TZ of the exchange originating
the quote there's no good way to decide if the quote is current or from
a previous market session, so we just punt and use a time of 16:00 for
all quotes.
2022-10-02 11:50:26 -07:00
John Ralls
19064093d2 [price-quotes] Remove m_comm_vec and m_fq_answer.
Passing the intermediate values comm_vec and quote_str on the stack instead.
2022-10-02 11:50:26 -07:00
John Ralls
734fb6ce2a [price-quotes] Switch error handling to exceptions.
Allows for cleaner code with less state, less coupling of the GncQuotes
class, and better transfer of error messages to client code.

Also translates some error messages for presentation to users.
2022-10-02 11:50:26 -07:00
John Ralls
d307295076 [price-quotes] Paramaterize GncMockQuoteSource construction.
So we can have different results passed back for different tests.
2022-10-02 11:50:26 -07:00
John Ralls
2b87066687 [price-quotes] Extract some static functions.
To get  GncQuoteImpl::parse_one_quote to a reasonable size.
2022-10-02 11:50:26 -07:00
John Ralls
a82c72cfb9 [price-quotes] Remove level of indirection when parsing quote data. 2022-10-02 11:50:26 -07:00
John Ralls
37dfab7f31 [price-quotes] Convert long quote parsing lambda to a regular function.
To begin separating price parsing from inserting in the price db.
2022-10-02 11:50:26 -07:00
John Ralls
dd8316714b [price-quotes] Extract function GncQuotesImpl::comm_vec_to_json_string. 2022-10-02 11:50:26 -07:00
John Ralls
e3ab384504 [price-quotes] Log messages instead of writing them to std::streams. 2022-10-02 11:50:26 -07:00
John Ralls
b8642e55d9 [price-quotes] Implement mock quote source.
Note that because the non-default constructor exists only on GncQuotesImpl
we must use that directly and violate the pimpl.
2022-10-02 11:50:26 -07:00
John Ralls
4dd3922871 [price-quotes] Make wiggle test conditional on F::Q being installed. 2022-10-02 11:50:26 -07:00
John Ralls
784aca5a4c [price-quotes] Extract class GncQuoteSource.
Provide a specialization GncFQQuoteSource and move the F::Q command
construction and query functions to GncFQQuoteSource.

This allows for dependency injection to provide testing that doesn't
need F::Q to be installed.
2022-10-02 11:50:26 -07:00
John Ralls
e9577b7996 [price-quotes] Basic wiggle test. 2022-10-02 11:50:26 -07:00
Geert Janssens
277f299ad6 GncQuotes - cleanups
- make more use of auto
- mark user visible strings as translatable
- return early on input errors
- fix date conversion fallback to actually fall back to today
2022-10-02 11:50:26 -07:00
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
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
fbf9aecd25 Use GncQuotes in transfer dialog 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
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