Commit Graph

1973 Commits

Author SHA1 Message Date
Geert Janssens
60209a766f Merge branch 'csv_import' 2023-02-04 19:13:16 +01:00
Geert Janssens
2d8bb6f62f Bug 796955 - Import CSV - Single-line two-currency transactions can't be imported
Behaviour is as follows:
If
  single line provides a price
And
  at some point in the import process we get into a
  situation where the base account and transfer
  account have a different commodity
Then
  transfer_acct amount = base_acct amount * price

If on the other hand base_acct and transfer_acct turn
out to have the same commodity, price is ignored.
2023-02-04 18:56:02 +01:00
Geert Janssens
99506d331a Reduce GncImportMatchMap to just the account
There is no added value in storing the book and account together
The book is easily retrieved from the account (as was
illustrated in the gnc_account_imap_new function).

I looked through the commit history to understand why this struct
was originally created and a long time ago it also had
a reference to a kvp frame.
2023-02-04 16:53:20 +01:00
Geert Janssens
51706f289c Minor corrections in comments 2023-02-04 16:43:46 +01:00
John Ralls
7bb14b9caa Merge Richard Cohen's 'use-reference-for-loop' into master 2023-02-02 14:32:14 -08:00
Robert Fewell
07f3f536cc Allow to select saved report on print invoice button
This change was inspired by mildred's #PR1247 and uses the new
GncReportCombo to allow selection of 'Saved Invoice reports' when the
invoice print button is used or when printing multiple invoices.

This change presents a dialog with the default for the report combo set
to the properties setting. This dialog has a timeout which is
adjustable under properties and will stop if a key is pressed or combo
popped so that a different report template can be selected and used.
There is also an 'OK' button that stops the time out and prints and a
'Cancel' button which cancels the print.
2023-02-02 14:05:53 +00:00
Robert Fewell
019214f1c2 Bug753307 - Custom Report be selectable as default Report for Printing
This commit changes the preference in Business->'Report for Printing'
to be saved as a book property and allow the selection of any Invoice
Report to be used as the default.
2023-02-01 16:29:11 +00:00
Richard Cohen
d8f45f2443 Use const references for for-loops to avoid unnecessary copies
Found by clazy - clazy-range-loop-reference
2023-01-31 14:44:57 +00:00
John Ralls
ce3447e6ea Bug 798740 - Build fails with gcc 13
Protect against passing an lseek failure rv to read().
2023-01-30 16:48:16 -08:00
Christopher Lam
119356752f Merge branch 'maint' 2023-01-30 09:56:13 +08:00
Geert Janssens
894f8241e1 Revisit invoice payment in multi-currency context
- Show proper amount in dialog when applying or editing an existing transaction as payment
- Be more careful not to waste the existing payment split
- If the user changed the payment amount while starting from an existing transaction
  unreconcile the changed payment split
