From: Moritz Bunkus Date: Thu, 19 Jun 2014 13:11:59 +0000 (+0200) Subject: SL::DB::Part: Cachen von Objekten gefixt X-Git-Tag: release-3.2.0beta~411^2~49 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0682dd7ebd3f16a8b7cf282df5c8343d6fa10068;p=kivitendo-erp.git SL::DB::Part: Cachen von Objekten gefixt Über Steuerzonen erhaltene Informationen müssen pro Part-ID gecachet werden, weil diese natürlich Artikel-spezifisch sind. --- diff --git a/SL/DB/Part.pm b/SL/DB/Part.pm index a0f9c1034..1380c4d2b 100644 --- a/SL/DB/Part.pm +++ b/SL/DB/Part.pm @@ -146,17 +146,18 @@ sub get_taxkey { my $taxzone = $params{ defined($params{taxzone}) ? 'taxzone' : 'taxzone_id' } * 1; my $tk_info = $::request->cache('get_taxkey'); - $tk_info->{$taxzone} ||= { }; - $tk_info->{$taxzone}->{$is_sales} ||= { }; + $tk_info->{$self->id} //= {}; + $tk_info->{$self->id}->{$taxzone} //= { }; + my $cache = $tk_info->{$self->id}->{$taxzone}->{$is_sales} //= { }; - if (!exists $tk_info->{$taxzone}->{$is_sales}->{$date}) { - $tk_info->{$taxzone}->{$is_sales}->{$date} = + if (!exists $cache->{$date}) { + $cache->{$date} = $self->get_chart(type => $is_sales ? 'income' : 'expense', taxzone => $taxzone) ->load ->get_active_taxkey($date); } - return $tk_info->{$taxzone}->{$is_sales}->{$date}; + return $cache->{$date}; } sub get_chart { @@ -165,7 +166,7 @@ sub get_chart { my $type = (any { $_ eq $params{type} } qw(income expense inventory)) ? $params{type} : croak("Invalid 'type' parameter '$params{type}'"); my $taxzone = $params{ defined($params{taxzone}) ? 'taxzone' : 'taxzone_id' } * 1; - my $charts = $::request->cache('get_chart_id/by_taxzones'); + my $charts = $::request->cache('get_chart_id/by_part_id_and_taxzone')->{$self->id} //= {}; my $all_charts = $::request->cache('get_chart_id/by_id'); $charts->{$taxzone} ||= { };