Commit Graph

786 Commits

Author SHA1 Message Date
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
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
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
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
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
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
John Ralls
9eeff5dd7e Bug 798204 - Creation of Imbalance Accounts
Search recursively when getting account by name.
2021-06-12 15:21:50 -07:00
John Ralls
68ec80e68d Bug 798203 - g_assert fault while reversing transaction
* Re-commit the original transaction to ensure that there aren't
any stray trading splits.
* If the original and cloned transactions have a different number of
splits don't leak the cloned transaction.
* Check that the cloned transaction isn't NULL before trying to invert
it.
2021-06-12 13:37:25 -07:00
John Ralls
80d6749989 Bug 787813 - Price change from editing a transaction not reflected...
in pricedb.

Allow PRICE_SOURCE_SPLIT_REG to overwrite PRICE_SOURCE_XFER_DLG_VAL.
2021-06-10 11:29:34 -07:00
Christopher Lam
321b5efabc Merge branch 'maint-leaks' into maint #1019 2021-06-09 06:47:23 +08:00
John Ralls
42213c597c Bug 798199 - Pasting invalid value in date column crashes GnuCash
Catch boost::gregorian::bad_year in LDT_from_struct_tm and rethrow
std::invalid_argument for C wrappers to catch and handle.
2021-06-08 13:14:30 -07:00
Christopher Lam
b095d1e7da Revert "[qofquery] q->terms g_list members must be freed"
This reverts commit a3e3823ee7.

Already freed earlier in the same function.
2021-06-08 07:36:47 +08:00
Christopher Lam
c8a7b9edb3 [Account] g_value_unset 2021-06-07 07:54:36 +08:00
Christopher Lam
bfdec74a48 [qof-backend] gchar * gnc_path_get_pkglibdir must be g_freed 2021-06-06 11:03:04 +08:00
Christopher Lam
f6a9be45ba [Split] g_value_unset 2021-06-05 00:21:52 +08:00
Christopher Lam
36901c5751 [gncJob] g_value_unset 2021-06-05 00:21:52 +08:00
Christopher Lam
1824a30bd0 [gncinvoice] g_value_unset 2021-06-05 00:21:52 +08:00
Christopher Lam
badd976e11 [gnc-lot] g_value_unset 2021-06-05 00:21:52 +08:00
Christopher Lam
c9565abe8b [gnc-commodity] g_value_unset 2021-06-05 00:21:52 +08:00
Christopher Lam
302020fcb7 [gnc-budget] g_value_unset 2021-06-05 00:21:50 +08:00
Christopher Lam
ceeb1dff7a [scrub.c] g_value_unset 2021-06-05 00:21:21 +08:00
Christopher Lam
92cd437562 [Transaction.c] g_value_unset to release GValue string 2021-06-05 00:21:20 +08:00
Christopher Lam
3353d3950b [gnc-budget] g_value_unset GValue 2021-06-05 00:20:23 +08:00
Christopher Lam
a3e3823ee7 [qofquery] q->terms g_list members must be freed 2021-06-03 17:16:09 +08:00
Christopher Lam
8a6413342d [SchedXaction] free GList* 2021-06-02 22:04:54 +08:00
Christopher Lam
c5585ebe2c [gncInvoice] free GList* 2021-06-02 22:04:52 +08:00
Christopher Lam
d611538ae7 [gncTaxtable] free GSList* 2021-06-02 22:04:33 +08:00
Christopher Lam
b3101c9385 [gnc-pricedb.c] plug GList leak 2021-06-02 20:09:45 +08:00
Christopher Lam
8a56a00313 Modify documentation for gncEntryComputeValue
Modify documentation for be19b489e
2021-06-01 08:14:25 +08:00
Christopher Lam
b25a444140 Merge branch 'maint' 2021-05-14 21:16:48 +08:00
John Ralls
da3c511b6c Remove trading splits instead of trying to adjust them. 2021-05-12 09:00:51 -07:00
John Ralls
4f030aac6e Bug 798093 - Changing the symbol/abbreviation of a security...
after the trading account was created breaks GnuCash.

Revisited. The original changeset looked for a top level trading account
and a namespace account in the transaction currency; if either of those
accounts had been created in a different currency it would duplicate
them.

This commit will accept any such account regardless of commodity. If
more than one exists it will prefer the one in the root currency if
there is one, otherwise it will select the first one found.
2021-05-12 09:00:51 -07:00
John Ralls
18c72baddf Don't bother scrubbing for orphans if there's no transaction currency.
If it found one it would try to create an orphan account with no
currency which will crash later.
2021-05-11 14:43:45 -07:00
John Ralls
2b48fd375d Revert "Fix duplicate trading accounts."
This reverts commit ed486a58a4.
2021-05-03 17:16:23 -07:00
Hong Xu
888676eb31 from_price and to_price may be uninitialized in extract_comon_prices
Fix the compilation error on gcc 10:

    gnucash/libgnucash/engine/gnc-pricedb.c: In function ‘extract_common_prices’:
    gnucash/libgnucash/engine/gnc-pricedb.c:2469:40: error:
    to_price may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2469 |     if (from_price == NULL || to_price == NULL)
           |                                        ^
           gnucash/libgnucash/engine/gnc-pricedb.c:2469:20:
           error: ‘from_price’ may be used uninitialized in this
           function [-Werror=maybe-uninitialized]
            2469 |     if (from_price == NULL || to_price == NULL)
                  |                    ^
2021-04-29 14:51:07 -07:00
Christopher Lam
ae7eb9b3ad [gnc-pricedb] extract common code into get_nearest_price
Extracts common code in:

* gnc_pricedb_get_nearest_before_price
* gnc_pricedb_get_nearest_price
* gnc_pricedb_get_latest_price
2021-04-26 07:16:25 +08:00
Christopher Lam
a2f5223148 [gnc-pricedb] use g_list_find and plug memory leak
found_coms was not being freed.
2021-04-26 07:16:25 +08:00
John Ralls
ed486a58a4 Fix duplicate trading accounts.
In many cases GnuCash would create a new trading account hierarchy
when one already existed because gnc_account_lookup_by_type_and_commodity
didn't check the account presented and didn't recurse down the
account hierarchy correctly.
2021-04-24 15:51:32 -07:00
John Ralls
2258e7a44e xaccAccountTypes was backwards
vs. the documentation. The unit tests and dialog-account were similarly
backwards, but the use in gnucash/import-export/ofx followed the docs.
2021-04-24 15:51:32 -07:00
Christopher Lam
5ce8f78f77 Merge branch 'maint' 2021-04-24 23:16:22 +08:00
Robert Fewell
e535ba5411 Change some functions to use const gnc_commodity for gnc_pricedb 2021-04-23 11:56:15 +01:00
Robert Fewell
e75308e684 Rename a couple of gnc-pricedb functions that have not been used.
To be more consistent change gnc_pricedb_lookup_latest_before_t64 and
gnc_pricedb_lookup_latest_before_any_currency_t64 to be of the form
'_nearest_before_' and add a missing utest.
2021-04-23 11:56:15 +01:00
Robert Fewell
d3bd7fda61 Add unit tests for new gnc-pricedb functions 2021-04-23 11:56:15 +01:00
Robert Fewell
4a491f7cde Change a couple of docbook definitions in gnc-pricdb.h 2021-04-23 11:56:15 +01:00
Robert Fewell
05507008c5 Add retrieval functions for price before the date given
Add a new function, gnc_pricedb_convert_balance_nearest_before_price_t64
that retrieves the balance using the last price dated before a
specified date like today for the preset value. This uses another new
function gnc_pricedb_get_nearest_before_price to do the retrieval.
2021-04-23 11:56:15 +01:00
Robert Fewell
b54c30e03d Bug 798148 - Chart of Accounts page Present(xxx) value wrong
If for some reason you have price information in the future for a
security, the present value is based on the price retrieved for the
greatest date and not a price which is before the current date.

