Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add auto-balancing for the amount edit #173

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Conversation

mpjk
Copy link
Contributor

@mpjk mpjk commented Jul 8, 2024

Somewhat related issue: #150

Motivation

Very recently I migrated to Spliit from Tricount, and I am missing a feature which I have found very useful when adding shared expenses.

This occurs for example, when a statement contains a personal purchase which I only want to incur on myself, and I want the rest to be shared evenly.

Solution

Example: I have a shared expense of 20€, and I want to incur a 3€ purchase only to myself and divide the rest evenly.

  • In this case when the total is given, the form divides it evenly with participants by default.
  • To achieve this, I deduct my expense of the total, divide it by the amount of participants, and then add my expense back to my own part.
    • For 4 participants, the process looks like the following:
      • $\frac{Total(€) - Personal(€)}{Participants(n)} + Personal(€)\ \rightarrow \ \frac{20-3}{4} + 3 = 7.25$
      • Then this value can be input to according row, and the rest are allocated automatically (as 4.25 €)

To avoid errors and provide intuitive balancing on multiple participants, the autobalance occurs only on the participants, whose rows have not yet been edited.

Issues and ideas

  • This implementation does not automatically allocate a surplus/remaining cent on uneven totals, though whether this should even be automatic, is another discussion.

  • My implementation reflects how I have worked with expense systems in the past, it works fine when you have the necessary amounts already calculated or arbitrarily given, but its not as intuitive as the proposal in the issue. It quickly becomes obvious that manually calculating these type of expenses is cumbersome. Despite this, I find that my solution is better than none at all

    • If wanted/necessary, I can try improve this later on, to match the behaviour of the issue.
  • More so related to the existing default splitting options:

    • For example when 15 and 12 shares is selected and defaulted, this carries over to other split modes. My implementation overrides this behaviour on the amount split, but this remains for example on the percentages, where you end up with 15% and 12% in the mentioned situation.

mpjk added 2 commits July 8, 2024 15:19
this implementation allocates the rest of the total
to participants, whose rows have yet not been edited.
Copy link
Member

@scastiel scastiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was sceptical when reading the description of your PR, but when playing with it I find it very intuitive to use! :)

Thanks @mpjk!

@scastiel scastiel merged commit c392c06 into spliit-app:main Aug 2, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants