Revision 101e13ee
Von Jan Büren vor etwa 2 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
49 | 49 |
use File::Temp (); |
50 | 50 |
use IO::File; |
51 | 51 |
use Math::BigInt; |
52 |
use Params::Validate qw(:all); |
|
52 | 53 |
use POSIX qw(strftime); |
53 | 54 |
use SL::Auth; |
54 | 55 |
use SL::Auth::DB; |
... | ... | |
1533 | 1534 |
sub check_exchangerate { |
1534 | 1535 |
$main::lxdebug->enter_sub(); |
1535 | 1536 |
|
1536 |
my ($self, $myconfig, $currency, $transdate, $fld) = @_; |
|
1537 |
|
|
1538 |
if ($fld !~/^buy|sell$/) { |
|
1539 |
$self->error('Fatal: check_exchangerate called with invalid buy/sell argument'); |
|
1540 |
} |
|
1541 |
|
|
1542 |
unless ($transdate) { |
|
1543 |
$main::lxdebug->leave_sub(); |
|
1544 |
return ""; |
|
1545 |
} |
|
1537 |
my $self = shift; |
|
1538 |
validate_pos(@_, |
|
1539 |
{ type => HASHREF, callbacks => { has_yy_in_dateformat => sub { $_[0]->{dateformat} =~ m/yy/ } } }, |
|
1540 |
{ type => SCALAR }, # should be ISO three letter codes for currency identification (ISO 4217) |
|
1541 |
{ type => SCALAR, callbacks => { is_valid_kivi_date => sub { shift =~ m/\d+\d+\d+/ } } }, # we have three numers |
|
1542 |
{ type => SCALAR, callbacks => { is_buy_or_sell_rate => sub { shift =~ m/^buy|sell$/ } } }, |
|
1543 |
); |
|
1544 |
my ($myconfig, $currency, $transdate, $fld) = @_; |
|
1546 | 1545 |
|
1547 | 1546 |
my ($defaultcurrency) = $self->get_default_currency($myconfig); |
1548 |
|
|
1549 | 1547 |
if ($currency eq $defaultcurrency) { |
1550 | 1548 |
$main::lxdebug->leave_sub(); |
1551 | 1549 |
return 1; |
Auch abrufbar als: Unified diff
Form: check_exchangerate auf Parameter-Validierung umgestellt