プロジェクト

全般

プロフィール

Vote #74287

未完了

Allow negative time entries

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Time tracking_13
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
13
version_id:
0
issue_org_id:
14735
author_id:
36999
assigned_to_id:
0
comments:
16
status_id:
1
tracker_id:
3
plus1:
2
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

journals

--------------------------------------------------------------------------------
Here is the first patch (Redmine::CoreExtensions::String::Conversions.to_hours).

I will furnish the last one (TimeEntry model validations) soon.

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Why should we allow negative time entries BTW?
--------------------------------------------------------------------------------
Well I'm not sure either.

Maybe for a different use case like planning time savings. But I don't need this.
--------------------------------------------------------------------------------
Jean-Philippe Lang wrote:
> Why should we allow negative time entries BTW?

It's very simple, time spent are reported in our billing software each month.
When the month is validated, we must not changed previous time spent.
So if we want to make fixes of previous months, but stay in line between Redmine and other software, we can use negative hours to cancel previous wrong time entries.
Thus time spent if fixed on the next month, with keeping previously entered values.

We have tested negative hours and it works pretty well.
--------------------------------------------------------------------------------
By the way, the previous patch has issues.
Here is a more correct version.
--------------------------------------------------------------------------------
Jérôme BATAILLE wrote:
> Jean-Philippe Lang wrote:
> > Why should we allow negative time entries BTW?
>
> It's very simple, time spent are reported in our billing software each month.
> When the month is validated, we must not changed previous time spent.
> So if we want to make fixes of previous months, but stay in line between Redmine and other software, we can use negative hours to cancel previous wrong time entries.
> Thus time spent if fixed on the next month, with keeping previously entered values.
>
> We have tested negative hours and it works pretty well.

Not sure either it's a good idea to store adjustments in Redmine which is not a billing system, maybe a plugin could do it?

--------------------------------------------------------------------------------
Etienne Massip wrote:
> Not sure either it's a good idea to store adjustments in Redmine which is not a billing system, maybe a plugin could do it?

It's just a question of extending the possible values.
for now, it's : *0 <= spent_hours < 1000*

It's only an enhancement to allow *-1000 < spent_hours < 1000*

The only places to modify are :
* the display helpers :
** to_hours
** l_hours

* the validation

Pretty simple.

We have done the missing modifications in our plugin, but it would be very great to have no need to put these in it.

+To explain our Redmine use :+

This enhancement is properly to address the issue of software separation.
In our company we had a lot of demands to extend Redmine to satisfy constraints :
* time_spent in days
* hours by day management
* etc.
We choiced to keep the way Redmine works, Redmine gathers hours that's all.

We are now modifying our business processes to track time with Redmine, and I suppose it's the normal choice that finish to appear, for companies that use Redmine as their main tracking software.
If you use it to be able to tell what are people are doing precisely, it's the right place to gather the duration of their actions.
The direct consequence is that collected time spent has to be exported each month (or more often) in another software with budget tracking constraints.

Thus time spent has to be *exported*, and *then adapted* to budget and billing constraints.

But allowing negative values is a simple way to allow Redmine to cope with input errors, while keeping a trace of the first input. This issue is linked too, to the fact that time_entries modifications are not journalized.

In fact we have even developed a big enhancement to be able to track too the budget and remaining time, and thus manage follow-up on our projects. Same choice, these data are exported and then adapted to budget and billing constraints.

So Redmine is really adapted to the buisness processes of a big company, but it has only to be tweaked on some very few and minor points.
--------------------------------------------------------------------------------
Hi, any chance that this enhancement can be examined ?

The patch is very simple and straightforward. We have been using it for more than 2 years and it works perfectly.
--------------------------------------------------------------------------------
Hi, In the patch (.diff) have a little error.

In the code of the patch miss a i letter. Check the next line:
s.gsub!(%r{^((-?\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0 * ($2.to_i > 0 ? 1 : -1)) : m[0] } <<WRONG
s.gsub!(%r{^((-?\d+)\s*(h|hours?))?\s*((\d+)\s*(m|min)?)?$}i) { |m| ($1 || $4) ? ($2.to_i + $5.to_i / 60.0 * ($2.to_i > 0 ? 1 : -1)) : m[0] } <<CORRECT

And it's necessary change the file /app/models/time_entry.rb :
........
def validate_time_entry
errors.add :hours, :invalid if hours && (hours <= -1000 || hours >= 1000)
errors.add :project_id, :invalid if project.nil?
errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project)
end
........
In order to admit values negatives.

Best.

--------------------------------------------------------------------------------
One bug more: Report don't show negative values.

We can correct this changing the following lines in the files:

./app/views/timelog/_report_criteria.html.erb: <td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
./app/views/timelog/_report_criteria.html.erb: <td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>
./app/views/timelog/report.html.erb: <td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td>
./app/views/timelog/report.html.erb: <td class="hours"><%= html_hours("%.2f" % total) if total > 0 %></td>

Change this lines inside the files as in the next:

./app/views/timelog/_report_criteria.html.erb: <td class="hours"><%= html_hours("%.2f" % sum) if sum > -1000 %></td>
./app/views/timelog/_report_criteria.html.erb: <td class="hours"><%= html_hours("%.2f" % total) if total > -1000 %></td>
./app/views/timelog/report.html.erb: <td class="hours"><%= html_hours("%.2f" % sum) if sum > -1000 %></td>
./app/views/timelog/report.html.erb: <td class="hours"><%= html_hours("%.2f" % total) if total > -1000 %></td>

Best.
--------------------------------------------------------------------------------
Edilberto, all your remarks about the other places to modify are correct.

what is the aim to add an *i* to the regular expression, we use it on our side without it.

--------------------------------------------------------------------------------
I have not found any mention of this *i* on the internet, and it's not used with the others regexp, could it be a typo ?
--------------------------------------------------------------------------------
+1 for allowing negative time entries
--------------------------------------------------------------------------------
+1

Jean-Philippe Lang wrote:
> Why should we allow negative time entries BTW?

Editing spent time does not leave a trace in the journals, so, we don't allow to do that. Adding negative values allows to make corrections but keep the history.
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリTime tracking_13 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0