On Wednesday, April 5, 2017 at 11:11:46 PM UTC+5:30, Kumar Appaiah wrote:
>
> Hi.
>
> For tax purposes for some mutual funds, I need to figure out the total 
> cost basis of the the units I have, along with the sale price, so that the 
> total cost minus total cost price of the units sold this year will be the 
> capital gain. In this example:
>
> 2016-04-01 * Buy MF 1
>     Assets    10 "MF1" @ 10.00 INR
>     MyBankAccount
>
> 2016-04-02 * Buy MF 2
>     Assets    20 "MF2" @ 12.00 INR
>     MyBankAccount
>
> 2016-05-01 * Buy MF 1
>     Assets    10 "MF1" @ 11.00 INR
>     MyBankAccount
>
> 2017-01-01 * Sell MF 1
>     Assets    -10 "MF1" {10.00 INR} [2016-04-01] @ 13.00 INR
>     Assets    -5 "MF1" {11.00 INR} [2016-05-01] @ 13.00 INR
>     CapitalGain    -40.00 INR
>     MyBankAccount    195.00 INR
>
> 2017-01-01 * Sell MF 2
>     Assets    -10 "MF2" {12.00 INR} [2016-04-02] @ 13.50 INR
>     CapitalGain    -15.00 INR
>     MyBankAccount    135.00 INR
>
> You can see that I've sold 15 MF1 units whose total cost is 10 * 10 + 5 * 
> 11 = 155 INR, and the total sale price is 195, giving me a capital gain of 
> 40.00 INR. Similarly, I've sold 10 MF2 units, so my cost is 120 INR and 
> sale value is 135.00 INR.
>
> What I need is a query (or queries) that will take the above file and give 
> me the total cost price (i.e. 155 + 120 = 275 INR) and total sale price 
> (195 + 135 = 330 INR). How can I get these numbers? I've coded up a hackish 
> Python program, but since the information to infer these is present in the 
> posts, it would be nice to get it directly from ledger.
>
> This worked for me:

Buy total price:
ledger -f test.dat bal -H --flat -l 'account =~ /(Assets)/' -l 'a < 0' 
--lots -B

Sell total price:
ledger -f test.dat bal -H --flat -l 'account =~ /(Assets)/' -l 'a < 0' 
--lots -V

Kumar

-- 

--- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to