| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In `ledger xml` export, include the `<posting>`-specific payee (from the
`Payee:` tag) as `<payee>`. This data is already included under
`<metadata>` as `<value key="Payee">`, but that is more specific to
Ledger's implementation; if in the future there is another way to set
the payee (or perhaps an option to have the Payee tag in one's own
language), that field wouldn't be a reliable method of getting this
info.
Example:
2022-01-01 Transaction-level payee
a 10
b ; Payee: Posting-level payee
Relevant XML output:
<transaction>
<date>2022-01-01</date>
<payee>Transaction-level payee</payee>
<postings>
<posting>
<account ref="0000558defd6f260">
<name>a</name>
</account>
<post-amount>
<amount>
<quantity>10</quantity>
</amount>
</post-amount>
<total>
<amount>
<quantity>10</quantity>
</amount>
</total>
</posting>
<posting>
<payee>Posting-level payee</payee>
<account ref="0000558defd6f960">
<name>b</name>
</account>
<post-amount>
<amount>
<quantity>-10</quantity>
</amount>
</post-amount>
<note> Payee: Posting-level payee</note>
<metadata>
<value key="Payee">
<string>Posting-level payee</string>
</value>
</metadata>
<total>
<amount>
<quantity>0</quantity>
</amount>
</total>
</posting>
</postings>
</transaction>
|
|
|
|
|
|
| |
to ensure access macros are only called on "legacy" unicode string
objects that are "ready".
See https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_READY
|
|
|
|
|
|
| |
Add test to python/demo.py
Fixes #2132
|
|
|
|
| |
Add test to python/demo.py
|
| |
|
|
|
|
|
|
|
|
| |
replacing it with APIs introduced in Python 3.3 to ensure ledger's
Python bindings continue to function when the legacy Unicode API is
removed in Python 3.12.
For details see https://docs.python.org/3.10/c-api/unicode.html
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, `ledger python -- -c 'raise RuntimeError'` would terminate
messily via SIGABRT, printing the following:
terminate called after throwing an instance of 'int'
[1] 2151711 abort (core dumped) ledger python -c 'raise RuntimeError'
This change makes the python subcommand throw a standard C++ exception
rather than just a plain int, which is never caught and triggers the
SIGABRT. Now, the process prints the uncaught Python exception as
usual and then exits with exit code 1.
|
| |
|
| |
|
| |
|
|
|
|
| |
Fixes #2061.
|
|
|
|
| |
Fixes #2049
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
it is currently not required but set. Incidentally, calling file_size()
on a bash pipe e.g. /proc/self/fd/11 fails with:
Error: boost::filesystem::file_size: Operation not permitted: "/proc/self/fd/11"
when executing ledger as
ledger -f <(cat journal)
|
|
|
|
| |
This reverts commit 7baa0efd71896711e563feb957926433f529d892.
|
| |
|
|
|
|
| |
closes 1948
|
|
|
|
|
|
| |
totals, not amounts"""
This reverts commit c99a4b03320242d3d5a6d64f73f8581fe5ea2306.
|
|
|
|
|
|
| |
rendering"""
This reverts commit bc45e0205d23f5a8f2e3e389195daa85f4b07ec0.
|
|
|
|
| |
This reverts commit 7f78cadea4a2359f1f53ce9c0c66b6d3fafd81c4.
|
|
|
|
|
|
| |
amounts""
This reverts commit 1600ee1f64f659b151c1c873d478baa1bdab89f2.
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While the current formula works for positive numbers, negative numbers
are incorrectly represented.
One of the issues comes from the fact that floor(x) < x for every x.
`amount_t precision` will always be a non negative number and the code
that attempts to fix the issue for negative number will never run.
If we truncate the number instead, the current formula works for both
positive and negative numbers without making negative numbers a corner
case. So let's do that.
Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com>
|
|
|
|
|
|
|
|
| |
Handle files that don't end with a new line. Throw an error when the buffer
size is exceeded.
Fixes #516
Contributes to #1149
|
|
|
|
|
|
|
|
| |
We were previously relying on an indirect include within Boost headers. We're
using scoped_ptr which is defined in <boost/smart_ptr/scoped_ptr.hpp>.
Bug: https://bugs.gentoo.org/790176
Closes: https://github.com/ledger/ledger/issues/2030
|
|
|
|
|
|
|
| |
Notes were already being escaped. The filename, the transaction code,
the payee,, postings' account names, and postings' cost expressions
were not. Everything else the lisp report prints appears to be a
number or a constant-valued non-string token for Lisp.
|
|
|
|
|
| |
An amount may have a (single) leading minus sign, but none after that.
Bug #2001 (and #1809).
|
|
|
|
| |
Also fix end-of-command boundary checks for keywords "at", "to", etc.
|
|
|
|
|
|
|
| |
Windows uses UTF-16 for command line arguments, so use boost::nowide
to convert to UTF-8.
Fixes #1986
|
| |
|
|
|
|
| |
Fixes #1905
|
|
|
|
|
| |
Payees declared on posting's metadata are now validated with `--check-payees`
option. Also, their aliases are now considered on reports as well.
|
| |
|
|
|
|
|
| |
This changes the error reported when a transaction with no amount is
imported.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit 501fbc08ae5493db77bb34f4c4fbe1f3a3bc14e3 changed the behavior
of this function to not return the "equal" result (==0) from the
recursive call. Previously, the function returned the result of the
recursive call unconditionally.
The current behavior causes an assertion error for certain
postings. The regression test added in this commit shows such a
posting.
I found through Travis CI that the old behavior was incomplete and
caused unstable orderings, so reverting to the old behavior doesn't
work. Instead, this change adds a fallback: If the recursive call that
compares the prices numerically returns "equal", then compare the
prices with their original commodity as a tie breaker.
This commit does not change any existing ordering, it only adds
deterministic ordering in a case that currently triggers an assertion
error.
This fixes issue #1998.
|
|
|
|
| |
also add unit tests
|
|
|
|
|
|
|
|
|
|
|
| |
Ledger is treating balance assignments that have a 0 diff as having
a null posting, leading to the posting being auto-balanced and
therefore causing incorrect values to be returned for the transaction.
I fixed this by just making the posting equal to amt - amt (0 in the
right commodity).
Fixes #1942
|
|
|
|
|
|
|
|
|
|
| |
Commit 557ab32 ("Expose a new utility function for balances:
sorted_amounts") split out some code into a separate function.
Unfortunately, in the process an "if" statement was dropped,
leading to amounts being shown that shouldn't be shown because
they are smaller than the display precision.
Fixes #1969
|
| |
|
|
|
|
|
| |
`$XDG_CONFIG_HOME/ledger/ledgerrc` and `$HOME/.config/ledger/ledgerrc`
are tried first when looking for an init file.
|
| |
|
|
|
|
|
|
|
|
| |
Before this commit, doing something like 'include data/*.dat' would
produce undesired behaviour because the matches for 'data/*.dat' would
not be sorted correctly.
See https://github.com/ledger/ledger/issues/1659 for details.
|
|
|
|
|
|
|
|
|
|
| |
Currently, collapsing is only done when both --depth and --collapse are
present. This is very unintuitive and I have even stumbled over this
myself while implenting the feature.
Change --depth to behave just like --collapse in all cases (except that
--depth has a parameter associated. --collapse defaults to 0 to retain
its old behavior).
|
|
|
|
|
|
| |
The temps will not have correct depth information attached which means
a display predicate involving `depth` will most likely lead to wrong
results.
|
|
|
|
|
|
|
|
|
|
| |
Because the only_predicate and display_predicate are applied to the
original posts, not the collapsed ones, they sometimes yield wrong
results leading to entire transactions getting dropped erroneously.
As this code is only relevant to depth == 0 collapsing (that is, the old
behavior), only follow the displayed_count == 1 code-path when the depth
is 0.
|
|
|
|
|
|
|
| |
When an account already has less depth than collapse_depth, a segfault
was caused by attempting to move up the account parents until parent is
NULL. Fix this by exiting early if the depth is already less than
collapse_depth.
|