Scheduled Transactions Unparsable Formula

子風 zpsyhapcst at gmail.com
Mon May 2 11:27:38 EDT 2016


John Ralls 於 2016/5/2 下午 10:57 寫道:
>> On May 1, 2016, at 11:37 PM, 子風 <zpsyhapcst at gmail.com> wrote:
>>
>> John Ralls 於 2016/5/2 下午 01:20 寫道:
>>>> On May 1, 2016, at 7:13 PM, 子風 <zpsyhapcst at gmail.com> wrote:
>>>>
>>>> John Ralls 於 2016/5/1 下午 10:29 寫道:
>>>>>> On May 1, 2016, at 1:57 AM, 子風 <zpsyhapcst at gmail.com> wrote:
>>>>>>
>>>>>> GnuCash 2.6.12
>>>>>> Window 7 32bit
>>>>>>
>>>>>> When I try to use Scheduled Transactions and make it more automatic.
>>>>>>
>>>>>> So I modified the "fin.scm" to meet what I need.
>>>>>>
>>>>>> But I can't do it. It always shows the error message "Couldn't parse redit-formula".
>>>>>>
>>>>>> The credit-formula is "computeInterestIncrementFixed(10422:i)"
>>>>>>
>>>>>> However, if I replaced "i" with "-i" like "computeInterestIncrementFixed(10422:-i)", it would be OK.
>>>>>>
>>>>>> But It is not what I need.
>>>>>>
>>>>>> There are source code as below. And I run it online working fine.
>>>>>>
>>>>>> https://repl.it/CLmn/1
>>>>>>
>>>>>> ;; for fixed rate once in a year
>>>>>> (define ratePublic 0.0116)
>>>>>>
>>>>>> (define (gnc:futureValueR a t)
>>>>>>     (if (<= t 0)
>>>>> Shouldn't that be "if (>= t 0)"?
>>>> I tried this as below, but it still had the same error message.
>>>> And when I used "computeInterestIncrement" like online example, it still had the same error message.
>>>> (define (gnc:futureValueR a t)
>>>>     (if (> t 0)
>>>>         (round (* (+ 1 ratePublic) (gnc:futureValueR a (- t 1))))
>>>>         a
>>>>      )
>>>> )
>>>>>>         a
>>>>>>         (round (* (+ 1 ratePublic) (gnc:futureValueR a (- t 1))))
>>>>>>      )
>>>>>> )
>>>>>>
>>>>>> (define (gnc:computeInterestIncrementFixed a t)
>>>>>>   (let ((thisVal (gnc:futureValueR a t))
>>>>>>         (prevVal (gnc:futureValueR a (- t 1)))
>>>>>>        )
>>>>>>     (- thisVal prevVal)
>>>>>>   )
>>>>>> )
>>>>>>
>>> Oh, sorry, missed the "a" for the condition being true.
>>>
>>> I'm confused. computeInterestIncrement raises "can't parse credit-formula" but computeInterestIncrementFixed doesn't if you pass -i for the second argument but does if you pass i?
>>>
>>> The way you wrote the call above, computeInterestIncrementFixed(10422:i) isn't right, it needs to have spaces around the ':'
>>> like computeInterestIncrementFixed(10422 : i), the parser tokenizes on spaces. Did you just type it without spaces here and had it right in GnuCash?
>>>
>>> I can enter computeInterestIncrement(1000 : 100 : 12 : i) and GnuCash doesn't raise an error.
>>>
>>> Regards,
>>> John Ralls
>>>
>>>
>> As test.png, when I tried computeInterestIncrement(1000 : 100 : 12 : i), but it still raise an error again like split test2
>>
>> And when I entered computeInterestIncrement(1000 : 100 : 12 : -i), it would be fine like split test1.
>>
>> However, as test2.png if I filled the form, and didn't key enter to finish, I just directly clicked the bottom right button, it would be fine.
>>
>> But when I want to edit it, it raised an error again.
>> <test.png><test2.png>
> Aha! I made the mistake of not completing the split before clicking OK. Now I can replicate the problem.
> Hmm. The parse error I see in gnucash.trace is
>     CRIT <gnc.gui> [func_op()] Attempt to convert nan to GncNumeric Failed: GNC_ERROR_OVERFLOW.
>
> A divide-by-zero error. That suggests it's not recognizing 'i' as a variable. Indeed, if I change 'i' to 'int' it works OK. See if it works for you.
>
> Regards,
> John Ralls
>
>
>
>
I tried computeInterestIncrement(1000 : 100 : 12 : int).

It still raised an error, and this is my gnucash.trace as below

CRIT <gnc.gui> [func_op()] Attempt to convert nan to GncNumeric Failed: 
GNC_ERROR_OVERFLOW

But if you mean replacing by integer like computeInterestIncrement(1000 
: 100 : 12 : 2), it would be OK.


More information about the gnucash-devel mailing list