Skip to content

Trouble with Balance Assertions/Assignments #538

@patbakdev

Description

@patbakdev

Maybe I am missing something, but I seem to be having issues with balance assertions/assignments. I am trying to track my starbucks points. Sometimes points are earned through spending, and sometimes there are bonus points. My plan was to use automatic transactions for stars earned through spending and then just set the balance to zero (or whatever the balance is after redeeming) when the points are redeemed. Here is the test journal I have put together.

; -*- ledger -*-

account Awards:Starbucks:Earned
account Awards:Starbucks:Balance
account Awards:Starbucks:Redeemed

commodity $
    note United States Dollars
    format $1,000.00
    nomarket
    default
   
= @/^Starbucks/ and /Coffee/
    Awards:Starbucks:Earned                              (-0.5 SB * amount)
    Awards:Starbucks:Balance                             ( 0.5 SB * amount)

2017-01-01 * Starbucks (Card Reloaded)
    Expenses:Coffee                                      50.00 USD
    Liabilities:Cash                                       

2017-01-03 * Starbucks (Stars Redeemed)
    Awards:Starbucks:Earned                                -95 SB   ; ## Ultimately I want this auto calculated. ##
    Awards:Starbucks:Redeemed                             8.00 USD @@ 120.00 SB
    Awards:Starbucks:Balance

at this point this command give me the following (accurate) balance: $ ledger -f .\Awards.dat -w bal awards -V --empty --flat

               0  Awards:Starbucks:Balance
       -120.0 SB  Awards:Starbucks:Earned
        120.0 SB  Awards:Starbucks:Redeemed

when I change the last transaction to

2017-01-03 * Starbucks (Stars Redeemed)
    Awards:Starbucks:Redeemed                             8.00 USD @@ 120.00 SB
    Awards:Starbucks:Balance    

and add

2017-01-03 * Starbucks (Stars Redeemed)
    Awards:Starbucks:Earned
    Awards:Starbucks:Balance                             = 0 SB 

I get the following balance:


$ ledger -f .\Awards.dat -w bal awards -V --empty --flat
             25.0 SB  Awards:Starbucks:Balance
           -145.0 SB  Awards:Starbucks:Earned
            120.0 SB  Awards:Starbucks:Redeemed

The question I have is why isn't Awards:Starbucks:Balance = 0 SB? Isn't that what the balance assertion is supposed to insure? And if it does, then shouldn't it also set the last Awards:Starbucks:Earned posting to -95 SB and ultimately resulted in the same balance of

                   0  Awards:Starbucks:Balance
           -120.0 SB  Awards:Starbucks:Earned
            120.0 SB  Awards:Starbucks:Redeemed

Hope that made sense. Thank.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions