X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fio.pl;h=90fdcc2db0a8c81b5002cb3f98d700d64500c228;hb=9d60642b51924a3fc44a0108777f0611ae19fb30;hp=d799a0c1c382cb0195a179f90aef02a392fd7bb8;hpb=ee90bef1624e0a71ed2bdc0807701cda64b58b4f;p=kivitendo-erp.git diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index d799a0c1c..90fdcc2db 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -317,24 +317,24 @@ sub display_row { $locale->text('Subtotal'), $form->{"subtotal_$i"} ? 'checked' : '' }; # begin marge calculations - my $marge_color; - my $real_sellprice = ($form->{"sellprice_$i"} - $discount) / $price_factor; - my $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1; - - $form->{"lastcost_$i"} *= 1; + $form->{"lastcost_$i"} *= 1; $form->{"marge_percent_$i"} = 0; - if ($real_sellprice && ($form->{"qty_$i"} * 1)) { - $form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice; - $myconfig{marge_percent_warn} ||= 15; - $marge_color = 'color="#ff0000"' if $form->{"id_$i"} && ($form->{"marge_percent_$i"} < (1 * $myconfig{marge_percent_warn})); + my $marge_color; + my $real_sellprice = $linetotal; + my $real_lastcost = $form->{"lastcost_$i"} * $form->{"qty_$i"} / ( $form->{"marge_price_factor_$i"} || 1 ); + my $marge_percent_warn = $myconfig{marge_percent_warn} * 1 || 15; + my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; + + if ($real_sellprice * 1 && ($form->{"qty_$i"} * 1)) { + $form->{"marge_percent_$i"} = ($real_sellprice - $real_lastcost) * 100 / $real_sellprice; + $marge_color = 'color="#ff0000"' if $form->{"id_$i"} && $form->{"marge_percent_$i"} < $marge_percent_warn; } - my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1; - $form->{"marge_absolut_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note; + $form->{"marge_absolut_$i"} = ($real_sellprice - $real_lastcost) * $marge_adjust_credit_note; $form->{"marge_total"} += $form->{"marge_absolut_$i"}; - $form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor; - $form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"}; + $form->{"lastcost_total"} += $real_lastcost; + $form->{"sellprice_total"} += $real_sellprice; map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent); @@ -750,7 +750,7 @@ sub check_form { #($form->{"sellprice_$i"},$form->{"$pricegroup_old_$i"}) = split /--/, $form->{"sellprice_$i"}; # fuer assemblies auskommentiert. siehe oben - # $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"} / ($form->{"price_factor_$i"} || 1)); + # $form->{sellprice} += ($form->{"qty_$i"} * $form->{"sellprice_$i"} / ($form->{"price_factor_$i"} || 1)); $form->{weight} += ($form->{"qty_$i"} * $form->{"weight_$i"} / ($form->{"price_factor_$i"} || 1)); $count++; } @@ -765,44 +765,9 @@ sub check_form { map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(listprice sellprice lastcost); } else { - my @flds = qw(id partnumber description qty ship sellprice unit - discount inventory_accno income_accno expense_accno listprice - taxaccounts bin assembly weight projectnumber project_id - oldprojectnumber runningnumber serialnumber partsgroup payment_id - not_discountable shop ve gv buchungsgruppen_id language_values - sellprice_pg pricegroup_old price_old price_new unit_old ordnumber - transdate longdescription basefactor marge_total marge_percent - marge_price_factor lastcost price_factor_id partnotes - stock_out stock_in has_sernumber); - - my $ic_cvar_configs = CVar->get_configs(module => 'IC'); - push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; - - # this section applies to invoices and orders - # remove any empty numbers - if ($form->{rowcount}) { - for my $i (1 .. $form->{rowcount} - 1) { - if ($form->{"partnumber_$i"}) { - push @a, {}; - my $j = $#a; - - map { $a[$j]->{$_} = $form->{"${_}_$i"} } @flds; - $count++; - if ($main::lizenzen) { - if ($form->{"licensenumber_$i"} == -1) { - &new_license($i); - exit; - } - } - } - } - - $form->redo_rows(\@flds, \@a, $count, $form->{rowcount}); - $form->{rowcount} = $count; + remove_emptied_rows(1); - $form->{creditremaining} -= &invoicetotal; - - } + $form->{creditremaining} -= &invoicetotal; } #sk @@ -825,6 +790,37 @@ sub check_form { $main::lxdebug->leave_sub(); } +sub remove_emptied_rows { + my $dont_add_empty = shift; + my $form = $::form; + + return unless $form->{rowcount}; + + my @flds = qw(id partnumber description qty ship sellprice unit + discount inventory_accno income_accno expense_accno listprice + taxaccounts bin assembly weight projectnumber project_id + oldprojectnumber runningnumber serialnumber partsgroup payment_id + not_discountable shop ve gv buchungsgruppen_id language_values + sellprice_pg pricegroup_old price_old price_new unit_old ordnumber + transdate longdescription basefactor marge_total marge_percent + marge_price_factor lastcost price_factor_id partnotes + stock_out stock_in has_sernumber); + + my $ic_cvar_configs = CVar->get_configs(module => 'IC'); + push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs }; + + my @new_rows; + for my $i (1 .. $form->{rowcount} - 1) { + next unless $form->{"partnumber_$i"}; + + push @new_rows, { map { $_ => $form->{"${_}_$i" } } @flds }; + } + + my $new_rowcount = scalar @new_rows; + $form->redo_rows(\@flds, \@new_rows, $new_rowcount, $form->{rowcount}); + $form->{rowcount} = $new_rowcount + ($dont_add_empty ? 0 : 1); +} + sub invoicetotal { $main::lxdebug->enter_sub(); @@ -1421,10 +1417,10 @@ sub print_form { call_sub($display_form); # saving the history - if(!exists $form->{addition}) { + if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; - $form->{addition} = "PRINTED"; - $form->save_history($form->dbconnect(\%myconfig)); + $form->{addition} = "PRINTED"; + $form->save_history($form->dbconnect(\%myconfig)); } # /saving the history exit; @@ -1641,16 +1637,16 @@ sub print_form { if(!exists $form->{addition}) { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; if($form->{media} =~ /printer/) { - $form->{addition} = "PRINTED"; + $form->{addition} = "PRINTED"; } elsif($form->{media} =~ /email/) { - $form->{addition} = "MAILED"; + $form->{addition} = "MAILED"; } elsif($form->{media} =~ /queue/) { - $form->{addition} = "QUEUED"; + $form->{addition} = "QUEUED"; } elsif($form->{media} =~ /screen/) { - $form->{addition} = "SCREENED"; + $form->{addition} = "SCREENED"; } $form->save_history($form->dbconnect(\%myconfig)); } @@ -1809,72 +1805,72 @@ sub ship_to { - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
| +
| . $locale->text('Billing Address') . qq|| + | . $locale->text('Shipping Address') . qq|
$number$form->{"$form->{vc}number"}
| . $locale->text('Company Name') . qq|$form->{name}
| . $locale->text('Department') . qq|$form->{department_1}
 $form->{department_2}
