Commit Graph
1369 Commits
Author SHA1 Message Date
Sherlock 4d6f19a0f9 Bug: Missing account event
An account event should be generated for the original account if a lot is moved to a different account in xaccAccountInsertLot() as it is, if the lot is removed in xaccAccountRemoveLot().
2026-07-14 14:19:24 -07:00
Sherlock b1efe0763c The lot scrubber should exclude stock-split splits. 2026-07-14 14:19:24 -07:00
Sherlock 0aac4438e7 Bug: Gain/Loss displayed in "Splits free" is not correct
The gain/loss displayed for splits in the "Splits free" is historical.  It may or may not be correct.  Instead, the gain should be calculated against the selected lot for appropriate splits.

Implements xaccSplitLotCapGain() to obtain the gain for the selected lot.
2026-07-14 14:19:12 -07:00
Sherlock 31978c1b4d Only show the “Show stock split adjusted amounts” checkbox when there are stock splits
Added has_stock_split field to Account private.  This flag is set to true when  xaccAccountRecomputeBalance() detects a stock-split split otherwise it is false.  Defined and declared xaccAccountHasStockSplit() for use by the Lot Viewer to whether to display the check box.
2026-07-09 01:17:17 -07:00
Sherlock 28cdb77a0b Improve code reuse 2026-07-09 01:15:59 -07:00
Sherlock 1e654412ab use adjusted_amount in place of amount
impacts gains, lots, and policy
2026-07-09 01:15:59 -07:00
Sherlock b1eb12f558 Determine the adjusted_amount for each split in an account
The algorithm to determine the current adjusted_amount is implemented in xaccAccountRecomputeBalance().

If the balance or new balance is nil, the stock-split split is ignored as it isn't possible to calculate the stock-split ratio.  This means the prior split adjusted amounts will not reflect the true current adjusted amounts.  These are conditions that should be raised appropriately to the user with sufficient details for resolution.
2026-07-09 01:15:59 -07:00
Sherlock 254ec4b4d0 Improve stock-split type detection
Noted split_type field in Split exists but is not used...

Reset split_type field's data type to hold the type of the getter.
Implemented xaccSplitIsStockSplit() abstraction to limit the split type string reference to Split.cpp and propagated it's use.
2026-07-09 01:12:49 -07:00
Sherlock 0d5c74b868 Add adjusted_amount field to split
The adjusted_amount field of a split will hold the stock split adjusted amount.  The adjusted amount is initially the same as the original amount.  When the account balances are recomputed and a stock-split split type is encountered, the ratio of the stock split will be applied to the preceding splits adjusted_amounts.  If there are no stock splits in the split's account, the adjusted amount remains the original amount.
2026-07-09 00:48:41 -07:00
John Ralls dc03a84c33 Merge Christopher Lam's 'qof-ctor-dtor' into stable. 2026-06-23 16:15:03 -07:00
John Ralls 7f4e8c29e0 Merge Noah Noerr's 'online-id-engine-accessors' into stable. 2026-06-23 14:55:41 -07:00
Noah R 3e98c5d8c8 [engine] Add first-class online_id accessors for Split and Account
Promote the OFX/HBCI online_id to named engine accessors:
  xaccSplitGetOnlineID / SetOnlineID / HasOnlineID
  xaccAccountGetOnlineID / SetOnlineID
The getters return an instance-owned const char* (mirroring
xaccTransGetDocLink / xaccTransGetNotes), so the existing
add_methods_with_prefix auto-wrapper exposes them in the Python bindings
with no .i changes and no %newobject.  They write to the same engine KVP
slot ("online_id") the desktop importer uses, so there is no data or
behavior change.

With the accessors in place the gnc_import_*_online_id wrappers in
import-utilities are redundant, so replace every call site (OFX,
AqBanking, and the generic matcher/backend) with them, delete
import-utilities.cpp, and drop the online_id declarations from
import-utilities.h (its importer preference-key macros are retained).

- The engine getters return an instance-owned const char* instead of a
  g_strdup'd copy, so callers no longer free the result; the affected
  locals are retyped const and their g_free()s dropped.
  hash_account_online_ids() g_strdups before inserting, since its hash
  table owns its keys (g_free key-destructor).
- xaccAccountSetOnlineID(acc, "") clears the slot, matching the OFX
  "delete the online_id" intent (the old wrapper stored an empty string).
- Drop the two unused wrappers: gnc_import_set_trans_online_id (marked
  "Not actually used") and gnc_import_trans_has_online_id (no callers).
- Add xaccSplitGet/SetOnlineID to the Split gmock so test-import-backend
  links without import-utilities.
