Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision df1b03d5

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

  • ID df1b03d578280d71fb839b437505dd283f6dd749
  • Vorgänger 0409db7c
  • Nachfolger 2bdd0bc5

PriceSource: Featureabdeckung

- Einkaufs/Verkauf abgedeckt
- Klarere Regeln für price_from_source, available_prices und best_price
- makemodels unterstützung
- bugfixes für Rechnungen und neue Belege
- best_price jetzt getestet
- Verkäuferabhängigkeit von makemodels und pricegroup implementiert und getestet

Unterschiede anzeigen:

SL/PriceSource/MasterData.pm
13 13
sub available_prices {
14 14
  my ($self, %params) = @_;
15 15

  
16
  my $part = $self->part;
16
  return () unless $self->part;
17 17

  
18
  return () unless $part;
19

  
20
  # TODO: sellprice only in sales, lastcost in purchase
21
  return $self->make_sellprice($part);
18
  grep { $_->price > 0 } $self->record->is_sales
19
    ? ($self->make_sellprice, $self->make_listprice)
20
    : ($self->make_lastcost,  $self->make_listprice);
22 21
}
23 22

  
24 23
sub price_from_source {
25 24
  my ($self, $source, $spec) = @_;
26 25

  
27
  if ($spec eq 'sellprice') {
28
    return $self->make_sellprice($self->part);
29
  }
26
    $spec eq 'sellprice' ? $self->make_sellprice
27
  : $spec eq 'lastcost'  ? $self->make_lastcost
28
  : $spec eq 'listprice' ? $self->make_listprice
29
  : do { die "unknown spec '$spec'" };
30
}
31

  
32
sub best_price {
33
  $_[0]->record->is_sales
34
  ? $_[0]->make_sellprice
35
  : $_[0]->make_lastcost
30 36
}
31 37

  
32 38
sub make_sellprice {
33
  my ($self, $part) = @_;
39
  my ($self) = @_;
34 40

  
35 41
  return SL::PriceSource::Price->new(
36
    price        => $part->sellprice,
42
    price        => $self->part->sellprice,
37 43
    spec         => 'sellprice',
38 44
    description  => t8('Sellprice'),
39 45
    price_source => $self,
40 46
  );
41 47
}
42 48

  
49
sub make_listprice {
50
  my ($self) = @_;
51

  
52
  return SL::PriceSource::Price->new(
53
    price        => $self->part->listprice,
54
    spec         => 'listprice',
55
    description  => t8('List Price'),
56
    price_source => $self,
57
  );
58
}
59

  
60
sub make_lastcost {
61
  my ($self) = @_;
62

  
63
  return SL::PriceSource::Price->new(
64
    price        => $self->part->lastcost,
65
    spec         => 'lastcost',
66
    description  => t8('Lastcost'),
67
    price_source => $self,
68
  );
69
}
70

  
43 71
1;

Auch abrufbar als: Unified diff