Commit Graph

1437 Commits

Author SHA1 Message Date
Christopher Lam
128c8d6f88 [utest-Transaction] add tests for xaccTransGetReadOnly 2021-09-25 13:27:56 +08:00
Geert Janssens
8ea52ae212 GSettings - run data model transations while setting up
This makes sure all schema changes are in effect before
the first consumer can query them. For example this will
prevent a one-time re-occurrence of the tip of the day dialog
the first time the new migrations are run.
2021-09-22 15:44:30 +02:00
Christopher Lam
c0736a1a04 Merge branch 'maint-leaks' into maint #1135 2021-09-22 21:06:25 +08:00
Geert Janssens
f1802b6fdf GSettings Upgrade - add code to migrate settings
The rules for migration are read from an xml file. This file was
prepared in a previous commit. Future settings 'data model' changes can
reuse this code by simply adding migration rules in the xml file.

This replaces the hardcoded rules that were currently in place to
migrate a few settings from 2.6 and older to 3.0. These rules are no
longer meaningful as we require users to migrate from one major release
series to the immediate next one. So by the time the new migration rules
in this commit are applied by users they should already have run gnucash
3.x at least once. That run should have taken care of the pre-3.0
migration actions.
2021-09-21 17:10:56 +02:00
Geert Janssens
f21c7b6e90 GSettings - define old prefix and check settings for the presence of both prefixes while normalizing 2021-09-21 17:10:56 +02:00
Geert Janssens
a203c5b2d5 GSettings - drop logic to relocate our settings
This was ported from GConf, but GSettings doesn't work that way.
Settings locations are defined at compile time and can't be
relocated at run time (unless you make all of the settings
explicitly relocatable. That however is not how GSettings is meant to be
used.)
2021-09-21 17:10:56 +02:00
Geert Janssens
d1113a4534 GSettings - build as cpp 2021-09-21 17:10:56 +02:00
Geert Janssens
02fbf217f6 GSettings Upgrade - change schema prefix from org.gnucash to org.gnucash.GnuCash
The latter is the prefix format prescribed by gsettings itself. The former never
was an issue until flatpak decided to not accept the shorter prefix when
requesting a settings migration from host system to flatpak sandbox.

In order to allow for migration, keep the old schema around in
org.gnucash.GnuCash.deprecated.gschema.in

While we're at it, make the new prefix an internal implementation detail.
There's no need for it to be visible to the rest of the gnucash code.
2021-09-21 17:10:55 +02:00
Geert Janssens
6674b1bb6b Cleanup - minimal glib=2.56.1 - drop all conditionals on older versions 2021-09-21 17:10:55 +02:00
Christopher Lam
87b61bf6fb [account.cpp] GValue must be unset in old functions
GValue in DxaccAccount[Set|Get]Currency is unset correctly.

However dxaccAccountGetPriceSrc and dxaccAccountSetQuoteTZ reuse a
static char* therefore the latter must be used carefully before
calling the function again. The functions are tested in
4309469730.
2021-09-19 11:28:25 +08:00
Christopher Lam
86cf327f09 [account.cpp] GValue containing string must be unset
already have comprehensive tests in 15852031d
2021-09-19 11:28:25 +08:00
Christopher Lam
c8a53c54f2 [account.cpp] refactor gnc_account_get_map_entry
Have comprehensive tests in a5d101d1b
2021-09-19 11:28:25 +08:00
Christopher Lam
4309469730 [utest-Account] test old dxaccAccount* functions
dxaccAccountGetPriceSrc and dxaccAccountGetQuoteTZ.

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

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

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

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

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

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

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

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

The rewrite left out one test.  This was most obvious in the dummy
transaction used to enter a new transaction into an account.
xaccSplitGetOtherSplit never returned an "other split" for this
transaction.  It turns out the old code was broken too, but
it worked for this case by coincidence.
2021-09-06 02:45:37 -04:00
jean
4e9fe0a4d1 Add missing function to mock account 2021-09-05 17:52:34 -07:00
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
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