X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FOE.pm;h=a0a0abfc89d79b99fd958246f3f0c320b3b129a3;hb=e18af94c0dc72def3629a352dbf048baa0dfd72d;hp=3e3ed3f56e51d29d4859d4736db5054404794e34;hpb=1b9a64fa292f375c82b4af788d0606354bc4e8ff;p=kivitendo-erp.git diff --git a/SL/OE.pm b/SL/OE.pm index 3e3ed3f56..a0a0abfc8 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -138,11 +138,9 @@ sub transactions { qq|WHERE (o.quotation = ?) |; push(@values, $quotation); - my ($null, $split_department_id) = split /--/, $form->{department}; - my $department_id = $form->{department_id} || $split_department_id; - if ($department_id) { + if ($form->{department_id}) { $query .= qq| AND o.department_id = ?|; - push(@values, $department_id); + push(@values, $form->{department_id}); } if ($form->{"project_id"}) { @@ -722,8 +720,6 @@ SQL my $quotation = $form->{type} =~ /_order$/ ? 'f' : 't'; - ($null, $form->{department_id}) = split(/--/, $form->{department}) if $form->{department}; - # save OE record $query = qq|UPDATE oe SET @@ -1055,15 +1051,14 @@ sub _retrieve { $sth = prepare_execute_query($form, $dbh, $query, $form->{id}); $ref = $sth->fetchrow_hashref("NAME_lc"); - delete($ref->{id}); - map { $form->{$_} = $ref->{$_} } keys %$ref; + $form->{$_} = $ref->{$_} for grep { m{^shipto(?!_id$)} } keys %$ref; $sth->finish; - if ($form->{shipto_id}) { + if ($ref->{shipto_id}) { my $cvars = CVar->get_custom_variables( dbh => $dbh, module => 'ShipTo', - trans_id => $form->{shipto_id}, + trans_id => $ref->{shipto_id}, ); $form->{"shiptocvar_$_->{name}"} = $_->{value} for @{ $cvars }; } @@ -1095,6 +1090,7 @@ sub _retrieve { c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from as expense_valid, oe.ordnumber AS ordnumber_oe, oe.transdate AS transdate_oe, oe.cusordnumber AS cusordnumber_oe, p.partnumber, p.part_type, p.listprice, o.description, o.qty, + p.classification_id, o.sellprice, o.parts_id AS id, o.unit, o.discount, p.notes AS partnotes, p.part_type, o.reqdate, o.project_id, o.serialnumber, o.ship, o.lastcost, o.ordnumber, o.transdate, o.cusordnumber, o.subtotal, o.longdescription, @@ -1282,8 +1278,7 @@ sub order_details { push(@project_ids, $form->{"globalproject_id"}) if ($form->{"globalproject_id"}); - $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS', - 'departments' => 'ALL_DEPARTMENTS'); + $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); my %price_factors; foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) { @@ -1292,13 +1287,6 @@ sub order_details { $pfac->{formatted_factor} = $form->format_amount($myconfig, $pfac->{factor}); } - # lookup department - foreach my $dept (@{ $form->{ALL_DEPARTMENTS} }) { - next unless $dept->{id} eq $form->{department_id}; - $form->{department} = $dept->{description}; - last; - } - # sort items by partsgroup for $i (1 .. $form->{rowcount}) { $partsgroup = ""; @@ -1331,6 +1319,7 @@ sub order_details { # so that they can be sorted in later my %prepared_template_arrays = IC->prepare_parts_for_printing(myconfig => $myconfig, form => $form); my @prepared_arrays = keys %prepared_template_arrays; + my @separate_totals = qw(non_separate_subtotal); $form->{TEMPLATE_ARRAYS} = { }; @@ -1437,6 +1426,17 @@ sub order_details { push @{ $form->{TEMPLATE_ARRAYS}->{discount_nofmt} }, ($discount != 0) ? $discount * -1 : ''; push @{ $form->{TEMPLATE_ARRAYS}->{p_discount} }, $form->{"discount_$i"}; + if ( $prepared_template_arrays{separate}[$i - 1] ) { + my $pabbr = $prepared_template_arrays{separate}[$i - 1]; + if ( ! $form->{"separate_${pabbr}_subtotal"} ) { + push @separate_totals , "separate_${pabbr}_subtotal"; + $form->{"separate_${pabbr}_subtotal"} = 0; + } + $form->{"separate_${pabbr}_subtotal"} += $linetotal; + } else { + $form->{non_separate_subtotal} += $linetotal; + } + $form->{ordtotal} += $linetotal; $form->{nodiscount_total} += $nodiscount_linetotal; $form->{discount_total} += $discount; @@ -1606,10 +1606,12 @@ sub order_details { $form->{username} = $myconfig->{name}; + $form->{department} = SL::DB::Manager::Department->find_by(id => $form->{department_id})->description if $form->{department_id}; $form->{delivery_term} = SL::DB::Manager::DeliveryTerm->find_by(id => $form->{delivery_term_id} || undef); $form->{delivery_term}->description_long($form->{delivery_term}->translated_attribute('description_long', $form->{language_id})) if $form->{delivery_term} && $form->{language_id}; $form->{order} = SL::DB::Manager::Order->find_by(id => $form->{id}) if $form->{id}; + $form->{$_} = $form->format_amount($myconfig, $form->{$_}, 2) for @separate_totals; $main::lxdebug->leave_sub(); }