2026-06-21 16:43:03 -07:00
Noah R 222714d764 [engine] Remove the unused Transaction online_id property
The "online-id" GObject property on Transaction (KVP slot "online_id")
was vestigial: GnuCash records the OFX/HBCI import identifier on the
bank/asset Split, not on the Transaction.  Drop the property, its
get/set_property cases, the xaccTransClone special-case that cleared it,
and the corresponding test_trans_kvp_properties coverage.
2026-06-21 16:35:56 -07:00
John Ralls 32a6868f52 Merge Noerr-Noah's 'bug-split-setparent-kvp-slots' into stable. 2026-06-21 15:41:47 -07:00
Noah R ea93d42f58 Bug 799777 - xaccSplitSetParent: keep a reparented split's KVP slots
When an already-committed split is moved to another transaction with
xaccSplitSetParent(), the split was marked dirty *after* the old
transaction was committed.  trans_cleanup_commit() only drops a
moved-out split from the old transaction's split list when the split is
dirty at that commit, so the still-clean split was left dangling in the
old transaction's split list.

On the SQL/DBI backends, destroying the now-vacated old transaction then
deleted the moved split's KVP slots (online_id, cap-gains links, ...) by
the split's own GUID, even though the split now belongs to another
transaction.  The split's native columns survive -- they are rewritten
under the new tx_guid -- but its slots are lost; in some sequences the
save fails outright with "UNIQUE constraint failed: transactions.guid".
The XML backend is unaffected because it re-serializes the whole book.

Mark the split dirty before committing the old transaction so
trans_cleanup_commit() removes it from the old transaction's split list,
as that code already intends.  This is a no-op for split creation (the
overwhelmingly common caller), where the prior parent is NULL.

Add a DBI round-trip regression test (sqlite3, and mysql/pgsql when the
TEST_*_URL variables are set): seed a split carrying an online_id, save
and reload, reparent it onto another transaction, destroy the old
transaction, then save and reload again and assert the online_id
survived.
2026-06-21 15:23:08 -07:00
John Ralls 59f0de826b Merge Vincent Lucarelli's 'finnhub into stable. 2026-06-21 14:50:08 -07:00
Vincent Lucarelli 21d861338e Add new Finance::Quote source Finnhub.io
Free API key (personal/non-professional use) available at https://finnhub.io.
Set FINNHUB_API_KEY environment variable to API key to use this source.
As of June 2026, free tier API limit is 60 API calls/minute.
2026-06-21 14:47:09 -07:00
Christopher Lam 54693abe30 [gnc-commodity.cpp] gnc_quote_source_num_entries speedup
previously was allocating a vector copy, and measuring the distance
manually. return std::list size() which is maintained internally.
2026-06-19 16:30:20 +08:00
Christopher Lam 368b2894b5 [guid.cpp] plug char* guid_to_string leak
it seems unused however
2026-06-16 19:16:49 +08:00
Christopher Lam fab8a3520a eradicate QOF_TYPE_COLLECT
it's unused...
2026-06-15 08:43:39 +08:00
Christopher Lam 56467754f1 [qofid.cpp] use ctor/dtor for QofCollection
which will make it easier to construct in-place in book->hash_of_collections
2026-06-15 08:43:01 +08:00
Robert Fewell 8f10b4f864 Couple of spelling errors in gnc-accounting-period 2026-06-11 11:42:25 +01:00
Christopher Lam 13112ab809 rename gmock-qofbook.h and gmock-Split.h to .hpp 2026-06-10 09:58:19 +08:00
Christopher Lam 63917e0824 [qofbook.cpp] move _QofBook definition from qofbook.h to qofbook-p.hpp
to make it opaque

and change:
- qofbook.h to .hpp
- test-qofbook.c to test-qofbook.cpp
2026-06-10 09:58:19 +08:00
Christopher Lam 8b6d93eb87 [test-qofbook.c] use getters instead of accessing QofBook members 2026-06-10 09:46:39 +08:00
Christopher Lam db6cac5b82 [qofbook.h] add further getters/setters for QofBook 2026-06-10 09:44:16 +08:00
Christopher Lam f36532131b ensure boost::regex is compiled at startup
instead of per-call
2026-05-28 17:07:19 +08:00
John Ralls 2911a0cce3 Bug 797384 - Gnucash doesn't handle commodity prices with big...
numerator/denominator properly

- Use GNC_HOW_DENOM_REDUCE | GNC_HOW_RND_ROUND to preserve precision while
avoiding overflows.

- Rearrange the function's tests to perform only one division or
multiplication instead of unconditionally dividing

