X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fic.pl;h=4b563e6b0a76210e6a36a94dc1113157b605ee37;hb=723b79bdf889207b36f5ab0edcfd4a6d81c6f8b6;hp=abd36a84d1f4f886c05afac37d9a605a14d77e5f;hpb=1b6ded9f5b9dcd1367f803592786a8df48992a7d;p=kivitendo-erp.git diff --git a/bin/mozilla/ic.pl b/bin/mozilla/ic.pl index abd36a84d..4b563e6b0 100644 --- a/bin/mozilla/ic.pl +++ b/bin/mozilla/ic.pl @@ -46,6 +46,7 @@ use SL::ReportGenerator; our ($form, $locale, %myconfig, $lxdebug); require "bin/mozilla/io.pl"; +require "bin/mozilla/invoice_io.pl"; require "bin/mozilla/common.pl"; require "bin/mozilla/reportgenerator.pl"; @@ -109,44 +110,33 @@ sub search { |; #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1", - "transdateto", "BL", "trigger2"); + $jsscript = Form->write_trigger(\%myconfig, "2", "transdatefrom", "BL", "trigger1", "transdateto", "BL", "trigger2"); } else { # without JavaScript Calendar - $button1 = qq| - |; - $button2 = qq| - |; + $button1 = qq| |; + $button2 = qq| |; } unless ($form->{searchitems} eq 'service') { - $onhand = qq| -  | - . $locale->text('On Hand') . qq| -  | - . $locale->text('Short') . qq| + $onhand = qq|  | . $locale->text('On Hand') . qq| +  | . $locale->text('Short') . qq| |; $makemodel = qq| - | . $locale->text('Make') . qq| - - | . $locale->text('Model') . qq| - + | . $locale->text('Make') . qq| + | . $locale->text('Model') . qq| |; $serialnumber = qq| - | . $locale->text('Serial Number') . qq| - + | . $locale->text('Serial Number') . qq| |; $l_serialnumber = qq| -  | - . $locale->text('Serial Number') . qq| +  | . $locale->text('Serial Number') . qq| |; } @@ -1736,10 +1726,11 @@ sub generate_report { # fresh row, for inserting later my $row = { map { $_ => { 'data' => $ref->{$_} } } @columns }; - $ref->{exchangerate} = 1 unless $ref->{exchangerate}; - $ref->{sellprice} *= $ref->{exchangerate}; - $ref->{listprice} *= $ref->{exchangerate}; - $ref->{lastcost} *= $ref->{exchangerate}; + $ref->{exchangerate} ||= 1; + $ref->{price_factor} ||= 1; + $ref->{sellprice} *= $ref->{exchangerate} / $ref->{price_factor}; + $ref->{listprice} *= $ref->{exchangerate} / $ref->{price_factor}; + $ref->{lastcost} *= $ref->{exchangerate} / $ref->{price_factor}; # use this for assemblies my $onhand = $ref->{onhand}; @@ -1909,7 +1900,7 @@ sub link_part { # if this is a tax field if ($key =~ /IC_tax/) { - if ($key =~ /$item/) { + if ($key =~ /\Q$item\E/) { $form->{taxaccounts} .= "$ref->{accno} "; $form->{"IC_tax_$ref->{accno}_description"} = "$ref->{accno}--$ref->{description}"; @@ -1986,6 +1977,7 @@ sub form_header { my ($notdiscountableok, $notdiscountable); my ($formula, $formula_label, $imagelinks, $obsolete, $shopok, $shop); + $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); map({ $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, -2) } qw(sellprice listprice lastcost gv)); @@ -2326,6 +2318,22 @@ sub form_header { $unit_select .= AM->unit_select_html($units, "unit", $form->{"unit"}); } + my $price_factor; + if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) { + my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} }); + my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} }; + + $price_factor = + qq|| + . $locale->text('Price Factor') + . qq|| + . NTI($cgi->popup_menu('-name' => 'price_factor_id', + '-default' => $form->{price_factor_id}, + '-values' => \@values, + '-labels' => \%labels)) + . qq||; + } + $form->{fokus} = "ic.partnumber"; $form->header; @@ -2377,16 +2385,14 @@ sub form_header { - - + + - @@ -2439,6 +2445,7 @@ sub form_header { $lastcost + $price_factor @@ -2892,7 +2899,7 @@ sub save { # now take it apart and restore original values foreach my $item (split /&/, $previousform) { - my ($key, $value) = split /=/, $item, 2; + my ($key, $value) = split m/=/, $item, 2; $value =~ s/%26/&/g; $form->{$key} = $value; } @@ -2912,8 +2919,7 @@ sub save { $form->{weight} -= $form->{"weight_$i"} * $form->{"qty_$i"}; # change/add values for assembly item - map { $form->{"${_}_$i"} = $newform{$_} } - qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno); + map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit weight listprice sellprice inventory_accno income_accno expense_accno price_factor_id); $form->{sellprice} += $form->{"sellprice_$i"} * $form->{"qty_$i"}; $form->{weight} += $form->{"weight_$i"} * $form->{"qty_$i"}; @@ -2924,15 +2930,17 @@ sub save { $i = $form->{rowcount}; $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); - map { $form->{"${_}_$i"} = $newform{$_} } - qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice); + map { $form->{"${_}_$i"} = $newform{$_} } qw(partnumber description bin unit listprice inventory_accno income_accno expense_accno sellprice lastcost price_factor_id); + $form->{"sellprice_$i"} = $newform{lastcost} if ($form->{vendor_id}); + if ($form->{exchangerate} != 0) { $form->{"sellprice_$i"} /= $form->{exchangerate}; } + $lxdebug->message($LXDebug::DEBUG1, qq|sellprice_$i in previousform 2 = | . $form->{"sellprice_$i"} . qq|\n|); - map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, - $newform{taxaccount}; + + map { $form->{"taxaccounts_$i"} .= "$_ " } split / /, $newform{taxaccount}; chop $form->{"taxaccounts_$i"}; foreach my $item (qw(description rate taxnumber)) { my $index = $form->{"taxaccounts_$i"} . "_$item"; @@ -2940,26 +2948,28 @@ sub save { } # credit remaining calculation - $amount = - $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * - $form->{"qty_$i"}; - map { $form->{"${_}_base"} += $amount } - (split / /, $form->{"taxaccounts_$i"}); - map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } - split / /, $form->{"taxaccounts_$i"} - if !$form->{taxincluded}; + $amount = $form->{"sellprice_$i"} * (1 - $form->{"discount_$i"} / 100) * $form->{"qty_$i"}; + + map { $form->{"${_}_base"} += $amount } (split / /, $form->{"taxaccounts_$i"}); + map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded}; $form->{creditremaining} -= $amount; # redo number formatting, because invoice parse them! - $i = $form->{rowcount}; - map { - $form->{"${_}_$i"} = - $form->format_amount(\%myconfig, $form->{"${_}_$i"}) - } qw(weight listprice sellprice rop); + map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice rop); } $form->{"id_$i"} = $parts_id; + + # Get the actual price factor (not just the ID) for the marge calculation. + $form->get_lists('price_factors' => 'ALL_PRICE_FACTORS'); + foreach my $pfac (@{ $form->{ALL_PRICE_FACTORS} }) { + next if ($pfac->{id} != $newform{price_factor_id}); + $form->{"marge_price_factor_$i"} = $pfac->{factor}; + last; + } + delete $form->{ALL_PRICE_FACTORS}; + delete $form->{action}; # restore original callback @@ -3063,10 +3073,19 @@ sub parts_language_selection { my $languages = IC->retrieve_languages(\%myconfig, $form); + if ($form->{language_values} ne "") { + foreach $item (split(/---\+\+\+---/, $form->{language_values})) { + my ($language_id, $translation, $longdescription) = split(/--\+\+--/, $item); - my $callback = "$form->{script}?action=parts_language_selection&"; - map({ $callback .= "$_=" . $form->escape($form->{$_}) . "&" } - (qw(login password name input_name), grep({ /^[fl]_/ } keys %$form))); + foreach my $language (@{ $languages }) { + next unless ($language->{id} == $language_id); + + $language->{translation} = $translation; + $language->{longdescription} = $longdescription; + last; + } + } + } my @header_sort = qw(name longdescription); my %header_title = ( "name" => $locale->text("Name"), @@ -3082,9 +3101,9 @@ sub parts_language_selection { $form->{"title"} = $locale->text("Language Values"); $form->header(); - print($form->parse_html_template("ic/parts_language_selection", { "HEADER" => \@header, - "LANGUAGES" => $languages, - "onload" => $onload })); + print $form->parse_html_template2("ic/parts_language_selection", { "HEADER" => \@header, + "LANGUAGES" => $languages, + "onload" => $onload }); $lxdebug->leave_sub(); }
| - . $locale->text('') . qq|
+ + $buchungsgruppe + $linkaccounts +
+
- - $buchungsgruppe - $linkaccounts -
-
| . $locale->text('Notes') . qq| $formula_label{sellprice}>
| . $locale->text('Unit') . qq| $unit_select