julien-nc / cospend-nc

💰 💲hared budget manager Nextcloud app
GNU Affero General Public License v3.0
238 stars 29 forks source link

Splitwise Import wrong total amount #244

Open besar22 opened 11 months ago

besar22 commented 11 months ago

Hello,

Great project. Amazing work.

I have an issue with a Splitwise project. Lets review an example for the rent split with 3 people. Rent is 1680 and split is even. Splitwise export:

Date Description Category Cost Currency Person A Person B Person C
2023-09-01 Rent Rent 1680 EUR -560 -560 1120

This line gets imported as a total of 1120 from Person C to Person A & B. I expect this line to be imported as 1680 paid from Person C to all.

How do you cover this case? Did Splitwise change the export format? What can I do to correct this case?

Looking forward to your thoughts.

bvanelli commented 6 months ago

This is because the Cospend does not take into account the splits (let's say 1/3), instead it uses the raw values.

So splitting woulnd't be 1680 between 3 people, but rather you paid 1120 and receives back the raw amounts of 560 and 560.

You can see the the to whom always excludes the person that was paying the bill.

Alternatively the import function could check if the splits make sense to be a fraction (1/number of people) and, in those cases, create the right splits.

Here are the relevant lines: https://github.com/julien-nc/cospend-nc/blob/e946be409d1126e169389c93eee98ad7479e33d2/lib/Service/ProjectService.php#L4870-L4904