X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FIR.pm;h=b8f22cd31a556ce68ee4e4780171634e70a54c75;hb=1bfdd83b1ba9b0dca96105be0a32ff3ea9794584;hp=1d4b9034836588760b3795cb0d48c8af8cc06369;hpb=b6dc5623d93c1be1c54248d4512e80f495af2899;p=kivitendo-erp.git diff --git a/SL/IR.pm b/SL/IR.pm index 1d4b90348..b8f22cd31 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -37,6 +37,7 @@ package IR; use SL::AM; use SL::Common; use SL::DBUtils; +use SL::DO; use SL::MoreCommon; use List::Util qw(min); @@ -178,8 +179,6 @@ sub post_invoice { @values = ($form->{"sellprice_$i"}, conv_i($form->{"id_$i"})); do_query($form, $dbh, $query, @values); - $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, $baseqty, $form->{"id_$i"}) if !$form->{shipped}; - # check if we sold the item already and # make an entry for the expense and inventory $query = @@ -540,8 +539,13 @@ sub post_invoice { Common::webdav_folder($form) if ($main::webdav); - my $rc = 1; + my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids}; + if (scalar @close_do_ids) { + DO->close_orders('dbh' => $dbh, + 'ids' => \@close_do_ids); + } + my $rc = 1; if (!$provided_dbh) { $rc = $dbh->commit(); $dbh->disconnect(); @@ -572,9 +576,6 @@ sub reverse_invoice { next unless $ref->{inventory_accno_id}; - # update onhand - $form->update_balance($dbh, "parts", "onhand", qq|id = $ref->{parts_id}|, $ref->{qty}); - # if $ref->{allocated} > 0 than we sold that many items next if ($ref->{allocated} <= 0); @@ -814,7 +815,6 @@ sub get_vendor { my ($self, $myconfig, $form, $params) = @_; $params = $form unless defined $params && ref $params eq "HASH"; - $main::lxdebug->message(0, Dumper($params)); # connect to database my $dbh = $form->dbconnect($myconfig); @@ -842,7 +842,7 @@ sub get_vendor { } my $query = qq|SELECT - v.id, v.name AS vendor, v.creditlimit, v.terms, v.notes AS intnotes, + v.name AS vendor, v.creditlimit, v.terms, v.notes AS intnotes, v.email, v.cc, v.bcc, v.language_id, v.payment_id, v.street, v.zipcode, v.city, v.country, v.taxzone_id, $duedate + COALESCE(pt.terms_netto, 0) AS duedate, @@ -1058,6 +1058,8 @@ sub retrieve_item { $stw->finish(); chop $ref->{taxaccounts}; + $ref->{onhand} *= 1; + push @{ $form->{item_list} }, $ref; } @@ -1079,7 +1081,7 @@ sub vendor_details { my @values; # get contact id, set it if nessessary - $form->{cp_id} = (split /--/, $form->{contact})[1]; + $form->{cp_id} *= 1; my $contact = ""; if ($form->{cp_id}) { $contact = "AND cp.cp_id = ?"; @@ -1109,6 +1111,11 @@ sub vendor_details { map { $form->{$_} = $ref->{$_} } keys %$ref; + my $custom_variables = CVar->get_custom_variables('dbh' => $dbh, + 'module' => 'CT', + 'trans_id' => $form->{vendor_id}); + map { $form->{"vc_cvar_$_->{name}"} = $_->{value} } @{ $custom_variables }; + $dbh->disconnect(); $main::lxdebug->leave_sub();