Commit Graph

2052 Commits

Author SHA1 Message Date
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
John Ralls
d8417c3cfa Move gnc-euro.[ch] to engine and unit test it. 2022-09-30 15:12:12 -07:00
John Ralls
2774f8f88c Bug 798614 - Croatia to join the Euro
Add HRK to the conversion array.
2022-09-30 13:51:28 -07:00
John Ralls
3949821da6 Merge branch 'maint' 2022-09-25 11:50:10 -07:00
John Ralls
2505955ab9 Fix test failure from Bug 798616 fix. 2022-09-20 09:09:34 -07: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
161b07b241 Merge branch 'maint' 2022-09-09 21:23:40 +08:00
Frank H. Ellenberger
47fa8b281e Merge PR #1425 into maint 2022-09-07 03:16:05 +02:00
John Ralls
a807d3e6b7 Create function gnc_tm_get_today_neutral.
To complement gnc_tm_get_today_begin and gnc_tm_get_today_end.
2022-09-06 14:35:11 -07:00
luz paz
ba94730a23 Fix various typos
Found via `codespell`
2022-09-06 10:44:29 -04:00
Christopher Lam
ecd2cdf425 [gnc-glib-utils] gnc_g_list_stringjoin skips NULL data 2022-09-06 18:14:15 +08: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
Christopher Lam
0b5a4cd298 Merge branch 'maint' 2022-08-03 20:38:08 +08:00
Christopher Lam
d1aefc851d [sx-book] free sx_list before g_object_unreffing sxes 2022-08-01 23:43:08 +08:00
John Ralls
688832b5f8 Bug 798585 - segfault running sample script
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.
2022-07-30 16:50:51 -07:00
Christopher Lam
67a1b7a873 [gnc-sx-instance-model] free GHashTable keys when destroying 2022-07-30 13:43:06 +08:00
Christopher Lam
ebf3439558 [gnc-sx-instance-model] free some GHashTable keys & Values 2022-07-29 12:56:02 +08:00
Christopher Lam
7c2a249511 [gnc-sx-instance-model.c] refactor Scrub function
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.
2022-07-29 12:47:10 +08:00
Christopher Lam
7880f9b16f [SchedXaction.c] free list of recurrences 2022-07-29 12:23:09 +08:00
Christopher Lam
c16840b840 more leaks because qof_instance_get returns a new char* 2022-07-21 07:46:40 +08:00
Christopher Lam
f1adb5da34 Merge branch 'TXN_TYPE-is-dynamic' xaccTransGetTxnType into maint #1201 2022-07-18 09:24:32 +08:00
Christopher Lam
ec3e996f92 tests xaccTransGetTxnType heuristics
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
2022-07-18 09:24:05 +08:00
Christopher Lam
fd12d3900c [Transaction.c] use heuristics to determine txn->txn_type 2022-07-18 09:24:05 +08:00
John Ralls
f4c27d4494 Move gnc_ui_account_get_tax_info_string to gnc-locale-tax.c
To prevent a circular dependency between libgnc-app-utils and
libgnucash-guile.
2022-07-17 10:00:23 -07:00
Robert Fewell
ce4768c357 Bug 798565 - Import map editor entry deletion
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.
2022-07-17 12:51:38 +01:00
Robert Fewell
d688a17ef6 Merge 'luzpaz' branch 'source-typos' into maint PR #1364 2022-07-17 11:31:54 +01:00
John Ralls
3e2f7bc66a Create separate shared library for expression parser and SX instance model.
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.
2022-07-16 18:20:17 -07:00
John Ralls
47904a858e Fix distcheck in master.
Several gnc-optiondb dependencies left out of tarball.
2022-07-16 18:15:57 -07:00
John Ralls
3fd8bd9ddf Merge branch 'maint' 2022-07-16 17:15:20 -07:00
Christopher Lam
263f007d5c [gnc-filepath-utils] new: gnc_list_all_paths 2022-07-10 23:44:13 +08:00
Christopher Lam
aa43c198c6 [Transaction.c] don't set TxnType kvp if it is the same as before
will avoid dirtying the transaction.
2022-07-08 18:15:09 +08:00
John Ralls
9f6d495ca1 Fix use-after-free crash in utest-Invoice. 2022-07-08 18:12:26 +08:00
luz paz
cfc6e9d7e0 Fix source typo begining->beginning 2022-06-27 07:16:54 -04:00
John Ralls
1e6c679e71 Merge branch 'maint' 2022-06-14 12:53:16 -07:00
John Ralls
903cbdcad3 Bug 798547 - Calculated Due Date is short 1 day when posting on...
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.
2022-06-02 15:46:59 -07:00
John Ralls
564d73a553 Bug 798531 - Selecting "Print" from the file menu on a report...
crashes gnucash

Ensure that every call to gnc_prefs_get_string correctly handles both
a NULL or empty string return value without crashing or leaking.
2022-05-20 14:33:29 -07:00
Christopher Lam
670902d5a8 Bug 798535 - Crash when increasing the number of periods in a budget
because in the SQL backend, gnc_budget_commit_edit will update the sql
by reading from vectors with an increased priv->num_periods.
2022-05-18 17:37:05 +08:00
Robert Fewell
27cab58bf2 Correct some text describing some date functions. 2022-05-08 10:09:50 +01:00
Robert Fewell
c000a890ad Bug 798501 - Balance wrong date end of account period
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.
2022-05-08 10:09:50 +01:00
Christopher Lam
a5cae6c5eb Don't export undefined functions 2022-05-05 09:46:49 +08:00
Christopher Lam
fcc3b27f92 Merge branch 'maint' 2022-05-05 09:46:44 +08:00
Robert Fewell
ee7ed89b68 This partly fixes the currency and commodity combos
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
2022-05-03 16:55:55 +01:00
Robert Fewell
db6a8f809b Tax Tables combo does not set the active one
Fixed by correcting spelling of tax table qof type, should
'gncTaxTable'. Also fixed setting tax table combo to 'none' when page
reset button used.
2022-05-03 16:55:55 +01:00
Robert Fewell
0b67a91217 Fix the option GncOptionRangeValue
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.
2022-05-03 16:55:48 +01:00
Robert Fewell
506eb38493 Update Chart Width/Height Plot setting
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.
2022-05-03 15:44:24 +01:00
John Ralls
1a186b953e [C++options] Correct handling of multichoice scheme option types.
Includes tests for save-to-scheme for each type.
2022-05-02 11:28:28 -07:00
John Ralls
a8e6a59bf8 [C++options] Fix Guile crash when restoring some reports.
In particular those with commodity options or those using a stylesheet
whose name has spaces like "Head or Tail".
2022-04-29 11:16:25 -07:00
Alex Aycinena
e381e70638 reverse commit d48937c. See discussion in Bug #79769. 2022-04-22 19:26:09 -07:00
Christopher Lam
dc620d4b24 Merge branch 'maint' 2022-04-22 13:43:47 +08:00
Alex Aycinena
d48937cf9c Bug #79769 - Allow US Income Tax txf code 296 (Returns and allowances) to be shown and assignable for both income and expense type accounts. 2022-04-21 18:51:05 -07:00
Christopher Lam
394e0a4b71 [gnc-sx-instance-model.c] leak: don't strdup char* for xaccTransSetNotes
For a while now, xaccTransSetNotes would strdup the notes. Don't need
to strdup it beforehand.
2022-04-19 22:59:51 +08:00
Christopher Lam
e1d52963ed [account.cpp] restore breadth-first search for 2 functions
gnc_account_lookup_by_name and gnc_account_lookup_by_code were
searching breadth-first and accidentally changed to depth-first in
4.7.

