Rodrigolmti / lunch_money_companion

A companion Android application for lunch money
Apache License 2.0
10 stars 1 forks source link

Total income and expenses differ greatly from website #5

Open smiba opened 3 months ago

smiba commented 3 months ago

Describe the bug My income and expenses per month differ greatly between the website and the app, not only are both significantly (incorrectly) higher in the app (nearly double), the profit/loss calculation also does not come to the same answer.

I think this might be because of "hidden" transactions, I do a lot of account to account transfers (just sorting payments through bank accounts) and I have a specific category for this so they don't show up in the overview as the money never actually got spent, just moved around.

To Reproduce Steps to reproduce the behavior: Not sure, but probably making some transactions and assigning them to a "hidden" category does this

Expected behavior The total expenses and income being exactly the same as on the desktop website.

Smartphone (please complete the following information):

Rodrigolmti commented 3 months ago

Hello, thanks for reporting. I'll have to investigate, I do have the same use case as you, but I call them ignored, and at least for me, the income / expense is correct. At the moment, the logic that I use to calculate is as follows:

val totalIncome = transactions.filter { it.isIncome && !it.excludeFromTotals }
            .sumOf { AmountNormalizer.normalizeAmount(it.amount).toDouble() }.toFloat()
        val totalExpense = transactions.filter { !it.isIncome && !it.excludeFromTotals }
            .sumOf { AmountNormalizer.normalizeAmount(it.amount).toDouble() }.toFloat()

Which translates to: income -> sum all transactions that are marked as income and are not excludedFromTotals expenses -> sum all transactions that are marked as expense and are not excludedFromTotals

I suspect that your transaction may not being marked as excluded.