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

Issue #3592: Wrong sum when adding up time at the same article #3593

Open
wants to merge 1 commit into
base: rel-11_0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions Kernel/System/Ticket.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6334,15 +6334,34 @@ sub TicketAccountTime {
$Param{TimeUnit} = $DBObject->Quote( $Param{TimeUnit}, 'Number' );

# db update
return if !$DBObject->Do(
SQL => "INSERT INTO time_accounting "
. " (ticket_id, article_id, time_unit, create_time, create_by, change_time, change_by) "
. " VALUES (?, ?, $Param{TimeUnit}, current_timestamp, ?, current_timestamp, ?)",
Bind => [
\$Param{TicketID}, \$Param{ArticleID}, \$Param{UserID}, \$Param{UserID},
],

$DBObject->Prepare(
SQL => 'SELECT id, time_unit FROM time_accounting WHERE article_id = ?',
Bind => [ \$Param{ArticleID} ],
Limit => 1
);

# fetch the data
if ( my @Row = $DBObject->FetchrowArray() ) {
my $ID = $Row[0];
my $NewTimeUnit = $Row[1] + $Param{TimeUnit};
return if !$DBObject->Do(
SQL => 'UPDATE time_accounting SET time_unit = ?, change_time = current_timestamp, change_by = ? WHERE id = ?',
Bind => [ \$NewTimeUnit, \$Param{UserID}, \$ID ],
);
}
else {
return if !$DBObject->Do(
SQL => "INSERT INTO time_accounting "
. " (ticket_id, article_id, time_unit, create_time, create_by, change_time, change_by) "
. " VALUES (?, ?, $Param{TimeUnit}, current_timestamp, ?, current_timestamp, ?)",
Bind => [
\$Param{TicketID}, \$Param{ArticleID}, \$Param{UserID}, \$Param{UserID},
],
);
}


# clear ticket cache
$Self->_TicketCacheClear( TicketID => $Param{TicketID} );

Expand All @@ -6362,6 +6381,7 @@ sub TicketAccountTime {
Data => {
TicketID => $Param{TicketID},
ArticleID => $Param{ArticleID},
TimeUnits => $Param{TimeUnit}
},
UserID => $Param{UserID},
);
Expand Down