Commit Graph

997 Commits

Author SHA1 Message Date
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
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
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
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
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
a6771754d5 GncQuotes - start implementation of fetch/fetch_all 2022-10-02 11:50:25 -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
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
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
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
7880f9b16f [SchedXaction.c] free list of recurrences 2022-07-29 12:23:09 +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
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
John Ralls
3fd8bd9ddf Merge branch 'maint' 2022-07-16 17:15:20 -07: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
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
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
dc620d4b24 Merge branch 'maint' 2022-04-22 13:43:47 +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
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
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
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
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
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
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
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
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
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
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
Christopher Lam
88ecf8dd17 Merge branch 'maint' 2021-11-23 16:14:53 +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
cf5da9fffd Resolve merge conflicts. 2021-11-12 19:56:29 -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
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
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
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
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
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
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
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
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
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
Christopher Lam
017ab06939 Merge branch 'maint' 2021-09-12 22:44:34 +08: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
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
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
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
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
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
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
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
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
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
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
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
John Ralls
9062be3d47 Merge Simon Arlott's 'string-cache-fixes' into maint. 2021-08-04 14:26:27 -07:00
John Ralls
76b0001cbe Remove option-util. 2021-07-31 17:54:29 -07:00
John Ralls
e2c87f23c3 Convert optiondb users in gnome and gnome-utils to C++.
To enable using std::unique_ptr<GncObjectDB> and avoid memory management
problems.
2021-07-31 17:54:29 -07:00
John Ralls
7dab089d49 Fix miscalculation of prev_quarter_end for the first quarter.
If the current quarter ends June 30 backing up 3 months from there
gets March 30, one day off. Back up first and calculate the end
of the actual quarter of interest.

Changed pre_quarter_start for consistency, it doesn't matter.
2021-07-31 17:54:28 -07:00
John Ralls
28438e3126 Rewire gnome and gnome-utils to use GncOptionDB. 2021-07-31 17:54:28 -07:00
John Ralls
67508ea039 Reimplement dialog-options for C++. 2021-07-31 17:54:28 -07:00
John Ralls
08bf3ec5b0 Merge branch 'maint' 2021-07-30 10:28:57 -07:00
Simon Arlott
4a5b5f3bf2
Don't cache the empty string
Avoid unnecessary reference counting for uses of the empty string.
2021-07-11 18:54:49 +01:00
Simon Arlott
320df7e409
Use const return values for string cache
This is a prerequisite for being able to return "" (which is const) and
none of the returned values should ever be modified.
2021-07-11 18:54:49 +01:00
Simon Arlott
4132939612
Avoid leaking string cache entries for "" in Transaction and Split
When g_object_new() is used, the strings that default to "" are added to
the string cache. These are then not correctly removed when updating them
with new values when cloning a Transaction/Split.

Use CACHE_REPLACE instead of CACHE_INSERT.
2021-07-11 18:52:09 +01:00
John Ralls
81c5ac6689 Remove the incomplete book-currency code.
Not everything from the 6 Book-Currency commits is removed: Switching
the Num and split-action fields and restricting edits of transactions
older than n days were included and those changes are left in place.

Some other partly-implemented features were also part of these commits
and were removed: Options for setting a default capital gains account
and currency, completion of the LIFO cap-gains policy, and creation of
a list of cap-gains policies.

If any of these are to be revived they should each be done in a separate
feature branch and submitted via Github pull request for a code review
before merging; a design discussion on gnucash-devel before restarting
work is also advisable.
2021-07-10 17:29:11 -07:00
John Ralls
d2535fe21b KvpValue: Use boost::typeindex::type_id instead of buildtin typeid.
Under some build conditions boost::typeindex will use an internal type
identifier that's different from the C++ builtin. In that case type equality
tests to C++ typeid in boost::variant will fail, breaking it. Using
boost::typeindex::type_id ensures that the comparisons always work.
2021-07-10 17:24:58 -07:00
Robert Fewell
0f026f6a10 Bug 798221 - Transfer funds between accounts with different currencies crashes Gnucash on macOS
In the scrub function find_account_matching_name_in_list there was a
test for account names being the same for currency but condition was
backwards so was matching on account names being different. There was
also a g_list_free resulting in a double free which was removed.
2021-07-08 09:33:10 +01:00
Simon Arlott
08b56e9669
[gnc-pricedb] Don't lookup old prices when doing bulk updates 2021-07-05 21:57:34 +01:00
Christopher Lam
1b4d30b3b1 Merge branch 'maint' 2021-06-22 23:30:20 +08:00
Hong Xu
0fd0aca531 Explain out what AsOfDate means in the doc
As discussed at
https://lists.gnucash.org/pipermail/gnucash-user/2021-June/096893.html
2021-06-16 12:07:23 -07:00
John Ralls
601eb51361 Improve transaction sorting on effective num field.
Inspired by PR #983. Transaction sorting on num broke down if the
user had a non-numeric string or a number larger than an int in
the effective num field (might be split-action if the option is set).

The comparison first tries to use strtoull on the two strings and
compares the results. If they're both nonzero and different then the
numeric order is returned. If they're both nonzero but the same the
unconverted parts of each are passed to g_utf8_collate; if either is 0
then the whole strings are passed to g_utf8_collate. strtoull will
return 0 for a negative number.
2021-06-15 14:02:25 -07:00
John Ralls
985a6420fc Bug 798196 - not building with Boost 1.76 2021-06-12 16:47:35 -07:00
John Ralls
6aa35ea7fb Better fix for bug 798204, doesn't break trading account selection. 2021-06-12 16:42:10 -07:00