I found this option working. 

D AMOUNT Specifies the default commodity to use, by specifying an amount in 
the expected format. The xact command will use this commodity as the 
default when none other can be determined. This command may be used 
multiple times, to set the default flags for different commodities; 
whichever is seen last is used as the default commodity. For example, to 
set US dollars as the default commodity, while also setting the thousands 
flag and decimal flag for that commodity, use: 

          D $1,000.00


I gave the following test

D $1000.00000
2014/03/21 * Test Round off
  Expenses          1 EUR @  $0.0086
  Expenses                 1 CAD @  $0.0083
  Income     -$0.0     
  
2014/03/21 * Test Round off
  Expenses          1 EUR @  $0.0086
  Expenses                 1 CAD @  $0.0083
  Income     -$0.02   
  
2014/03/21 * Test Round off
  Expenses          1 EUR @  $0.0086
  Expenses                 1 CAD @  $0.0083
  Income     -$0.0169   
  

and found it working even without round option. I received the expected 
error 

edger -f legtest/round.txt --unround -V -E     balance
While parsing file "/home/test/legtest/round.txt", line 6: 
While balancing transaction from "/home/test/legtest/round.txt", lines 2-6:
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income      -$0.0     
>   
Unbalanced remainder is:
            $0.01690
Amount to balance against:
            $0.01690
Error: Transaction does not balance
While parsing file "/home/test/legtest/round.txt", line 11: 
While balancing transaction from "/home/test/legtest/round.txt", lines 7-11:
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income      -$0.02   
>   
Unbalanced remainder is:
           $-0.00310
Amount to balance against:
            $0.01690
Error: Transaction does not balance

What do you think , should it remain as an input format or it will do 
better as an option to command line ? I mean you cannot expect people to 
use it in input file if it is imported from other programs such as a csv or 
gnucash file? 

Regards
Tripun Goel



On Thursday, 8 May 2014 23:49:36 UTC+5:30, tripun goel wrote:
>
>
>
> On Thursday, 8 May 2014 06:03:40 UTC+5:30, John Wiegley wrote:
>>
>> >>>>> tripun goel <tri...@gmail.com> writes: 
>>
>> > The point to note is that Ledger-CLI uses multiple precision floating 
>> point 
>> > numbers via MPFR library. 
>>
>> Hi Tripun, welcome to Ledger development. :) 
>>
>
> Thanks 
>
>>
>> Ledger-CLI does not use multiple precision floating point numbers.  It 
>> uses 
>> multi-precision integer rationals.  The only time MPFR is used is in 
>> exactly 
>> one place: rendering an integer rational as a floating-point string.  No 
>> rounding occurs internally -- only at report time, which is deferred 
>> until the 
>> last possible moment. 
>>
>>  As you told ledger uses integer rationals for internal representation  
> and MPFR to convert to floating point string. But for accounting as Brad 
> said what matters is reporting. I saw an option --unround to perform 
> unrounded calculations. But here is something :
>
> I tried this transaction
>
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income          
>
> and the result is 
> ledger -f legtest/round.txt --unround  -V -E    balance
>                    0  Expenses
>             $-0.0169  Income
> --------------------
>                    0
> without unround 
> ledger -f legtest/round.txt -V -E   balance
>                    0  Expenses
>                    0  Income
> --------------------
>                    0
>
>  and then
>
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income    $0.0
>
> the result with or without unround is the same
> ledger -f legtest/round.txt -V -E   balance
>                    0  Expenses
>                    0  Income
> --------------------
>                    0
>
>
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income    $0.00
>
> and the result comes with or without unround option 
>
>  ledger -f legtest/round.txt -V -E   balance
> While parsing file "/home/test/legtest/round.txt", line 5: 
> While balancing transaction from "/home/test/legtest/round.txt", lines 2-5:
> > 2014/03/21 * Test Round off
> >   Expenses          1 EUR @  $0.0086
> >   Expenses                 1 CAD @  $0.0083
> >   Income      -$0.00      
> Unbalanced remainder is:
>                $0.02
> Amount to balance against:
>              $0.0169
> Error: Transaction does not balance
>
> The point to note is although the amount remains exact within a 
> transaction , it is later rounded to highest display precision available.  
> The unround option simply does not work if precision of your amount is  
> less than what is required and the same result is carried of for later 
>
> For example I tried the following 
>
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income     -$0.0     
>   
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income     -$0.02   
>   
> 2014/03/21 * Test Round off
>   Expenses          1 EUR @  $0.0086
>   Expenses                 1 CAD @  $0.0083
>   Income     -$0.0169   
>   
>
> and the result is  with or without unround 
>
>  ledger -f legtest/round.txt --unround -V -E   balance
>              $0.0507  Expenses
>             $-0.0369  Income
> --------------------
>              $0.0138
>  
> Did you notice that Income of $0.0169 which was from the first transaction 
> is missing in the final result. Not to  mention that the precision of lot 
> prices is ignored for which bug 992 is filed.
> Will it not be good to have a precision option to set this precision (if 
> for display and for calculations). This provide flexibility to customize 
> and set the precision required in reporting and calculations. It does not 
> matter to the accountants what the internal storage is (however we are 
> relieved) but this result will definitely make them cautious.   Is such an 
> option available already?
>
>
> Regards
> Tripun Goel
>

-- 

--- 
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.

Reply via email to