X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FTemplate%2FPlugin%2FLxERP.pm;h=dded29777913a777b375558d55eead40795ddaa1;hb=91ee6cb28c37fe07d001da04808f9c49e1959502;hp=1bd03dab83a3986a19915e2729bb3ec5e86f7a23;hpb=f2860992e33c0269fe99dd8105cbf5ace857b50b;p=kivitendo-erp.git diff --git a/SL/Template/Plugin/LxERP.pm b/SL/Template/Plugin/LxERP.pm index 1bd03dab8..dded29777 100644 --- a/SL/Template/Plugin/LxERP.pm +++ b/SL/Template/Plugin/LxERP.pm @@ -7,6 +7,8 @@ use List::Util qw(min); use SL::AM; +use strict; + sub new { my $class = shift; my $context = shift; @@ -15,9 +17,16 @@ sub new { } sub format_amount { + my ($self, $var, $places, $skip_zero, $dash) = @_; + + return $main::form->format_amount(\%main::myconfig, $var * 1, $places, $dash) unless $skip_zero && $var == 0; + return ''; +} + +sub round_amount { my ($self, $var, $places, $skip_zero) = @_; - return $main::form->format_amount(\%main::myconfig, $var * 1, $places) unless $skip_zero && $var == 0; + return $main::form->round_amount($var * 1, $places) unless $skip_zero && $var == 0; return ''; } @@ -33,6 +42,8 @@ sub format_amount_units { sub format_percent { my ($self, $var, $places, $skip_zero) = @_; + $places ||= 2; + return $self->format_amount($var * 100, $places, $skip_zero); } @@ -90,4 +101,17 @@ sub turn90 { } } +sub abs { + my $self = shift; + my $var = shift; + + return $var < 0 ? $var * -1 : $var; +} + +sub t8 { + my ($self, $text, $args) = @_; + $self->{locale} ||= Locale->new($::myconfig{countrycode}, 'all'); + return $self->{locale}->text($text, @args) || $text; +} + 1;