To fix this use the 'xaccAccountGetBalanceAsOfDateInCurrencyRecursive'
function.
2021-04-23 11:56:15 +01:00
John Ralls
bbb4113a5a Bug 798156 - glib 2.68.0 breaks gnucash
Move all of the #include <glib> to before the extern "C" blocks
so that the include guards will protect against headers inside
the extern "C" block also including glib.h.
2021-04-20 11:03:23 -07:00
John Ralls
4eaa10c6be Another extern-C glib.h, for Windows this time. 2021-04-13 16:56:55 -07:00
Christopher Lam
d28ff20ff7 Merge branch 'maint' 2021-03-29 17:29:19 +08:00
John Ralls
27435b1038 Don't filter use of TTInfo file section based on sizeof time_t.
The whole point of GncDateTime is to work around 32-bit time_t.
2021-03-22 14:23:23 -07:00
John Ralls
b40589244c Fix test-gnc-datetime failure on Ubunutu. 2021-03-22 14:18:24 -07:00
John Ralls
c49b45d8f1 Finish the glib 2.67 fixes for CI tests. 2021-03-22 14:02:37 -07:00
John Ralls
1221d7ebc1 Bug 798150 - Error on report over time
Extract functions LDT_from_date_time and LDT_from_date_daypart
to avoid duplicate code. Handle date-times in start-of-DST transitions
and better handle those in end-of-DST transitions. Test the results.
2021-03-21 15:55:08 -07:00
John Ralls
ebb5eb1f17 Fix GncDateTime::format_zulu to emit the UTC timezone.
Instead of the GncDateTime's timezone with the UTC timestamp.
2021-03-21 15:55:08 -07:00
John Ralls
3a35514d84 Fix the implementations of gnc_foo_get_day_neutral.
As implemented these returned 10:59 AM local on the day but neutral
time is 10:59 UTC.
2021-03-20 09:45:38 -07:00
Christopher Lam
2a2f080813 Merge branch 'maint' 2021-03-18 07:36:40 +08:00
Frank H. Ellenberger
4a983761d7 Fix a typo in a comment of the last commit 2021-03-16 06:34:08 +01:00
John Ralls
a11065b823 Fix fencepost error in calculating the week_num for POSIX timezone rules.
Fixes CI failure caused by US starting DST in 2021, a year in which
March began on a Monday.
2021-03-15 17:07:16 -07:00
John Ralls
8e41857014 Catch more exceptions in gnc_numeric_convert
To enable fixing https://bugs.gnucash.org/show_bug.cgi?id=798132.
2021-03-12 13:47:24 -08:00
Christopher Lam
87473ed5f9 Merge branch 'maint' 2021-03-12 23:14:51 +08:00
Dong Lin
75209c024f Update price database for imported transactions
When a transaction is added from the ledger, price database is updated properly.
But if the transaction is imported, there is no price db update.

This change adds the proper pricedb update in the import path (qfx/ofx/qif).
Tested with make check
2021-03-09 10:39:56 -08:00
Sumit Bhardwaj
df579c257b Replace g_memdup by memcpy
GLib is deprecating g_memdup. Since older versions of GLib
wouldn't have g_memdup2, this PR replaces occurrences of
g_memdup by memcpy.
2021-03-08 15:14:17 -08:00
Frank H. Ellenberger
93e2829ee5 Merge PR #899 into maint 2021-03-02 01:17:26 +01:00
luz paz
16b4976381 Fix typos in libgnucash/
Found via `codespell -q 3 -L ans,ba,parm,parms,numer`
2021-03-02 01:15:32 +01:00
Christopher Lam
e79db92d8d [Split.c] xaccSplitListGetUniqueTransactionsReversed
Same as xaccSplitListGetUniqueTransactions but doesn't reverse the
list prior to returning. To be used by gnc-tree-model-split-reg.c

Several optimizations