as reported in https://github.com/Gnucash/gnucash/pull/1101#issuecomment-1098146573
2022-04-15 23:35:38 +08:00
John Ralls
95487eb4a0 Merge branch 'maint'
# Conflicts:
#	gnucash/gnome/window-reconcile2.c
#	libgnucash/app-utils/options.scm
#	libgnucash/engine/gnc-numeric.cpp
2022-04-14 18:02:17 -07:00
Christopher Lam
fae7ea02cd [account.cpp] gnc_accounts_and_all_descendants converted from scm
much more efficient than guile algorithm, avoids numerous repeated
GList<->SCM conversions, and traversals of account descendants.
2022-04-14 21:51:14 +08:00
Frank H. Ellenberger
2298590316 Merge PR #1309 into maint 2022-04-12 00:20:11 +02:00
Christopher Lam
736d223198 Merge branch 'maint-progress3' into maint #1312 2022-04-10 12:05:08 +08:00
Christopher Lam
0c4d438a0e [kvp-frame.cpp] expose iterator, skip inexistent frame 2022-04-09 17:45:44 +08:00
Christopher Lam
aab33954e7 [gnc-numeric.cpp] Reduce logging level of gnc_numeric exception message
Exceptions are expected in some use cases.
2022-04-09 07:21:15 +08:00
luz paz
8adedc2248 Fix various typos
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`
2022-04-08 14:12:50 -04:00
Christopher Lam
6a668df168 [qofutil.h] don't recurse includes 2022-04-08 19:20:40 +08:00
Robert Fewell
ae220b86a4 [C++options] Fix Ubuntu test failure. 2022-04-07 14:28:02 +01:00
Robert Fewell
83373563c3 Counter formats stored in wrong place.
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.
2022-04-07 10:33:11 +01:00
John Ralls
26b009c0f4 Bug 798500 - FTBFS (tests failure) on armhf
Ensure the transition_times are correctly aligned for their sizes
before attempting to copy them into the transitions vector.
2022-04-05 11:45:22 -07:00
Christopher Lam
ee8729dfb6 [account.cpp] char* must be freed 2022-04-02 14:14:50 +08:00
John Ralls
29bdd9b526 [C++options] Fix Ubuntu test failure. 2022-03-31 13:12:45 -07:00
John Ralls
1fddf70e21 [C++options] Fix previous month and previous quarter at the end of March
.

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.
2022-03-31 12:27:58 -07:00
John Ralls
abd1a0b3f1 Merge branch 'c++options' 2022-03-29 15:58:22 -07:00
John Ralls
03cbbd1cd1 Merge branch 'maint' 2022-03-27 06:46:09 -07:00
John Ralls
109efe62b8 Rework default non-currency commodity namespace.
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.
2022-03-24 18:10:32 -07:00
John Ralls
4fe83c3b32 [C++options] Remove GncOptionValue<SCM>.
No longer needed.
2022-03-21 14:08:06 -07:00
John Ralls
278aa484d7 [C++options] Implement new GncOptionValue type GncOptionReportPlacement.
For multicolumn reports so that we don't have to pass Scheme values.
2022-03-21 13:58:50 -07:00
Christopher Lam
4a75baa4c6 [gnc-xml-backend.cpp] gchar* must be freed after use.
It is used as a constructor for std::string which makes a copy but
doesn't take ownership.
2022-03-21 07:26:45 +08:00
Christopher Lam
cf1282501e Use original guile variable names changed in #1073
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.
2022-03-20 12:38:09 +08:00
Christopher Lam
5993ebf4d4 Merge branch 'maint' 2022-03-18 20:37:07 +08:00
Christopher Lam
5388cc8e2c [kvp-frame.cpp] minor speedups
reserve vector, cache iterator from m_valuemap.find for reuse
immediately afterwards.
2022-03-18 16:29:13 +08:00
John Ralls
30e6c8ab11 [gnc-optiondb.i]Explicitly include array.
Xcode-13.3 errors without it.
2022-03-15 16:16:50 -07:00
John Ralls
572cb6b1d1 Banish gnc_get_optiondb_from_dispatcher to gnc-report.cpp.
Puts it closer to its points of use and removes it with its Scheme
dependency from libgnucash.
2022-03-14 10:32:08 -07:00
John Ralls
e63baa6270 Merge Bob Fewell's 'rtl' into maint. 2022-03-14 09:25:42 -07:00
Robert Fewell
f8fc796c95 Bug797501 - Currency symbols in Hebrew (RTL) language
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.
2022-03-14 10:05:46 +00:00
John Ralls
d4c3c30b1a Use GUIDs to represent QofInstances instead of pointers.
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.
2022-03-12 17:58:23 -08:00
Christopher Lam
193a7aae5d Merge branch 'maint' 2022-03-12 15:18:43 +08:00
Christopher Lam
0052e3e483 [gnc-pricedb] add user:stock-transaction price source 2022-03-11 14:31:02 +08:00
John Ralls
c1001e6641 Better wording for tax table changed info message. 2022-03-10 13:44:47 -08:00
John Ralls
d841b322d0 Merge Frank Ellenberger's 'Bug684507' into maint. 2022-03-08 12:39:47 -08:00
John Ralls
ce2b89fd8c [business]Add diagnostic messages to GncEntry and GncInvoice. 2022-03-05 18:18:13 -08:00
John Ralls
916caa25f2 Integrate Windows gzopen differences so that only one ifdef is needed.
Clarifies code.
2022-03-05 16:20:08 -08:00
John Ralls
250b4ed733 Remove stray line left from earlier refactoring. 2022-03-04 14:53:02 -08:00
Robert Fewell
7e299cb2b0 Remove print statement left in commit c3f8daa 2022-03-04 10:16:14 +00:00
John Ralls
8ef8d3807c Silence spurious conditional uninitialized warning in gnc-owner-sql.cpp. 2022-03-03 13:21:51 -08:00
John Ralls
93f5e23cf5 Open gzfile if thread creation fails. 2022-03-03 13:20:41 -08:00
John Ralls
9ad24321b4 Remove investment-type namespaces.
Leave it to users to categorize their non-currency commodities. In the
QIF importer default non-classifiable commodities to
GNC_COMMODITY_NS_NONCURRENCY.
2022-03-01 19:58:23 -08:00
Frank H. Ellenberger
09296dfb96 Drop commodity-table.scm, no longer required after adjusting qif-dialog-utils 2022-03-01 19:58:11 -08:00
Frank H. Ellenberger
c7f842c081 Bug 684507 - commodity namespace should be localized 2022-03-01 19:58:11 -08:00
Christopher Lam
bd4a457040 Merge branch 'maint-lightning-budget' into maint #1248 2022-03-02 07:37:17 +08:00
Christopher Lam
a47413860a Factor out GValue access for setters and getters 2022-03-02 07:36:59 +08:00
Christopher Lam
8f845df934 Factor out make_period_[data|note]_path 2022-03-02 07:36:59 +08:00
Christopher Lam
919f392c7a Use kvp C++ interface rather than GValue 2022-03-02 07:36:59 +08:00
Christopher Lam
6c4c2512db Use C++ STL instead of GLib 2022-03-02 07:36:59 +08:00
Christopher Lam
9088acabd8 [gnc-budget.cpp] convert to c++ 2022-03-02 07:13:24 +08:00
John Ralls
81b9a02235 Bug 798458 - Build failure with gcc 12
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.
2022-03-01 12:49:12 -08:00
John Ralls
67e8c317da [xml backend] Extract functions to make gz_trhead_func more readable. 2022-03-01 12:49:12 -08:00
Christopher Lam
56cc021d33 Merge branch 'maint' 2022-02-12 22:24:24 +08:00
Alex Aycinena
a2825d33a1 Update Form/Schedule line references for 2021 for the US Income Tax Report 2022-01-27 12:00:31 -08:00
Christopher Lam
c1c198c9ff Merge branch 'maint' 2022-01-19 19:21:32 +08:00
Christopher Lam
f0de54ac7a Merge branch 'maint-798406' into maint #1240 2022-01-19 19:16:14 +08:00
Christopher Lam
8bc080b96d [gnc-budget] store budget kvp data onto memory upon first call.
then each getter will retrieve from memory rather than backend's kvp.
2022-01-17 09:34:46 +08:00
Christopher Lam
ef8d812d3f [utest-Budget] test data retention when modifying budget num_periods 2022-01-17 09:31:28 +08:00
Christopher Lam
87b0a41e9b [Split.c] return price==0 instead of 1, if !split, or amt==0 2022-01-10 19:19:25 +08:00
John Ralls
c1c75e8f81 Revert "Revert "Merge Stefan Bayer's 'SepaInternalTransfer' into maint.""
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.
2022-01-08 15:10:53 -08:00
Christopher Lam
5603acba31 Merge branch 'maint' 2022-01-06 21:32:41 +08:00
Christopher Lam
f7ee644695 Amendment to 73822f97a [1/2] use heuristics to scrub budget signs
Testing income<0 to conclude "none reversal" is likely a more sound
strategy than testing liability>0.
2022-01-04 08:25:02 +08:00
John Ralls
a7a643f7f2 Store option commodities and namespace and mnemonic instead of pointer.
Protects against crashes caused by the user deleting the commodity and
allows the option to work if a deleted commodity is recreated.
2022-01-03 14:47:18 -08:00
John Ralls
65bd860249 Fix relative_date_to_time64 calculations.
Where the date requested extends beyond the start or end of the year.
2022-01-01 16:05:06 -08:00
John Ralls
6841e5b5c8 Replace GncOptionValue<const QofInstance*> with GncOptionQofInstanceValue.
That stores its values as a pair of <QofIdType, gncGUID> so that it
won't have dangling ptrs if the instance gets deleted.
2021-12-30 12:21:56 -08:00
John Ralls
11225d9741 c++options: Remove gnc:options-data 2021-12-15 14:54:41 -08:00
John Ralls
16dc15964c c++options: Remove the callback registration functions. 2021-12-15 14:32:39 -08:00
John Ralls
759376eb13 c++options: Fix multicolumn report 2021-12-15 14:13:47 -08:00
John Ralls
18edc17541 c++options remove stray debugging comment. 2021-12-14 14:20:20 -08:00
John Ralls
b5d0c42505 c++options: Put copyright and FSF header comment on gnc-optiondb.i. 2021-12-14 12:06:39 -08:00
John Ralls
a700701cd3 c++options: Remove three unused test functions.
Scheme serialization is now tested in test-option-gnc-scheme-output.scm.
2021-12-14 11:52:15 -08:00
John Ralls
eb0bd4f998 c++options: Remove unneeded C++20 header and resolve ambiguous call. 2021-12-14 11:51:37 -08:00
John Ralls
a3f50586df c++options: More thorough testing of scheme serialization. 2021-12-14 11:03:37 -08:00
John Ralls
6cd88c230c c++options: Create bool or string internal options when possible.
There's no need to save internal options as SCM when we support the
underlying type in C++.
2021-12-14 11:03:01 -08:00
John Ralls
e9b850cca5 c++options: Correct Scheme serialization of type bool. 2021-12-14 10:58:48 -08:00
John Ralls
66f9fc81c7 c++options: Implement serialization for GncOwner. 2021-12-14 10:57:41 -08:00
John Ralls
0ce841d4ce c++options Fix Scheme bindings for QofQuery options. 2021-12-14 10:55:59 -08:00
John Ralls
216b483e26 c++options SCM bindings Rewrite save_scm_value to branch on type.
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.
2021-12-13 11:05:15 -08:00
Christopher Lam
c3eaff9bb2 [account.cpp] gnc_account_and_descendants_empty: don't copy children 2021-12-13 21:48:44 +08:00
Kevin M. Buckley
1e22632687 Bug 798382 - Typo corrections in comments 2021-12-12 09:50:48 -08:00
John Ralls
947c061989 C++options: Create QofQueryValue trait. 2021-12-11 15:12:22 -08:00
John Ralls
f26014a04e c++options: QofInstanceValue: Protect against crashes when m_value is nullptr. 2021-12-11 15:11:26 -08:00
John Ralls
95b973f792 Bug 798352 - Decimal Precision when Entering Mutual Fund Transaction
Let xaccParseAmount parse up to 12 decimal places instead of 8.
2021-12-09 15:55:37 -08:00
Christopher Lam
33b6dfc6ce [options.scm] addendum ca6604c93 gnc:make-budget-option
selection-budget changed from budget object to guid, handle other uses
as appropriate.
2021-12-04 20:35:04 +08:00
Christopher Lam
ca6604c93c [options.scm] Addon previous commit... need to initialize with guid 2021-12-04 08:59:14 +08:00
Christopher Lam
d740ac1cb0 Merge branch 'budget-option-stores-guid' into maint PR #1207 2021-12-04 08:24:10 +08:00
John Ralls
5c7967c4a5 Revert "Merge Stefan Bayer's 'SepaInternalTransfer' into maint."
This reverts commit 17a3f7fef2, reversing
changes made to b8458d0732.
2021-12-03 13:58:07 -08:00
John Ralls
ae7eaad018 Merge Chris Good's 'maintBug797678OfxAppend' into maint. 2021-12-03 13:44:50 -08:00
John Ralls
17a3f7fef2 Merge Stefan Bayer's 'SepaInternalTransfer' into maint. 2021-12-03 13:11:28 -08:00
Christopher Lam
5a812ca1eb [options.scm] gnc:make-budget-option stores guid instead of object
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.
2021-12-04 01:37:08 +08:00
Christopher Lam
91b1d291a5 [3/3][gnc-ui-util.c] Remove unused functions
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.
2021-12-03 17:40:21 +08:00
Christopher Lam
73822f97a9 [1/2][Scrubbudget.c] use heuristics to scrub budget signs
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.
2021-12-03 17:40:21 +08:00
Christopher Lam
6070aecd69 [2/3][gnc-features.c] add & expose gnc_features_set_unused
same as gnc_features_set_used but removes feature
2021-12-03 17:40:03 +08:00
Christopher Lam
5dab33694f [1/3][qofbook.cpp] add & expose qof_book_unset_feature
same as qof_book_set_feature but removes feature item
2021-12-03 17:39:34 +08:00
John Ralls
269249378f c++options fix setting account-selection widget from option. 2021-12-02 16:05:14 -08:00
John Ralls
6f93a68bad c++options: Serialize and deserialize to strings instead of streams.
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.
2021-12-02 15:04:49 -08:00
Christopher Lam
88ecf8dd17 Merge branch 'maint' 2021-11-23 16:14:53 +08:00
John Ralls
dd7feb9988 options.scm: Remove second license comment. 2021-11-19 11:45:54 -08:00
John Ralls
d1fe359e47 gnc_numeric_to_decimal: Change can't round warning to a debug.
Routinely used as a check so a warning isn't appropriate.
2021-11-19 11:44:57 -08:00
John Ralls
74fd716afb Clarify gnc_relative_date_to_time64 helper functions. 2021-11-19 11:43:04 -08:00
John Ralls
f6c9e63e3d Fix PR comments so far.
Except for gnc-option-date's normalize_tm and set_day_and_time.
2021-11-14 15:28:22 -08:00
John Ralls
cf5da9fffd Resolve merge conflicts. 2021-11-12 19:56:29 -08:00
John Ralls
96b09ded9f Doxygen documentation for new options classes. 2021-11-12 15:27:36 -08:00
John Ralls
00a982d97d Use Scheme to generate and parse saved option files.
The saved option files being Scheme executables.
2021-11-12 15:27:36 -08:00
John Ralls
ff04ad3785 Bug 798346 - crashes when running check & repair
Don't scrub trading accounts for imbalances, see the comment in
the commit for why.
2021-11-08 18:06:29 -08:00
Christopher Lam
984d816a58 Merge branch 'maint' 2021-11-06 21:41:17 +08:00
Christopher Lam
79d8ef0299 Revert b5f5129f7 using gnc_list_length_cmp 2021-11-02 23:34:26 +08:00
Christopher Lam
3dfdf60608 [gnc-glib-utils] Define and export gnc_list_length_cmp 2021-11-02 23:34:25 +08:00
Christopher Lam
b5f5129f7d Shortcut g_list_length comparison against small numbers
It's more efficient to test node && node->next etc when testing GList
length against small numbers
2021-10-30 22:29:17 +08:00
Christopher Lam
f813f7cd14 [gnc-autoclear] Move autoclear algorithm into gnome-utils 2021-10-28 21:41:46 +08:00
goodvibes2
8ad29feaba Bug797678 OFX import should append not replace, existing Notes & Desc
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).
2021-10-28 10:58:07 +11:00
Geert Janssens
bdb06479e8 GSettings - fix GObject warning when old prefs-version is unset
This will happen when current master (future 5.0) has been run
at least once.
2021-10-27 10:35:11 +02:00
John Ralls
5a8cbf4193 Bug 798325 - New Currency for Venezuela (VED)
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.
2021-10-23 12:27:11 -07:00
Christopher Lam
f40dbb8c28 Avoid unnecessary g_list_length in equality functions 2021-10-21 17:56:15 +08:00
Christopher Lam
f0970c8eb4 [gnc-features] don't repeatedly g_strconcat gchars* 2021-10-20 19:29:32 +08:00
Christopher Lam
31a0300abe [Recurrence.c] avoid repeated calls to g_list_length 2021-10-20 19:29:26 +08:00
Christopher Lam
b480600dc8 [gnc-pricedb] gnc_price_list_equal: avoid 4 g_list_length calls 2021-10-18 22:41:44 +08:00
Christopher Lam
23e528f51a [utest-gnc-pricedb] add tests for gnc_price_list_equal
Also need to change PWARN which causes test failure, to PINFO
2021-10-18 22:25:21 +08:00
Geert Janssens
09b3ce2382 Revert "Add structure to map migrated preferences to old ones"
This reverts commit c6103a5c17.
2021-10-16 19:02:17 +02:00
Geert Janssens
806d0b3157 Revert "GSettings - make most of the api private"
This reverts commit 26b2d7ca78.
2021-10-16 19:02:10 +02:00
Geert Janssens
1d4673ed2a Revert "GSettings - rework internal helper functions to use more C++"
This reverts commit 24fa289952.
2021-10-16 19:02:04 +02:00
Geert Janssens
24fa289952 GSettings - rework internal helper functions to use more C++ 2021-10-16 10:49:05 +02:00
Geert Janssens
26b2d7ca78 GSettings - make most of the api private
All preference calls should happen via the gnc_prefs_... apis.
The gnc_gsettings_... apis are an internal implementation of this.
2021-10-16 10:49:04 +02:00
Geert Janssens
c6103a5c17 Add structure to map migrated preferences to old ones
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.
2021-10-16 10:49:04 +02:00
John Ralls
2f4438ab28 Bug 798335 - No longer possible to change trading account
Strip trading splits only if "Use Trading Accounts" is enabled
for the book so that users who want to manage trading accounts by
hand may do so.
2021-10-14 17:22:32 -07:00
Christopher Lam
9eaa3eb23a Merge branch 'maint' 2021-10-14 09:34:28 +08:00
John Ralls
7c9c2eba3c Bug 798320 - Error message indicating a crash of GNUcash when closing...
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.
2021-10-08 14:17:28 -07:00
Geert Janssens
e64bcfe620 Merge branch 'maint' 2021-10-01 14:51:04 +02:00
Geert Janssens
9a465fc359 GSettings - add 'deprecate' and 'obsolete' conversions for user preferences
'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)
2021-10-01 14:46:55 +02:00
Geert Janssens
64576f7d27 GSettings - widen scope from 'migration' to 'transformation'
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).
2021-10-01 13:59:55 +02:00
John Ralls
29e7b07ed3 Remove superflous schema_source left over from pasting. 2021-09-28 17:17:23 -07:00
John Ralls
8bfa5a63f2 [gsettings] Avoid crash from settings schema not being registered. 2021-09-28 11:00:05 -07:00
Christopher Lam
10c1223df2 Merge branch 'maint-progress' into maint #1150 2021-09-27 08:10:02 +08:00
Geert Janssens
2a7566cc40 Win32 - drop conditional code never reached
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.
2021-09-26 22:58:08 +02:00
John Ralls
67191203ae Merge branch 'maint' 2021-09-26 10:46:06 -07:00
Christopher Lam
d82bb7b8a2 [Transaction.c] use is_unset static to denote uncached readonly_reason
tests in 128c8d6f88
2021-09-26 09:40:32 +08:00
Christopher Lam
128c8d6f88 [utest-Transaction] add tests for xaccTransGetReadOnly 2021-09-25 13:27:56 +08:00
Geert Janssens
8ea52ae212 GSettings - run data model transations while setting up
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.
2021-09-22 15:44:30 +02:00
Christopher Lam
c0736a1a04 Merge branch 'maint-leaks' into maint #1135 2021-09-22 21:06:25 +08:00
Geert Janssens
f1802b6fdf GSettings Upgrade - add code to migrate settings
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.
2021-09-21 17:10:56 +02:00
Geert Janssens
f21c7b6e90 GSettings - define old prefix and check settings for the presence of both prefixes while normalizing 2021-09-21 17:10:56 +02:00
Geert Janssens
a203c5b2d5 GSettings - drop logic to relocate our settings
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.)
2021-09-21 17:10:56 +02:00
Geert Janssens
d1113a4534 GSettings - build as cpp 2021-09-21 17:10:56 +02:00
Geert Janssens
02fbf217f6 GSettings Upgrade - change schema prefix from org.gnucash to org.gnucash.GnuCash
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.
2021-09-21 17:10:55 +02:00
Geert Janssens
6674b1bb6b Cleanup - minimal glib=2.56.1 - drop all conditionals on older versions 2021-09-21 17:10:55 +02:00
Christopher Lam
87b61bf6fb [account.cpp] GValue must be unset in old functions
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.
2021-09-19 11:28:25 +08:00
Christopher Lam
86cf327f09 [account.cpp] GValue containing string must be unset
already have comprehensive tests in 15852031d
2021-09-19 11:28:25 +08:00
Christopher Lam
c8a53c54f2 [account.cpp] refactor gnc_account_get_map_entry
Have comprehensive tests in a5d101d1b
2021-09-19 11:28:25 +08:00
Christopher Lam
4309469730 [utest-Account] test old dxaccAccount* functions
dxaccAccountGetPriceSrc and dxaccAccountGetQuoteTZ.

DxaccAccountSetCurrency remains untested - unsure how to retrieve an
ISO4217 currency to use as parameter.
2021-09-19 11:27:03 +08:00
Christopher Lam
a5d101d1be [utest-Account] test gnc_account_get_map_entry 2021-09-15 21:09:01 +08:00
Christopher Lam
73ad5b1265 [gnc-glib-utils] use g_stpcpy instead of gnc_strcat
g_stpcpy will use stpcpy wherever available.
2021-09-15 21:09:01 +08:00
Christopher Lam
aa0668f9e6 Revert "[account.cpp] deprecate old dxacc* functions"
This reverts commit d290c3c45d. These
functions are not deprecated after all.
2021-09-15 21:09:00 +08:00
Christopher Lam
d290c3c45d [account.cpp] deprecate old dxacc* functions 2021-09-15 09:20:04 +08:00
Christopher Lam
374443747d [account.cpp] new static: get/set_kvp_string_path
exactly the same as set_kvp_string_tag but will accept the full kvp
path.
2021-09-15 09:19:17 +08:00
John Ralls
1d8983191d Fix runaway sed error. 2021-09-14 16:24:28 -07:00
John Ralls
824b515430 Fix qoflog's comments to reflect a preference for the macros over GLib functions. 2021-09-14 15:59:01 -07:00
John Ralls
74d0630867 Bug 798237 - Logging during XML file loading degrades performance...
significantly

Modify the DEBUG and PINFO macros to return unless qof_log_check is
true. Replace almost all direct calls to g_debug and g_message with
DEBUG and PINFO respectively.

Track the highest logging level sent to qof_log_set_level to provide a
short-circuit return in qof_log_check. Remove setting GNC_MOD_TESTS to
QOF_LOG_DEBUG so that the short-circuit threshold isn't defeated by
always being DEBUG.

Net result: 33% improvement in xml load times.
2021-09-14 15:15:11 -07:00
John Ralls
574f567b62 Refactor GncXmlBackend::get_file_lock.
Moving all of the error-handling to it for better clarity and
simplicity. Drop the unnecessary stat call, open will fail with
EEXIST if there's already a lock file. Provide specific messages
for file system failures.
2021-09-14 09:32:12 -07:00
John Ralls
d7eae0664f [gz_open] Use compress and write consistent with calling functions. 2021-09-14 08:29:11 -07:00
Christopher Lam
15852031d4 [utest-account.cpp] increase test coverage
adds getter/setter tests for

xaccAccountSetLastNum
xaccAccountSetTaxUSCode
xaccAccountSetTaxUSPayerNameSource
2021-09-14 07:12:15 +08:00
John Ralls
c3f8daaf7d Bug 798250 - Gnucash permanent hang on save while loading report
Prevent WebKit's fork from getting a copy of the pipe's file descriptors
and so keeping the pipe from closing.

Thanks to Simon Arlott for recognizing the FD duplication.
2021-09-13 13:18:10 -07:00
Christopher Lam
017ab06939 Merge branch 'maint' 2021-09-12 22:44:34 +08:00
John Ralls
edad194389 Bug 798180 - Update to macOS Big Sur 11.3 breaks Finance Quote
Added new dependency Test2 to gnc-fq-update. This is a second-order
dependency of Finanance::Quote that CPAN doesn't seem to recognize
on its own.
2021-09-11 16:09:55 -07:00
John Ralls
cd0d50aac1 Deprecate date options with a time of day setting.
Removing the only use, an example in hello-world.scm. GnuCash doesn't
use this value in any of its own report options and the feature will
be removed in GnuCash 5.

Related to bug 798297 Pref "Use 24-hour clock" obsolete?.
2021-09-10 12:21:46 -07:00
John Ralls
8ab8642e76 Fix leak of trading_splits list in xaccTransClearTradingSplits 2021-09-09 16:32:43 -07:00
John Ralls
1387d5f960 Fix unchecked ptr dereference.
First crash in Bug 798225.
2021-09-09 16:32:43 -07:00
John Ralls
ab24c34660 Merge Simon Arlott's 'free-template-root' into maint. 2021-09-07 12:14:41 -07:00
Simon Arlott
4a8acf3fb2 Free template root accounts on book end
The template root should be unset so that it's destroyed when the book is
ending. This is required to free all the template accounts and referenced
strings.

The scheduled transactions themselves need to be freed first so reverse
the order that SXRegister and gnc_sxtt_register are called in
cashobjects_register: The list resulting from that function is traversed
from the bottom up.
2021-09-07 12:11:05 -07:00
John Ralls
901fea158f Merge Simon Arlott's 'xml-locking-fixes' into maint. 2021-09-06 15:22:49 -07:00
John Ralls
38cd06e54a Remove the lock-file-link-count test from the XML backend.
This was an effort of somewhat dubious value to detect if a process
on another ocmputer had a hsrd-link to a lockfile on an NFS share.
NFS is rarely used now and SMB doesn't support hard links so this check
adds complexity with no real value.
2021-09-06 15:18:34 -07:00
John Ralls
079a900300 Bug 798298 - Re-imported transactions no longer ignored
Merges Jean Laroche's '798298_reimport_ofx' into maint.
2021-09-06 13:51:26 -07:00
Mike Alexander
068a5d2fa8 Fix xaccSplitGetOtherSplit which was broken by 028bf9826, don't
count splits that aren't really in the transaction.

The rewrite left out one test.  This was most obvious in the dummy
transaction used to enter a new transaction into an account.
xaccSplitGetOtherSplit never returned an "other split" for this
transaction.  It turns out the old code was broken too, but
it worked for this case by coincidence.
2021-09-06 02:45:37 -04:00
jean
4e9fe0a4d1 Add missing function to mock account 2021-09-05 17:52:34 -07:00
John Ralls
00c2e99d2e Convert the Scheme RelativeDatePeriod lookup table to a std::vector.
From a Scheme alist. The vector can be used to find the scheme symbol
as a direct lookup, which isn't possible with an alist, and can be
searched for the Scheme symbol match more quickly than an alist can.
2021-09-02 14:33:35 -07:00
Christopher Lam
8d502fcdd8 Merge branch 'maint' 2021-09-02 22:17:22 +08:00
Christopher Lam
1eb6709331 [test-lots.cpp] add kvp getter/setter changes 2021-08-31 23:16:43 +08:00
Christopher Lam
323182c9f7 [utest-Account.cpp] add kvp getter/setter changes 2021-08-31 23:16:43 +08:00
Christopher Lam
8a37c4c019 [utest-Invoice.c] add kvp getter/setter tests 2021-08-31 23:16:43 +08:00
Christopher Lam
9ec670f828 [test-commodities.cpp] add kvp setter/getter test 2021-08-31 23:16:42 +08:00
Christopher Lam
d4c8b36f9f [utest-Transaction.cpp] add kvp setter/getter tests
wasn't tested before
2021-08-31 23:16:42 +08:00
Christopher Lam
c3b50f0b58 [gnc-lot.c] fix - cache value properly 2021-08-31 23:16:42 +08:00
Christopher Lam
595e126a34 [account.cpp] modify set_kvp_string_tag to accept strstrip or nullptr
- will remove a second call to g_strstrip (g_strdup (str))
2021-08-31 23:16:42 +08:00
Christopher Lam
c5a6383b43 [account.cpp] fix - incomplete #1117
- init struct members properly to: is_unset and TriState::Unset
- test acct kvp "equity-type" for "opening-balance" instead of "true"
- cached account->color/sort_order/notes/filter gets strstripped
  similarly to previous behavior
2021-08-31 23:16:42 +08:00
John Ralls
bed44f404f Remove the always questionable Scheme generation and parsing code.
It's more reasonable to do that in Scheme than in C++.
2021-08-30 11:47:04 -07:00
Christopher Lam
001b34616f [Transaction.c] GValue string must be unset 2021-08-29 15:38:16 +08:00
Christopher Lam
a47bee97d6 [Split.c] GValue string must be unset 2021-08-29 15:38:16 +08:00
Christopher Lam
0ecbcb4ef1 [gnc-lot.c] GValue string must be unset 2021-08-29 15:38:16 +08:00
Christopher Lam
ac2afc7e13 [gncInvoice.c] GValue string must be unset 2021-08-29 15:38:16 +08:00
Christopher Lam
3bf49ed8d7 [Account.cpp] GValue string must be unset 2021-08-29 15:38:16 +08:00
Christopher Lam
e3af2f22f9 [gnc-commodity.c] cache user_symbol into commodity struct
Continuation of ff2ceb111 which introduced issue whereby user_symbol
returned could become stale, leading to invalid read fixed with
c398bef59. There are likely other user_symbol pointers becoming stale
without this commit.

This change will save the user_symbol into the commodity struct,
avoids gchar* becoming stale.
2021-08-29 15:38:16 +08:00
John Ralls
a487ca3f98 Improve template conditional readability with custom traits values. 2021-08-28 16:45:31 -07:00
John Ralls
57f73d70c7 Merge Yordan Miladinov's denom_lcd into maint. 2021-08-27 12:34:07 -07:00
Christopher Lam
c6d8333811 Merge branch 'maint' 2021-08-27 20:33:31 +08:00
Christopher Lam
c55ab50349 [gnc-budget.c] gnc_budget_get_account_period_note to be freed by the caller 2021-08-24 23:02:15 +08:00
Christopher Lam
9ddb9e8215 [gnc-module.c] free a GList* properly
g_list_free (current) was a NOP because current became NULL after the
preceding GList traversal.
2021-08-24 22:32:39 +08:00
Simon Arlott
0665208299
xml-backend: Lock file is deleted even if the lock is not acquired
The lock file is set in m_lockfile and then unlinked in session_end even if
the lock was not acquired.

Clear m_lockfile if locking was not successful.
2021-08-24 09:29:47 +01:00
Simon Arlott
e4619fdae6
xml-backend: Don't try to close m_lockfd if it's not open
m_lockfd is not initialised. If the file is locked then it will not be set
before session_end and close() will be called on an uninitialised int.

Initialise it to -1 in the class definition.
Consistently use -1 instead of "< 0" or "< 1" as the definition of invalid.
Always set it to -1 after closing it.
2021-08-24 09:29:45 +01:00
Yordan Miladinov
6cb509ea7d
fix an uncaught exception: denom_lcd may throw an overflow exception if casting lcm to int64_t fails 2021-08-24 00:58:31 +03:00
Christopher Lam
7e41efc232 Merge branch 'maint-speedup-and-leaks' into maint #1109
Speedup xaccSplitGetOtherSplit
2021-08-20 21:23:35 +08:00
Christopher Lam
ff2ceb111d [gnc-commodity] GValue must be unset 2021-08-20 17:02:58 +08:00
John Ralls
62ab148a3e Output a pair when writing relative date values to scheme file.
So that the can be properly recognized on input.
2021-08-19 09:48:44 -07:00
John Ralls
b3f96701a0 GncOptionAccountListValue: Make setter param cv match template. 2021-08-18 16:14:21 -07:00
John Ralls
b361582cf2 Ensure option UI is sorted: Tabs by names, items by keys. 2021-08-18 15:42:29 -07:00
John Ralls
10381d42e0 Fix color option handling.
Read and write color options the way legacy code does. Pass only values
with no alpha to gdk_rgba_parse because it fails if a hex-string has
alpha.
2021-08-18 13:38:06 -07:00
John Ralls
97a317b50c Ensure that alpha values in colors aren't passed to html.
html color tags don't like them.
2021-08-17 15:47:11 -07:00
John Ralls
3d1812aacd Explicitly cast a value to the decltype of get_value().
Can't always rely on implicit conversion working.
2021-08-17 15:41:26 -07:00
Christopher Lam
028bf9826b [Split] xaccSplitGetOtherSplit don't test book trading-accts
don't test trading-acct property when finding other split.
2021-08-17 13:04:34 +08:00
John Ralls
474bc360f4 Improve converting vectors to SCM lists. 2021-08-15 14:25:52 -07:00
Robert Fewell
71d73beb6c Original splits are not freed in xaccTransRollbackEdit
At the beginning of a transactions edit, xaccTransBeginEdit is used and
part of that duplicates the existing splits so that they can be
restored if editing is cancelled. If cancelled, xaccTransRollbackEdit
is used to restore the origin splits but if a split was not changed,
the copy was not being freed so loop over the original split list and
free them.
2021-08-15 12:20:35 +01:00
Robert Fewell
cacdb12aa5 Dereference the prices used in function convert_price
The two prices used in convert_price had there reference count
increased in extract_common_prices. This lead to the reference count
continuously increasing and not being freed on close so add
gnc_price_unref on both prices to reduce the reference count.
2021-08-15 12:20:35 +01:00
Robert Fewell
77cf90f198 Free the template root account after the scheduled transactions
have been freed.
2021-08-15 12:20:29 +01:00
Christopher Lam
6bf5a618de qof_instance_get gchar* must be freed
A call to qof_instance_get expecting a gchar* receives a newly
allocated string which must be freed.
2021-08-15 09:49:06 +08:00
Robert Fewell
a76fa5631c Free schedule Transaction accounts
There is no need to act differently when destroying the scheduled
transactions accounts, they can be destroyed when the scheduled
transaction is freed under normal conditions and on book close.
2021-08-14 15:09:42 +01:00
Robert Fewell
a9a3ed425a Free Accounts on book close 2021-08-14 15:09:33 +01:00
Robert Fewell
6a9ff287cd Wrap BillTermDecRef and TaxTableDecRef in test for shutdown
When Gnucash is shutting down, the TaxTables and BillTerms will be
destroyed/freed and may already have been so there is no point trying
to decrement a reference that is used to stop them being destroyed if
in use.
2021-08-14 15:09:33 +01:00
John Ralls
1cd2cf211c Specialize QofInstance* options set_value, catch validation exceptions.
GncOptionValue<const QofInstance*>.get_value() returns a QofInstance* but
reports store them as strings, either commodity mnemonics or GUIDs.
Specialize set_value/set_default_value from scheme to handle those
possibilities.

GncOptionValidatedValue throws an invalid_argument exception if it's
fed an invalid argument. Catch that so that it doesn't crash the program.
2021-08-13 14:06:47 -07:00
John Ralls
852b2ffc2e Handle bare currency mnemonics, catch invalid GUID string exceptions. 2021-08-13 14:06:47 -07:00
John Ralls
e43ff93279 Fix some overly-long lines. 2021-08-13 14:06:47 -07:00
John Ralls
1af97ebb9a Implement registering/unregistering/calling change callbacks.
Drives reloading the report when the Apply or OK button is pressed.
2021-08-13 14:06:47 -07:00
Christopher Lam
e4d808e674 [qofbook] qof_book_use_split_action_for_num_field: free a char*
qof_instance_get allocates a new char* which must be freed.
2021-08-13 08:58:07 +08:00
John Ralls
86da12d844 Use RGB instead of RGBA for color set for color 2021-08-12 14:28:44 -07:00
Robert Fewell
b421b3d2af Free Jobs for Customers and Vendors on book close 2021-08-12 16:07:31 +01:00
Robert Fewell
c2a6f1e911 Free TaxTable and BillTerms on book close 2021-08-12 16:07:31 +01:00
Christopher Lam
eafc290034 Merge branch 'maint' 2021-08-12 22:28:58 +08:00
Christopher Lam
40d886fa9d gnc_account_list_name_violations elements must be freed 2021-08-12 09:39:08 +08:00
Christopher Lam
4c37f6d4ef [account.cpp] gnc_g_list_stringjoin instead of repeated allocations 2021-08-12 09:19:34 +08:00
Christopher Lam
e84549926b [gnc-glib-utils] gnc_g_list_stringjoin to join a GList of strings
It traverses the GList twice (once to calculate the length) but
allocates only once.

Includes snippet from
https://www.joelonsoftware.com/2001/12/11/back-to-basics/
2021-08-12 09:19:34 +08:00
John Ralls
86d7637160 Handle GncOptionMultichoiceValue::set_value parameters
that don't match the get_value return type.
2021-08-08 15:22:53 -07:00
Christopher Lam
bedc85afa3 Merge branch 'maint-leaks' into maint #1101 2021-08-06 19:30:01 +08:00
Christopher Lam
0420ae6a66 [account.cpp] refactor gnc_account_list_name_violations 2021-08-06 17:31:36 +08:00
Christopher Lam
67bd513514 [account.cpp] rewrite gnc_account_foreach_descendant_until in C++ 2021-08-06 17:31:36 +08:00
Christopher Lam
17953441cb [account.cpp] refactor gnc_account_foreach_descendant 2021-08-06 17:31:36 +08:00
Christopher Lam
5698b67bf5 [account.cpp] refactor gnc_account_lookup_by_code 2021-08-06 17:31:36 +08:00
Christopher Lam
09e2e7613c [account.cpp] refactor gnc_account_lookup_by_name 2021-08-06 17:31:36 +08:00
Christopher Lam
bebc366e88 [account.cpp] refactor gnc_account_n_descendants 2021-08-06 17:31:35 +08:00
John Ralls
b6622a386b Pick up option aliases recently added in maint. 2021-08-05 15:52:13 -07:00
John Ralls
a97b3e0c6d Don't let C code destroy the ODB, it's owned by Guile. 2021-08-05 15:52:13 -07:00
John Ralls
a2e1a3e1b8 Extract the GncOptionDB* from the Scheme dispatch function closure.
Scheme code keeps the GncOptionDB in a closure. Extract it for C/C++
use. Ownership remains with the closure, don't free the GncOptionDB*.
2021-08-05 15:46:56 -07:00
John Ralls
f0926d66c1 Merge Simon Arlott's 'qof-instance-dispose' into maint. 2021-08-05 11:45:14 -07:00
Christopher Lam
e6c33a39bc [account.cpp] refactor gnc_account_get_descendants{_sorted} 2021-08-06 00:23:12 +08:00
Christopher Lam
d2db43019c [account.cpp] internal function account_foreach_descendant
fast and efficient
2021-08-06 00:23:12 +08:00
Christopher Lam
de1ad9367a g_free gnc_ctime which returns a new gchar* 2021-08-05 21:42:31 +08:00
Simon Arlott
7a0ea190ca
qof_instance_dispose should always complete dispose processes
If QofInstancePrivate has no collection then qof_instance_dispose() returns
without completing the rest of its dispose processes, skipping removal of
its type string from the string cache resulting in a reference count leak.

Change the check for a collection so that it only affects the call to
qof_collection_remove_entity().
2021-08-05 08:56:51 +01:00
Christopher Lam
c9db551693 g_free qof_print_date which returns a new char* 2021-08-05 09:23:28 +08:00
John Ralls
d099d39afd Merge Simon Arlott's 'commit-root-on-load' into maint. 2021-08-04 15:52:51 -07:00
John Ralls
fd56512cf7 Merge Simon Arlott's 'load-test-xml' into maint. 2021-08-04 15:48:42 -07:00
John Ralls
9062be3d47 Merge Simon Arlott's 'string-cache-fixes' into maint. 2021-08-04 14:26:27 -07:00