X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=22c25c7ad9368ac732b2ea828c3c7ae285f7218a;hb=e36cc2a647f25b9b8f1b9b8965f9fdef09a5cd8b;hp=d90a0d0dbffd2e669e570c5e7bd499bb8179d774;hpb=debd14edcc23a6168e827be861a052f396aee901;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index d90a0d0db..22c25c7ad 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -353,7 +353,9 @@ sub invoice_details { $sth->finish; } - map { push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, $form->{"ic_cvar_$_->{name}_$i"} } @{ $ic_cvar_configs }; + push @{ $form->{TEMPLATE_ARRAYS}->{"ic_cvar_$_->{name}"} }, + CVar->format_to_template(CVar->parse($form->{"ic_cvar_$_->{name}_$i"}, $_), $_) + for @{ $ic_cvar_configs }; } } @@ -448,7 +450,8 @@ sub customer_details { # get rest for the customer my $query = qq|SELECT ct.*, cp.*, ct.notes as customernotes, - ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail + ct.phone AS customerphone, ct.fax AS customerfax, ct.email AS customeremail, + ct.curr AS currency FROM customer ct LEFT JOIN contacts cp on ct.id = cp.cp_cv_id WHERE (ct.id = ?) $where @@ -468,6 +471,9 @@ sub customer_details { map { $form->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{currency} =~ s/\s*$// if ($form->{currency}); + if ($form->{delivery_customer_id}) { $query = qq|SELECT *, notes as customernotes @@ -877,7 +883,7 @@ sub post_invoice { # record payments and offsetting AR if (!$form->{storno}) { for my $i (1 .. $form->{paidaccounts}) { - + if ($form->{"acc_trans_id_$i"} && $payments_only && ($::lx_office_conf{features}->{payments_changeable} == 0)) { @@ -1438,7 +1444,7 @@ sub retrieve_invoice { my ($sth, $ref, $query); - my $query_transdate = ", current_date AS invdate" if !$form->{id}; + my $query_transdate = !$form->{id} ? ", current_date AS invdate" : ''; $query = qq|SELECT @@ -1645,7 +1651,7 @@ sub get_customer { c.id AS customer_id, c.name AS customer, c.discount as customer_discount, c.creditlimit, c.terms, c.email, c.cc, c.bcc, c.language_id, c.payment_id, c.street, c.zipcode, c.city, c.country, - c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, + c.notes AS intnotes, c.klass as customer_klass, c.taxzone_id, c.salesman_id, c.curr, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.discount AS tradediscount, b.description AS business FROM customer c @@ -1659,6 +1665,12 @@ sub get_customer { map { $form->{$_} = $ref->{$_} } keys %$ref; + # remove any trailing whitespace + $form->{curr} =~ s/\s*$//; + + # use customer currency if not empty + $form->{currency} = $form->{curr} if $form->{curr}; + $query = qq|SELECT sum(amount - paid) AS dunning_amount FROM ar