X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9a941d5ec0d9db936c85b16bedd39f1d3aae835f..de8868c:/SL/CVar.pm diff --git a/SL/CVar.pm b/SL/CVar.pm index e91a2366d..bd58cbd7e 100644 --- a/SL/CVar.pm +++ b/SL/CVar.pm @@ -3,6 +3,7 @@ package CVar; use strict; use List::Util qw(first); +use Scalar::Util qw(blessed); use Data::Dumper; use SL::DBUtils; @@ -706,6 +707,25 @@ sub custom_variables_validity_by_trans_id { return sub { !$invalids{+shift} }; } +sub parse { + my ($self, $value, $config) = @_; + + return $::form->parse_amount(\%::myconfig, $value) if $config->{type} eq 'number'; + return DateTime->from_lxoffice($value) if $config->{type} eq 'date'; + return !ref $value ? SL::DB::Manager::Customer->find_by(id => $value * 1) : $value if $config->{type} eq 'customer'; + return $value; +} + +sub format_to_template { + my ($self, $value, $config) = @_; + # stupid template expects everything formated. except objects + # do not use outside of print routines for legacy templates + + return $::form->parse_amount(\%::myconfig, $value) if $config->{type} eq 'number'; + return $value->to_lxoffice if $config->{type} eq 'date' && blessed $value && $value->can('to_lxoffice'); + return $value; +} + 1; __END__