format_amount - negative 0 vermeiden
[kivitendo-erp.git] / SL / Form.pm
index a0dbb91..35b21d5 100644 (file)
@@ -66,6 +66,7 @@ use SL::IC;
 use SL::IS;
 use SL::Layout::Dispatcher;
 use SL::Locale;
+use SL::Locale::String;
 use SL::Mailer;
 use SL::Menu;
 use SL::MoreCommon qw(uri_encode uri_decode);
@@ -821,6 +822,7 @@ sub format_amount {
   my $force_places = defined $places && $places >= 0;
 
   $amount = $self->round_amount($amount, abs $places) if $force_places;
+  $neg    = 0 if $amount == 0; # don't show negative zero
   $amount = sprintf "%.*f", ($force_places ? $places : 10), abs $amount; # 6 is default for %fa
 
   # before the sprintf amount was a number, afterwards it's a string. because of the dynamic nature of perl
@@ -2607,16 +2609,17 @@ sub mtime_ischanged {
   my ($self, $table, $option) = @_;
 
   return                                       unless $self->{id};
-  croak ("wrong call, no valid table defined") unless $table =~ /(oe|ar|ap|delivery_orders|parts)/;
+  croak ("wrong call, no valid table defined") unless $table =~ /^(oe|ar|ap|delivery_orders|parts)$/;
 
   my $query       = "SELECT mtime, itime FROM " . $table . " WHERE id = ?";
   my $ref         = selectfirst_hashref_query($self, $self->get_standard_dbh, $query, $self->{id});
   $ref->{mtime} ||= $ref->{itime};
 
   if ($self->{lastmtime} && $self->{lastmtime} ne $ref->{mtime} ) {
-      my $etxt = ($option eq 'mail') ? "The document has been changed from other user. Please reopen it in another window and copy the changes to the new window" :
-                                       "The document has been changed from other user. No mail was sent. Please reopen it in another window and copy the changes to the new window";
-      $self->error($main::locale->text($etxt));
+      $self->error(($option eq 'mail') ?
+        t8("The document has been changed by another user. No mail was sent. Please reopen it in another window and copy the changes to the new window") :
+        t8("The document has been changed by another user. Please reopen it in another window and copy the changes to the new window")
+      );
     ::end_of_request();
   }
 }