- Rename the from_ and to_ variables to p(rice)1 and p2 to reduce
conflation with the input from and to.
2026-05-25 11:32:19 -07:00
John Ralls ec4a85a56c Correct the Doxygen doc for qof_instance_get/set_kvp. 2026-05-22 15:47:40 -07:00
Christopher Lam bbb80105ff [gnc-aqbanking-templates.cpp] fix incorrect setter, free GList* 2026-05-22 21:15:29 +08:00
Christopher Lam 55856c63dd [gnc-budget.cpp] null check arguments *before* accessing them 2026-05-22 21:15:27 +08:00
Bruce Schuck 4ff491b565 Removed AEX from list of commodities.
euronext.com is now using JS based anti-webscraping.
2026-05-10 10:49:32 -07:00
John Ralls d4c6101c6c Return immediately from qof_book_destroy if hash_of_collections is null.
If qof_book_destroy is called on a QofBook* freshly created with
qof_book_new (usually because it was used to create a session that now
must be destroyed) it would try to empty the non-existent hash tables,
crashing.
2026-04-22 11:24:18 -07:00
John Ralls d42e2c5e40 Apply -Wall -Werr -Wmissing-prototypes to C++ compilation on Windows.
And fix the resulting errors.
2026-03-29 13:46:27 -07:00
Christopher Lam 3d4f19f830 [gnc-date.cpp] fix ifdef conditional, and comment 2026-03-17 09:10:19 +08:00
Christopher Lam 06c7f4bd3f [gnc-datetime.cpp] fast_iso8601_utc_parse: precompute length
because std::from_chars is UB if the string is less than 4 bytes
therefore end_ptr would point to unallocated memory.
2026-03-17 09:10:19 +08:00
Robert Fewell b02612c437 Bug799722 - Inconsistent wording: Bill and Invoice
There is some inconsistency with the wording of the invoice menu
entries when say a bill is displayed, like 'Jump to Invoice' when it
would be 'Jump to Bill'. Whilst looking at this, further places where
this could be a problem was highlighted so this commit changes entries
to 'Business item'.
2026-03-13 16:05:36 +00:00
Robert Fewell 62af7f0d6d Bug 799734 - mapped OFX income account not listed
Change the Import Map Editor to look for the KVP slot
"ofx/associated-income-account" so it can be listed. The account
reference stored is a GUID so add a function to retrieve that so the
existing gnc_account_delete_map_entry function can be used to remove it.
2026-03-13 09:26:22 +00:00
John Ralls 1fda575c5b Bug 666536 - smallest fraction of KRW is invalid 2026-02-27 13:14:20 -08:00
Christopher Lam 47938d1a2c [gnc-date.cpp] gnc_date_interval_format localisable with ICU 2026-02-13 21:58:01 +08:00
Stefan Koch e1bbb9bb7b Bug 798873 - Crash when scrubbing after "undoing” changes
Fix double delete in qof_instance_kvp_remove_guid and remove vestigial glist support.

In the KvpValue::Type::FRAME case if the guid matches, it does both:
            delete inst->kvp_data->set_path({path}, nullptr);
            delete v;
Where earlier the v was set to be:
    auto v = inst->kvp_data->get_slot({path});
The second delete is a duplicate of the first and should be removed.
2026-01-30 09:50:21 -05:00
Stefan Koch 52bbcf72c5 Fix innocuous bug in qofinstance idata property. 2026-01-30 09:50:21 -05:00
Christopher Lam 0b4f14e107 [Transaction.cpp] use g_list_copy_deep avoiding g_list_append 2026-01-27 23:43:49 +08:00
Christopher Lam d64c8c8d59 [account.cpp] remove unused static var 2026-01-27 23:43:44 +08:00
Christopher Lam 3a2ac526a6 [gnc-commodity.cpp] improve gnc_commodity_compare
ensure it is a stable sort
2026-01-24 23:49:30 +08:00
John Ralls e5fe2f3e0e Merge Stefan Koch's 'sk-unittest-qofid' into stable. 2026-01-17 17:11:27 -08:00
Stefan Koch 113af56272 fixup: Review comments about style of code. 2026-01-15 13:14:36 -05:00
Stefan Koch 7f0d66d439 fixup: Add the new test-qofid.cpp file the the source distribution. 2026-01-15 13:00:52 -05:00
Stefan Koch be5933a1ec fixup: Remove memory leaks in the test code. 2026-01-15 11:52:59 -05:00
Stefan Koch 0e3853bfb7 Fix undefined behaviour in collection_compare_cb function.
The collection_compare_cb function set the user_data pointer to point to a local variable
of the function.  That pointer is then used in the (only) calling function
qof_collection_compare to make decisions.  This is undefined.  It is likely not an actual
problem because the stack depth of the qof_collection_foreach followed by
collection_compare_cb is deeper than the qof_collection_get_data call (and others
in between if any) that the stack data user data stays uncorrupted.

But, it is undefined behavior, and could cause really subtle bugs if these there are code
changes that have deeper stack between the setting and using.

Also, using this local variable is not necessary, the qof_collection_compare function
already  sets up a variable local to its scope for this that the collection_compare_cb can
use directly.

This commit removes the local (to collection_compare_cb) variable and uses the one setup
in qof_collection_compare.

The full coverage test for qofid.cpp passed before and after this change.
2026-01-15 08:52:50 -05:00