Revision fd9eb2e3
Von Jan Büren vor etwa 2 Jahren hinzugefügt
SL/DB/Helper/Payment.pm | ||
---|---|---|
15 | 15 |
use Data::Dumper; |
16 | 16 |
use DateTime; |
17 | 17 |
use List::Util qw(sum); |
18 |
use Params::Validate qw(:all); |
|
18 | 19 |
|
19 | 20 |
use SL::DATEV qw(:CONSTANTS); |
20 | 21 |
use SL::DB::Exchangerate; |
... | ... | |
609 | 610 |
return @skonto_charts; |
610 | 611 |
} |
611 | 612 |
|
613 |
|
|
612 | 614 |
sub within_skonto_period { |
613 | 615 |
my $self = shift; |
614 |
my $dateref = shift || DateTime->now->truncate( to => 'day' ); |
|
615 |
|
|
616 |
return undef unless ref $dateref eq 'DateTime'; |
|
617 |
return 0 unless $self->skonto_date; |
|
618 |
|
|
619 |
# return 1 if requested date (or today) is inside skonto period |
|
620 |
# this will also return 1 if date is before the invoice date |
|
621 |
return $dateref <= $self->skonto_date; |
|
622 |
}; |
|
616 |
validate( |
|
617 |
@_, |
|
618 |
{ transdate => { |
|
619 |
isa => 'DateTime', |
|
620 |
callbacks => { |
|
621 |
'self has a skonto date' => sub { ref $self->skonto_date eq 'DateTime' }, |
|
622 |
'is within skonto period' => sub { return shift() <= $self->skonto_date }, |
|
623 |
}, |
|
624 |
}, |
|
625 |
} |
|
626 |
); |
|
627 |
# then return true |
|
628 |
return 1; |
|
629 |
} |
|
623 | 630 |
|
624 | 631 |
sub valid_skonto_amount { |
625 | 632 |
my $self = shift; |
Auch abrufbar als: Unified diff
S/D/H/Payment: within_skonto_period umgeschrieben auf Params::Validate