Skip to content

Instantly share code, notes, and snippets.

@adept
Created November 24, 2017 21:13
Show Gist options
  • Save adept/0c0e932d789adc803e93d219f7e168c9 to your computer and use it in GitHub Desktop.
Save adept/0c0e932d789adc803e93d219f7e168c9 to your computer and use it in GitHub Desktop.
splitSpan issues demo
year-test.journal:
```
2015/02/01 first half
expenses $1
assets
2015/07/01 second half
expenses $2
assets
2016/02/01 first half
expenses $4
assets
2016/07/01 second half
expenses $8
assets
2017/02/01 first half
expenses $16
assets
2017/07/01 second half
expenses $32
assets
```
Year balances are good:
```
$ hledger balance -f year-test.journal -p yearly ~/devel/haskell/darcs-get/hledger/examples
Balance changes in 2015/01/01-2017/12/31:
|| 2015 2016 2017
==========++==================
assets || $-3 $-12 $-48
expenses || $3 $12 $48
----------++------------------
|| 0 0 0
```
Note how first transaction in 2015 is not included. Note that this is old period expression, so this bug exsits in master:
```$ hledger balance -f year-test.journal -p 'every 2nd day of month' ~/devel/haskell/darcs-get/hledger/examples
Balance changes in 2015/07/02-2017/07/01:
|| 2015/07/02-2015/08/01 2015/08/02-2015/09/01 2015/09/02-2015/10/01 2015/10/02-2015/11/01 2015/11/02-2015/12/01 2015/12/02-2016/01/01 2016/01/02-2016/02/01 2016/02/02-2016/03/01 2016/03/02-2016/04/01 2016/04/02-2016/05/01 2016/05/02-2016/06/01 2016/06/02-2016/07/01 2016/07/02-2016/08/01 2016/08/02-2016/09/01 2016/09/02-2016/10/01 2016/10/02-2016/11/01 2016/11/02-2016/12/01 2016/12/02-2017/01/01 2017/01/02-2017/02/01 2017/02/02-2017/03/01 2017/03/02-2017/04/01 2017/04/02-2017/05/01 2017/05/02-2017/06/01 2017/06/02-2017/07/01
==========++========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
assets || 0 0 0 0 0 0 $-4 0 0 0 0 $-8 0 0 0 0 0 0 $-16 0 0 0 0 $-32
expenses || 0 0 0 0 0 0 $4 0 0 0 0 $8 0 0 0 0 0 0 $16 0 0 0 0 $32
----------++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|| 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
```
Note how 2015 is absent entirely. This is new expression, but i think that general nature of bug is the same...
```
$ hledger balance -f year-test.journal -p 'every 4th Apr' ~/devel/haskell/darcs-get/hledger/examples
Balance changes in 2016/04/04-2018/04/03:
|| 2016/04/04-2017/04/03 2017/04/04-2018/04/03
==========++==============================================
assets || $-24 $-32
expenses || $24 $32
----------++----------------------------------------------
|| 0 0
```
@adept
Copy link
Author

adept commented Nov 25, 2017

After the fix:

All of 2015 is in monthly report:

$ hledger balance -f year-test.journal -p 'every 2nd day of month' 
Balance changes in 2015/01/02-2017/07/01:

          || 2015/01/02-2015/02/01  2015/02/02-2015/03/01  2015/03/02-2015/04/01  2015/04/02-2015/05/01  2015/05/02-2015/06/01  2015/06/02-2015/07/01  2015/07/02-2015/08/01  2015/08/02-2015/09/01  2015/09/02-2015/10/01  2015/10/02-2015/11/01  2015/11/02-2015/12/01  2015/12/02-2016/01/01  2016/01/02-2016/02/01  2016/02/02-2016/03/01  2016/03/02-2016/04/01  2016/04/02-2016/05/01  2016/05/02-2016/06/01  2016/06/02-2016/07/01  2016/07/02-2016/08/01  2016/08/02-2016/09/01  2016/09/02-2016/10/01  2016/10/02-2016/11/01  2016/11/02-2016/12/01  2016/12/02-2017/01/01  2017/01/02-2017/02/01  2017/02/02-2017/03/01  2017/03/02-2017/04/01  2017/04/02-2017/05/01  2017/05/02-2017/06/01  2017/06/02-2017/07/01 
==========++==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
 assets   ||                   $-1                      0                      0                      0                      0                    $-2                      0                      0                      0                      0                      0                      0                    $-4                      0                      0                      0                      0                    $-8                      0                      0                      0                      0                      0                      0                   $-16                      0                      0                      0                      0                   $-32 
 expenses ||                    $1                      0                      0                      0                      0                     $2                      0                      0                      0                      0                      0                      0                     $4                      0                      0                      0                      0                     $8                      0                      0                      0                      0                      0                      0                    $16                      0                      0                      0                      0                    $32 
----------++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
          ||                     0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0                      0 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment