From: Moritz Bunkus Date: Fri, 16 Feb 2007 08:51:36 +0000 (+0000) Subject: Große Codeteile entfernt, die zur Vorbereitung von Mehrlagerfähigkeit in SQL-Ledger... X-Git-Tag: release-2.4.2~97 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=5b60c0df87a1150394dddfdf5c4b0c130a9e004a;p=kivitendo-erp.git Große Codeteile entfernt, die zur Vorbereitung von Mehrlagerfähigkeit in SQL-Ledger gedient haben und nie benutzt wurden. --- diff --git a/SL/OE.pm b/SL/OE.pm index 48ff26e30..b95098374 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -88,15 +88,7 @@ sub transactions { FROM oe o JOIN $form->{vc} ct ON (o.$form->{vc}_id = ct.id) JOIN orderitems oi ON (oi.trans_id = o.id) - JOIN parts p ON (p.id = oi.parts_id)|; - - if ($warehouse_id && $form->{type} eq 'ship_order') { - $query .= qq| - JOIN inventory i ON (oi.parts_id = i.parts_id) - |; - } - - $query .= qq| + JOIN parts p ON (p.id = oi.parts_id) LEFT JOIN employee e ON (o.employee_id = e.id) LEFT JOIN exchangerate ex ON (ex.curr = o.curr AND ex.transdate = o.transdate) @@ -508,7 +500,6 @@ Message: $form->{message}\r| if $form->{message}; # adjust onhand &adj_onhand($dbh, $form, $ml * -1); - &adj_inventory($dbh, $myconfig, $form); } my $rc = $dbh->commit; @@ -1254,132 +1245,6 @@ sub project_description { return $_; } -sub get_warehouses { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my $dbh = $form->dbconnect($myconfig); - - # setup warehouses - my $query = qq|SELECT id, description - FROM warehouse|; - - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - push @{ $form->{all_warehouses} }, $ref; - } - $sth->finish; - - $dbh->disconnect; - - $main::lxdebug->leave_sub(); -} - -sub save_inventory { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my ($null, $warehouse_id) = split /--/, $form->{warehouse}; - $warehouse_id *= 1; - - my $employee_id; - ($null, $employee_id) = split /--/, $form->{employee}; - - my $ml = ($form->{type} eq 'ship_order') ? -1 : 1; - - my $dbh = $form->dbconnect_noauto($myconfig); - my $sth; - my $wth; - my $serialnumber; - my $ship; - - $query = qq|SELECT o.serialnumber, o.ship - FROM orderitems o - WHERE o.trans_id = ? - AND o.id = ? - FOR UPDATE|; - $sth = $dbh->prepare($query) || $form->dberror($query); - - $query = qq|SELECT sum(i.qty) - FROM inventory i - WHERE i.parts_id = ? - AND i.warehouse_id = ?|; - $wth = $dbh->prepare($query) || $form->dberror($query); - - for my $i (1 .. $form->{rowcount} - 1) { - - $ship = - (abs($form->{"ship_$i"}) > abs($form->{"qty_$i"})) - ? $form->{"qty_$i"} - : $form->{"ship_$i"}; - - if ($warehouse_id && $form->{type} eq 'ship_order') { - - $wth->execute($form->{"id_$i"}, $warehouse_id) || $form->dberror; - - ($qty) = $wth->fetchrow_array; - $wth->finish; - - if ($ship > $qty) { - $ship = $qty; - } - } - - if ($ship != 0) { - - $ship *= $ml; - $query = qq|INSERT INTO inventory (parts_id, warehouse_id, - qty, oe_id, orderitems_id, shippingdate, employee_id) - VALUES ($form->{"id_$i"}, $warehouse_id, - $ship, $form->{"id"}, - $form->{"orderitems_id_$i"}, '$form->{shippingdate}', - $employee_id)|; - $dbh->do($query) || $form->dberror($query); - - # add serialnumber, ship to orderitems - $sth->execute($form->{id}, $form->{"orderitems_id_$i"}) - || $form->dberror; - ($serialnumber, $ship) = $sth->fetchrow_array; - $sth->finish; - - $serialnumber .= " " if $serialnumber; - $serialnumber .= qq|$form->{"serialnumber_$i"}|; - $ship += $form->{"ship_$i"}; - - $query = qq|UPDATE orderitems SET - serialnumber = '$serialnumber', - ship = $ship - WHERE trans_id = $form->{id} - AND id = $form->{"orderitems_id_$i"}|; - $dbh->do($query) || $form->dberror($query); - - # update order with ship via - $query = qq|UPDATE oe SET - shippingpoint = '$form->{shippingpoint}', - shipvia = '$form->{shipvia}' - WHERE id = $form->{id}|; - $dbh->do($query) || $form->dberror($query); - - # update onhand for parts - $form->update_balance($dbh, "parts", "onhand", - qq|id = $form->{"id_$i"}|, - $form->{"ship_$i"} * $ml); - - } - } - - my $rc = $dbh->commit; - $dbh->disconnect; - - $main::lxdebug->leave_sub(); - - return $rc; -} - sub adj_onhand { $main::lxdebug->enter_sub(); @@ -1458,185 +1323,5 @@ sub adj_onhand { $main::lxdebug->leave_sub(); } -sub adj_inventory { - $main::lxdebug->enter_sub(); - - my ($dbh, $myconfig, $form) = @_; - - my %oid = ('Pg' => 'oid', - 'Oracle' => 'rowid'); - - # increase/reduce qty in inventory table - my $query = qq|SELECT oi.id, oi.parts_id, oi.ship - FROM orderitems oi - WHERE oi.trans_id = $form->{id}|; - my $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - $query = qq|SELECT $oid{$myconfig->{dbdriver}} AS oid, qty, - (SELECT SUM(qty) FROM inventory - WHERE oe_id = $form->{id} - AND orderitems_id = ?) AS total - FROM inventory - WHERE oe_id = $form->{id} - AND orderitems_id = ?|; - my $ith = $dbh->prepare($query) || $form->dberror($query); - - my $qty; - my $ml = ($form->{type} =~ /(ship|sales)_order/) ? -1 : 1; - - while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - - $ith->execute($ref->{id}, $ref->{id}) || $form->dberror($query); - - while (my $inv = $ith->fetchrow_hashref(NAME_lc)) { - - if (($qty = (($inv->{total} * $ml) - $ref->{ship})) >= 0) { - $qty = $inv->{qty} if ($qty > ($inv->{qty} * $ml)); - - $form->update_balance($dbh, "inventory", "qty", - qq|$oid{$myconfig->{dbdriver}} = $inv->{oid}|, - $qty * -1 * $ml); - } - } - $ith->finish; - - } - $sth->finish; - - # delete inventory entries if qty = 0 - $query = qq|DELETE FROM inventory - WHERE oe_id = $form->{id} - AND qty = 0|; - $dbh->do($query) || $form->dberror($query); - - $main::lxdebug->leave_sub(); -} - -sub get_inventory { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my ($null, $warehouse_id) = split /--/, $form->{warehouse}; - $warehouse_id *= 1; - - my $dbh = $form->dbconnect($myconfig); - - my $query = qq|SELECT p.id, p.partnumber, p.description, p.onhand, - pg.partsgroup - FROM parts p - LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) - WHERE p.onhand > 0|; - - if ($form->{partnumber}) { - $var = $form->like(lc $form->{partnumber}); - $query .= " - AND lower(p.partnumber) LIKE '$var'"; - } - if ($form->{description}) { - $var = $form->like(lc $form->{description}); - $query .= " - AND lower(p.description) LIKE '$var'"; - } - if ($form->{partsgroup}) { - $var = $form->like(lc $form->{partsgroup}); - $query .= " - AND lower(pg.partsgroup) LIKE '$var'"; - } - - $sth = $dbh->prepare($query); - $sth->execute || $form->dberror($query); - - $query = qq|SELECT sum(i.qty), w.description, w.id - FROM inventory i - LEFT JOIN warehouse w ON (w.id = i.warehouse_id) - WHERE i.parts_id = ? - AND NOT i.warehouse_id = $warehouse_id - GROUP BY w.description, w.id|; - $wth = $dbh->prepare($query) || $form->dberror($query); - - while ($ref = $sth->fetchrow_hashref(NAME_lc)) { - - $wth->execute($ref->{id}) || $form->dberror; - - while (($qty, $warehouse, $warehouse_id) = $wth->fetchrow_array) { - push @{ $form->{all_inventory} }, - { 'id' => $ref->{id}, - 'partnumber' => $ref->{partnumber}, - 'description' => $ref->{description}, - 'partsgroup' => $ref->{partsgroup}, - 'qty' => $qty, - 'warehouse_id' => $warehouse_id, - 'warehouse' => $warehouse } - if $qty > 0; - } - $wth->finish; - } - $sth->finish; - - $dbh->disconnect; - - # sort inventory - @{ $form->{all_inventory} } = - sort { $a->{ $form->{sort} } cmp $b->{ $form->{sort} } } - @{ $form->{all_inventory} }; - - $main::lxdebug->leave_sub(); - - return @{ $form->{all_inventory} }; -} - -sub transfer { - $main::lxdebug->enter_sub(); - - my ($self, $myconfig, $form) = @_; - - my $dbh = $form->dbconnect_noauto($myconfig); - - my $query = qq|INSERT INTO inventory - (warehouse_id, parts_id, qty, shippingdate, employee_id) - VALUES (?, ?, ?, ?, ?)|; - $sth = $dbh->prepare($query) || $form->dberror($query); - - $form->get_employee($dbh); - - my @a = localtime; - $a[5] += 1900; - $a[4]++; - $shippingdate = "$a[5]-$a[4]-$a[3]"; - - for my $i (1 .. $form->{rowcount}) { - $qty = $form->parse_amount($myconfig, $form->{"transfer_$i"}); - - $qty = $form->{"qty_$i"} if ($qty > $form->{"qty_$i"}); - - if ($qty) { - - # to warehouse - $sth->execute($form->{warehouse_id}, $form->{"id_$i"}, $qty, - $shippingdate, $form->{employee_id}) - || $form->dberror; - - $sth->finish; - - # from warehouse - $sth->execute($form->{"warehouse_id_$i"}, - $form->{"id_$i"}, $qty * -1, $shippingdate, - $form->{employee_id}) - || $form->dberror; - - $sth->finish; - } - } - - my $rc = $dbh->commit; - $dbh->disconnect; - - $main::lxdebug->leave_sub(); - - return $rc; -} - 1; diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index df330d3ac..16205a7b1 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -3006,7 +3006,7 @@ sub save { $locale->text( "Inventory quantity must be zero before you can set this $form->{item} obsolete!" )) - if ($form->{onhand}); + if ($form->{onhand} * 1); } if (!$form->{buchungsgruppen_id}) { @@ -3170,181 +3170,6 @@ sub delete { $lxdebug->leave_sub(); } -sub stock_assembly { - $lxdebug->enter_sub(); - - $form->{title} = $locale->text('Stock Assembly'); - - $form->header; - - print qq| - - -
{script}> - - - - - - - - - - -
$form->{title}
- - - - - - - - - - -
| - . $locale->text('Part Number') . qq| 
| - . $locale->text('Part Description') . qq|
-

- -{path}> -{login}> -{password}> - - - -
- -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub list_assemblies { - $lxdebug->enter_sub(); - - IC->retrieve_assemblies(\%myconfig, \%$form); - - $column_header{partnumber} = - qq|| . $locale->text('Part Number') . qq||; - $column_header{description} = - qq|| . $locale->text('Part Description') . qq||; - $column_header{bin} = - qq|| . $locale->text('Bin') . qq||; - $column_header{onhand} = - qq|| . $locale->text('Qty') . qq||; - $column_header{rop} = - qq|| . $locale->text('ROP') . qq||; - $column_header{stock} = - qq|| . $locale->text('Add') . qq||; - - @column_index = (qw(partnumber description bin onhand rop stock)); - - $form->{title} = $locale->text('Stock Assembly'); - - $form->{callback} = - "$form->{script}?action=stock_assembly&path=$form->{path}&login=$form->{login}&password=$form->{password}"; - - $form->header; - - $colspan = $#column_index + 1; - - print qq| - - -
{script}> - - - - - - - |; - - map { print "\n$column_header{$_}" } @column_index; - - print qq| - -|; - - $i = 1; - foreach $ref (@{ $form->{assembly_items} }) { - - map { $ref->{$_} =~ s/\"/"/g } qw(partnumber description); - - $column_data{partnumber} = qq||; - $column_data{description} = - qq||; - $column_data{bin} = qq||; - $column_data{onhand} = - qq||; - $column_data{rop} = - qq||; - $column_data{stock} = qq||; - - $j++; - $j %= 2; - print - qq|{id}>\n|; - - map { print "\n$column_data{$_}" } @column_index; - - print qq| - -|; - - $i++; - - } - - $i--; - print qq| - - -
$form->{title}
$ref->{partnumber}$ref->{description} $ref->{bin} | - . $form->format_amount(\%myconfig, $ref->{onhand}) - . qq|| - . $form->format_amount(\%myconfig, $ref->{rop}) - . qq|

-
- - -{path}> -{login}> -{password}> - - - - - -
- - -
- - - -|; - - $lxdebug->leave_sub(); -} - -sub restock_assemblies { - $lxdebug->enter_sub(); - - $form->redirect($locale->text('Assemblies restocked!')) - if (IC->restock_assemblies(\%myconfig, \%$form)); - $form->error($locale->text('Cannot stock assemblies!')); - - $lxdebug->leave_sub(); -} - sub price_row { $lxdebug->enter_sub(); diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 312003aec..c0fdcdad0 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1549,20 +1549,6 @@ sub print_options { . $locale->text('Credit Note'); } - if ($form->{type} eq 'ship_order') { - $type = qq| -