X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIS.pm;h=7f4920134dbe50ee840812437adaefb041d502f8;hb=df956e31b1c10d194b1a2784147344684ec0efff;hp=b197053640cfb905c012e4a173e2e973348f21e7;hpb=98452aaaecf90a5689c21cc959074976985506c6;p=kivitendo-erp.git diff --git a/SL/IS.pm b/SL/IS.pm index b19705364..7f4920134 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -34,8 +34,6 @@ package IS; -#use strict; - use List::Util qw(max); use SL::AM; @@ -47,8 +45,11 @@ use SL::DO; use SL::GenericTranslations; use SL::MoreCommon; use SL::IC; +use SL::IO; use Data::Dumper; +use strict; + sub invoice_details { $main::lxdebug->enter_sub(); @@ -155,7 +156,7 @@ sub invoice_details { my @payment_arrays = qw(payment paymentaccount paymentdate paymentsource paymentmemo); - map { $form->{TEMPLATE_ARRAYS}{$_} => [] } (@arrays, @tax_arrays, @payment_arrays); + map { $form->{TEMPLATE_ARRAYS}->{$_} = [] } (@arrays, @tax_arrays, @payment_arrays); foreach $item (sort { $a->[1] cmp $b->[1] } @partsgroup) { $i = $item->[0]; @@ -197,7 +198,7 @@ sub invoice_details { push @{ $form->{TEMPLATE_ARRAYS}->{longdescription} }, $form->{"longdescription_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{qty} }, $form->format_amount($myconfig, $form->{"qty_$i"}); push @{ $form->{TEMPLATE_ARRAYS}->{unit} }, $form->{"unit_$i"}; - push @{ $form->{TEMPLATE_ARRAYS}->{deliverydate_oe} }, $form->{"deliverydate_$i"}; + push @{ $form->{TEMPLATE_ARRAYS}->{deliverydate_oe} }, $form->{"reqdate_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{sellprice} }, $form->{"sellprice_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{ordnumber_oe} }, $form->{"ordnumber_$i"}; push @{ $form->{TEMPLATE_ARRAYS}->{transdate_oe} }, $form->{"transdate_$i"}; @@ -737,8 +738,6 @@ sub post_invoice { } } - $form->{datepaid} = $form->{invdate}; - # total payments, don't move we need it here for my $i (1 .. $form->{paidaccounts}) { if ($form->{type} eq "credit_note") { @@ -950,9 +949,11 @@ sub post_invoice { $form->{marge_total} *= -1; } + IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh); + if ($payments_only) { - $query = qq|UPDATE ar SET paid = ?, datepaid = ? WHERE id = ?|; - do_query($form, $dbh, $query, $form->{paid}, $form->{paid} ? conv_date($form->{datepaid}) : undef, conv_i($form->{id})); + $query = qq|UPDATE ar SET paid = ? WHERE id = ?|; + do_query($form, $dbh, $query, $form->{paid}, conv_i($form->{id})); if (!$provided_dbh) { $dbh->commit(); @@ -990,7 +991,7 @@ sub post_invoice { $query = qq|UPDATE ar set invnumber = ?, ordnumber = ?, quonumber = ?, cusordnumber = ?, transdate = ?, orddate = ?, quodate = ?, customer_id = ?, - amount = ?, netamount = ?, paid = ?, datepaid = ?, + amount = ?, netamount = ?, paid = ?, duedate = ?, deliverydate = ?, invoice = ?, shippingpoint = ?, shipvia = ?, terms = ?, notes = ?, intnotes = ?, curr = ?, department_id = ?, payment_id = ?, taxincluded = ?, @@ -999,11 +1000,11 @@ sub post_invoice { cp_id = ?, marge_total = ?, marge_percent = ?, globalproject_id = ?, delivery_customer_id = ?, transaction_description = ?, delivery_vendor_id = ?, - donumber = ? + donumber = ? WHERE id = ?|; @values = ( $form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"}, conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}), - $amount, $netamount, $form->{"paid"}, conv_date($form->{"datepaid"}), + $amount, $netamount, $form->{"paid"}, conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), '1', $form->{"shippingpoint"}, $form->{"shipvia"}, conv_i($form->{"terms"}), $form->{"notes"}, $form->{"intnotes"}, $form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}), $form->{"taxincluded"} ? 't' : 'f', @@ -1012,17 +1013,10 @@ sub post_invoice { conv_i($form->{"cp_id"}), 1 * $form->{marge_total} , 1 * $form->{marge_percent}, conv_i($form->{"globalproject_id"}), conv_i($form->{"delivery_customer_id"}), $form->{transaction_description}, conv_i($form->{"delivery_vendor_id"}), - $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb + $form->{"donumber"}, #das entsprechende feld lieferscheinnummer aus der html-form 12.02.09 jb conv_i($form->{"id"})); do_query($form, $dbh, $query, @values); - if($form->{"formname"} eq "credit_note") { - for my $i (1 .. $form->{rowcount}) { - $query = qq|UPDATE parts SET onhand = onhand - ? WHERE id = ?|; - @values = (conv_i($form->{"qty_$i"}), conv_i($form->{"id_$i"})); - do_query($form, $dbh, $query, @values); - } - } if ($form->{storno}) { $query = @@ -1753,8 +1747,8 @@ sub retrieve_item { #Es soll auch nach EAN gesucht werden, ohne Einschränkung durch Beschreibung if ($form->{"partnumber_$i"} && !$form->{"description_$i"}) { - $where .= qq| OR (NOT p.obsolete = '1' AND p.ean = ? )|; - push @values, $form->{"partnumber_$i"}; + $where .= qq| OR (NOT p.obsolete = '1' AND p.ean = ? )|; + push @values, $form->{"partnumber_$i"}; } if ($form->{"description_$i"}) { @@ -1978,12 +1972,10 @@ sub get_pricegroups_for_parts { $id = $form->{"id_$i"}; if (!($form->{"id_$i"}) and $form->{"new_id_$i"}) { - $id = $form->{"new_id_$i"}; } - my ($price, $selectedpricegroup_id) = split(/--/, - $form->{"sellprice_pg_$i"}); + my ($price, $selectedpricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"}); my $pricegroup_old = $form->{"pricegroup_old_$i"}; $form->{"new_pricegroup_$i"} = $selectedpricegroup_id; @@ -2056,14 +2048,11 @@ sub get_pricegroups_for_parts { # if there is an exchange rate change price if (($form->{exchangerate} * 1) != 0) { - $pkr->{price} /= $form->{exchangerate}; } $pkr->{price} *= $form->{"basefactor_$i"}; - $pkr->{price} *= $basefactor; - $pkr->{price} = $form->format_amount($myconfig, $pkr->{price}, 5); if ($selectedpricegroup_id eq undef) {