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

Bug: When adding repetitive bills with "Repeat until" set to "No limit" thousands of bills are created in advance #201

Open
v3DJG6GL opened this issue Mar 9, 2023 · 8 comments
Labels
bug Something isn't working testing

Comments

@v3DJG6GL
Copy link

v3DJG6GL commented Mar 9, 2023

Issue/Actual behaviour:
When creating repetitive bills with Repeat until set to no limitation, thousands of bills are in advanced created - up to the year 12491!
Screenshot 2023-03-09 at 15-50-49 Cospend - Nextcloud

Expected behaviour:
If Repeat until is set to No limit when creating repetitive invoices, the invoices are created one after the other when the set repetition time is reached each time. In this case, it would be every 1st day of the month.

@julien-nc
Copy link
Owner

julien-nc commented Mar 11, 2023

Thanks for the bug report.

I can't reproduce this. Bill repetition is not supposed to create bills in the future.

Which version of Cospend/Nextcloud are you using?
What did you do exactly to trigger this infinite bill repetition? Initial bill date, date at which you pressed "Repeat now" etc... Any additional information could be useful.

@julien-nc julien-nc added bug Something isn't working question Further information is requested labels Mar 11, 2023
@v3DJG6GL
Copy link
Author

v3DJG6GL commented Mar 13, 2023

Thank you for your answer.

Nextcloud version: 25.0.2
Cospend version: 1.5.8

I have tried to reproduce the issue with new projects, but so far it has not worked either.
The project where the error occurred was an imported "I hate money" project. Maybe this could be the reason?
I will try to reproduce this in the coming days with an imported "I hate money" project....

@ouaisbahouais
Copy link

Screenshot_20230513-185734_Fennec_1

I have the same problem here. What bothers me the most is that it creates a bill every month for 11,000 years. So it's going to take a long time to go down the list to clean this up.
The other problem is that the Android apps don't sync anymore.

Nextcloud 26.0.1
Cospend 1.5.8
MoneyBuster 0.1.16

julien-nc added a commit that referenced this issue May 14, 2023
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc
Copy link
Owner

@ouaisbahouais Thanks for reporting this too.

I gave it a closer look, imported a IHateMoney project and could reproduce the bug.
The bill repetition was stuck in an infinite loop because the next bill repetition date was always considered to be in the past... The only thing stopping the infinite repetition was the Php memory limit so the more you gave the more you produced bills 🙈.
I have no real idea of why the date comparison was wrong. It seems like a weird behaviour of Php's DateInterval::invert.
This is now fixed by using timestamps to compare dates. This is a more reliable way to compare dates 😁

The fix is available in Cospend v1.5.9 which is out.
Could you play around and confirm this is fixed?
To reproduce the bug, I imported a IHM project, set monthly repetition on one bill, no date limit, and pressed "repeat now".

@julien-nc julien-nc added testing and removed question Further information is requested labels May 14, 2023
@ouaisbahouais
Copy link

I have searched a bit to find out how to delete false invoices. But I can't find a way to delete between one date and another. Because I think I have 35000 lines to delete.
I just did the update but I don't know if it's supposed to delete invoices of the future

Thanks for your help in any case

@julien-nc
Copy link
Owner

If you have access to your database you could run a DELETE query with a condition on the timestamp column.

The simplest query you could run is DELETE FROM oc_cospend_bills WHERE timestamp > MIN_TIMESTAMP
in which you would replace "MIN_TIMESTAMP" by a timestamp in the future. You would get rid of most of the created bills and then you could manually delete the remaining ones.

Problem is this will not delete the related rows in oc_cospend_bill_owers. You could run a query that deletes every row in oc_cospend_bill_owers for which the billid is not in the oc_cospend_bills table.

@julien-nc
Copy link
Owner

I could also implement a basic feature in Cospend to delete bills with date filters. Let's see if I find time and motivation to add that.

@julien-nc
Copy link
Owner

@ouaisbahouais v1.5.10 is out and includes a new occ command to delete bills.

occ cospend:delete-bills PROJECT_ID --what="WHAT" --min_timestamp=MIN_TIMESTAMP --simulate

"--what" and "--min_timestamp" are optional.
"--simulate" will only print the bills and not delete them.

I'm interested in any kind of feedback on this new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing
Projects
None yet
Development

No branches or pull requests

3 participants