Commit Graph

1436 Commits

Author SHA1 Message Date
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
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
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
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
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
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
John Ralls
f6766d42ec Merge Simon Arlott's 'string-cache-no-refcount-empty' into maint. 2021-08-04 14:19:21 -07:00
Christopher Lam
a5edacf0fc [options.scm] Rename option name to "Levels of Subaccounts"
Original name "Show Accounts until level". Add backward compatibility
missed in 08f490ee98
2021-08-04 19:02:30 +08:00
Christopher Lam
23bd716451 g_free gnc-path's gchar* intermediate strings 2021-08-03 12:14:12 +08:00
John Ralls
08bf3ec5b0 Merge branch 'maint' 2021-07-30 10:28:57 -07:00
Christopher Lam
f1e35daab3 Rename option name from "Extra notes" to "Extra Notes" 2021-07-23 06:25:01 +08:00
Christopher Lam
251db8c37b Rename option name from "Report title" to "Report Title" 2021-07-23 06:25:01 +08:00
Christopher Lam
2606ddf905 Rename option name from "Invoice number" to "Invoice Number"
This ensures it matches all other invoice reports.
2021-07-23 06:24:55 +08: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
Simon Arlott
bf8fe1123c
Commit root accounts after loading from XML
The root accounts start with a non-zero editlevel because BeginEdit is
called for them during loading but not committed after loading.

If the book is then closed without performing any further edits that would
require a commit, the Account book_end process does nothing because the
root account is still being edited and so none of the accounts are freed.
2021-07-11 15:04:57 +01:00
Simon Arlott
f15402a9a6
Load test data from XML properly
If qof_session_new() is called without a book then qof_session_load()
won't do anything.

Set up a book for it to use.
2021-07-11 14:56:56 +01:00
John Ralls
e1c153a516 Bug 798224 - Scheduled transactions are created with date-entered...
copied from the template transaction.
2021-07-10 16:35:20 -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
John Ralls
ebf84fbf8d Bug 798229 - GncDate::c_formats is being created and destroyed twice...
resulting in a double free crash on every exit.

Exclude by name the obsolete pre-GnuCash 4 modules from being inspected
so that they don't try to construct and destroy their static variables
twice.
2021-07-06 12:03:41 -07:00
John Ralls
06fc58c39d Merge Simon Arlott's 'load-pricedb-faster' into maint. 2021-07-05 14:48:48 -07:00
Simon Arlott
08b56e9669
[gnc-pricedb] Don't lookup old prices when doing bulk updates 2021-07-05 21:57:34 +01:00
Geert Janssens
60f50e34c7 Tax - fully express source file dependencies in build scripts 2021-06-30 15:19:34 +02:00
luz paz
95f8884892 Fix misc. typos in comments 2021-06-29 08:46:34 +02:00
Christopher Lam
1b4d30b3b1 Merge branch 'maint' 2021-06-22 23:30:20 +08:00
Christopher Lam
e653c30193 [gnc-xml-backend] g_free char* 2021-06-22 18:57:55 +08:00
John Ralls
b1b368746f Merge Hong Xu's 'explain-as-of-date' into maint. 2021-06-19 13:19:31 -07:00
John Ralls
b33d7eb98d Doxygenize some function description comments in gnc-ui-util. 2021-06-18 11:54:14 -07:00
John Ralls
7f62c5395a Bug 743999 - Deleting a digit from an existing number greater than...
four digits in length generates an error message.

