X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/3afbacf294bdbe21b08047c0a9fc1ad92f4c5c37..5b47ed3efe5f4ef0810096b0f4849047cee54690:/SL/IR.pm diff --git a/SL/IR.pm b/SL/IR.pm index c84778110..2077e6b0e 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -35,6 +35,7 @@ package IR; use SL::AM; +use SL::DBUtils; sub post_invoice { $main::lxdebug->enter_sub(); @@ -107,8 +108,12 @@ sub post_invoice { if ($form->{storno}) { $form->{"qty_$i"} *= -1; } + + if ($main::eur) { + $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"}; + } - if ($form->{"qty_$i"} != 0) { + if ($form->{"id_$i"}) { # get item baseunit $query = qq|SELECT p.unit @@ -620,6 +625,8 @@ sub post_invoice { ordnumber = '$form->{ordnumber}', quonumber = '$form->{quonumber}', transdate = '$form->{invdate}', + orddate = | . conv_dateq($form->{"orddate"}) . qq|, + quodate = | . conv_dateq($form->{"quodate"}) . qq|, vendor_id = $form->{vendor_id}, amount = $amount, netamount = $netamount, @@ -841,7 +848,8 @@ sub retrieve_invoice { # retrieve invoice $query = qq|SELECT a.cp_id, a.invnumber, a.transdate AS invdate, a.duedate, - a.ordnumber, a.quonumber, a.paid, a.taxincluded, a.notes, a.taxzone_id, a.storno, + a.orddate, a.quodate, + a.ordnumber, a.quonumber, a.paid, a.taxincluded, a.notes, a.taxzone_id, a.storno, a.gldate, a.intnotes, a.curr AS currency FROM ap a WHERE a.id = $form->{id}|; @@ -1147,7 +1155,7 @@ sub retrieve_item { $form->{transdate} ? $dbh->quote($form->{transdate}) : "current_date"; } - my $query = qq|SELECT p.id, p.partnumber, p.description, p.sellprice, + my $query = qq|SELECT p.id, p.partnumber, p.description, p.lastcost AS sellprice, p.listprice, p.inventory_accno_id, c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from as inventory_valid, c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid, @@ -1218,7 +1226,7 @@ sub retrieve_item { sub vendor_details { $main::lxdebug->enter_sub(); - my ($self, $myconfig, $form) = @_; + my ($self, $myconfig, $form, @wanted_vars) = @_; # connect to database my $dbh = $form->dbconnect($myconfig); @@ -1245,6 +1253,14 @@ sub vendor_details { # remove id and taxincluded before copy back delete @$ref{qw(id taxincluded)}; + + @wanted_vars = grep({ $_ } @wanted_vars); + if (scalar(@wanted_vars) > 0) { + my %h_wanted_vars; + map({ $h_wanted_vars{$_} = 1; } @wanted_vars); + map({ delete($ref->{$_}) unless ($h_wanted_vars{$_}); } keys(%{$ref})); + } + map { $form->{$_} = $ref->{$_} } keys %$ref; $sth->finish;