* doesn't call g_list_find and g_list_append for every iteration
* uses g_hash_table to cache list of txns already added instead of g_list_find
* does not reverse the result, thereby returning a reversed list.
2021-02-24 09:08:25 +08:00
Christopher Lam
b2b8792110 prepend-and-reverse instead of O(N^2) append 2021-02-24 09:08:25 +08:00
Frank H. Ellenberger
6bc8679932 I18N: replace several spourious spaces 2021-02-22 17:56:50 +01:00
John Ralls
7a7c26f87e Move glib and gtk includes out of extern C for tests.
Needed to compile with glib 2.67 and later.
2021-02-16 13:23:48 -08:00
Bill Nottingham
c0f2c3ae25 Fix build with glib2 2.67.x.
glib headers should not be included with 'extern "C"'.
2021-02-16 13:23:16 -08:00
Christopher Lam
092040c7fe Merge branch 'maint' 2021-02-16 18:44:02 +08:00
John Ralls
4359243c08 Move glib and gtk includes out of extern C for tests.
Needed to compile with glib 2.67 and later.
2021-02-15 12:37:09 -08:00
Bill Nottingham
f60b6354f8 Fix build with glib2 2.67.x.
glib headers should not be included with 'extern "C"'.
2021-02-13 16:35:27 -05:00
Christopher Lam
c20a588e0f Don't use g_list_append unnecessarily 2021-02-10 07:09:02 +08:00
Christopher Lam
d16f39046d Merge branch 'maint' 2021-01-30 07:13:32 +08:00
John Ralls
0f8d9f6d7c Bug 798093 - Changing the symbol/abbreviation of a security after...
the trading account was created breaks GnuCash.

Introduces a new function, gnc_account_lookup_by_type_and_commodity
that does that, though it also looks at name for the one special case
of finding/creating the Namespace placeholder account. Adds a parameter
checkname to xaccScrubUtilityGetOrMakeAccount to flag whether to look
for the name.

Namespaces aside this makes it possible for the user to rename trading
accounts or securities independent of each other.
2021-01-27 17:44:21 -08:00
John Ralls
bcbebe62b1 Make xaccScrubUtilityGetOrMakeAccount static and remove ScrubP.h
It being the only declaration in ScrubP.h
2021-01-27 17:44:21 -08:00
Christopher Lam
ddc86579c0 Merge branch 'master-remove-deprecated' #855 2021-01-24 09:25:08 +08:00
Frank H. Ellenberger
84cc64daed I18N: Remove annoying stars from translator comments 2021-01-22 10:19:54 +01:00
John Ralls
ffa2f606e3 Fix use-after-free in test_xaccTransEqual. 2021-01-17 11:51:12 -08:00
Christopher Lam
c5e7406c9f [account.cpp] remove deprecated function 2021-01-04 08:46:09 +08:00
Allan Nordhøy
383b0b2f19 Replace 'Non Bayesian' with grammatically more correct 'non-Bayesian'. 2021-01-03 07:01:14 +01:00
Allan Nordhøy
8d4d1f1523 Replace 'Non Bayesian' with grammatically more correct 'non-Bayesian'. 2021-01-02 20:29:21 -08:00
Christopher Lam
f1c1fca023 [account.cpp][API] deprecate xaccAccountCountSplits 2020-12-28 09:48:06 +08:00
John Ralls
ae66da9632 Fix test-gnc-timezone failure caused by latest zoneinfo release.
See the comment for details.
2020-12-26 13:46:09 -08:00
John Ralls
2ff3bf5877 Echo into CMakeLists.txt rename of gmock-qofqury to fake-qofquery. 2020-12-13 11:52:32 -08:00
Christopher Lam
d11bdb3e3a Bug 798015 - cash flow numerical-overflow
error is caused by pricedb containing an invalid gnc_numeric
price. multiplication of (invalid) price with amount causes a report
crash.

