Re: GitHub workflows for ledger CI - help required

2021-09-05 Thread Michael Cooper
In other projects, those have come from the branch protections settings for
me.

On Sun, Sep 5, 2021, 11:56 Rahix  wrote:

> On Sun, 2021-09-05 at 10:08 +0800, Martin Michlmayr wrote:
> > * Rahix  [2021-09-04 09:35]:
> > > Now that GHA seems to be up and running, can you drop Travis from the
> > > repository?  The checks still show up in each pull-request and make the
> > > overall status "waiting" because the Travis check never completes.
> >
> > I removed the Travis hook already but I can't figure out how to remove
> > the Travis requirement for pull requests.  Do you know how?
>
> Hm, not sure... IIRC there was a thing on the travis website where you
> need to disable a project.  Also maybe in the "Integrations" project
> settings on GitHub?
>
> If all else fails, maybe the travis manifest needs to be removed?
>
> --
> Rahix
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ledger-cli/d3884c71fc606588f91f72bdf10ab95ae69049d7.camel%40rahix.de
> .
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAFOMguY7Ge%2BuArF4-KZ8jeBhaJCm0OTa8LBbv_5rUu9Xokp5Ew%40mail.gmail.com.


Re: Credit card charges and payments

2020-08-08 Thread Michael Cooper
In ledger negatives go between the commodity and the amount. So instead of
-$100 you should right $-100.

It looks to me like you have 2,300 of the commodity "$" and 2,500 of the
commodity "-$", and ledger is treating them as separate, unrelated
commodities.

If you change your negatives to the $-100 form, I expect it will work like
you want.


On Sat, Aug 8, 2020, 16:55 Remco Rijnders  wrote:

> On Sat, Aug 08, 2020 at 03:11:45PM -0700, Oliver wrote in
> <0371f69e-5077-4e93-a08c-3a7967ed4d...@googlegroups.com>:
> >If I run a balance inquiry in ledger, at the end of a long list are 2
> >entries:
> >-$2500.00 Liabilities:Credit_Card
> >  $2300.00 Liabilities:Credit_Card
> >
> >The first entry is how much I've charged to the card. The second entry is
> >my latest payment. The $200 difference is how much I
> >currently owe on the card.
> >
> >2 Questions:
> >
> >1) Is this how it is supposed to look when one runs a balance report with
> 2
> >entries for Liabilities:Credit_Card?
>
> No, the entries should show you the "balance", so in this case
> -$200.00 and each account should appear in the balance just once.
>
> >2)Is there a command to run to find what I currently owe or do I always
> >need to pull out a calculator and subtract?
>
> The output you get looks suspect. It should work without a calculator
> and just show you the balance. Can you show us the command you used to
> run the balance report? Do any of your other accounts exhibit this
> same problem, or is it just the Credit_Card account? I notice your
> amounts are all nice and rounded. Did you change the amounts for the
> sake of simplifying your question and/or hiding private details? Are
> the 2500 and 2300 amounts single entries in your ledger file, or are
> they composed of multiple entries?
>
> Kind regards,
>
> Remco
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ledger-cli/Xy87aIyg0MKMoNDC%40settler.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAFOMguYczyviRJHYCCmKLsHBK2Z9%2B9PCDQyc%3Ddj%2BR_puPSjRAg%40mail.gmail.com.


Re: Getting a periodic report with all subaccounts rolled up into a higher account

2020-05-15 Thread Michael Cooper
For this purpose, I use balance with the --group-by option, like this:

ledger balance Expense:Entertainment --depth 2 --group-by
'format_date(date, "%Y-%m")'

That would produce a series of balances grouped by month. You could also
use "%Y" as the format string to get grouped by year, or many other things.

-Mythmon

On Thu, May 14, 2020 at 1:44 PM MN  wrote:

> Hi,
>
> Say I have the account Expense:Entertainment.
>
> Under it I have:
>
> Expense:Entertainment:Movies
> Expense:Entertainment:Travel
> Expense:Entertainment:Hobbies
>
> I want a report of how much I spent on Expense:Entertainment overall for
> each year. It shouldn't show me all the subaccounts, but their amounts
> shouldn't be ignored.
>
> So if, for 2019, Expense:Entertainment had $100 and the other three
> categories each had $50, it should show it as $250 for
> Expense:Entertainment for the whole year.
>
> I can't seem to find a way to do this in Ledger. I've tried:
>
> ledger -Y reg "^Expense:Entertainment$"  --period-sort "(amount)"
>
> But this gives just the amounts in Expense:Entertainment
>
> I also tried:
>
> ledger -Y reg ^Expense:Entertainment --depth 2 --period-sort "(amount)"
>
> This is a bit better, but it doesn't quite do it. In the first column it
> shows only the amount for Expense:Entertainment. In the second column it
> has all the subaccounts, but the problem is it is cumulative:
>
> 15-Jan-01 - 15-Dec-31   Expense:Entertainment  4.30 USD
> 402.92 USD
> 16-Jan-01 - 16-Dec-31   Expense:Entertainment   1233.76 USD
> 2687.10 USD
> 17-Jan-01 - 17-Dec-31   Expense:Entertainment 80.23 USD
> 2800.33 USD
> 18-Jan-01 - 18-Dec-31   Expense:Entertainment  9.89 USD
> 2949.82 USD
>
> Also, just on the side - I noticed this command:
>
> ledger reg Expense:Entertainment --depth 2 --period yearly
>
> Gives slightly different values in the second column. Not sure why.
>
> The other problem with this is that it starts in 2015, when I have entries
> prior to 2015 (but they appear only in subaccounts, and not the parent
> Expense:Entertainment account).
>
> Any help would be appreciated.
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ledger-cli/6ec1ac43-7bf6-4f3f-b104-eb9b6989bcc8%40googlegroups.com
> 
> .
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAFOMguZmSxxj5U-yS3NtJh634Nx56%3D1XMyQ6dhoiam%2B6-Z%3DCvA%40mail.gmail.com.


Re: assert an account's amount

2020-04-06 Thread Michael Cooper
To deal with the default account problem, I make the transaction explicitly
0. To deal with it not being a real transaction, I make it a virtual one.
Together it looks like this

2020-04-06 * Reconcile
[Assets:Checking]  $0 = $123.00
[Assets:Savings]  $0 = $456.00

-Mythmon


On Mon, Apr 6, 2020 at 10:09 PM Randy Josleyn 
wrote:

> Hi Taylor,
>
> I knew someone one say this as soon as I hit send :)
>
> It does seem a little simpler than what I was trying to do. My beef with
> that is that it's not *really* a transaction, so I don't want to write it
> as one. That's really a minor reason.
>
> What I did find is that if you have a default account set and the balance
> assignment is incorrect, the difference will end up in the default account
> instead of causing an error. That might actually be a useful side affect if
> you set the default account as something noticeable like "FAILED ASSERTION"
> or something. It would show up in your balance report and so on and still
> let you see the current state of your accounts.
>
> Thanks for your response!
>
> On April 7, 2020 12:51:33 PM GMT+08:00, Taylor R Campbell <
> campbell+ledger-...@mumble.net> wrote:
>>
>> Date: Tue, 07 Apr 2020 12:47:37 +0800
>>> From: Randy Josleyn 
>>>
>>> I realized I could just add a transaction that assigns the balance
>>> of assets:checking, but that doesn't seem like the best way to do
>>> it.
>>>
>>
>> This is exactly what I do.  Why wouldn't it be the best way?
>>
>> 2020-04-01 Balance assertion
>> Assets:Checking   = 123.00 USD
>>
>> --
>> --
>> 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 ledger-cli+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ledger-cli/20200407045133.ACA4C60A44%40jupiter.mumble.net.
>>
>>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ledger-cli/64C852DB-2DB8-4C1B-8BF8-49907395A212%40gmail.com
> 
> .
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAFOMguZTWvF%3DRv%3DSiES8-67n7wprDQ705zMAd_Z5aPuDygi%3DaQ%40mail.gmail.com.


Re: Planning for ledger 3.2

2019-12-15 Thread Michael Cooper
Hey psion,

Every well behaving command line app should only use color at interactive
colors that can render them. If you are seeing raw formatting codes, I
think we can all agree there is a problem somewhere. It would be great if
you could give some specific examples of times this goes wrong.

In the meantime, this is pretty far off topic for the thread. Can you move
this troubleshooting elsewhere, perhaps a GitHub issue or another thread?
Martin asked for *critical bugs* that would prevent a release. I don't
think changing the intended behavior of the program fits into that category.