Because the grouping is off. Checking grouping on input is pointless so
just ignore the grouping separator when parsing number input.
2021-06-18 11:40:06 -07: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
John Ralls
66685f042e Merge Bob Fewell's 'bug796761' into maint. 2021-06-08 11:58:27 -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
Robert Fewell
7ee9dac2e9 Add filter for currency symbol for GNCAmountEdit widget
When pasting an amount that includes the currency symbol the validation
will silently fail which may lead to unusual behaviour.
2021-05-31 11:11:01 +01:00
Robert Fewell
748dbf54e0 Change monetary value for gnc_default_share_print_info
Share values are not currencies so set the monetary value to 0 for the
GNCPrintAmountInfo
2021-05-31 11:11:01 +01:00
Robert Fewell
435bb1c76b Parse the register monetary cells for a currency symbol
Add the ability to strip the currency symbol from a registry monetary
cell if it is pasted with one so it can be validated.
2021-05-31 11:11:01 +01:00
Robert Fewell
d55060c0fc Bug 796761 - Control characters can be pasted in register fields
If copied text includes control characters they are inserted when
pasted which can cause alignment issues. This commit filters the
clipboard text for control characters before it is pasted.
2021-05-31 11:11:01 +01:00
Christopher Lam
f37fa85705 build dom_tree_to_list_kvp_value more efficiently
seems to be unused however
2021-05-30 11:09:39 +08:00
Christopher Lam
59386b4081 gchar* dom_tree_to_text must be g_freed 2021-05-30 08:10:19 +08:00
Christopher Lam
292deb0a11 [binreloc.c] free strings
subdir, prefix are not consistently freed.
2021-05-29 07:55:26 +08:00
Christopher Lam
d83eff3a55 Merge branch 'maint' 2021-05-28 08:00:20 +08:00
Christopher Lam
c1cb29df53 GncGUIDs should be freed with guid_free instead of g_free 2021-05-17 21:00:59 +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
f7f35faefe Bug 797928 - Since last run asks for security price when no shares traded
Refactor a bit to ensure that the same price variable names and transaction
currency is used for both extracting the variables and retrieving
any required exchange rates, and that splits with no formula are
ignored in both cases.
2021-04-19 14:25:59 -07:00
Robert Fewell
33b8a19253 Add depreciation warnings for the removal of individual option tool tips 2021-04-18 12:17:51 +01:00
Robert Fewell
02a6a0ae4a Remove the function gnc_option_permissible_value_description
Remove function and scheme using this function which deals with
individual tool tips on multi-choice options.
2021-04-18 12:17:51 +01:00
John Ralls
4eaa10c6be Another extern-C glib.h, for Windows this time. 2021-04-13 16:56:55 -07:00
Christopher Lam
67e65d436c Remove duplicate definitions 2021-04-02 09:37:14 +08:00
Christopher Lam
9b671b2039 [date-utilities.scm] remove unused date selectors code & string 2021-03-30 18:09:44 +08:00
Christopher Lam
b06ee5efaf Merge branch 'maint' 2021-03-30 18:09:08 +08:00
Christopher Lam
d316b01da7 [date-utilities] deprecate unused date selectors 2021-03-29 20:14:18 +08:00
Christopher Lam
d28ff20ff7 Merge branch 'maint' 2021-03-29 17:29:19 +08:00
Geert Janssens
a4cab54afc i18n - Reuse strings for less translation work 2021-03-28 20:51:19 +02:00
John Ralls
170502c6c5 Bug 797906 - GnuCash data file is locked after a "save-as"...
to mysql database.

It's more general, any save-as to a different backend type, i.e.
xml->sql or sql->xml, left the previous book locked.

Ensure that the session is ended and the book unlocked in the
backend's destructor. This also fixes a memory leak in the SQL
backend because the GncSqlConnection wasn't being deleted.
2021-03-23 11:27:37 -07: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
Geert Janssens
e9dfd0d9ea Still more fixes for Arch ci failure 2021-03-22 21:30:41 +01:00
Geert Janssens
cb04365013 More fixes for Arch ci failure 2021-03-22 21:14:34 +01: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
Geert Janssens
fbabcd58e0 Remove dead code 2021-03-17 16:24:22 +01:00
Geert Janssens
b9208eccbf Remove duplicate declaration
The function is also declared and defined in gnc-locale-utils
2021-03-17 16:24:22 +01:00
Geert Janssens
e973a1b60d Drop default locale currency special case for euro
The condition mentioned in the comment no longer applies.
All European locales on Windows (MingW64) properly present EUR
as currency these days
2021-03-17 16:24:22 +01: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
a6276708c0 Bug 797630 - Check for missing dependencies of 'Get Quotes'...
to avoid Gnucash crash.

We already did, just not in the right order to get the error to
percolate up to price-quotes.scm.
2021-03-14 10:48:25 -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
Christopher Lam
3739d9121c [date-utilities.scm] typo fix and deprecate unused functions 2021-03-07 13:35:39 +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
Alex Aycinena
9d74333d82 2nd Update Form/Schedule line references for 2020 for the US Income Tax Report. 2021-02-16 18:41:20 -08:00
Alex Aycinena
320e84b990 Update Form/Schedule line references for 2020 for the US Income Tax Report. 2021-02-16 16:21:31 -08: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
Christopher Lam
779c0521e0 [options.scm API] yank canonically-tabbed parent-subtotal-mode
'canonically-tabbed option is buggy and has never graduated out of
experimental for 17 years. Time to put it to rest.

All previous saved reports with this option will be switched to 't
i.e. parent-subtotal-mode enabled..
2021-02-15 08:59:50 +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
John Ralls
ba0e412815 Bug 798112 - An error occurred while processing mysql ...
A "Feature" of MYSQL is that it allows C-style backslash escapes
in string constants and replaces them with the actual character
(e.g. \n is converted to 0x0a). This causes round trip problems
if the escape is one of the allowed ones and a MYSQL error if it
isn't.