Fix: if invalid price, return zero for amount converted to report
currency.
2020-11-22 23:35:46 +08:00
Ralf Habacker
63580d91ba Add feature GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE
When the above function is activated, the slot 'equity type' is used and
set in relation to opening balances and the checkbox for marking the
opening balance in the accounts dialog can be changed.
2020-11-16 08:51:51 +01:00
Ralf Habacker
f8dcd23023 Add support for the opening balance accounts flag
Up to now, opening balance accounts have been identified by means of
fixed names and their translations, which in some cases is not
appropriate.

With this commit, therefore, opening balance accounts can now be
identified by a special slot, which should solve the above problem.

in gnc_find_or_create_equity_account(), when querying the
EQUITY_OPENING_BALANCE type, the system now first searches for an
account with an existing 'equity-type' slot having the value
'opening-balance' and returns it as an opening balance account if
one exists. If no corresponding account is found, the search is
continued as before. An account found in the process is automatically
given the status of an opening balance account (it is given an
'equity-type' slot with value 'opening-balance') to simplify the
future search.

The opening balance status of an account is visualized in the account
settings dialog with a check box. If a Gnucash file does not yet contain
an opening balance account, one can be selected in the account settings
dialog.

https://bugs.gnucash.org/show_bug.cgi?id=797836
2020-11-16 08:51:51 +01:00
John Ralls
e09a26ba3a Merge Christian Gruber's 'test_import_backend' into maint. 2020-11-08 14:27:26 -08:00
John Ralls
2290fa7c22 Fix exception when converting to decimal values that reduce to N/1.
Before this the loop wouldn't terminate until the denominator had been
reduced to 0 and trying to create a GncRational with a 0 denominator
throws.
2020-11-07 16:22:18 -08:00
John Ralls
d03dc07b8d Remove redundant and incorrectly named constant. 2020-11-07 13:20:22 -08:00
John Ralls
3bcf57e7f2 Fix timezone transition times.
This is responsible for test failures on DST transition days.

See the comments in gnc-timezone.cpp for an explanation of why this is
correct. The rubric was tested on macOS, Arch Linux, Debian Unstable,
Fedora 33, and Ubuntu 18.04 to confirm universal applicability.
2020-11-07 11:02:54 -08:00
McLayn
cebe6022c8 fix CZK partname to nominative singular 2020-10-30 00:40:02 +01:00
Christopher Lam
e833c8e1aa [utest-gnc-pricedb.c] test: gnc_pricedb_get_[latest|nearest]_price 2020-10-26 23:56:33 +08:00
Christopher Lam
2ecdd70e24 [gnc-pricedb.c][api] pull out composite pricedb price retriever
* tries direct price retrieval from pricedb.
* if fails, tries intermediate currency.
2020-10-26 23:55:51 +08:00
Christopher Lam
4d63eb922f [gnc-pricedb.c] copy convert_amount to convert_price 2020-10-23 09:49:27 +08:00
Christopher Lam
26e7eada37 [gnc-pricedb.c] refactor amount converters, use common code 2020-10-23 09:49:27 +08:00
Robert Fewell
8e5e3480ad Bug 797984 - Infinite loop while Check&Repair AR and AP accounts
If using the Check&Repair option from the Chart of Accounts on 'Account
Receivable or Payable' add has a voided transaction will cause an
infinite loop.

This occurs from checking the transaction split amount is zero in
gncScrubBusinessSplit and trying to delete it. As the transaction is
read only as a result of being voided this fails so add a further
condition for the 'else if' statement to include !is_void.
2020-10-20 14:45:44 +01:00
Robert Fewell
122cd682f6 Add some additional places where Check&Repair can be aborted 2020-10-20 14:43:39 +01:00
Robert Fewell
6ee537e1a7 Allow the Check&Repair routine to be cancellable from CoA
Add a callback for a keypress event when on the Accounts page that
checks for the Escape key and presents a dialog to confirm whether to
abort the Check&Repair. A similar dialog is used if you decide to quit
Gnucash while the Check&Repair is still running.
2020-10-20 14:42:32 +01:00
John Ralls
94a68dca7c Bug 797983 - v4.2 report numbers change over gnucash restarts;...
Price Database dropping user:price-editor entries.

