mayflower / PayForMe

iOS client for Cospend on Nextcloud
Apache License 2.0
78 stars 14 forks source link

Creation of new bill overwrites existing bill 99 #34

Closed m-idler closed 3 years ago

m-idler commented 3 years ago

In case there are 99 or more bills existing in the backend database, the creation of a new bill in the app overwrites the existing item with id 99.

The problem seems to be that newly created bills get an internal id of 99 in the app: https://github.com/mayflower/PayForMe/blob/f00330590dcb54146de5f05a3999e58947cc1bd4/PayForMe/Model/Bill.swift#L48

And due to the fact that an item with id 99 already exists in the app database, an "update" is send to the backend, and this overwrites the existing backend item 99: https://github.com/mayflower/PayForMe/blob/788c0babaa7d1f3d336289c303488fb271073d29/PayForMe/Services/ProjectManager.swift#L222

Maybe this location is affected as well? https://github.com/mayflower/PayForMe/blob/13a5d922c885b2b57f62b858828d25256ec5cce6/PayForMe/Views/Balance/BalanceList.swift#L84

A quick fix might be, to always create new items with an internal id of -1 instead of 99

redmull1611 commented 3 years ago

Hello m-idler

How o can solve the problem? Or it solved?

m-idler commented 3 years ago

A quick & easy workaround would be, to delete the entry with id 99 in the webinterface and create a new entry with that data. A newly created item within the app won't then overwrite anything anymore. I already tried the described solution with @Hustenbonbon and it seemed to work, so a change should be available soonish

Hustenbonbon commented 3 years ago

After debugging with @m-idler, the fix for this bug should be in the last release, so it should be fixed since 26.11.

@redmull1611 please confirm or tell if you still experience this bug.