X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=8f00225bec301928c9ff3408f860b4d24d4ca711;hb=979543127ce95408792573c99fc7eb09c30448c3;hp=32b5171214db191af9fb4a73c6e687658664f417;hpb=da4d7cff62387bda4ef51e2ca2001bd311db4cc4;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index 32b517121..8f00225be 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -48,6 +48,7 @@ use SL::MoreCommon; use SL::IC; use SL::IO; use SL::TransNumber; +use SL::DB::Default; use Data::Dumper; use strict; @@ -258,8 +259,7 @@ sub invoice_details { $subtotal_header = 0; } else { - push @{ $form->{TEMPLATE_ARRAYS}->{discount_sub} }, ""; - push @{ $form->{TEMPLATE_ARRAYS}->{nodiscount_sub} }, ""; + push @{ $form->{TEMPLATE_ARRAYS}->{$_} }, "" for qw(discount_sub nodiscount_sub discount_sub_nofmt nodiscount_sub_nofmt); } if (!$form->{"discount_$i"}) { @@ -887,7 +887,7 @@ sub post_invoice { if ($form->{"acc_trans_id_$i"} && $payments_only - && ($::lx_office_conf{features}->{payments_changeable} == 0)) { + && (SL::DB::Default->get->payments_changeable == 0)) { next; } @@ -933,18 +933,16 @@ sub post_invoice { # exchangerate difference $form->{fx}{$accno}{ $form->{"datepaid_$i"} } += - $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $diff; + $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $diff; # gain/loss $amount = - $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} * - $form->{"exchangerate_$i"}; + $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} * + $form->{"exchangerate_$i"}; if ($amount > 0) { - $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } += - $amount; + $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } += $amount; } else { - $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } += - $amount; + $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } += $amount; } $diff = 0; @@ -963,35 +961,32 @@ sub post_invoice { IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); - if ($payments_only) { - $query = qq|UPDATE ar SET paid = ? WHERE id = ?|; - do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); - - $dbh->commit if !$provided_dbh; - - $main::lxdebug->leave_sub(); - return; - } - # record exchange rate differences and gains/losses foreach my $accno (keys %{ $form->{fx} }) { foreach my $transdate (keys %{ $form->{fx}{$accno} }) { - if ( - ($form->{fx}{$accno}{$transdate} = - $form->round_amount($form->{fx}{$accno}{$transdate}, 2) - ) != 0 - ) { + $form->{fx}{$accno}{$transdate} = $form->round_amount($form->{fx}{$accno}{$transdate}, 2); + if ( $form->{fx}{$accno}{$transdate} != 0 ) { $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1', (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|; - @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, $project_id); + @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_i($project_id)); do_query($form, $dbh, $query, @values); } } } + if ($payments_only) { + $query = qq|UPDATE ar SET paid = ? WHERE id = ?|; + do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); + + $dbh->commit if !$provided_dbh; + + $main::lxdebug->leave_sub(); + return; + } + $amount = $netamount + $tax; # save AR record @@ -1163,7 +1158,7 @@ sub post_payment { $old_form = save_form(); # Delete all entries in acc_trans from prior payments. - if ($::lx_office_conf{features}->{payments_changeable} != 0) { + if (SL::DB::Default->get->payments_changeable != 0) { $self->_delete_payments($form, $dbh); } @@ -1676,6 +1671,7 @@ sub get_customer { 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.curr, + c.taxincluded_checked, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, b.discount AS tradediscount, b.description AS business FROM customer c