Disable the feature so that MYSQL follows the SQL standard.
2021-02-07 13:53:00 -08:00
John Ralls
fe4f9ed64a [test-backend-dbi] Fix copying hidden property.
So that it actually copies it to the *other* root account.
2021-02-07 13:50:29 -08:00
Micha Lenk
9386b276e5 Make prototypes static for autoclear unit test
With the explicit prototypes not marked as static unit test builds on Debian
Buster (using buster-backports) fail with

error: testing::internal::ParamGenerator<TestCase*> gtest_InstantiationAutoClearTestAutoClearTest_EvalGenerator_() was declared extern and later static [-fpermissive]

According to the comment preceding the declaration the only intent of the
explicit prototype (in newer versions of googletest implicitly defined by the
GTEST macros) seems to be to silence a warning which would cause a build
failure on Ubuntu 18.04 when using -Werror.

Builds on Debian unstable seem to build just fine without this explicit
declaration, hence I consider it safe to just drop it. However, builds on
Ubuntu 18.04 then fail (see above).

Making the prototypes as static should make both build environments happy.
2021-02-07 13:50:29 -08:00
Christopher Lam
0d196bfb65 Merge branch 'remove-scheme-deprecated-module' #891 2021-02-01 21:43:59 +08:00
Frank H. Ellenberger
f556ad35ef Merge branch 'maint' 2021-01-31 23:17:19 +01:00
John Ralls
12ad4fadae Bug 798101 - Do not #undef __STRICT_ANSI__
Remove defines and undefines for Windows, they were needed with
MinGW classic but are not with MinGW-w64.
2021-01-30 17:38:37 -08:00
Christopher Lam
d16f39046d Merge branch 'maint' 2021-01-30 07:13:32 +08:00
Christopher Lam
bbcffa3eca Remove deprecated scheme modules 2021-01-30 00:42:20 +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
2fa5cba250 Merge branch 'maint' 2021-01-25 22:25:20 +08:00
John Ralls
b66eab2583 Bug 798100 - Equity totals calculating incorrectly
Prevents creation of non-currency opening balance accounts.
2021-01-24 16:53:02 -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
Sebastian Ovide
49ce463aaa
sorting sources
I've did a small bash script that retrieve the sources from gnc-fq-dump and try to find one source that has the specific stock. At that point I've noticed that the sources returned by Finance::Quote have always a different order. Just wondering if it is done in that way intentionally (?)
2021-01-10 15:09:51 +00:00
Christopher Lam
c5e7406c9f [account.cpp] remove deprecated function 2021-01-04 08:46:09 +08:00
Christopher Lam
ebcb0bc478 [master] remove deprecated scheme functions 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
Christopher Lam
ca606e7694 [c-interface.scm] deprecate gnc:last-captured-error 2021-01-03 06:28:31 +08:00
Christopher Lam
f1c1fca023 [account.cpp][API] deprecate xaccAccountCountSplits 2020-12-28 09:48:06 +08:00
John Ralls
c8c58bf349 Add test_autoclear_SOURCES to the dist list for inclusion in the tarball. 2020-12-26 17:23:28 -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
Christopher Lam
455ae59a56 [app-utils] fix dependency chain 2020-12-24 22:51:08 +08:00
Christopher Lam
0510ecfe85 [c-interface] internal defines must be declared first
An internal (define) cannot be after a statement such
as (issue-deprecation-warning). This rule was strict in guile-2.2 but
relaxed in guile-3.0, hence, the mixed results in CI.
2020-12-24 22:08:44 +08:00
Christopher Lam
bf671d4fc7 [c-interface] Deprecate gnc:make-string-database
It's only used by date-utilities.scm

