use SL::Iconv;
use SL::SEPA::XML::Transaction;
-use SL::DB::Helper::ReplaceSpecialChars qw(replace_special_chars);
sub new {
my $class = shift;
croak "Missing parameter: $missing_parameter" if ($missing_parameter);
croak "Missing parameter: creditor_id" if !$self->{creditor_id} && $self->{collection};
- map { $self->{$_} = replace_special_chars($self->{iconv}->convert($self->{$_})) } qw(company message_id creditor_id);
+ map { $self->{$_} = $self->_replace_special_chars($self->{iconv}->convert($self->{$_})) } qw(company message_id creditor_id);
}
sub add_transaction {
return 1;
}
+sub _replace_special_chars {
+ my $self = shift;
+ my $text = shift;
+
+ my %special_chars = (
+ 'ä' => 'ae',
+ 'ö' => 'oe',
+ 'ü' => 'ue',
+ 'Ä' => 'Ae',
+ 'Ö' => 'Oe',
+ 'Ü' => 'Ue',
+ 'ß' => 'ss',
+ '&' => '+',
+ '`' => '\'',
+ );
+
+ map { $text =~ s/$_/$special_chars{$_}/g; } keys %special_chars;
+
+ # for all other non ascii chars 'OLÉ S.L.' and 'Årdberg AB'!
+ use Text::Unidecode qw(unidecode);
+ $text = unidecode($text);
+
+ return $text;
+}
+
sub _format_amount {
my $self = shift;
my $amount = shift;
my $is_coll = $self->{collection};
my $cd_src = $is_coll ? 'Cdtr' : 'Dbtr';
my $cd_dst = $is_coll ? 'Dbtr' : 'Cdtr';
- my $pain_id = $is_coll ? 'pain.008.002.02' : 'pain.001.002.03';
+ my $pain_id = $is_coll ? 'pain.008.001.02' : 'pain.001.001.03';
my $pain_elmt = $is_coll ? 'CstmrDrctDbtInitn' : 'CstmrCdtTrfInitn';
my @pii_base = (strftime('PII%Y%m%d%H%M%S', @now), rand(1000000000));