From: Moritz Bunkus Date: Mon, 5 Feb 2007 11:47:08 +0000 (+0000) Subject: Beim Speichern von Artikeln werden die Kontennummern jetzt anhand von $form->{"item... X-Git-Tag: release-2.4.2~151 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b80a03a9cf7a249e771c5ce080970ce5131e10f0;p=kivitendo-erp.git Beim Speichern von Artikeln werden die Kontennummern jetzt anhand von $form->{"item"} gefüllt. --- diff --git a/SL/IC.pm b/SL/IC.pm index 933b80173..11bf58690 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -328,16 +328,6 @@ sub save { $main::lxdebug->enter_sub(); my ($self, $myconfig, $form) = @_; - $form->{IC_expense} = "1000"; - $form->{IC_income} = "2000"; - - if ($form->{item} ne 'service') { - $form->{IC} = $form->{IC_expense}; - } - - ($form->{inventory_accno}) = split(/--/, $form->{IC}); - ($form->{expense_accno}) = split(/--/, $form->{IC_expense}); - ($form->{income_accno}) = split(/--/, $form->{IC_income}); # connect to database, turn off AutoCommit my $dbh = $form->dbconnect_noauto($myconfig); @@ -459,10 +449,10 @@ sub save { $form->{orphaned} = 1; $form->{onhand} = $form->{stock} if $form->{item} eq 'assembly'; - if ($form->{partnumber} eq "" && $form->{inventory_accno} eq "") { + if ($form->{partnumber} eq "" && $form->{"item"} eq "service") { $form->{partnumber} = $form->update_defaults($myconfig, "servicenumber"); } - if ($form->{partnumber} eq "" && $form->{inventory_accno} ne "") { + if ($form->{partnumber} eq "" && $form->{"item"} ne "service") { $form->{partnumber} = $form->update_defaults($myconfig, "articlenumber"); } @@ -473,6 +463,30 @@ sub save { ($partsgroup, $partsgroup_id) = split /--/, $form->{partsgroup}; } + my ($subq_inventory, $subq_expense, $subq_income); + if ($form->{"item"} eq "part") { + $subq_inventory = + qq|(SELECT bg.inventory_accno_id | . + qq| FROM buchungsgruppen bg | . + qq| WHERE bg.id = | . $dbh->quote($form->{"buchungsgruppen_id"}) . qq|)|; + } else { + $subq_inventory = "NULL"; + } + + if ($form->{"item"} ne "assembly") { + $subq_expense = + qq|(SELECT bg.expense_accno_id_0 | . + qq| FROM buchungsgruppen bg | . + qq| WHERE bg.id = | . $dbh->quote($form->{"buchungsgruppen_id"}) . qq|)|; + } else { + $subq_expense = "NULL"; + } + + $subq_income = + qq|(SELECT bg.income_accno_id_0 | . + qq| FROM buchungsgruppen bg | . + qq| WHERE bg.id = | . $dbh->quote($form->{"buchungsgruppen_id"}) . qq|)|; + $query = qq|UPDATE parts SET partnumber = '$form->{partnumber}', description = '$form->{description}', @@ -491,12 +505,9 @@ sub save { bin = '$form->{bin}', buchungsgruppen_id = '$form->{buchungsgruppen_id}', payment_id = '$form->{payment_id}', - inventory_accno_id = (SELECT c.id FROM chart c - WHERE c.accno = '$form->{inventory_accno}'), - income_accno_id = (SELECT c.id FROM chart c - WHERE c.accno = '$form->{income_accno}'), - expense_accno_id = (SELECT c.id FROM chart c - WHERE c.accno = '$form->{expense_accno}'), + inventory_accno_id = $subq_inventory, + income_accno_id = $subq_income, + expense_accno_id = $subq_expense, obsolete = '$form->{obsolete}', image = '$form->{image}', drawing = '$form->{drawing}',