This removes the date-utilities -> c-interface dependency.
2020-12-23 23:58:09 +08:00
John Ralls
c2ba88d91d Add MAKE_LINKS to app-utils and qif-import scheme targets.
Needed to successfully build on Windows.
2020-12-13 16:57:48 -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
dcf90b98c0 [options.scm] use srfi-1
because list-index (used in options.scm) wants srfi-1 version rather
than the one in guile-core. the guile-core one crashes when editing options.
2020-12-09 21:54:26 +08:00
Christopher Lam
5bd65a6b22 [modularise] (gnucash locale) 2020-12-09 06:40:07 +08:00
Christopher Lam
59ec912928 [modularise] (gnucash app-utils) 2020-12-09 06:40:07 +08:00
Christopher Lam
0630c214f0 [options.scm] move gnc:options-fancy-date to business-options.scm
it needs gnc:fancy-date-info which is defined in business-options
2020-12-08 22:50:15 +08:00
Christopher Lam
51e3a65762 [options.scm] typo ref -> list-ref 2020-12-04 21:33:31 +08:00
Christopher Lam
a2ef6ed6a5 Use proper format syntax 2020-12-04 18:37:35 +08:00
Christopher Lam
854c117820 [trep-engine] move currency options into their own section
tidier, also includes backward compatibility with saved-reports
2020-12-02 18:46:25 +08:00
John Ralls
7a8a0f40b1 Fix missing space in warning message. 2020-11-29 10:59:25 -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
Christopher Lam
72982de588 Revert "[date-utilities] Convert reldate list into srfi-9 records"
This reverts commit 3be7935965.
2020-11-22 21:56:42 +08:00
Christopher Lam
8b5dd55dc4 Revert "[c-interface] deprecate gnc:make-string-database"
This reverts commit b67bf4b761.
2020-11-22 21:56:35 +08:00
Christopher Lam
b67bf4b761 [c-interface] deprecate gnc:make-string-database 2020-11-22 21:21:58 +08:00
Christopher Lam
3be7935965 [date-utilities] Convert reldate list into srfi-9 records 2020-11-22 21:14:13 +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
26fa239f89 Merge Christian Klein's 'auto-clear-tests' into maint. 2020-11-08 13:44:41 -08:00
Cristian Klein
69789b2b93 [auto-tests] Stick to CodingStandard for member variables 2020-11-08 09:58:57 +01:00
Cristian Klein
f26215feae [auto-tests] Fix misspelling 2020-11-08 09:58:17 +01: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
Robert Fewell
65b7b8c4a2 Section help on windows not working
Key and group names are case sensitive and in the gnucash-help.hhmap
file the section name is [MAP] so change gnc-help-utils.c to match
2020-11-06 13:05:42 +00:00
Cristian Klein
e5378b2048 [auto-clear] Make test more future-proof with GoogleTest 2020-10-30 09:42:05 +01:00
Cristian Klein
982cf86deb [auto-clear] Fix test with googletest 1.8 2020-10-30 09:42:05 +01:00
Cristian Klein
9d4c0b05db [auto-clear] Improve #include style 2020-10-30 09:42:05 +01:00
Cristian Klein
1cf7defee8 [auto-clear] Address feedback 2020-10-30 09:42:05 +01:00
Cristian Klein
9bf550d38f [auto-clear] Include test for ambiguous cases 2020-10-30 09:42:05 +01:00
Cristian Klein
5cd777b673 [auto-clear] Fix test: Add xaccAccountBeginEdit / xaccAccountCommitEdit 2020-10-30 09:42:05 +01:00
Cristian Klein
2faecb2074 [auto-clear] Avoid testing ambigous auto-clear 2020-10-30 09:42:05 +01:00
Cristian Klein
a1806a2f94 [auto-clear] Fix model 2020-10-30 09:42:05 +01:00
Cristian Klein
51715e454c [auto-clear] Add tests 2020-10-30 09:42:05 +01: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
Christopher Lam
78c8b03c5e [window-autoclear.c] cleanup, optimize, prevent UI lag
abort:
1. if too many splits lead to >1,000,000 reachable amounts
2. if the end_balance is the same as cleared_balance

also:
- g_free lists properly
- move knapsack algorithm to gnc-ui-balances.c
- show newly cleared splits in a new register: "Cleared Transactions"
- remove unneeded #includes
2020-10-23 09:11:29 +08:00
Robert Fewell
3c5066feb4 Change source files option-util.* for spaces and tabs 2020-10-22 14:30:46 +01:00
Robert Fewell
c11f4db96e Bug 345924 - Report options 'Reset Button' always flags changes
If a report is loaded with default settings and the 'Reset button' is
pressed the 'OK/Apply' buttons will be enabled which should not happen
as there are no changes to be made.

Fixed by resetting the changed flag on options load and then comparing
the current value to the default one when the 'Reset button' pressed.
2020-10-22 14:26:50 +01: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
Bill Nottingham
06110e2abd Fix warning about misleading indentation from recent gcc.
Patch by <law@redhat.com>
2020-10-15 08:38:00 +08:00
Geert Janssens
e8c321d954 Drop as dependency from gnc-module 2020-10-10 12:32:58 +02:00
Christopher Lam
39a6704169 [options.scm] rename new-owner-report "Links" to "Transaction Links" 2020-10-07 19:11:12 +08: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
44fc52f5c6 Fix unnecessary copy in range-for loop
Flagged by new clang Apple version 12.
2020-09-25 12:31:13 -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
Robert Fewell
edaa0d7eea Fix some spaces on blank lines is source files 2020-09-18 16:13:35 +01:00