Commit Graph

696 Commits

Author SHA1 Message Date
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
Geert Janssens
a6771754d5 GncQuotes - start implementation of fetch/fetch_all 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
John Ralls
283a5b7ce9 Fix dist, files moved 2022-10-01 17:39:31 -07:00
John Ralls
95361ad060 [options] Move gnc-options test to engine/test/CMakeLists.txt. 2022-08-29 17:05:33 -07:00
John Ralls
4ae17d12c7 [options] Move options from app-utils to engine.
Options is required for book options that are stored as part of the data
 file and so belongs in engine.
2022-08-25 22:09:56 -07:00
John Ralls
f24f29830b [options] Change std::cerr stream output to PWARN.
Remove temporary diagnostic.
2022-08-25 22:09:56 -07:00
Christopher Lam
3e02859277 Merge branch 'maint' 2022-08-25 23:47:18 +08:00
Christopher Lam
b7a3652de7 [date-utilities] avoid report crash if start>end date 2022-08-21 17:27:05 +08:00
John Ralls
087501d316 Bug 798262 - Scheduled transactions with blank amounts do not get created.
Handle template transactions that don't have any splits with empty credit
and debit strings and those having no set transaction account.

Set the concrete transaction commodity to the first found of:
The template transaction's commodity
The commodity of the first split with a credit or debit string
The commodity of the first split.
2022-08-14 15:31:46 -07:00
John Ralls
410db42df0 Test case where the template txn doesn't have a set currency. 2022-08-14 15:28:14 -07:00
John Ralls
229f6f5e85 Fix gdate adjustments. 2022-08-12 12:58:58 -07:00
Simon Arlott
4c1fc1d555 Bug 798262 - Add test case for basic scheduled transactions
Test these scheduled transactions:
* 2 splits with fixed amounts "123"
* 2 splits with fixed amounts "0"
* 2 splits with empty amounts ""

Verify that automatically created scheduled transactions exist.
2022-08-11 11:01:03 -07:00
Christopher Lam
6ba912ee0d Merge branch 'maint' 2022-08-09 18:15:23 +08:00
Christopher Lam
de7a63082b [gnc-sx-instance-model] leaks: free temporal_state
it's a simple struct containing GDate and int
2022-08-08 13:58:53 +08:00
Christopher Lam
ad27be333e [gnc-sx-instance-model] prepend GList loops instead of append 2022-08-08 13:58:53 +08:00
John Ralls
8b07ac88cd [options] Add "key" to the register-option documentation blocks. 2022-08-06 17:17:32 -07:00
John Ralls
e29ab5336f [options] Remove key and doc_string from gnc_register_query_option.
It's always used as an internal option with no UI component so it doesn't
use them.
2022-08-06 17:17:32 -07:00
John Ralls
6faaf3b427 [options] Provide a const char* value flavor for register_commodity
And register_currency_option
2022-08-06 17:17:32 -07:00
John Ralls
1ff844c195 [options] Fix implementation of gnc_register_owner_option
To take an owner-type parameter and to set the UIType accordingly.
2022-08-06 17:17:32 -07:00
John Ralls
aa0b0921f4 [options] Add a function to check if an option is internal.
Instead of relying on the legacy underscore-section-name hack.
2022-08-06 17:17:32 -07:00
John Ralls
da0eff2cac [options] Implement widget-changed callbacks.
Enables full functionality for complex-boolean and multichoice-callback
options.

Note that setter-function callback isn't used in any GnuCash code so it
is not implemented and is not present in the register-callback functions.
2022-08-06 17:17:26 -07:00
John Ralls
552aa438ff [options] Implement gnc_register_internal_option. 2022-08-06 17:13:28 -07:00
John Ralls
0e9ed8cf0a [options] Provide float variants to gnc_register_plot_size_option. 2022-08-06 17:13:28 -07:00
John Ralls
0213787a2f [options] Enable registering an absolute date option. 2022-08-06 16:25:42 -07:00
John Ralls
cf2870b71a [options] Change RelativeDate and Multichoice index type to uint16_t.
From size_t because clang thinks that std::is_same_v<size_t, time64> is
true and we need to differentiate the handling of the two.
2022-08-06 16:25:42 -07:00
John Ralls
0b2d14ee72 Fix distribution for expressions target. 2022-08-06 16:25:42 -07:00
Christopher Lam
b94440b16a Bug 798588 - sx scrubbing was using incorrect free function
the GHashTable values are gnc_numeric*.
2022-08-06 16:25:42 -07:00
Christopher Lam
ea56d67797 [gnc-sx-instance-model.c] indent attributes properly 2022-08-06 16:25:42 -07:00
Christopher Lam
bfa0fd1819 Bug 798588 - sx scrubbing was using incorrect free function
the GHashTable values are gnc_numeric*.
2022-08-06 14:39:57 +08:00
Christopher Lam
f0ac8d69b2 [gnc-sx-instance-model.c] indent attributes properly 2022-08-06 14:39:55 +08:00