Use the existence of void timestamp instead of void reason to
determine if a transaction is voided. A user can void a transaction
without providing a reason.
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().
Pasted, duplicated, or reversed stock split transactions and pasted or duplicated stock split splits do not maintain the "stock-split" type. They become "normal" split types.
As we only have two split types, "normal" and "stock-split", added a flag to FloatingSplit for a stock split.
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.
session_begin() runs dbi_library_test() (Bug #611936) on every open to
detect a libdbi/-ffast-math miscompilation that mangles 64-bit values.
The probe CREATEs, INSERTs into, SELECTs from and DROPs a temporary
table, so it needs write privileges on the database -- even for
SESSION_READ_ONLY. A least-privilege, read-only database user therefore
cannot open the book at all: the temporary-table create fails and
session_begin returns ERR_SQL_DBI_UNTESTABLE.
The defect the probe guards against is on the write side of libdbi, so it
can be neither triggered nor detected by a read-only session, which never
writes. Skip the probe when the session is opened SESSION_READ_ONLY, at
the two call sites a read-only open reaches (the SQLite session_begin and
the shared MySQL/PostgreSQL session_begin); the third call site is inside
the create branch, which read-only never enters. The write-capable modes
(NORMAL_OPEN, NEW_STORE, NEW_OVERWRITE, BREAK_LOCK) still run the probe
unchanged.
This lets a SELECT-only database user open a book read-only through the API.
qof_session_end() is documented to release the session lock and shut the
backend connection but it does not release the session lock in all scenarios
(BUG). qof_session_end() looked the backend up via qof_book_get_backend().
The book's backend pointer is only set by load() or a data-changing save() (an
empty book's save() early-returns before attaching it); begin() sets only the
session's own m_backend. So a session that creates a store and ends it without
loading or making a real change had a backend on the session but not on the
book: end() found none, skipped session_end(), and never released the lock --
it was only released later at destroy().
Because the fault is in backend-agnostic engine code it affects every backend
that locks at begin(): the SQL/DBI backends leave a stale row in the gnclock
table, and the XML/file backend leaves an abandoned <file>.LCK sentinel (with
no data file, since XML data is only written at save). The store then appears
locked to the next opener.
End the session's own backend (m_backend, always set at begin()) instead. It
already equals the book's backend whenever the latter is set, so the change is
a no-op for loaded/saved sessions and additionally covers the
created-but-not-attached case.
Add regression tests for both backends, each of which begins a create-mode
session, ends it without a data-changing save, and checks the lock is gone:
- test-backend-dbi-basic.cpp (test_dbi_new_store_end_releases_lock): reopens
the store and asserts it is not ERR_BACKEND_LOCKED.
- test-load-backend.cpp (test_new_store_end_releases_lock): asserts the XML
<file>.LCK lockfile has been removed.
file has backslash just before final quote in a quoted field
https://bugs.gnucash.org/show_bug.cgi?id=799774
Added a checkbox to the "File Format" section of the "Import Preview" step
of the CSV Import Assistant. This checkbox is labeled "Enable escape character"
and is enabled by default. If this checkbox is not enabled, GncCsvTokenizer
will insert an escape character (backslash) before any escape found in the
input which will prevent boost::tokenizer with escaped_list_separator from
processing this backslash as part of an escape sequence.
Ensured that saved import settings that have no current value for the
new "EnableEscape" field will set the "Enable escape character" checkbox.
Changed the test framework in GncTokenizerTest to specify whether escape
characters are enabled, and added test cases for escape characters disabled.
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.
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.
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.
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.