- Avoid needlessly changing transaction currency (only do so if the user chose
  a new transfer account and the old currency is neither the new transfer account's
  currency nor the post account's currency)
2023-01-29 23:09:06 +01:00
John Ralls
44f4b55927 Merge Richard Cohen's 'fix-memleaks' into master. 2023-01-26 12:52:21 -08:00
Richard Cohen
846e75146a Fix some typos so that the correct tests are run
- test_gnc_txn_to_float_txn_cut_semantics
- test_dbi_business_store_and_reload
2023-01-26 15:42:13 +00:00
Richard Cohen
a2ffc7fe75 Fix memory leak in binreloc function _br_find_exe()
Ironically, it seems to be in a code path that
is only followed when using valgrind
2023-01-26 14:36:43 +00:00
luzpaz
67ab9e90d2 Fix some typos 2023-01-26 13:48:58 +01:00
Christopher Lam
17820ec261 Merge branch 'maint' 2023-01-26 18:40:44 +08:00
John Ralls
f4c6d65395 Merge Bob Fewell's 'nofree' into maint. 2023-01-24 13:25:02 -08:00
John Ralls
f6919e60a7 Merge Richard Cohen's 'cleanup' into master. 2023-01-24 12:05:47 -08:00
John Ralls
46f9fb01c9 Simplify gnc_commodity equality and compare functions.
gnc_commodity_compare is used for sorting and so needs to have a less-than
return value. The only place it's used presents nothing to the UI; a GncGUID
ordering is fast and stable.

GnuCash allows only one commodity per book for any namespace/mnemonic pair, so
the exhaustive string comparisons are superflous. While the current engine
design allows only one instance of any object, meaning that a pointer comparison
is sufficient to determine equality, that may not be true in the future, but the
GncGUID is guaranteed to sufficiently identify a single commodity. Note that
gnc_commodity_equiv is used to enforce that single-commodity rule and so cannot
use GncGUID comparison.
2023-01-24 10:46:01 -08:00
Richard Cohen
6927535a0a Remove unused test function get_object_is_initialized in qofobject.cpp 2023-01-24 13:36:37 +00:00
Richard Cohen
925fcbc3fd Remove unused gnc-jalali.{c,h} 2023-01-24 13:36:23 +00:00
Richard Cohen
e83c91050c Remove unneeded dummy.cpp 2023-01-24 13:36:02 +00:00
Richard Cohen
d6ac56ce5f Re-enable -Waddress - gncInvoiceLookup etc. are now inline functions, not macros
- Remove outdated comments
2023-01-24 13:35:22 +00:00
Richard Cohen
3360a6d13b Remove extra semicolons
Courtesy of gcc -pedantic
2023-01-24 13:22:18 +00:00
John Ralls
046e4a156e Silence Clang deprecation warnings about sprintf. 2023-01-23 12:54:25 -08:00
John Ralls
dd2497416c Merge Richard Cohen's 'internal-extern-c' into master. 2023-01-23 11:27:05 -08:00
John Ralls
60c06debce [c++options] Don't crash when find_option returns nullopt. 2023-01-23 11:22:35 -08:00
Richard Cohen
1cec0cb3f3 Use internal extern "C" { ... } for C++
- removes warnings compiling swig engine
...
[ 10%] Generating swig-engine.cpp
.../libgnucash/engine/engine-helpers.h:31: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gnc-date.h:83: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/qofquery.h:90: Warning 302: Identifier 'QofQuery' redefined (ignored),
.../libgnucash/engine/gnc-option.hpp:55: Warning 302: previous definition of 'QofQuery'.
.../libgnucash/engine/gnc-commodity.h:56: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncBusiness.h:40: Warning 313: Unrecognized extern type "C++".
.../libgnucash/engine/gncEntry.h:37: Warning 313: Unrecognized extern type "C++".
2023-01-23 18:40:01 +00:00
Richard Cohen
19bbde7000 Fix some typos 2023-01-23 15:01:46 +00:00
John Ralls
432f2d4bb8 Merge Richard Cohen's suppress-boost-warning into master. 2023-01-22 10:50:11 -08:00
John Ralls
9a1a90d8d0 Merge branch 'maint' 2023-01-22 10:49:29 -08:00
richardcohen
f3cc223f5f Fix some bad code formatting 2023-01-22 10:39:48 -08:00
richardcohen
8044f79f75
Silence the boost (<1.76) warning message
from .../gnucash-4.8/libgnucash/app-utils/gnc-quotes.cpp:33:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message:

    The practice of declaring the Bind placeholders (_1, _2, ...) in the
    global namespace is deprecated.
    Please use <boost/bind/bind.hpp> + using namespace boost::placeholders,
    or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
    
The issue was fixed in boost 1.76, but, e.g ubuntu 22.04 has boost 1.74
2023-01-22 17:50:34 +00:00
Christopher Lam
fd007a0af1 Merge branch 'maint' 2023-01-13 07:45:31 +08:00
Robert Fewell
6df866f876 Add tests for the reconcile account functions 2023-01-12 14:38:08 +00:00
Robert Fewell
fd37ee997d Fix getting xaccAccountGetReconcilePostponeBalance
Change the G_VALUE from a INT64 to BOXED.
2023-01-12 14:38:08 +00:00
John Ralls
fb9947b7b6 Rename GncDateTime's ymd to gnc_ymd to avoid a name conflict with Carbon. 2023-01-09 14:36:06 -08:00
John Ralls
fed4daf4e7 [c++ quotes] Make sure to include all of the required Boost libraries.
Also Boost-iostreams needs winsock but doesn't tell Cmake, so explicitly
add it to the link list.
2023-01-08 16:11:58 -08:00
Christopher Lam
c65b36490a Merge branch 'master-progress' 2023-01-06 16:33:46 +08:00
Frank H. Ellenberger
506a1b3c5e Merge branch 'maint' 2023-01-06 01:31:13 +01:00
Alex Aycinena
1085d8920b Update Form/Schedule line references for 2022 for the US Income Tax Report 2023-01-04 16:58:57 -08:00
John Ralls
b922cfd78d Bug 798679 - Unicode normalization should be used for comparison but not stored.
Change to NFC normalization for all comparisons because the Unicode
meaning of compatible might collide with the user's intent.
2023-01-04 13:19:36 -08:00
John Ralls
31d79e3004 Merge Bob Fewell's 'bug798673' into master. 2022-12-30 16:00:12 -08:00
John Ralls
5c17950a59 Merge Bob Fewell's 'mainwin2' into master. 2022-12-30 13:56:54 -08:00
Christopher Lam
259881f940 [gnc-optiondb] add some more renamed options
following ab13b01f8c Replace ... with … in all translatable strings.
2022-12-24 22:14:35 +08:00
John Ralls
ab13b01f8c Replace ... with … in all translatable strings.
Also a few other places like translator comments and report options.

Replaces https://github.com/Gnucash/gnucash/pull/1033.
2022-12-23 12:43:54 -08:00
Geert Janssens
734f90bd36 Replace string literal 'gnucash' with PROJECT_NAME parameter where it makes sense
The idea behind this is to not assume the project is always built
as "gnucash" exactly.
One example where it can be useful to use a different project name
would be when building multiple development versions of the project
on the same system and don't want these different versions share
the same settings in GSettings or the same stored passwords.
2022-12-19 22:18:12 +01:00
John Ralls
b8c0673526 Merge branch 'maint' 2022-12-19 12:11:32 -08:00
Robert Fewell
7536fcaf2f Change the balance limit icon if both limits are zero
When higher and lower limits are zero, when used for a a suspense
account, change the icon to 'dialog-warning'. This type of use is to
indicate that a non zero balance exists.
2022-12-17 11:44:45 +00:00
John Ralls
091d4aff22 Bug 798657 - Import Summary language is wrong
Root cause is using boost::locale::translate because it ignores
the LANGUAGES environment variable and doesn't support different
values for LC_MESSAGES, LC_DATE, LC_MONETARY, and LC_NUMERIC.
That makes it impossible to configure a user environment that
presents translated strings in a different locale from the one
applied to formatting dates and numbers.

To correct this replace all use of boost::locale::translate
with GNU gettext.
2022-12-16 15:34:10 -08:00
Robert Fewell
3be25ff0a9 Add some tests for the account functions 2022-12-16 15:16:58 +00:00
Robert Fewell
a15c6f81b3 Allow the balances of sub accounts to be used in limits 2022-12-16 15:16:53 +00:00
Robert Fewell
60ab654d2b Add account balance test functions to gnc-ui-balance 2022-12-16 15:16:16 +00:00
John Ralls
73a134730f Bug 798680 - Not able to match a reverse transaction of a...
previously matched transaction.

Cloned transactions and copied splits shouldn't keep the online-id
slot.
2022-12-13 13:13:13 -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
Robert Fewell
518ecfe041 Add some functions that would allow adding a balance limit to accounts 2022-12-10 13:37:41 +00: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
bfc325f63c Merge branch 'maint' 2022-11-27 16:12:46 +08:00
Marco Scardovi
6fe2028bca
Fix test
Signed-off-by: Marco Scardovi <mscardovi@icloud.com>
2022-11-24 23:20:07 +01:00
Robert Fewell
59d95a4ce6 Bug 798545 - Crash when updating document link on vendor bill
There were two issues here, the first one was that the copied doclink
was pointing to the original doclink which lead to a double-free. The
second is the setting of the doclink on the copied invoice needs to be
done with gncInvoiceSetDocLink otherwise on closure the doclink value
will disappear.
2022-11-24 11:16:01 +00:00
Christopher Lam
3d8a28898d [gnc-budget] gnc_budget_get_account_period_note returns a const
to harmonize with all other char getters
2022-11-19 10:35:49 +08:00
Christopher Lam
2ee0c98200 [gnc-budget] use operator[] instead of find() and insert()
- avoid hashing Account* twice. one call to operator[] is sufficient.
- don't need use std::move with better constructors
- sanity check - can't have a budget with num_periods = 0
- remove unused headers
2022-11-19 10:35:43 +08:00
Christopher Lam
3e5fcc8709 Merge branch 'maint' 2022-11-15 22:20:54 +08:00
Robert Fewell
4f8643674b Remove all references to GncDisplayItem 2022-11-05 17:04:12 +00:00
Robert Fewell
078d7875d3 Change all references to plugin_class->actionsb
Change all references to plugin_class->actionsb and n_actionsb to
plugin_class->actions and n_actions
2022-11-05 17:04:11 +00:00
Christopher Lam
6f80c548e6 [gtest-qofevent.cpp] comprehensive tests for qofevent 2022-11-05 09:25:24 +08:00
Christopher Lam
05ffd3d4eb [budget-feature] move unset_feature call to gnc_budget_gui_delete_budget
because gnc_budget_gui_delete_budget is a more general function to
delete a budget.
2022-10-31 12:03:58 +08:00
Christopher Lam
b87aa004f9 [test-qofbook] add tests for unknown features
tests that gnc_features_test_unknown returns a suitable error message
2022-10-31 10:40:12 +08:00
Robert Fewell
0f70143c55 Initial change to plugin source files 2022-10-30 13:16:34 +00:00
John Ralls
b9077bccd3 Bug 798640 - Segfault when running saved report 2022-10-29 17:45:35 -07:00
Christopher Lam
fc94b41c81 Merge branch 'maint' 2022-10-29 21:53:57 +08:00
Christopher Lam
4716af24e4 Merge branch 'maint' 2022-10-29 21:16:34 +08:00
Christopher Lam
ba44f720c1 Merge branch 'maint' 2022-10-29 21:15:41 +08:00
Christopher Lam
f2354d6b2a [test-qofbook.c] add test for gnc_features_set_unused 2022-10-29 21:01:08 +08:00
Christopher Lam
1516bb18b0 [gnc-features.cpp] backport gnc_features_set_unused from master 2022-10-29 21:01:01 +08:00
Christopher Lam
a078921a33 [qofbook.cpp] backport qof_book_unset_feature from master 2022-10-29 21:00:54 +08:00
John Ralls
cf088f2a70 Merge John Ralls's 'Bug798614' into maint. 2022-10-28 15:27:28 -07:00
Christopher Lam
093aa81ed1 [qofbook.cpp] deprecate qof_book_get_features 2022-10-28 21:57:15 +08:00
Christopher Lam
8192deff37 [gnc-features.cpp] convert to cpp
- don't need to create/destroy GHashTable for each feature query
- plugs leak: g_hash_table_unref (features_used) not always called properly
- to check 1 feature, don't need to traverse whole GHashTable
2022-10-28 20:50:35 +08:00
Christopher Lam
6f6d2fef48 [test-qofbook] basic features test
sets a feature and tests it's set. it's impossible to design a book
with unknown features using the API.
2022-10-27 20:10:49 +08: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
939a77407c Merge branch 'price-quotes-cpp' 2022-10-14 11:25:14 -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
fe9b23ff2b [price quotes] Pass short errors to gnc-quotes.
And wordier but not translated messages when STDERR is a tty.
2022-10-14 10:26:51 -07:00
John Ralls
88d658fef0 [price-quotes] Date::Manip is no longer required. 2022-10-13 14:58:27 -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
John Ralls
f24c2c8bdd Instrument failure to set the account when creating a split. 2022-10-11 14:05:45 -07:00
Mike Alexander
3c306eae65 Merge branch 'maint' 2022-10-09 22:27:55 -04: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
c7d1b6ab26 Bug 798633 - 4.12 build failure on 32-bit Linux: "No code for module" 2022-10-04 09:12:10 -04:00
John Ralls
673a925554 [price-quotes] Remove superseded gnc-fq-dump and Quotes-example.pl 2022-10-02 11:50:26 -07: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
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
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
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
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
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
eb24099a91 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 11:43:06 -07:00
John Ralls
23ca899a77 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 11:42:52 -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
John Ralls
8cb8f5067d Remove non-ISO4217 currency codes from gnc-euro table.
They're not reachable because they don't have commodities associated with them.
2022-09-30 15:12:19 -07:00