Thank,
-Mythmon




On Sun, Dec 15, 2019, 22:57 psionl0  wrote:

> Does it work for all piping commands?
>
> I shouldn't have to research how to output unformatted text. Let those who
> want special formatting include those options in their command line.
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ledger-cli/a04c8f73-1568-43e4-8307-ad2ae22be19a%40googlegroups.com
> 
> .
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/CAFOMguZQ3budKKQ31vNmL8h03dbBxmv0fbTHxL1dEPsVGEXYeg%40mail.gmail.com.


Re: print doesn't print the balancing accounts (?)

2018-03-26 Thread Michael Cooper
You'll need to pass --generated to the command to see the automatically
generated parts of transactions.

On Mon, Mar 26, 2018, 08:41 Ella Lobatina  wrote:

> Yes I did :)
> Here is an example:
> (Ledger 3.0.3-20140608 on Fedora 18)
>
> This block in one file (journal):
> ===
> year 2017
>
> account assets:ff:cash:wallet:Extalta:S
> alias ffCaE
> assets:hh:cash:wallet:Agelica:S
>
> alias hhCaA
>
> commodity "Those super crypto coins"
>
> bucket hhCaA
>
> 2017/10/01 ff
> ffCaE  3000 "Those super crypto coins" {=BTC 6}
> ===
>
> then run and watch the output:
>
> $ ledger -f journal --pedantic print
> 2017/10/01 ff
>   assets:ff:cash:wallet:Extalta:S  3000 "Those super crypto coins" {=BTC6}
> $
>
>
> Thanks
>
>
> On Saturday, March 24, 2018 at 6:29:00 PM UTC, John Wiegley wrote:
>
>> > "EL" == Ella Lobatina  writes:
>>
>> EL> Could I respectfully bump this up please?
>>
>> JW> Can you show me an example of a single transaction (fake) within the
>> JW> context of the other settings you have in your Ledger file? I'd like
>> to
>> JW> try it here.
>>
>> Did you ever send that example? I may have misplaced it...
>>
>> Thanks, John
>>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Balance assertions problems

2018-01-08 Thread Michael Cooper
Ledger cares a lot about the order of transactions, and doesn't care much
for dates in many ways.

HLedger and Beancount both ignore the order of transactions, and only care
about dates.

On Sat, Jan 6, 2018 at 4:45 AM Eduardo Elias  wrote:

> Hi,
>
> I was having problems using *Balance assertions, Balance Assignments and
> Resetting Balance*.
>
> I found what was causing the error, but I would like to report to know if
> it is a working as design case or a bug.
>
> If transactions are being registered from newer to older.
>
>  fuel.ledger =
>
> 2018-01-06 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
> 2018-01-05 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
> 2018-01-04 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
> 2018-01-02 * Rebalance
> Bank=100.00 USD
> Openning:Balance
>
> ==
>
> $ ledger -f test.ledger
> bal
>
>   100.00 USD
> Bank
>
>60.00 USD  Expenses:Fuel
>  -160.00 USD  Openning:Balance (OB)
> 
>0
>
> Bank will have 100.00 USD forever. Bank account becomes a permanent
> redirect to OB.
>
>
> If the re-balance happens in the middle it would lock on Bank any value
> left to it, and will redirect to OB.
>
> 
>
> 2018-01-07 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
> 2018-01-06 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
> 2018-01-02 * Rebalance
> Bank=100.00 USD ; date is older, but
> transaction got moved.
> Openning:Balance
>
> 2018-01-05 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
> 2018-01-04 * Fuel
> Expenses:Fuel 20.00 USD
> Bank
>
>  
>
> ledger -f fuel.ledger
> bal
>
>60.00 USD
> Bank
>
>80.00 USD  Expenses:Fuel
>  -140.00 USD  Openning:Balance
> 
>0
>
>
> My understanding was that Ledger wouldn't care about the order of the
> transactions, but looks like if you are using Balance Assertions it does.
>
> 
> Eduardo
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please, make a new relelase

2017-12-13 Thread Michael Cooper
I would generally agree with the "if it isn't broken, don't fix it" ideal,
but in Ledger's case, there is almost 2 years and 172 commits worth of
development, according to Github [0], since the release of 3.1.1. There
should be at least a plan for when that effort is going to be deemed
suitable for a new release. Otherwise it goes to waste.

[0] https://github.com/ledger/ledger/releases

On Wed, Dec 13, 2017 at 8:11 AM Eric S Fraga  wrote:

> On Wednesday, 13 Dec 2017 at 04:05, Vitaly Lipatov wrote:
> > Please, plan a new release. It is hard to maintain application when it
> rare
> > released.
>
> Curious: why?  If an application works, why is there a need for a new
> release?
>
> --
> Eric S Fraga via Emacs 27.0.50, org 9.1.4
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Budget causes my ledger not to parse file?

2017-12-06 Thread Michael Cooper
Your problem is that there is a space character on the "empty" line between
the two transactions. Since the line is not totally empty, it throws off
ledger's parser. Deleting the space character makes the file work for me.

On Wed, Dec 6, 2017 at 11:32 AM Andrew Thorp  wrote:

> This file throws the same error. I created it by duplicating my file,
> skimming off most of the posts, and changing the numbers.
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Debugging assertion failures / printing the value of a value expression

2017-10-20 Thread Michael Cooper
Ah, I misunderstood your original problem, apologies.

Dodging your question again (since I really don't know the answer), I've
also found that storing values in non-leaf accounts gets me into all sorts
of trouble. It generally is confusing and my automation doesn't understand
it. If this example were in accounts, I would do this:

2017-10-01 * Opening Balance
Assets:CurrentAccount:Real  $1000
Equity:OpeningBalance

2017-10-02 * Savings
Assets:CurrentAccounts:Savings  $100
Assets:CurrentAccounts:Real

This works with the "assert account(...).total" style of assertion, but
totally fails with the Reconcile method I posted (it thinks that there is
$0 in Assets:CurrentAccounts). The assert style still doesn't show you in
what direction it is wrong, unfortunately.

Alternatively, this sounds sort of like the envelope-budgeting system I
use. Would something like the below be interesting for you?

2017-10-01 * Opening Balance
Assets:CurrentAccount$1000
(Budgets:SpendingMoney)  $1000
Equity:OpeningBalance

2017-10-02 * Savings
[Budgets:Saved]  $100
[Budgets:SpendingMoney]

2017-10-03 * Reconcile
[Assets:CurrentAccount]  $0 = $1000

The "Budgets" subtree are accounts made entirely of virtual transactions to
track how money has been allocated, whereas the Assets subtree is about
where money really is. I have scripts that help make sure that in
transactions like 2017-10-01 the amount that the asset increases by
balances with the amount the budgets increase by. I then have rules to
automatically pair up Expense and Budget transactions.

On Fri, Oct 20, 2017 at 1:46 PM John Lee <j...@pobox.com> wrote:

> Hi Michael
>
> If you take a look at my previous thread here from a week or so back
> you'll see the problem you run into when trying to apply that to the
> transactions I posted in this thread.
>
> https://groups.google.com/forum/#!topic/ledger-cli/bqu-qNr6cjM
>
> Consider:
>
> 2017-10-01 * Opening Balance
> Assets:CurrentAccount   $1000
> Equity:OpeningBalance
>
> 2017-10-02 * Savings
> Assets:CurrentAccount:Savings   $100
> Assets:CurrentAccount
>
> 2017-10-03 * Assertion
> [Assets:CurrentAccount]   $0 = $1000
>
>
> That final balance assertion fails for the same reason I mentioned in my
> second post in the earlier thread:  that assertion refers not to the
> summed-up total of everything in *or under* Assets:CurrentAccount (as
> you'd see in the output of ledger b Assets:CurrentAccount), but the
> amount that lives in that *exact* location (which you might write in a
> balance command as
> '^Assets:CurrentAccount$').  So $1000 errors, and $900 does not.  That
> means I can't record the total balance of that real account, which is
> what I'm after.  That's what motivated my use of assertion value
> expressions, with which I guess I've either run into a bug, or I don't
> understand something (see my previous post in this thread).
>
> I get the impression that transferring between subaccounts in this way
> suggested here earlier, is a bit of a dark corner of ledger that's not
> terribly well supported?
>
> I'm keen to hear about other approaches, but so far I'm running into
> roadblocks whichever way I try to tackle using ledger the problem I set
> out in that first thread (which is the same basic problem I'm trying to
> solve here in this thread, though my question here was about a detail).
>
> I guess I should either dust off my very dusty C++ and try to fix it, or
> try one of the ledger spinoffs like beancount... maybe there are
> beancount / hledger people here who can comment re whether those systems
> have ways to tackle the problem from the thread linked above?
>
> On Thu, 19 Oct 2017, at 23:54, Michael Cooper wrote:
> > This isn't a direct answer to your question, but this is how I do these
> > kind of balance checks:
> >
> > 2017/01/01 * Opening Balance
> > Assets:Checking$1000
> > Equity:Opening
> >
> > 2017/01/02 * Savings
> > Assets:Savings  $100
> > Assets:Checking
> >
> > 2017/01/03 * Reconcile
> > [Assets:Checking]  $0 = $900
> > [Assets:Savings]   $0 = $100
> >
> > 2017/01/04 * Savings
> > Assets:Savings  $100
> > Assets:Checking
> >
> > 2017/01/05 * Reconcile
> > [Assets:Checking]  $0 = $800
> > [Assets:Savings]   $0 = $200
> >
> > This works well. I read these reconcile transactions as "If $0 is added
> > to
> > the account, the balance should be $800".
> >
> > If I instead change the last reconcile to "[Assets:Checking]  $0 = $700"
> > (that is, make it $100 off) I get this error:
> >
> > While parsing fil

Re: Debugging assertion failures / printing the value of a value expression

2017-10-19 Thread Michael Cooper
This isn't a direct answer to your question, but this is how I do these
kind of balance checks:

2017/01/01 * Opening Balance
Assets:Checking$1000
Equity:Opening

2017/01/02 * Savings
Assets:Savings  $100
Assets:Checking

2017/01/03 * Reconcile
[Assets:Checking]  $0 = $900
[Assets:Savings]   $0 = $100

2017/01/04 * Savings
Assets:Savings  $100
Assets:Checking

2017/01/05 * Reconcile
[Assets:Checking]  $0 = $800
[Assets:Savings]   $0 = $200

This works well. I read these reconcile transactions as "If $0 is added to
the account, the balance should be $800".

If I instead change the last reconcile to "[Assets:Checking]  $0 = $700"
(that is, make it $100 off) I get this error:

While parsing file "/home/mythmon/tmp/foo.ledger", line 18:
While parsing posting:
  [Assets:Checking]  $0 = $700
  
Error: Balance assertion off by $-100 (expected to see $800)

This shows me both the value I said it should be ($700), the value Ledger
says it should be ($800), and the difference ($-100). All of these end up
being very useful at different times.

I leave these in my ledger files. This gives me both a history of balances,
and also a sort of test suite. If I change the organization of my files,
change rules, or do other refactoring, these assertions give me confidence
that I didn't break anything.

-Michael Cooper


On Thu, Oct 19, 2017 at 3:43 PM John Lee <j...@pobox.com> wrote:

> An example that currently has me puzzled: the first assert below passes,
> and the second fails.  I'm interested both in learning why in this
> particular case, and more important, learning how to use ledger to debug
> problems like this in general.
>
> 2017-10-01 * Opening Balance
> Assets:CurrentAccount   $1000
> Equity:OpeningBalance
>
> 2017-10-02 * Savings
> Assets:CurrentAccount:Savings   $100
> Assets:CurrentAccount
>
> assert account("Assets:CurrentAccount").total == $1000
>
> 2017-10-03 * Savings
> Assets:CurrentAccount:Savings   $100
> Assets:CurrentAccount
>
> assert account("Assets:CurrentAccount").total == $1000
>
>
> This surprises me because if I comment that last assert out and run
> ledger b '^Assets:CurrentAccount$' I get $800, and ledger b
> '^Assets:CurrentAccount:Savings$' prints $200 -- which adds to $1000,
> and indeed ledger b '^Assets:CurrentAccount' prints $1000.  Bug??  How
> can I see what ledger *thinks* the total is when it evaluates the
> assert?
>
>
> On Thu, 19 Oct 2017, at 23:13, John Lee wrote:
> > Sometimes the assert expressions I'm adding to my ledger file fail and I
> > don't immediately know why.  If I have something like this:
> >
> > assert account("Assets:CurrentAccount").total == $123.45
> >
> > and I'm wrong about the total, then I'll just be told that I'm wrong,
> > and not what the correct value is.  What's the easiest way to get ledger
> > to compute and print the correct value?
> >
> > Maybe there's a way to print out account values at a given point in a
> > ledger file?  In particular, maybe there's a way to print the values of
> > value expressions as the ledger file is evaluated by a command like
> > balance?
> >
> > I realize it's good to be able to see what the answer is before one
> > writes it down, but sometimes it just saves time to have the computer
> > work it out so you can see quickly what you did wrong.
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bug with automated transactions and balance assertions?

2017-02-25 Thread Michael Cooper
In the test file I included in my first message the automated transaction
definition occurs first thing in the file. My real files are a little more
complex, consisting of multiple files all included together, but the rules
are included before the transactions in that case as well.

On Fri, Feb 24, 2017 at 11:32 PM John Wiegley <jo...@newartisans.com> wrote:

> >>>>> "MC" == Michael Cooper <myth...@gmail.com> writes:
>
> MC> for transaction in transactions_from(some_file):
> MC> transaction.check_assertions()
> MC> book.apply_automated(transaction)
> MC> book.add(transaction)
>
> Yes, this is how it should be.  In the parser we find:
>
> void instance_t::xact_directive(char * line, std::streamsize len)
> {
>   if (xact_t * xact = parse_xact(line, len, top_account())) {
> unique_ptr manager(xact);
>
> if (context.journal->add_xact(xact)) {
>   manager.release();// it's owned by the journal now
>   context.count++;
> }
>   } else {
> throw parse_error(_("Failed to parse transaction"));
>   }
> }
>
> This is run whenever a transaction is parsed.  It's
> current.journal->add_xact
> that does the processing of automated transactions before adding it to the
> journal.
>
> Just to check: Do your automated transaction occur earlier in the Ledger
> file
> than the transactions in question?
>
> --
> John Wiegley  GPG fingerprint = 4710 CF98 AF9B 327B B80F
> http://newartisans.com  60E1 46C4 BD1A 7AC1 4BA2
>
> --
>
> ---
> 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 ledger-cli+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Bug with automated transactions and balance assertions?

2017-02-20 Thread Michael Cooper
I'm not sure I can whether the automated transaction's posting get inserted
before or after the posting that triggered them, as I don't expect to be
able to make assertions inside a transaction that is affected by an
automated transaction. I think what I care about is that transactions
affected by automated transactions don't ever exist in a partially-complete
state.

To be clear, the error that I'm trying  to point out is not that the
automated transaction didn't apply "in-time" to the 3rd transaction, the
one on 01/03, but that it didn't apply correctly to the *second*
transaction, the one on 01/02. Right now it seems that the automated
transaction is only processed after all transactions have been processed,
instead of "in-line". To explain in code, I think the current process is
something like (in Python):

```
for transaction in transactions_from(some_file):
transaction.check_assertions()
book.add(transaction)

for transaction in book:
book.apply_automated(transaction)
```

What I think it *should* be is more like

```
for transaction in transactions_from(some_file):
transaction.check_assertions()
book.apply_automated(transaction)
book.add(transaction)
```

Disclaimer: I haven't read any of the ledger source code, and I don't know
C++. This is just based on a guess of how I might write a ledger-like-tool.

On Sun, Feb 19, 2017 at 9:48 AM John Wiegley <jo...@newartisans.com> wrote:

> >>>>> "MC" == Michael Cooper <myth...@gmail.com> writes:
>
> MC> It seems that the automated transaction has not taken affect when the
> MC> balance assertion is evaluated. I consider this a bug.
>
> Looking at the code, it seems we handle balance assertions right away,
> before
> automated transactions are processed.
>
> The problem with reversing the order is this: The ordering of the postings
> in
> the transaction is significant. If all the automated transactions's
> postings
> just get added to the end (which is what happens), it won't change the
> behavior to what you're expecting.
>
> It seems like what you want to happen is that the automated transaction's
> posting get inserted immediately *before* the posting the triggered them.
> This
> is the only way they could effect the balance assertions, but it seems a
> bit
> of a strange place to insert them...
>
> --
> John Wiegley  GPG fingerprint = 4710 CF98 AF9B 327B B80F
> http://newartisans.com  60E1 46C4 BD1A 7AC1 4BA2
>

-- 

--- 
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 ledger-cli+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.