That was indeed the problem. And you were right about me running into 
another issue.

In case it helps anyone else, the issue was getting an error like "Cannot 
multiply
a balance with an amount" and it was solved by simplifying my defined 
functions.
Turns out ledger supports ternary conditionals, so my defines went from

define bktmax = tag('BucketMax')
define pct = tag('IncomePercent')
define tax = tag('TaxRatio')
define budget_val = (a * -1 * (1 - tax) * pct * 0.8)
define bucket_remaining(act) = bktmax - account(act).total
define bucket_diff(act) = bucket_remaining(act) - budget_val
define bucket_filled(act) = (((abs(bucket_diff(act)) + bucket_diff(act)) / 
(2*(bucket_diff(act)))) * -1) + 1
define bucket_not_filled(act) = (bucket_filled(act) * -1) + 1
define post_amount(act) = (bucket_filled(act) * bucket_remaining(act)) + 
(bucket_not_filled(act) * budget_val)

To the following:

define bktmax = tag('BucketMax')
define pct = tag('IncomePercent')
define tax = tag('TaxRatio')
define budget_val = (a * -1 * (1 - tax) * pct * 0.8)
define bucket_remaining(act) = bktmax - account(act).total
define bucket_diff(act) = bucket_remaining(act) - budget_val
define post_amount(act) = (bucket_diff(act) < 0 ? bucket_remaining(act) : 
budget_val) 

And the issue went away.

On Thursday, October 17, 2019 at 9:04:41 PM UTC-7, John Wiegley wrote:
>
> >>>>> "MB" == Michael Bryant <[email protected] <javascript:>> writes: 
>
> MB> Attached is a file with a minimal version of what I am trying to 
> MB> accomplish. Due to using the account() function, I am using the latest 
> MB> master branch version of ledger. 
>
> MB> Is this a bug, or am I doing something wrong? 
>
> The problem here, which ought to be considered a bug, is that "define" 
> cannot 
> override the definition of "max", which is a built-in function taking two 
> arguments. 
>
> Once you change the name of max to something else, you'll hit another 
> problem, 
> but maybe you'll know the answer to that one... 
>
> 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/e48a17d5-223c-4644-a71c-ae686d8a47f4%40googlegroups.com.

Reply via email to