maxrossello / redmine_app_timesheets

A true timesheet plugin using orders, not bound to timelogs over issues
GNU General Public License v2.0
32 stars 10 forks source link

TsTimeEntry deletion and copy edge case #71

Closed greyman888 closed 8 years ago

greyman888 commented 8 years ago

Hi Max,

I just raised this issue and linked it to my previous Pull Request #67 so that if you want you can reject the PR without losing the issue.

It would really be good to get this fixed soon as I have had a few instances of people complaining that rows have magically disappeared from their timesheets and I suspect that this is the cause.

Thanks,

Adam

I've found and proposed a fix for a small edge case bug that I ran into last week. Here is the scenario:

A user creates a version and makes it an order called 'Version Order'. The user creates an issue called 'Issue X' and selects 'Version Order'. The user works on the issue and adds some time with an activity called 'Design' The user adds the time entry to their timesheet In the timesheet, the user selects 'Version Order' from the order selection In the timesheet, the user selects 'Design' from the activity selection In the timesheet, the user leaves the issue selection blank In the timesheet, the user adds some time to this entry Now the user has two lines in their timesheet: Line 1 - has Version Order, Design, Issue X and some time Line 2 - has Version Order, Design, (no issue) and some time.

The user may realise they've made a mistake or just want to change their mind so they select delete on Line 2. The result is that Line 1 and Line 2 are deleted at the same time.

This only happens when both lines have the same activity and order.

The pull request fixes this by ensuring that when params[:issue_id] is nil only orders where issue_id = nil are selected.

I also did some very minor refactoring but if I've messed up your flow then the only really important change is to add .where(:issue_id => nil) to the line where entries are selected based on order_id.

BTW, I've started thinking about what to put in the wiki, so I hopefully will get that done in the next month or so.

Adam