From 1228aa97dd33175f74c5dfbdf759a6b3d9458f93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 22 Jul 2010 10:49:03 +0200 Subject: [PATCH] IC->retrieve_account umgeschrieben auf batchmode. --- SL/IC.pm | 63 ++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/SL/IC.pm b/SL/IC.pm index 61543ae6e..13cf55e00 100644 --- a/SL/IC.pm +++ b/SL/IC.pm @@ -1479,14 +1479,17 @@ sub follow_account_chain { sub retrieve_accounts { $main::lxdebug->enter_sub(2); - my ($self, $myconfig, $form, $parts_id, $index) = @_; + my $self = shift; + my $myconfig = shift; + my $form = shift; + my $dbh = $form->get_standard_dbh; + my %args = @_; # part_id => index my ($query, $sth); $form->{taxzone_id} *= 1; - my $dbh = $form->get_standard_dbh; - + # transdate madness. my $transdate = ""; if ($form->{type} eq "invoice") { if (($form->{vc} eq "vendor") || !$form->{deliverydate}) { @@ -1505,8 +1508,9 @@ sub retrieve_accounts { } else { $transdate = $dbh->quote($transdate); } + #/transdate - $query = <{taxzone_id} = c3.id WHERE p.id = ? SQL - my $ref = selectfirst_hashref_query($form, $dbh, $query, $parts_id); - - return $main::lxdebug->leave_sub(2) if (!$ref); - - $ref->{"inventory_accno_id"} = undef unless ($ref->{"is_part"}); - - my %accounts; - foreach my $type (qw(inventory income expense)) { - next unless ($ref->{"${type}_accno_id"}); - ($accounts{"${type}_accno_id"}, $accounts{"${type}_accno"}) = - $self->follow_account_chain($form, $dbh, $transdate, - $ref->{"${type}_accno_id"}, - $ref->{"${type}_accno"}); - } - - map { $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} } - qw(inventory income expense); - - my $inc_exp = $form->{"vc"} eq "customer" ? "income" : "expense"; - my $accno_id = $accounts{"${inc_exp}_accno_id"}; - $query = <leave_sub(2); - return; - } + while (my ($part_id, $index) = each %args) { + my $ref = $sth_accno->fetchrow_hashref($part_id) or next; + + $ref->{"inventory_accno_id"} = undef unless $ref->{"is_part"}; + + my %accounts; + for my $type (qw(inventory income expense)) { + next unless $ref->{"${type}_accno_id"}; + ($accounts{"${type}_accno_id"}, $accounts{"${type}_accno"}) = + $self->follow_account_chain($form, $dbh, $transdate, $ref->{"${type}_accno_id"}, $ref->{"${type}_accno"}); + } + + $form->{"${_}_accno_$index"} = $accounts{"${_}_accno"} for qw(inventory income expense); + + my $inc_exp = $form->{"vc"} eq "customer" ? "income" : "expense"; + $ref = $sth->fetchrow_hashref($accounts{"${inc_exp}_accno_id"}, quote_db_date($transdate)) or next; + + $form->{"taxaccounts_$index"} = $ref->{"accno"}; + $form->{"taxaccounts"} .= "$ref->{accno} "if $form->{"taxaccounts"} !~ /$ref->{accno}/; - $form->{"taxaccounts_$index"} = $ref->{"accno"}; - if ($form->{"taxaccounts"} !~ /$ref->{accno}/) { - $form->{"taxaccounts"} .= "$ref->{accno} "; + $form->{"$ref->{accno}_${_}"} = $ref->{$_} for qw(rate description taxnumber); } - map { $form->{"$ref->{accno}_${_}"} = $ref->{$_}; } qw(rate description taxnumber); $::lxdebug->leave_sub(2); } -- 2.20.1