projects
/
kivitendo-erp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Presenter Code - gl_transaction aus invoice wieder entfernt
[kivitendo-erp.git]
/
SL
/
PriceSource
/
Pricegroup.pm
diff --git
a/SL/PriceSource/Pricegroup.pm
b/SL/PriceSource/Pricegroup.pm
index
b1c75f8
..
8a322c5
100644
(file)
--- a/
SL/PriceSource/Pricegroup.pm
+++ b/
SL/PriceSource/Pricegroup.pm
@@
-4,6
+4,7
@@
use strict;
use parent qw(SL::PriceSource::Base);
use SL::PriceSource::Price;
use parent qw(SL::PriceSource::Base);
use SL::PriceSource::Price;
+use SL::DB::Price;
use SL::Locale::String;
use List::UtilsBy qw(min_by);
use List::Util qw(first);
use SL::Locale::String;
use List::UtilsBy qw(min_by);
use List::Util qw(first);
@@
-15,6
+16,8
@@
sub description { t8('Pricegroup') }
sub available_prices {
my ($self, %params) = @_;
sub available_prices {
my ($self, %params) = @_;
+ return () unless $self->record->is_sales;
+
my $item = $self->record_item;
my $prices = SL::DB::Manager::Price->get_all(
my $item = $self->record_item;
my $prices = SL::DB::Manager::Price->get_all(
@@
-30,34
+33,40
@@
sub available_prices {
} @$prices;
}
} @$prices;
}
+sub available_discounts { }
+
sub price_from_source {
my ($self, $source, $spec) = @_;
sub price_from_source {
my ($self, $source, $spec) = @_;
- my $price = SL::DB::Manager::Price->find_by(
id => $spec
);
+ my $price = SL::DB::Manager::Price->find_by(
pricegroup_id => $spec, parts_id => $self->part->id
);
+ # TODO: if someone deletes the prices entry, this fails. add a fallback
return $self->make_price($price);
}
sub best_price {
my ($self, %params) = @_;
return $self->make_price($price);
}
sub best_price {
my ($self, %params) = @_;
- my @prices = $self->availabe_prices;
+ return () unless $self->record->is_sales;
+
+ my @prices = $self->available_prices;
my $customer = $self->record->customer;
my $customer = $self->record->customer;
- my $min_price = min_by { $_->price } @prices;
- return
$min_price if !$customer || !$customer->cv_
klass;
+ return
() if !$customer || !$customer->
klass;
- my $best_price = first { $_->spec == $customer->
cv_c
lass } @prices;
+ my $best_price = first { $_->spec == $customer->
k
lass } @prices;
- return $best_price ||
$min_price
;
+ return $best_price ||
()
;
}
}
+sub best_discount { }
+
sub make_price {
my ($self, $price_obj) = @_;
SL::PriceSource::Price->new(
price => $price_obj->price,
sub make_price {
my ($self, $price_obj) = @_;
SL::PriceSource::Price->new(
price => $price_obj->price,
- spec => $price_obj->id,
+ spec => $price_obj->
pricegroup->
id,
description => $price_obj->pricegroup->pricegroup,
price_source => $self,
)
description => $price_obj->pricegroup->pricegroup,
price_source => $self,
)