@Ajoeibin The problem with doing it your way is that at the end of the
exercise, your assets is now a negative value instead of zero and rather
than the gain/loss being included in income, it is just recorded as a
change in the value of your assets.
That is why I use Asset Sales as an income category and Cost of Sales as an
expense category (so I can write off the cost of the assets sold).
On Tuesday, October 5, 2021 at 7:23:28 AM UTC+8 Jasel17212 wrote:
> After much research and tons of trial and error, I landed on the following
> solution. It's simple and elegant and seems to achieve my goal, even if
> there appears to be a minor bug (see below). Ironically, I was led down
> this path by a post I found elsewhere concerning hledger. I figured I
> would document my findings for those looking for a solution to this problem
> in the future.
>
> 2019/03/18 * Buy xx
> Assets:Investing:ABC Securities:xx 5.37578 xx @
> $26.725424031
> Equity:Opening Balances
>
> 2019/03/19 * Sell xx
> Assets:Investing:ABC Securities:xx -5.37578 xx
> {$26.725424031} @ $44.373095625
> Assets:Investing:ABC Securities:Cash $238.54
> Income:Capital Gains:Realized
>
> After making these entries, my ABC Securities:Cash balance is correct, and
> the balance report balances to $0.00.
>
> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit bal
> --depth=1 -e 2019-03-20
>
> $xxx,xxx.xx Assets
> $-xxx,xxx.xx Equity
> $xxx,xxx.xx Expenses
> $-xxx,xxx.xx Income
> $-xxx,xxx.xx Liabilities
> --------------------
> 0
>
> If I run the same report with the --unrealized flag, I still see the
> $94.87 show up in the unrealized gain category, and I see a balance for the
> same amount. This seems like a bug to me. If this report result is correct
> based on my journal entries above, I could use some help with understanding
> the logic.
>
> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit bal
> --depth=2 -e 2019-03-20 --unrealized
>
> $xxx,xxx.xx Assets
> $-xxx,xxx.xx Equity
> $-xxx,xxx.xx Opening Balances
> $-94.87 Unrealized Gains
> $xxx,xxx.xx Expenses
> $-xxx,xxx.xx Income
> $-xxx,xxx.xx Liabilities
> --------------------
> $-94.87
>
> Thanks!
> JL
>
> On Sunday, October 3, 2021 at 9:18:40 PM UTC-5 Jasel17212 wrote:
>
>> It seems that the order of the transactions matter. If I swap the
>> entries I get the following:
>>
>> 2019/03/19 * Sell xx
>> Assets:Investing:ABC Securities:xx -5.37578 xx @
>> $26.725424031
>> Expenses:Investing:ABC Securities:Cost of Sale $143.67
>> Income:Investing:ABC Securities:Sales -5.37578 xx @
>> $44.373095625
>> Assets:Investing:ABC Securities:Cash $238.54
>>
>> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit bal
>> --depth=1 -e 2019-03-20
>>
>> $xxx,xxx.xx Assets
>> $-xxx,xxx.xx Equity
>> $xxx,xxx.xx Expenses
>> $-xxx,xxx.xx Income
>> $-xxx,xxx.xx Liabilities
>> --------------------
>> 0
>>
>> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit bal
>> --depth=2 -e 2019-03-20 --unrealized
>>
>> $xxx,xxx.xx Assets
>> $-xxx,xxx.xx Equity
>> $-xxx,xxx.xx Opening Balances
>> $-94.87 Unrealized Gains
>> $xxx,xxx.xx Expenses
>> $-xxx,xxx.xx Income
>> $-xxx,xxx.xx Liabilities
>> --------------------
>> $-94.87
>>
>> That seems right to me.
>>
>> I would appreciate any other perspectives on this topic.
>>
>> Thanks!
>> JL
>>
>> On Sunday, October 3, 2021 at 8:52:52 PM UTC-5 Jasel17212 wrote:
>>
>>> That seems to get me a step closer, but I still see a balance of $94.87
>>> when I run my balance reports.
>>>
>>> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit
>>> bal --depth=1 -e 2019-03-20
>>>
>>> $xxx,xxx.xx Assets
>>> $-xxx,xxx.xx Equity
>>> $xxx,xxx.xx Expenses
>>> $-xxx,xxx.xx Income
>>> $-xxx,xxx.xx Liabilities
>>> --------------------
>>> $94.87
>>>
>>> The same report with the --unrealized flag also shows the same balance,
>>> but the unrealized category is now gone.
>>>
>>> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit
>>> bal --depth=2 -e 2019-03-20 --unrealized
>>>
>>> $xxx,xxx.xx Assets
>>> $-xxx,xxx.xx Equity
>>> $-xxx,xxx.xx Opening Balances
>>> $xxx,xxx.xx Expenses
>>> $-xxx,xxx.xx Income
>>> $-xxx,xxx.xx Liabilities
>>> --------------------
>>> $94.87
>>>
>>> I'm missing something here. How do I record the $94.87 as a capital
>>> gain and make the report balance to zero?
>>>
>>> Thanks
>>> JL
>>>
>>> On Sunday, October 3, 2021 at 8:23:20 PM UTC-5 [email protected]
>>> wrote:
>>>
>>>> Your asset sale is actually an income category and should be recorded
>>>> as such. In the same transaction you record the cost of the asset sold as
>>>> an expense:
>>>>
>>>> 2019/03/18 * Buy xx
>>>> Assets:Investing:ABC Securities:xx 5.37578 xx
>>>> @ $26.725424031
>>>> Equity:Opening Balances
>>>>
>>>> 2019/03/19 * Sell xx
>>>> Income:Investing:ABC Securities:Sales -5.37578 xx
>>>> @ $44.373095625
>>>> Assets:Investing:ABC Securities:Cash $238.54
>>>> Assets:Investing:ABC Securities:xx -5.37578 xx
>>>> @ $26.725424031
>>>> Expenses:Investing:ABC Securities:Cost of Sale $143.67
>>>>
>>>>
>>>> On Monday, October 4, 2021 at 8:53:07 AM UTC+8 Jasel17212 wrote:
>>>>
>>>>> I've run into an issue that I just can't find an answer to in either
>>>>> the manual or archived conversations from this group, so I thought I
>>>>> would
>>>>> post to see if you guys can help me out.
>>>>>
>>>>> Following is an example of a stock transaction:
>>>>>
>>>>> 2019/03/18 * Buy xx
>>>>> Assets:Investing:ABC Securities:xx 5.37578 xx
>>>>> @ $26.725424031
>>>>> Equity:Opening Balances
>>>>>
>>>>> 2019/03/19 * Sell xx
>>>>> Assets:Investing:ABC Securities:xx -5.37578 xx
>>>>> @ $44.373095625
>>>>> Assets:Investing:ABC Securities:Cash
>>>>>
>>>>> After completing the transaction, all of my ABC Securities:Cash
>>>>> balance is correct, and all is good. If I run a balance report, however,
>>>>> I
>>>>> see a $94.87 balance when I expected to see $0.00.
>>>>>
>>>>> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit
>>>>> bal --depth=1 -e 2019-03-20
>>>>>
>>>>> $xxx,xxx.xx Assets
>>>>> $-xxx,xxx.xx Equity
>>>>> $xxx,xxx.xx Expenses
>>>>> $-xxx,xxx.xx Income
>>>>> $-xxx,xxx.xx Liabilities
>>>>> --------------------
>>>>> $94.87
>>>>>
>>>>> If I run the same report with the --unrealized flag, I can see the
>>>>> $94.87 show up in the unrealized gain category.
>>>>>
>>>>> ledger -f register.ldg --price-db price_db.txt -V --strict --explicit
>>>>> bal --depth=2 -e 2019-03-20 --unrealized
>>>>>
>>>>> $xxx,xxx.xx Assets
>>>>> $-xxx,xxx.xx Equity
>>>>> $-xxx,xxx.xx Opening Balances
>>>>> $-94.87 Unrealized Gains
>>>>> $xxx,xxx.xx Expenses
>>>>> $-xxx,xxx.xx Income
>>>>> $-xxx,xxx.xx Liabilities
>>>>> --------------------
>>>>> 0
>>>>>
>>>>> In this example, I have realized the gain, so how do I record it as
>>>>> such? I have many more examples of this where the transaction has
>>>>> occurred
>>>>> exactly as above, but the accounts have a tax-deferred status, so how do
>>>>> I
>>>>> handle those accounts as well?
>>>>>
>>>>> Thanks
>>>>> JL
>>>>>
>>>>
--
---
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/2efac2cf-1b98-44f2-846a-e52ff09fc9fbn%40googlegroups.com.