A wider problem: QofInstance was unmarking itself dirty as long as the
backend raised an error and unconditionally marking itself non-infant.

This matters because the SQL backend depends on infant status to decide
whether to do an insert or update query; either will fail if the infant
status is wrong.

The price editor dialog clones a price having only its commodity set and
GncSqlPriceBackend declines to save if the currency isn't set. Since the
instance marked itself non-infant even though it wasn't saved subsequent
commits tried to use an update query and since the price wasn't in the
table that inevitably failed.

Requiring that QofBackend::commit should doing the marking-clean
required implementing it in the backends where it wasn't already.
2020-10-18 16:09:41 -07:00
Christian Gruber
6394b6491b fixup! Simplify type checking for GObject mockups 2020-10-05 22:48:52 +02:00
Christian Gruber
feba64624c Fix xaccTransSetNotes()
This is a bugfix for commit 954ce9577f
2020-10-05 22:20:02 +02:00
Christopher Lam
6eb2e36c2d minor optimisations, g_list_prepend then g_list_sort separately
if building a g_list incrementally, don't sort on each insertion.
2020-10-01 11:34:21 +08:00
Christopher Lam
e6486e9d95 deprecate xaccAccountCountSplits with include_children = FALSE
whereby xaccAccountCountSplits is called with with_children = FALSE,
test xaccAccountGetSplitList against NULL.
2020-10-01 11:34:21 +08:00
Christopher Lam
1b31c06b29 [Account.cpp] add gnc_account_and_descendants_empty (acc)
and deprecate xaccAccountCountSplits
2020-10-01 11:34:21 +08:00
John Ralls
5e6f9b3460 Fix some return of ptr-to-temporary errors
Flagged by new clang Apple version 12.
2020-09-25 12:31:52 -07:00
John Ralls
1c5561714d Fix ptr-comparison-to-string-literal error
A new error raised in the latest versions of gcc and clang.

The address of string literals is undefined in the C standard so the
compiler raises an error if one tries to test for string equality by
comparing them. A better fix would be to replace QOF_ID strings with an
int-based identifier; an even better one would get rid of QOF_ID
entirely and use the C++ type system.
2020-09-25 12:23:56 -07:00
Christian Gruber
e44cf9c61f Add missing C linkage statements 2020-09-23 19:59:40 +02:00
Christian Gruber
63969e8628 Remove unecessary include 2020-09-22 22:52:37 +02:00
Christian Gruber
d673c32e35 Mock methods should not neccessarily return mock objects 2020-09-22 22:52:37 +02:00
Christian Gruber
0e634c5446 Relax runtime type checks
Runtime type checks should only check for the mock up type, if
neccessary. If objects of another class than the mocked object itself
are processed, runtime type check should only check for the base-class
type. It should be possible to use mockup objects and non-mockup objects
within the same application.

The included headers are adapted accordingly.
2020-09-22 22:52:37 +02:00
Christian Gruber
99256c385b Add missing _get_type() functions of all mocked GObject classes
If a GObject is replaced by a mock up, its _get_type() function has to
be replaced as well. The replaced _get_type() functions have to return
the type of the mock up now.
2020-09-22 22:07:21 +02:00
Christian Gruber
833edd0b29 Add missing comment 2020-09-21 00:50:24 +02:00
Christian Gruber
bc80bbb325 Simplify type checking for GObject mockups
A type conversion function is introduced for each GObject mockup. This
function does a runtime type check and generates a GoogleTest failure in
case of any type error. This avoids checking GObject type twice.
2020-09-21 00:47:53 +02:00
Christian Gruber
b0906b5e2a Use MOCK_CONST_METHODn() macro instead of MOCK_METHODn() macro if necessary 2020-09-20 23:36:34 +02:00
Christian Gruber
5408854c28 Rename GObject type names of mock classes
According to a remark in PR #738 the lower case type name is changed.
Underscores should only be used between namespace and type name and
between type name and suffixes.
2020-09-20 22:33:51 +02:00