| . $locale->text('Street') . qq|$form->{street}
| . $locale->text('Zipcode') . qq|$form->{zipcode}
| . $locale->text('City') . qq|$form->{city}
| . $locale->text('Country') . qq|$form->{country}
| . $locale->text('Contact') . qq|$form->{contact}
| . $locale->text('Phone') . qq|$form->{phone}
| . $locale->text('Fax') . qq|$form->{fax}
| . $locale->text('E-mail') . qq|$form->{email}
$number$form->{"$form->{vc}number"}
| . $locale->text('Company Name') . qq|$form->{name}
| . $locale->text('Department') . qq|$form->{department_1}
 $form->{department_2}
| . $locale->text('Street') . qq|$form->{street}
| . $locale->text('Zipcode') . qq|$form->{zipcode}
| . $locale->text('City') . qq|$form->{city}
| . $locale->text('Country') . qq|$form->{country}
| . $locale->text('Contact') . qq|$form->{contact}
| . $locale->text('Phone') . qq|$form->{phone}
| . $locale->text('Fax') . qq|$form->{fax}
| . $locale->text('E-mail') . qq|$form->{email}
@@ -2077,7 +2073,7 @@ sub _update_custom_variables { } sub _render_custom_variables_inputs { - $main::lxdebug->enter_sub(); + $main::lxdebug->enter_sub(2); my $form = $main::form; @@ -2114,5 +2110,5 @@ sub _render_custom_variables_inputs { }; } - $main::lxdebug->leave_sub(); + $main::lxdebug->leave_sub(2); }