spiral-project / ihatemoney

A simple shared budget manager web application
https://ihatemoney.org
Other
1.2k stars 270 forks source link

Adding invalid reimbursements can cause the debt solver to fail #1295

Open TomRoussel opened 8 months ago

TomRoussel commented 8 months ago

Description

I was playing around with the new bill types when I ran into this problem. When you manually add a reimbursement that is invalid, this error triggers on the settle page:

image

Looks like this is related to reimbursement types with multiple people in the "payed_for" field. This does not happen when you use the "settle" button, as it creates valid reimbursements, but users can also manually add reimbursements. If they do this incorrectly, this completely breaks the settle page.

I think we can fix this by adding a constraint on bill creation that any reimbursement type bills should only have 1 'payed_for' entry.

To reproduce

Because of #1293, you can't reproduce this on the current master (as of commit 4af4c10). You can reproduce this issue using 483b94cd1afd72f1a34e8db411d7afa2ab297d26. Steps to reproduce:

zorun commented 8 months ago

Indeed, and statistics are also off in that case.

Alternatively, we could fix all places doing computation so that they take into account multiple beneficiaries. It's not hard, just reusing the same code as expense bill should do the trick (and that would factor code which is good).

But as you said, it doesn't really make sense to settle to multiple people at once.

I suggest doing both so that we are robust: fix computation, but also prevent creation of settlements with multiple beneficiairies. Also, tests would be good.

zorun commented 8 months ago

The "fix computation" part is in #1300