| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
- Add some tests from comments to pull request #2361.
- Fix decimal separator in earlier added tests.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Copy amount quantity before rounding.
- Fix `amount_t::roundto(int)`.
- Transform `balance/testRound` into `balance/testRoundto`.
It was a mix of `round` and `roundto` operation with unclear purpose
and was relying on `in_place_roundto` behavior modifying all copies.
There is no unit tests for balance `round` and `unround` any more.
Closes #2362
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Multiprecision rational created from a double value may have large power
of 2 denominator since fractional decimal numbers can not be represented
as binary floating point numbers. It leads to failed assertion when
result is compared to a value converted directly from strings.
Use integer multiprecision arithmetics to round numbers to ensure
proper denominator. Inspired by python gmpy2 package
<https://github.com/aleaxit/gmpy/blob/3e4564ae9d/src/gmpy2_mpq_misc.c#L315>
The change makes `roundto` symmetric for positive/negative arguments.
Halves are rounded to nearest even. Rounded away from zero are discussed
in #1663 and it may be achieved with minimal modification.
- See #2329
- Closes #1983
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When the account name is longer than the --account-width (default 36),
the amounts stop aligning:
2023/01/01 Transaction with long account names
Assets:Very:Long:Account:Name:That:Will:Push:The:Amount -10 ABC
Assets:Another:Long:Account:Name:That:Will:Push:The:Amount -10 ABC
Expenses:Short 20 ABC
One can set a larger --account-width, but that is not a great solution
for cases where you have only a few accounts with problematically long
names. Instead, keep the current account width wherever possible, but
when an account name is longer than the account width, account for that
and still align the values:
2023/01/01 Transaction with short account names
Assets:Short -10 ABC
Assets:Short -10 ABC
Expenses:Short 20 ABC
2023/01/01 Transaction with long account names
Assets:Very:Long:Account:Name:That:Will:Push:The:Amount -10 ABC
Assets:Another:Long:Account:Name:That:Will:Push:The:Amount -10 ABC
Expenses:Short 20 ABC
This is similar to hledger's behavior.
|
|
|
|
| |
Fixes #2324
|
| |
|
|
|
|
|
|
|
| |
Part of the expr_t::compile() process is to store the current scope, but
In post_t::add_to_value that scope is temporary and on the stack.
Restore the original context after that process is complete.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add failing test for use case
TBH I don't know what I'm doing here, but this seems to fail for the
right reasons enough to reflect the parser bug here.
* Append to the ident on a closing brace ')'
When parsing the automated rule, a scanner reads the line left-to-right
char-by-char. The default behaviour is to append the char under the
cursor to some `ident` string. When the cursor is on a ')', it skips the
default handling and switches into some special handling: it tries to
test the string it's reading if it's one of the keywords it knows, to
select which type of token just got scanned. If what was scanned is not
a known token, it defaults to `token_t::TERM` and returns a new token
with the currently accumulated `ident` as a `token_t::TERM`. Issue is,
since it skipped the appending to do some custom handling, the
`token_t::TERM` will always be without its closing brace. The scanner
needs to append the character under the cursor if it's falling through
to default processing.
* fix test case
- ensure proper spacing for the posting to have an amount
- ensure the posting balances against an account
- the meaning of the number after `->` is the exit code
* undo wrong approach
* consume_next if unbalanced_braces
* how this can be extended
|
| |
|
| |
|
|\ |
|
| | |
|
|/
|
|
| |
by using argparse and pathlib and removing Python 2 specific code.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
The manpage documents `=regex` as equivalent to the `note regex` query
syntax, but the former does not actually work as the parser only handles
an equals sign in the case of `tag type=dining` syntax, and doesn't
handle the case where an equals sign starts a note query.
Fixing this does break queries like `tag type = dining` with spaces
around the equals sign, but that syntax was not intended or documented.
Closes: #2275
|
| |
|
|
|
|
|
|
| |
This adds a new item flag, `ITEM_INFERRED`, that differentiates
generated items from bucket items. This makes them show up as
related items in reports.
|
|
|
|
|
| |
Bugs #777 and #2207 were fixed by commit 49cf3323a ("Change a use of
is_realzero to just is_zero"). Let's add test cases.
|
| |
|
| |
|
|
|
|
| |
[skip ci]
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Setters for types wrapped in boost::optional, such as item_t::note were
broken, e.g. setting a note on a transaction resulted in garbled data
that would cause Python to throw utf-8 errors when retrieving the note.
(But setters that accessed strings directly, e.g. "payee" on a transaction
worked fine.)
This change alters the from-python conversion for optional-wrapped
types based on the example at
https://stackoverflow.com/questions/36485840/wrap-boostoptional-using-boostpython
and a test case to verify the behavior.
|
|
|
|
|
|
|
| |
Ledger's expression parser considers quoted_rfc4180 to be an
amount (quantity 4180 of commodity "quoted_rfc").
Fixes #2007.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
1. Remove references to modules (exceptions, StringIO) no longer needed for Pythn3
2. Use assertEqual instead of assertEquals
3. Clear journal files with a close_journal_files() function that uses the then-current underlying python_session pointer. Calling session.close_journal_files() sometimes leads to segfaults because python_session has changed after it was injected into the python module (as "session") on module startup.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
| |
to fix failing tests on Darwin, where /tmp is a symlink to /private/tmp
and the tests fail as ledger reports filenames with the symlink resolved
to /private/tmp, but the tests expect files with /tmp.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In `compare_items` if `sort_order` is a top level expression, it has
no context and `get_context()` method returns the null pointer. To see
this, run
$ ledger -f test/input/demo.ledger --sort display_amount reg --debug scope.symbols
and there will be many lines like
[DEBUG] Binding scope 0 with ...
In such case making a reference to the context is an undefined
behavior (honestly the dereferencing itself feels quite problematic,
but many compilers just run without any complaints) and could
potentially cause segfaults.
Therefore, we change to use only the grandchild scope (`left` or
`right`) for `find_sort_values` here. Note that it may seem to be more
appropriate to use `report` here for the parent scope. However, in
`find_sort_values` which is called right after, the `report` scope is
always bound to this scope. So we only use grandchild scope to avoid
unnecessary operations.
Fixes #2069.
|
|
|
|
|
|
|
| |
Here `comm` could be a null pointer (the new test regress/2057 shows
such a case). So test it before dereferencing to avoid segfault.
Re: #2057
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Ensure the path of file to include in `instance_t::include_directive`
is always an absolute path.
Previously when the journal file is given through stdin, we prepend a
"./" to the filename to include. However, in Boost >= 1.77,
`path::normalize` strips the leading "./" [1]. Our `resolve_path`
function calls `normalize` and thus now it returns "file" for "./file"
instead of the previous "./file".
This change causes a failing test regress/BF3C1F82-2 [2], and also
breaks the `include` directive for stdin input:
$ touch file-to-include
$ echo "include file-to-include" | ledger -f - reg
gives
While parsing file "", line 1:
Error: File to include was not found: "file-to-include"
Therefore, we change to prepend the `context.current_directory` to
make the filename absolute in this case as well. The test
regress/BF3C1F82-2 is also updated to match the new output.
Fixes #2075.
[1] https://github.com/boostorg/filesystem/commit/16bd89b7c0398d0dc5904148a865ef3fc3ece7ec
[2] https://github.com/ledger/ledger/issues/2075
|
|
|
|
| |
A better fix for this issue is needed, however.
|
|
|
|
|
|
|
|
| |
This makes it safe to compare results to -1 to indicate EOF,
regardless of whether char is considered signed or unsigned;
and so eliminates compiler warnings on platforms such as ARM.
Fixes bug #2058.
|