1 package SL::SEPA::XML::Transaction;
7 use List::Util qw(first);
8 use POSIX qw(strftime);
25 $self->{sepa} = $params{sepa};
28 my $missing_parameter = first { !$params{$_} } qw(src_iban src_bic dst_iban dst_bic company reference amount end_to_end_id);
29 croak "Missing parameter: $missing_parameter" if ($missing_parameter);
31 $params{end_to_end_id} ||= 'NOTPROVIDED';
32 $params{execution_date} ||= strftime "%Y-%m-%d", localtime;
34 croak "Execution date format wrong for '$params{execution_date}': not YYYY-MM-DD." if ($params{execution_date} !~ /^\d{4}-\d{2}-\d{2}$/);
36 map { $self->{$_} = $self->{sepa}->{iconv}->convert($params{$_}) } keys %params;
37 map { $self->{$_} =~ s/\s+//g } qw(src_iban src_bic dst_iban dst_bic);
38 map { $self->{$_} = $self->{sepa}->_replace_special_chars($self->{$_}) } qw(company reference end_to_end_id);
46 return undef if (!defined $self->{$key});
48 my $str = $max_len ? substr($self->{$key}, 0, $max_len) : $self->{$key};
50 return encode('UTF-8', $str);