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.
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.
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.
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.
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.
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.
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.
Instead of using static_assert. This prevents the compiler from even
trying and avoids weird compilation errors when testing types for
instantiating other templates.
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.
Instead of using static_assert. This prevents the compiler from even
trying and avoids weird compilation errors when testing types for
instantiating other templates.
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.
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.
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.
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.
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.
The root cause of which is that on recent releases of GLib (recent
meaning 2.66 in the current Debian stable!) g_type_instance_get_private
looks in the wrong place for the private data. When running the script
in question it returned NULL and since the code didn't check for a valid
pointer, it crashed.
So this change replaces all calls to g_type_instance_get_private with
the function [type_prefix]_get_instance_private() added in glib-2.36
except for two register2 files that have been removed from master; those
are ignored to avoid unnecessary merge conflicts.
This scrubbing function calls xaccTransRollbackEdit which is
leaky. Instead of trying to fix xaccTransRollbackEdit which requires
superhuman skills, it's easiest to track the changes separately in a
GList, and use xaccTransBeginEdit/xaccTransCommitEdit only if
necessary.
tests TXN_TYPE_NONE in utest-Transaction.c
testing TXN_TYPE_INVOICE, TXN_TYPE_PAYMENT, and TXN_TYPE_LINK will
require valid posted invoices, so, are best tested in utest-Invoice.c
When a top level bayesian entry is deleted, the book is not marked
dirty and so the save button is not highlighted. Deleting individual
entries did mark book dirty.
Fixed in gnc_account_delete_all_bayes_maps by wrapping the deletion
with xaccAccountBeginEdit/CommitEdit block.
These functions depend on both libgnc-app-utils and libgnucash-guile,
creating a circular dependency when the app-utils bindings are added to
libgnucash-guile.
day of fall change from Daylight Time to Standard Time.
Really any day where the period crosses the dst->std change, and
since the date dialog returns local midnight for the time that includes
the day of the change.
Convert both the parameter time and the return time to neutral time
to ensure that the interval is handled correctly.
With the accounting period preference settings set to 'Start/End of
previous quarter' and balance sheet report using 'End of accounting
period' the date is wrong, currently is 30/03/2022 when it should be
31/03/2022.
Simplify gnc_gdate_set_quarter_end to get correct last day and
subtract the 3 months befor calling said function.
With these changes the currency works but the commodity allows you to
set the commodity but will crash if you save config or leave report
open, this was tested on the 'Price scatter plot' report. Fixed with
John's commit a8e6a59
The GncOptionRangeValue can be used with integers or doubles, the
default being doubles. When used for setting the plot width/height,
integers are used so all ValueTypes need to be integers other wise
the when create_range_spinner is used you end up with the upper_bound
value being G_MAXDOUBLE, a 309 character wide spin button. To
differentiate the two, use 'set_alternate(true)' for integers.
The new plot setting does both settings, values above 100 are treated
as pixels and ones below are treated as a percentage. This means the
maximum valid setting must be higher and also the tooltip needs to be
changed.
Found via `codespell -q 3 -S *.po,./po,*.min.js,./ChangeLog*,./NEWS,./borrowed,./doc/README*,./AUTHORS,./libgnucash/tax/us/txf-de*,./data/accounts -L ans,ba,cas,dragable,gae,iff,iif,mut,nd,numer,parm,parms,startd,stoll`
The Book Options, counter formats were being stored under the 'options'
tree but need to be stored in the 'counter_format' tree similar to the
'counters' tree.
.
Because March has more days than February the previous month offset was
getting normalized back to the current month--th 29 February this
year is really 1 March, so normalizing before setting the day caused
begin/end previous month to return the begin/end of the current month.
That probably happened on the 31st of May, July, October, and December
as well, I just hadn't managed to test on those days. Switching the
normalization to after calculating the day of the month broke the
previous quarter calculation because now the month was out of range, so
normalize month & year first.
Separate the "All noncurrency" convenience category in the commodity
selector and the default non-commodity namespace proposed by the QIF
importer because they have different functions.
Also remove the namespace guessing code from qif-dialog because with
only one default non-currency namespace there's nothing to guess.
The changes 09296dfb96, 1373233cd0 and 189db58e6 had caused
inconsistencies. Best restore original guile variable names using
underscore, bound to strings instead of functions returning strings.
When Gnucash is run in Hebrew which is a RTL language, on the accounts
page the tree view is displaying the required number as the following...
TreeView entry is '1,500.00 ₪' or '-1,500.00 ₪'
TreeModel string is '₪ 1,500.00' or '₪ 1,500.00-'
This seems to be down to the GTK 'Unicode Bidirectional Text Algorithm'
which is changing the representation of the model string based on the
first strongly typed character, in this case the Israeli shekel sign.
To fix this, when creating the displayed monetary amount insert a BiDi
ltr isolate uni-character at the start of the string.
Converting them to pointers for Scheme to use. Prevents
dangling pointers when the user deletes a QofInstance as long as the
Scheme report code re-fetches its pointers from the options when it's
regenerated.
Leave it to users to categorize their non-currency commodities. In the
QIF importer default non-classifiable commodities to
GNC_COMMODITY_NS_NONCURRENCY.
Refactor try_gz_open to return a std::pair<FILE*, thread>. That removes
the need for the threads hash-table and wait_for_gzip().
The cause of the gcc12 error was that we were using the thread's pipe's
FILE* as the key to the hash-table and had to close it before calling
wait_for_gzip(file) to remove the thread from the hash-table. gcc12
considers that a use-after-free. It happens to be wrong, but removing the
need for it results in a cleaner implementation as well as silencing the
warning.
The original merge was of a PR based on master into maint, bringing
along all of the development changes in master along with it. We don't
want that so the merge was reverted and the PR's two changes
cherry-picked in. That fixed maint, but then the next regular merge of
maint into master naturally included that revert commit undoing the
changes in master. Not so good. Reverting the revert, this commit,
restores the changes, albeit with messed up history.
Instead of GncOptionUIType, mostly. We still need to do that to tell apart
commodities and currencies from other QofInstances.
Allows compile-time dispatch for most types.
because object may become stale if UI is used to delete it, leading to
stale pointer and segfault. storing guid is safer, and will return
null if budget is deleted.
These functions were used to (optionally) reverse amounts according to
whether the feature GNC_FEATURE_BUDGET_UNREVERSED was set. They are
now obsolete because code will now assume feature is set for all
loaded datafiles.
If book has budgets, and GNC_FEATURE_BUDGET_UNREVERSED isn't set,
check and fix budget amount signs. Previously budgets were created
with assumption that sign reversal was set to credit amounts. A
heuristic approach is used:
- if budgeted expense is negative, conclude sign reversal is
"Income and Expense"
- if budgeted liability is positive, conclude sign reversal is
"None"
- otherwise conclude sign reversal is "Credit Accounts"
The above is calibrated to (hopefully) prefer sign reversal of Credit
Accounts.
And use serialize to create values for gnc:generate-restore-forms and both
of them for the meat of the stream functions.
This fixes in particular QofInstance serialization where passing the
option value directly to scheme format resulted in a notation about
a swig pointer instead of the desired GUID string or commodity namespace
and mnemonic strings.
Add an "Append" checkbox to the bottom of the "Generic import
transaction matcher" window to the left of the "Reconcile after match"
checkbox.
When ticked, this causes the imported Description/Notes to be appended
to the matched transaction Description/Notes respectively.
The selected ticked/unticked state of the "Append" checkbox is saved in
a key value pair for the import account, so the next import for that
account will automatically default it to the saved state.
As these mods are limited to the code for the matcher window, this
should work for all the imports that use it - ie ofx & csv file imports
(both tested) & aqbanking (cannot test).
Add latest Venezuelan revaluation of the Bolivar Soberano, following
the ISO notation replacing VES (which the Venezualan central bank is
keeping) with VED and the exchange code (ditto) with 926.
This can be used to keep both in sync in the period between
initial migration and eventual obsolence.
Note only non-obsoleted, migrated preferences are tracked.
We don't want to resync preferences that have been
obsoleted (reset). That would nullify the whole idea
of making them obsolete for future removal.
This commit only adds the mapping, synching will follow in a future
commit.
application - MacOS 10.15.7 (19H1419)
Destruction order problem: The SX template accounts can't be destroyed
until after the template splts and transactions are.
Register them before the transactions and splits, as destruction occurs
in reverse order of registration.
'deprecate' is technically a noop. It serves to remind maintainers
the 'deprecated' preference is to be obsoleted in the next major
release.
'obsolete' goes one step further in that it will cause gnucash to reset
the preference, effectively clearing the value stored in the preferences
backend. This is the final phase of a preference. Following this it
will be completely removed from the GSettings schema in the next
major release.
Notes
* 'deprecate' and 'migrate' are related. Both are a reminder the
preference is to be obsoleted in the next major release. 'deprecate'
does only that though while 'migrate' will also trigger a copy of
the old value to a new location in the databse.
* This commit readds a couple of preferences that had been removed
in the past to be able to properly obsolete them (and to test
the obsoleting code)
This commit mostly changes descriptions and variable names to
use the more generic terms 'transformations' or 'conversions'.
'migration' is only one possible transform, future commits will
add others.
There are no functional changes in this commit other than
a logic inversion in parse_one_release_node. It now checks
for nodes named 'migrate' rather than for nodes not named
'migrate' (the code is adapted accordingly to match this
logic change).
We had hardcoded HAVE_HTMLHELPW to always be true so the fallback
code that's only reached when it is false was never reached.
Time to drop this dead code.
This makes sure all schema changes are in effect before
the first consumer can query them. For example this will
prevent a one-time re-occurrence of the tip of the day dialog
the first time the new migrations are run.
The rules for migration are read from an xml file. This file was
prepared in a previous commit. Future settings 'data model' changes can
reuse this code by simply adding migration rules in the xml file.
This replaces the hardcoded rules that were currently in place to
migrate a few settings from 2.6 and older to 3.0. These rules are no
longer meaningful as we require users to migrate from one major release
series to the immediate next one. So by the time the new migration rules
in this commit are applied by users they should already have run gnucash
3.x at least once. That run should have taken care of the pre-3.0
migration actions.
This was ported from GConf, but GSettings doesn't work that way.
Settings locations are defined at compile time and can't be
relocated at run time (unless you make all of the settings
explicitly relocatable. That however is not how GSettings is meant to be
used.)
The latter is the prefix format prescribed by gsettings itself. The former never
was an issue until flatpak decided to not accept the shorter prefix when
requesting a settings migration from host system to flatpak sandbox.
In order to allow for migration, keep the old schema around in
org.gnucash.GnuCash.deprecated.gschema.in
While we're at it, make the new prefix an internal implementation detail.
There's no need for it to be visible to the rest of the gnucash code.
GValue in DxaccAccount[Set|Get]Currency is unset correctly.
However dxaccAccountGetPriceSrc and dxaccAccountSetQuoteTZ reuse a
static char* therefore the latter must be used carefully before
calling the function again. The functions are tested in
4309469730.