ananthakumaran / paisa

Paisa – Personal Finance Manager. https://paisa.fyi demo: https://demo.paisa.fyi
https://paisa.fyi
GNU Affero General Public License v3.0
2.24k stars 111 forks source link

Paisa ignores lot prices #248

Open abcdw opened 2 weeks ago

abcdw commented 2 weeks ago

Describe your Environment OS: podman Paisa Version: 0.6.6 App Variant: Web

Describe the bug Reports for multi-currency transactions with lot price doesn't seem right.

I'm not very experienced ledger user, so it can be some mistake on my side, but ledger cli seems to produce right and expected for me results.

To Reproduce Open corresponding report pages.

Expected behavior I would expect liabilities to be fully repaid and balance amount equaled to zero, rather than 299.

Screenshots image

But it doesn't seem that Paisa respects lot prices: image image

Journal

P 2024-06-20 EUR 3.0103794 GEL

2024-06-29 Friend payed for me
    Expenses:Food                               1000 GEL
    Liabilities:Debt:Friend0                   -1000 GEL

2024-06-30 Convert
    Assets:Personal:Bank:SuperBank               -33 EUR @@ 1000 GEL
    Assets:GEL                                  1000 GEL

2024-06-30 Settle up with Friend
    Liabilities:Debt:Friend0                    1000 GEL
    Assets:GEL                                 -1000 GEL

P.S. Thank you very much for working on the Paisa, it makes it much easier to understand the structure of my finances.

ananthakumaran commented 2 weeks ago
2024-06-30 Convert
    Assets:Personal:Bank:SuperBank               -33 EUR @@ 1000 GEL
    Assets:GEL                                  1000 GEL

is the EUR price here correct? Paisa internally stores everything in the default currency format, so if the conversion rate has changed on 30th, it might affect other transactions. Ledger doesn't have a concept of default currency though, that's why it's not giving incorrect answers.

abcdw commented 2 weeks ago
2024-06-30 Convert
    Assets:Personal:Bank:SuperBank               -33 EUR @@ 1000 GEL
    Assets:GEL                                  1000 GEL

is the EUR price here correct?

It's not a real price, but for demonstration purpose it's correct. It has a big difference with price mentioned here: P 2024-06-20 EUR 3.0103794 GEL to make the problem more clear.

Paisa internally stores everything in the default currency format, so if the conversion rate has changed on 30th, it might affect other transactions.

It doesn't matter if conversation rate (price) changed on this date. I bought GEL for very different price that explicitly specified in lot price.

Ledger doesn't have a concept of default currency though, that's why it's not giving incorrect answers.

Not sure how "having default currency" should produce incorrect calculations, because I explicitly specified all the currencies for all transactions.

The Asset:Debt (-1000 GEL) was repaid with +1000 GEL (which was bought for 33 EUR) and now should be equal to 0. But it seems it calculated this way instead: 1000 GEL -> 332 EUR, repay with 33 EUR -> the total balance becomes 299, which is wrong.

Probably Paisa ignores lot prices?

ledger cli show correct value for the account.

image

ananthakumaran commented 2 weeks ago

1000 GEL -> 332 EUR, repay with 33 EUR -> the total balance becomes 299, which is wrong.

Unlike ledger Paisa doesn't keep track of multiple currencies when it computes the balance. I am assuming what you suspect might be actually happening. Have a look at the capital gains section of the docs, that might give some clues. I will try to debug later if I get any time

On Sun, 30 Jun, 2024, 12:08 pm Andrew Tropin, @.***> wrote:

2024-06-30 Convert Assets:Personal:Bank:SuperBank -33 EUR @@ 1000 GEL Assets:GEL 1000 GEL

is the EUR price here correct?

It's not a real price, but for demonstration purpose it's correct. It has a big difference with price mentioned here: P 2024-06-20 EUR 3.0103794 GEL to make the problem more clear.

Paisa internally stores everything in the default currency format, so if the conversion rate has changed on 30th, it might affect other transactions.

It doesn't matter if conversation rate (price) changed on this date. I bought GEL for very different price that explicitly specified in lot price.

Ledger doesn't have a concept of default currency though, that's why it's not giving incorrect answers.

Not sure how "having default currency" should produce incorrect calculations, because I explicitly specified all the currencies for all transactions.

The Asset:Debt (-1000 GEL) was repaid with +1000 GEL (which was bought for 33 EUR) and now should be equal to 0. But it seems it calculated this way instead: 1000 GEL -> 332 EUR, repay with 33 EUR -> the total balance becomes 299, which is wrong.

Probably Paisa ignores lot prices?

ledger cli show correct value for the account.

image.png (view on web) https://github.com/ananthakumaran/paisa/assets/1218615/deb9d57f-a531-4a94-8fa6-a1c978c17419

— Reply to this email directly, view it on GitHub https://github.com/ananthakumaran/paisa/issues/248#issuecomment-2198453471, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEN5UUJHED6CT5QGLRRKDZJ6RXHAVCNFSM6AAAAABKDZPDYCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJYGQ2TGNBXGE . You are receiving this because you commented.Message ID: @.***>

abcdw commented 2 weeks ago

1000 GEL -> 332 EUR, repay with 33 EUR -> the total balance becomes 299, which is wrong.

Unlike ledger Paisa doesn't keep track of multiple currencies when it computes the balance. I am assuming what you suspect might be actually happening. Have a look at the capital gains section of the docs, that might give some clues.

BTW, why it doesn't offload balance calculation to ledger? It could probably simplify the logic inside Paisa and make it more consistent in behavior with ledger.

I will try to debug later if I get any time

Thank you!

abcdw commented 2 weeks ago

Ok, the issue is not related to lot prices. It seems the reporting itself doesn't behave.

I made a simplier reproducer:

P 2024-06-20 EUR 3.0103794 GEL

2024-06-25 Friend payed for me
    Expenses:Food                               1000 GEL
    Liabilities:Debt:Friend0                   -1000 GEL

P 2024-06-30 EUR 33.3333333 GEL

2024-06-30 Convert
    Income:Personal:Salary                       -33 EUR
    Liabilities:Debt:Friend0                    1000 GEL

The ledger calculates balance correctly: image

The cash flow and liabilities views are problematic. The liabilities was in GEL and must remain in GEL, but from Paisa standpoint it seems like the liability were acquired in EUR, which is not what transaction says. image