X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FForm.pm;h=c163532842950a2db75a5805e79a0a7de3c35e00;hb=fd8558c8cfd92d3399401a7ca27cbb0faf2a021d;hp=0573ed9d0bf256554d74d5d46efdbc61d17fb1d1;hpb=1a76210c4ec6ce96c12aa5e3a3a2e66a84143089;p=kivitendo-erp.git diff --git a/SL/Form.pm b/SL/Form.pm index 0573ed9d0..c16353284 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1,4 +1,4 @@ -#===================================================================== +#==================================================================== # LX-Office ERP # Copyright (C) 2004 # Based on SQL-Ledger Version 2.1.9 @@ -519,6 +519,12 @@ sub format_amount { $main::lxdebug->enter_sub(); my ($self, $myconfig, $amount, $places, $dash) = @_; + + #Workaround for $format_amount calls without $places + if (!defined $places){ + (my $dec) = ($amount =~ /\.(\d+)/); + $places = length $dec; + } if ($places =~ /\d/) { $amount = $self->round_amount($amount, $places); @@ -584,19 +590,44 @@ sub parse_amount { $main::lxdebug->enter_sub(); my ($self, $myconfig, $amount) = @_; - - if (!(substr($amount, -3, 1) eq ".")) { - if ( ($myconfig->{numberformat} eq '1.000,00') - || ($myconfig->{numberformat} eq '1000,00')) { - $amount =~ s/\.//g; - $amount =~ s/,/\./; - } - - $amount =~ s/,//g; - } - + $main::lxdebug->message(LXDebug::DEBUG2, "Start amount: $amount"); + + if ($myconfig->{in_numberformat} == 1){ + # Extra input number format 1000.00 or 1000,00 + $main::lxdebug->message(LXDebug::DEBUG2, "in_numberformat: " . $main::locale->text('1000,00 or 1000.00')); + $amount =~ s/,/\./g; + #$main::lxdebug->message(LXDebug::DEBUG2, "1.Parsed Number: $amount") if ($amount); + $amount = scalar reverse $amount; + #$main::lxdebug->message(LXDebug::DEBUG2, "2.Parsed Number: $amount") if ($amount); + $amount =~ s/\./DOT/; + #$main::lxdebug->message(LXDebug::DEBUG2, "3.Parsed Number: $amount") if ($amount); + $amount =~ s/\.//g; + #$main::lxdebug->message(LXDebug::DEBUG2, "4.Parsed Number: $amount") if ($amount); + $amount =~ s/DOT/\./; + #$main::lxdebug->message(LXDebug::DEBUG2, "5.Parsed Number:" . $amount) if ($amount); + $amount = scalar reverse $amount ; + $main::lxdebug->message(LXDebug::DEBUG2, "Parsed amount:" . $amount . "\n"); + + return ($amount * 1); + + } + $main::lxdebug->message(LXDebug::DEBUG2, "in_numberformat: " . $main::locale->text('equal Outputformat')); + $main::lxdebug->message(LXDebug::DEBUG2, " = numberformat: $myconfig->{numberformat}"); + if ( ($myconfig->{numberformat} eq '1.000,00') + || ($myconfig->{numberformat} eq '1000,00')) { + $amount =~ s/\.//g; + $amount =~ s/,/\./; + } + + if ($myconfig->{numberformat} eq "1'000.00") { + $amount =~ s/'//g; + } + + $amount =~ s/,//g; + + $main::lxdebug->message(LXDebug::DEBUG2, "Parsed amount:" . $amount. "\n") if ($amount); $main::lxdebug->leave_sub(); - + return ($amount * 1); } @@ -846,6 +877,7 @@ sub parse_template { } s/<%(.+?)%>/$self->{$1}/g; + s/<\/nobr>/ /g; print OUT; } @@ -1277,6 +1309,11 @@ sub get_exchangerate { $main::lxdebug->enter_sub(); my ($self, $dbh, $curr, $transdate, $fld) = @_; + + unless ($transdate) { + $main::lxdebug->leave_sub(); + return ""; + } my $query = qq|SELECT e.$fld FROM exchangerate e WHERE e.curr = '$curr' @@ -1667,7 +1704,7 @@ sub create_links { LEFT Join tax t ON (a.taxkey = t.taxkey) WHERE a.trans_id = $self->{id} AND a.fx_transaction = '0' - ORDER BY a.transdate|; + ORDER BY a.oid,a.transdate|; $sth = $dbh->prepare($query); $sth->execute || $self->dberror($query); @@ -1677,12 +1714,17 @@ sub create_links { $self->{exchangerate} = $self->get_exchangerate($dbh, $self->{currency}, $self->{transdate}, $fld); + my $index=0; # store amounts in {acc_trans}{$key} for multiple accounts while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { $ref->{exchangerate} = $self->get_exchangerate($dbh, $self->{currency}, $ref->{transdate}, $fld); + if ( !($xkeyref{ $ref->{accno} } =~ /tax/)) { + $index++; + } + $ref->{index} = $index; push @{ $self->{acc_trans}{ $xkeyref{ $ref->{accno} } } }, $ref; } @@ -1760,10 +1802,9 @@ sub lastname_used { $where = "quotation = '1'"; } - my $query = qq|SELECT id FROM $arap - WHERE id IN (SELECT MAX(id) FROM $arap + my $query = qq|SELECT MAX(id) FROM $arap WHERE $where - AND ${table}_id > 0)|; + AND ${table}_id > 0|; my $sth = $dbh->prepare($query); $sth->execute || $self->dberror($query); @@ -2209,7 +2250,7 @@ sub audittrail { $query = qq|INSERT INTO audittrail (trans_id, tablename, reference, formname, action, employee_id, transdate) VALUES ( $audittrail->{id}, '$audittrail->{tablename}', | - .$dbh->quote($audittrail->{reference}).qq|', + .$dbh->quote($audittrail->{reference}).qq|, '$audittrail->{formname}', '$audittrail->{action}', $employee_id, '$audittrail->{transdate}')|; } else {