Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 96717bed

Von Sven Schöling vor mehr als 10 Jahren hinzugefügt

  • ID 96717bed8061efaa4d626d5da34122ef0cb3e8d2
  • Vorgänger ee4b5270
  • Nachfolger 55872fd8

PriceTaxCalculator: chart->taxkey lookup vorberechnen

Unterschiede anzeigen:

SL/DB/Chart.pm
16 16
sub get_active_taxkey {
17 17
  my ($self, $date) = @_;
18 18
  $date ||= DateTime->today_local;
19

  
20
  my $cache = $::request->{cache}{chart}{$date};
21
  if ($cache->{$self->id}) {
22
    return $cache->{$self->id};
23
  }
24

  
19 25
  require SL::DB::TaxKey;
20 26
  return SL::DB::Manager::TaxKey->get_all(query   => [ and => [ chart_id  => $self->id,
21 27
                                                                startdate => { le => $date } ] ],
SL/DB/Helper/PriceTaxCalculator.pm
37 37
  $self->netamount(  0);
38 38
  $self->marge_total(0);
39 39

  
40
  SL::DB::Manager::Chart->cache_taxkeys(date => $self->transdate);
41

  
40 42
  my $idx = 0;
41 43
  foreach my $item ($self->items) {
42 44
    $idx++;
SL/DB/Manager/Chart.pm
6 6
use base qw(SL::DB::Helper::Manager);
7 7

  
8 8
use SL::DB::Helper::Sorted;
9
use DateTime;
10
use SL::DBUtils;
9 11

  
10 12
sub object_class { 'SL::DB::Chart' }
11 13

  
......
20 22
                  link => { like => "\%:${link}:\%" } ]);
21 23
}
22 24

  
25
sub cache_taxkeys {
26
  my ($self, %params) = @_;
27

  
28
  my $date  = $params{date} || DateTime->today;
29
  my $cache = $::request->{cache}{chart}{$date} ||= {};
30

  
31
  require SL::DB::TaxKey;
32
  my $tks = SL::DB::Manager::TaxKey->get_all;
33
  my %tks_by_id = map { $_->id => $_ } @$tks;
34

  
35
  my $rows = selectall_hashref_query($::form, $::form->get_standard_dbh, <<"", $date);
36
    SELECT DISTINCT ON (chart_id) chart_id, startdate, id
37
    FROM taxkeys
38
    WHERE startdate < ?
39
    ORDER BY chart_id, startdate DESC;
40

  
41
  for (@$rows) {
42
    $cache->{$_->{chart_id}} = $tks_by_id{$_->{id}};
43
  }
44
}
45

  
23 46
1;
24 47

  
25 48
__END__

Auch abrufbar als: Unified diff