Skip to content

Support non-equally split shares + various fixes#25

Open
tobast wants to merge 14 commits intobartromgens:masterfrom
tobast:weighted_share
Open

Support non-equally split shares + various fixes#25
tobast wants to merge 14 commits intobartromgens:masterfrom
tobast:weighted_share

Conversation

@tobast
Copy link
Contributor

@tobast tobast commented Feb 8, 2021

This is quite a lengthy PR, sorry for the huge review. Fixes #23.

High level overview

  • Introduce shares & recurrent shares that are not equally split: a user can specify each consumer's weight for a share. If users u1, u2, u3 participate with respective weights 1, 2, 1.25, for a total of 4.25, u1 would pay 1/4.25th of the price, u2, 2/4.25th of the price, etc. Note that the weights are purely arbitrary and only the fraction user_weight / total_weight counts.
  • Introduce all sorts of UI changes to support these without cluttering too much the space.
  • Introduce share presets: possibly weighted sets of consumers of a GroupAccount, saved under a name (eg. "rent"). This can come in handy if the same subset of people is often used, and if this group usually requires weighting.
  • Introduce a "presets" button in each group panel to add/edit/remove these presets.
  • Update to jquery 3.5.1 (1.10.2 was super old); serve jquery locally (do not use a CDN)
  • Fix Django-recurrence widget (to select recurrent shares' rules). Seems that this has been broken for a while.

Technical overview

  • A non-weighted (equally split) share is just a weighted share with weights of 1.0 for everyone.
  • Weighted shares only require adding a custom through model for the ManyToMany relationship between Transactions and UserProfile. This, however, requires a bit of implementation and refactoring.
  • The migration that moves from the standard through model to the new custom one is a tricky one — but I tested it heavily and I believe it safe.
  • Use path() instead of url() in urls.py (Django 2 style)
  • Rename BaseView -> BaseMixin, do not inherit from TemplateView anymore: this was breaking views that were not TemplateViews (eg. CreateView) becasue eg. get() does not generally call the super()-method.

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.

Split shares unequally

1 participant