I also found the following invocation would cause a crash

./build/ledger/debug/ledger -f file reg --sort=d --period "from 2024-01-01 
to 2025-01-01" "Expenses:Commu:Server Infra" -X CHF --historical --group-by 
payee
terminate called after throwing an instance of 'ledger::assertion_failed'
  what():  Assertion failed in "/home/kikeg/projects/ledger/src/op.h", line 
260:void ledger::expr_t::op_t::release() const: refc > 0
zsh: IOT instruction  ./build/ledger/debug/ledger -f 
~/projects/ikegami-journal/root.ledger reg

interestingly removing --historical would solve the issue.
2024年4月18日木曜日 13:06:56 UTC+2 Katsuaki Ikegami:

> I'm trying to produce "Income & Expense" report exchanged into CHF 
> commodity,
> with monthly basis. I don't want revaluation because I don't need 
> expense/income to be revalued for my analysis.
>
> I used this command line
> ledger -f <my_file> reg --historical --period "from 2024-01-01 to 
> 2025-01-01" ^Expenses: ^Income: -X CHF -M 
> --format="%(quoted(date)),%(quoted(display_account)),%(quoted(quantity(scrub(display_amount))))\n"
>  
> > /tmp/2024.csv
>
> (I also want to know if there's a simpler one, but it's not the main topic)
>
> I found this had a few hundreds of adjustment, this is totally unexpected. 
> I poked through one particular account, and see some interesting 
> discrepancy.
>
> If I list all spending on one particular account, this is shown as below
>  % ledger -f filter/profit_loss.ledger reg --sort=d --period "from 
> 2024-01-01 to 2025-01-01" "Expenses:2 Stable:Commu:Server Infra" --anon
> 24-Jan-01 37d4432c                                             
> 9167484f:e5761dea:65fae140:65152b09:63a9282c                               
>          10.00 C                         10.00 C
> 24-Jan-03 1f30ac3d                                             
> 702f258b:da2e4da6:b774d818:cc19a2ff:b37fa806                               
>            946 B                           946 B
>                                                                           
>                                                                             
>                              10.00 C
> 24-Jan-25 023f5980                                             
> 406576b3:5e94f61c:acfea254:a0ab84bb:6096026c                               
>           7.00 A                          7.00 A
>                                                                           
>                                                                             
>                                946 B
>                                                                           
>                                                                             
>                              10.00 C
> 24-Feb-03 ac470c8d                                             
> f4187d89:c82d7941:3b33caac:45929fdd:f73cae17                               
>            946 B                          7.00 A
>                                                                           
>                                                                             
>                              1,892 B
>                                                                           
>                                                                             
>                              10.00 C
> 24-Feb-26 936295a8                                             
> 2c7f7db4:ec421e78:a87ad0a6:773a9723:2c2c4e7a                               
>           7.00 A                         14.00 A
>                                                                           
>                                                                             
>                              1,892 B
>                                                                           
>                                                                             
>                              10.00 C
> 24-Apr-02 c34b1b48                                             
> 0d0e3a53:4f139f81:aba516f9:7a918351:2017b48e                               
>           7.00 A                         21.00 A
>                                                                           
>                                                                             
>                              1,892 B
>                                                                           
>                                                                             
>                              10.00 C
>
> (A = USD, B = JPY, C = CHF)
>
> If I exchange them into CHF, with/without --monthly, it'll be like this
>
>  % ledger -f filter/profit_loss.ledger reg --sort=d --period "from 
> 2024-01-01 to 2025-01-01" "Expenses:2 Stable:Commu:Server Infra" -X CHF
> 24-Jan-01 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                             
>  10.00 CHF                       10.00 CHF
> 24-Jan-03 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 5.90 CHF                       15.90 CHF
> 24-Jan-25 Commodities revalued                                 <Revalued> 
>                                                                       
>  -0.17 CHF                       15.73 CHF
> 24-Jan-25 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 6.18 CHF                       21.91 CHF
> 24-Feb-03 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 5.73 CHF                       27.64 CHF
> 24-Feb-16 Commodities revalued                                 <Revalued> 
>                                                                         
> 0.13 CHF                       27.76 CHF
> 24-Feb-24 Commodities revalued                                 <Revalued> 
>                                                                       
>  -0.73 CHF                       27.03 CHF
> 24-Feb-26 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 5.97 CHF                       33.00 CHF
> 24-Mar-20 Commodities revalued                                 <Revalued> 
>                                                                         
> 0.48 CHF                       33.48 CHF
> 24-Mar-24 Commodities revalued                                 <Revalued> 
>                                                                         
> 0.21 CHF                       33.69 CHF
> 24-Mar-27 Commodities revalued                                 <Revalued> 
>                                                                         
> 0.16 CHF                       33.85 CHF
> 24-Apr-02 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 6.34 CHF                       40.19 CHF
>
>  % ledger -f filter/profit_loss.ledger reg --sort=d --period "from 
> 2024-01-01 to 2025-01-01" "Expenses:2 Stable:Commu:Server Infra" -X CHF -M
> 24-Jan-01 - 24-Jan-31                                          Expenses:2 
> Stable:Commu:Server Infra                                             
>  21.91 CHF                       21.91 CHF
> 24-Feb-01 - 24-Feb-29                                         
>  <Adjustment>                                                               
>        -0.41 CHF                       21.50 CHF
>                                                                Expenses:2 
> Stable:Commu:Server Infra                                             
>  11.50 CHF                       33.00 CHF
> 24-Apr-01 - 24-Apr-30                                         
>  <Adjustment>                                                               
>         0.85 CHF                       33.85 CHF
>                                                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 6.34 CHF                       40.19 CHF
>
> And if I use --historical, there won't be any adjustment as expected.
>
>  % ledger -f filter/profit_loss.ledger reg --sort=d --period "from 
> 2024-01-01 to 2025-01-01" "Expenses:2 Stable:Commu:Server Infra" -X CHF 
> --historical
> 24-Jan-01 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                             
>  10.00 CHF                       10.00 CHF
> 24-Jan-03 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 5.90 CHF                       15.90 CHF
> 24-Jan-25 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 6.18 CHF                       22.08 CHF
> 24-Feb-03 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 5.73 CHF                       27.81 CHF
> 24-Feb-26 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 5.97 CHF                       33.78 CHF
> 24-Apr-02 xxxxxxxxxxxxxxxxxxxxx                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 6.34 CHF                       40.12 CHF
>
> This looks reasonable. But once I add -M, it'll get awkward.
>
>  % ledger -f filter/profit_loss.ledger reg --sort=d --period "from 
> 2024-01-01 to 2025-01-01" "Expenses:2 Stable:Commu:Server Infra" -X CHF 
> --historical -M
> 24-Jan-01 - 24-Jan-31                                          Expenses:2 
> Stable:Commu:Server Infra                                             
>  53.82 CHF                       21.91 CHF
> 24-Feb-01 - 24-Feb-29                                         
>  <Adjustment>                                                               
>       -11.91 CHF                       10.00 CHF
>                                                                Expenses:2 
> Stable:Commu:Server Infra                                             
>  23.00 CHF                       33.00 CHF
> 24-Apr-01 - 24-Apr-30                                         
>  <Adjustment>                                                               
>         0.85 CHF                       33.85 CHF
>                                                                Expenses:2 
> Stable:Commu:Server Infra                                               
> 6.34 CHF                       40.19 CHF
>
> Where this 53.82 CHF come from? I want to debug why this happened, but no 
> luck how to proceed with debug / logging.
> I wanted to provide a minimal example for reproducing the issue, but not 
> yet succeeded to reproduce with smaller case.
> I'm using latest stable Debian with Ledger 3.3.0.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/274b849c-8be1-406e-aab0-f10ce89eb74en%40googlegroups.com.

Reply via email to