Revision 2a976334
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; |
... | ... | |
617 | 618 |
return @skonto_charts; |
618 | 619 |
} |
619 | 620 |
|
621 |
|
|
620 | 622 |
sub within_skonto_period { |
621 | 623 |
my $self = shift; |
622 |
my $dateref = shift || DateTime->now->truncate( to => 'day' ); |
|
623 |
|
|
624 |
return undef unless ref $dateref eq 'DateTime'; |
|
625 |
return 0 unless $self->skonto_date; |
|
626 |
|
|
627 |
# return 1 if requested date (or today) is inside skonto period |
|
628 |
# this will also return 1 if date is before the invoice date |
|
629 |
return $dateref <= $self->skonto_date; |
|
630 |
}; |
|
624 |
validate( |
|
625 |
@_, |
|
626 |
{ transdate => { |
|
627 |
isa => 'DateTime', |
|
628 |
callbacks => { |
|
629 |
'self has a skonto date' => sub { ref $self->skonto_date eq 'DateTime' }, |
|
630 |
'is within skonto period' => sub { return shift() <= $self->skonto_date }, |
|
631 |
}, |
|
632 |
}, |
|
633 |
} |
|
634 |
); |
|
635 |
# then return true |
|
636 |
return 1; |
|
637 |
} |
|
631 | 638 |
|
632 | 639 |
sub valid_skonto_amount { |
633 | 640 |
my $self = shift; |
Auch abrufbar als: Unified diff
S/D/H/Payment: within_skonto_period umgeschrieben auf Params::Validate