Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f8ea96a8

Von Jan Büren vor mehr als 2 Jahren hinzugefügt

  • ID f8ea96a8998769793579960f6c220722fb6c6b6c
  • Vorgänger 2cbf256e
  • Nachfolger 1216d52e

S/D/H/Payment: within_skonto_period umgeschrieben auf Params::Validate

Unterschiede anzeigen:

SL/DB/Helper/Payment.pm
use Data::Dumper;
use DateTime;
use List::Util qw(sum);
use Params::Validate qw(:all);
use SL::DATEV qw(:CONSTANTS);
use SL::DB::Exchangerate;
......
return @skonto_charts;
}
sub within_skonto_period {
my $self = shift;
my $dateref = shift || DateTime->now->truncate( to => 'day' );
return undef unless ref $dateref eq 'DateTime';
return 0 unless $self->skonto_date;
# return 1 if requested date (or today) is inside skonto period
# this will also return 1 if date is before the invoice date
return $dateref <= $self->skonto_date;
};
validate(
@_,
{ transdate => {
isa => 'DateTime',
callbacks => {
'self has a skonto date' => sub { ref $self->skonto_date eq 'DateTime' },
'is within skonto period' => sub { return shift() <= $self->skonto_date },
},
},
}
);
# then return true
return 1;
}
sub valid_skonto_amount {
my $self = shift;

Auch abrufbar als: Unified diff