1 #=====================================================================
4 # Based on SQL-Ledger Version 2.1.9
5 # Web http://www.lx-office.org
6 #############################################################################
7 # Veraendert 2005-01-05 - Marco Welter <mawe@linux-studio.de> - Neue Optik #
8 #############################################################################
9 # SQL-Ledger, Accounting
10 # Copyright (c) 1998-2002
12 # Author: Dieter Simader
13 # Email: dsimader@sql-ledger.org
14 # Web: http://www.sql-ledger.org
17 # This program is free software; you can redistribute it and/or modify
18 # it under the terms of the GNU General Public License as published by
19 # the Free Software Foundation; either version 2 of the License, or
20 # (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #######################################################################
32 # common routines used in is, ir but not in oe
34 #######################################################################
38 use List::Util qw(max);
44 require "bin/mozilla/common.pl";
48 # any custom scripts for this one
49 if (-f "bin/mozilla/custom_invoice_io.pl") {
50 eval { require "bin/mozilla/custom_ivvoice_io.pl"; };
52 if (-f "bin/mozilla/$main::form->{login}_invoice_io.pl") {
53 eval { require "bin/mozilla/$main::form->{login}_invoice_io.pl"; };
60 # this is for our long dates
61 # $locale->text('January')
62 # $locale->text('February')
63 # $locale->text('March')
64 # $locale->text('April')
65 # $locale->text('May ')
66 # $locale->text('June')
67 # $locale->text('July')
68 # $locale->text('August')
69 # $locale->text('September')
70 # $locale->text('October')
71 # $locale->text('November')
72 # $locale->text('December')
74 # this is for our short month
75 # $locale->text('Jan')
76 # $locale->text('Feb')
77 # $locale->text('Mar')
78 # $locale->text('Apr')
79 # $locale->text('May')
80 # $locale->text('Jun')
81 # $locale->text('Jul')
82 # $locale->text('Aug')
83 # $locale->text('Sep')
84 # $locale->text('Oct')
85 # $locale->text('Nov')
86 # $locale->text('Dec')
91 ########################################
92 # Eintrag fuer Version 2.2.0 geaendert #
93 # neue Optik im Rechnungsformular #
94 ########################################
96 # $main::lxdebug->enter_sub();
97 # my $numrows = shift;
100 # (substr($form->{type}, 0, 6) eq "sales_")
101 # || (($form->{type} eq "invoice") && ($form->{script} eq "is.pl"))
102 # || ($form->{type} eq 'credit_note');
104 # if ($lizenzen && $form->{vc} eq "customer") {
105 # if ($form->{type} =~ /sales_order/) {
106 # @column_index = (runningnumber, partnumber, description, ship, qty);
107 # } elsif ($form->{type} =~ /sales_quotation/) {
108 # @column_index = (runningnumber, partnumber, description, qty);
110 # @column_index = (runningnumber, partnumber, description, qty);
113 # if ( ($form->{type} =~ /purchase_order/)
114 # || ($form->{type} =~ /sales_order/)) {
115 # @column_index = (runningnumber, partnumber, description, ship, qty);
117 # @column_index = (runningnumber, partnumber, description, qty);
120 ############### ENDE Neueintrag ##################
122 # my $all_units = AM->retrieve_units(\%myconfig, $form);
123 # my $dimension_units = $all_units;
124 # my $service_units = $all_units;
126 # my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
128 # push @column_index, qw(unit);
130 # #for pricegroups column
131 # if ( $form->{type} =~ (/sales_quotation/)
132 # or (($form->{level} =~ /Sales/) and ($form->{type} =~ /invoice/))
133 # or (($form->{level} eq undef) and ($form->{type} =~ /invoice/))
134 # or ($form->{type} =~ /sales_order/)) {
135 # push @column_index, qw(sellprice_pg);
138 # push @column_index, qw(sellprice);
140 # if ($form->{vc} eq 'customer') {
141 # push @column_index, qw(discount);
144 # push @column_index, "linetotal";
146 # my $colspan = $#column_index + 1;
148 # $form->{invsubtotal} = 0;
149 # map { $form->{"${_}_base"} = 0 } (split(/ /, $form->{taxaccounts}));
151 #########################################
152 # # Eintrag fuer Version 2.2.0 geaendert #
153 # # neue Optik im Rechnungsformular #
154 #########################################
155 # $column_data{runningnumber} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('No.') . qq|</th>|;
156 # $column_data{partnumber} = qq|<th align="left" nowrap width="12%" class="listheading">| . $locale->text('Number') . qq|</th>|;
157 # $column_data{description} = qq|<th align="left" nowrap width="30%" class="listheading">| . $locale->text('Part Description') . qq|</th>|;
158 # if ($form->{"type"} eq "purchase_order") {
159 # $column_data{ship} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Ship rcvd') . qq|</th>|;
161 # $column_data{ship} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Ship') . qq|</th>|;
163 # $column_data{qty} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Qty') . qq|</th>|;
164 # $column_data{unit} = qq|<th align="left" nowrap width="20%" class="listheading">| . $locale->text('Unit') . qq|</th>|;
165 # $column_data{license} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('License') . qq|</th>|;
166 # $column_data{serialnr} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Serial No.') . qq|</th>|;
167 # $column_data{projectnr} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Project') . qq|</th>|;
168 # $column_data{sellprice} = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Price') . qq|</th>|;
169 # $column_data{sellprice_pg} = qq|<th align="left" nowrap width="15%" class="listheading">| . $locale->text('Pricegroup') . qq|</th>|;
170 # $column_data{discount} = qq|<th align="left" nowrap width="5%" class="listheading">| . $locale->text('Discount') . qq|</th>|;
171 # $column_data{linetotal} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Extended') . qq|</th>|;
172 # $column_data{bin} = qq|<th align="left" nowrap width="10%" class="listheading">| . $locale->text('Bin') . qq|</th>|;
173 ############### ENDE Neueintrag ##################
175 # $myconfig{"show_form_details"} = 1
176 # unless (defined($myconfig{"show_form_details"}));
177 # $form->{"show_details"} = $myconfig{"show_form_details"}
178 # unless (defined($form->{"show_details"}));
179 # $form->{"show_details"} = $form->{"show_details"} ? 1 : 0;
180 # my $show_details_new = 1 - $form->{"show_details"};
181 # my $show_details_checked = $form->{"show_details"} ? "checked" : "";
185 # <td>| . $cgi->hidden("-name" => "show_details", "-value" => $form->{show_details}) . qq|
186 # <input type="checkbox" id="cb_show_details" onclick="show_form_details($show_details_new);" $show_details_checked>
187 # <label for="cb_show_details">| . $locale->text("Show details") . qq|</label><br>
188 # <table width="100%">
189 # <tr class="listheading">|;
191 # map { print "\n$column_data{$_}" } @column_index;
197 # $runningnumber = $locale->text('No.');
198 # $deliverydate = $locale->text('Delivery Date');
199 # $serialnumber = $locale->text('Serial No.');
200 # $projectnumber = $locale->text('Project');
201 # $partsgroup = $locale->text('Group');
202 # $reqdate = $locale->text('Reqdate');
204 # $delvar = 'deliverydate';
206 # if ($form->{type} =~ /_order$/ || $form->{type} =~ /_quotation$/) {
207 # $deliverydate = $locale->text('Required by');
208 # $delvar = 'reqdate';
211 # $form->{marge_total} = 0;
212 # $form->{sellprice_total} = 0;
213 # $form->{lastcost_total} = 0;
214 # my %projectnumber_labels = ();
215 # my @projectnumber_values = ("");
216 # foreach my $item (@{ $form->{"ALL_PROJECTS"} }) {
217 # push(@projectnumber_values, $item->{"id"});
218 # $projectnumber_labels{$item->{"id"}} = $item->{"projectnumber"};
221 # for $i (1 .. $numrows) {
225 # $form->{"${_}_$i"} =
226 # $form->parse_amount(\%myconfig, $form->{"${_}_$i"})
227 # } qw(qty ship discount sellprice price_new price_old) unless ($form->{simple_save});
229 # if (!$form->{"unit_old_$i"}) {
230 # # Neue Ware aus der Datenbank. In diesem Fall ist unit_$i die
231 # # Einheit, wie sie in den Stammdaten hinterlegt wurde.
232 # # Es sollte also angenommen werden, dass diese ausgewaehlt war.
233 # $form->{"unit_old_$i"} = $form->{"unit_$i"};
236 # # Die zuletzt ausgewaehlte mit der aktuell ausgewaehlten Einheit
237 # # vergleichen und bei Unterschied den Preis entsprechend umrechnen.
238 # $form->{"selected_unit_$i"} = $form->{"unit_$i"} unless ($form->{"selected_unit_$i"});
240 # my $check_units = $form->{"inventory_accno_$i"} ? $dimension_units : $service_units;
241 # if (!$check_units->{$form->{"selected_unit_$i"}} ||
242 # ($check_units->{$form->{"selected_unit_$i"}}->{"base_unit"} ne
243 # $all_units->{$form->{"unit_old_$i"}}->{"base_unit"})) {
244 # # Die ausgewaehlte Einheit ist fuer diesen Artikel nicht gueltig
245 # # (z.B. Dimensionseinheit war ausgewaehlt, es handelt sich aber
246 # # um eine Dienstleistung). Dann keinerlei Umrechnung vornehmen.
247 # $form->{"unit_old_$i"} = $form->{"selected_unit_$i"} = $form->{"unit_$i"};
249 # if ((!$form->{"prices_$i"}) || ($form->{"new_pricegroup_$i"} == $form->{"old_pricegroup_$i"})) {
250 # if ($form->{"unit_old_$i"} ne $form->{"selected_unit_$i"}) {
251 # my $basefactor = 1;
252 # if (defined($all_units->{$form->{"unit_old_$i"}}->{"factor"}) &&
253 # $all_units->{$form->{"unit_old_$i"}}->{"factor"}) {
254 # $basefactor = $all_units->{$form->{"selected_unit_$i"}}->{"factor"} /
255 # $all_units->{$form->{"unit_old_$i"}}->{"factor"};
257 # $form->{"sellprice_$i"} *= $basefactor;
258 # $form->{"unit_old_$i"} = $form->{"selected_unit_$i"};
262 # ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
263 # $decimalplaces = max length($dec), 2;
265 # $price_factor = $price_factors{$form->{"price_factor_id_$i"}} || 1;
266 # $discount = (100 - $form->{"discount_$i"} * 1) / 100;
268 # $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} * $discount / $price_factor, $decimalplaces);
270 # my $real_sellprice = $form->{"sellprice_$i"} * $discount / $price_factor;
272 # # marge calculations
273 # my ($marge_font_start, $marge_font_end);
275 # $form->{"lastcost_$i"} *= 1;
277 # $marge_price_factor = $form->{"marge_price_factor_$i"} * 1 || 1;
279 # if ($real_sellprice && ($form->{"qty_$i"} * 1)) {
280 # $form->{"marge_percent_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * 100 / $real_sellprice;
281 # $myconfig{"marge_percent_warn"} = 15 unless (defined($myconfig{"marge_percent_warn"}));
283 # if ($form->{"id_$i"} &&
284 # ($form->{"marge_percent_$i"} < (1 * $myconfig{"marge_percent_warn"}))) {
285 # $marge_font_start = "<font color=\"#ff0000\">";
286 # $marge_font_end = "</font>";
290 # $form->{"marge_percent_$i"} = 0;
293 # my $marge_adjust_credit_note = $form->{type} eq 'credit_note' ? -1 : 1;
294 # $form->{"marge_total_$i"} = ($real_sellprice - $form->{"lastcost_$i"} / $marge_price_factor) * $form->{"qty_$i"} * $marge_adjust_credit_note;
295 # $form->{"marge_total"} += $form->{"marge_total_$i"};
296 # $form->{"lastcost_total"} += $form->{"lastcost_$i"} * $form->{"qty_$i"} / $marge_price_factor;
297 # $form->{"sellprice_total"} += $real_sellprice * $form->{"qty_$i"};
299 # map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_total marge_percent);
301 # # convert " to "
302 # map { $form->{"${_}_$i"} =~ s/\"/"/g }
303 # qw(partnumber description unit unit_old);
305 #########################################
306 # # Eintrag fuer Version 2.2.0 geaendert #
307 # # neue Optik im Rechnungsformular #
308 #########################################
309 # $column_data{runningnumber} =
310 # qq|<td><input name="runningnumber_$i" size="5" value="$i"></td>|; # HuT
311 ############### ENDE Neueintrag ##################
313 # $column_data{partnumber} =
314 # qq|<td><input name="partnumber_$i" size=12 value="$form->{"partnumber_$i"}"></td>|;
316 # if (($rows = $form->numtextrows($form->{"description_$i"}, 30, 6)) > 1) {
317 # $column_data{description} =
318 # qq|<td><textarea name="description_$i" rows="$rows" cols="30" wrap="soft">| . H($form->{"description_$i"}) . qq|</textarea><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
320 # $column_data{description} =
321 # qq|<td><input name="description_$i" size="30" value="| . $form->quote($form->{"description_$i"}) . qq|"><button type="button" onclick="set_longdescription_window('longdescription_$i')">| . $locale->text('L') . qq|</button></td>|;
324 # (my $qty_dec) = ($form->{"qty_$i"} =~ /\.(\d+)/);
325 # $qty_dec = length $qty_dec;
327 # $column_data{qty} =
328 # qq|<td align="right" nowrap><input name="qty_$i" size="5" value="|
329 # . $form->format_amount(\%myconfig, $form->{"qty_$i"}, $qty_dec) .qq|">|;
330 # if ($form->{"formel_$i"}) {
331 # $column_data{qty} .= qq|<button type="button" onclick="calculate_qty_selection_window('qty_$i','alu_$i', 'formel_$i', $i)">| . $locale->text('*/') . qq|</button>|
332 # . $cgi->hidden("-name" => "formel_$i", "-value" => $form->{"formel_$i"}) . $cgi->hidden("-name" => "alu_$i", "-value" => $form->{"alu_$i"});
334 # $column_data{qty} .= qq|</td>|;
335 # $column_data{ship} =
336 # qq|<td align="right"><input name="ship_$i" size=5 value="|
337 # . $form->format_amount(\%myconfig, $form->{"ship_$i"})
340 # my $is_part = $form->{"inventory_accno_$i"};
341 # my $is_assembly = $form->{"assembly_$i"};
342 # my $is_assigned = $form->{"id_$i"};
343 # my $this_unit = $form->{"unit_$i"};
344 # if ($form->{"selected_unit_$i"} && $this_unit &&
345 # $all_units->{$form->{"selected_unit_$i"}} && $all_units->{$this_unit} &&
346 # ($all_units->{$form->{"selected_unit_$i"}}->{"base_unit"} eq $all_units->{$this_unit}->{"base_unit"})) {
347 # $this_unit = $form->{"selected_unit_$i"};
348 # } elsif (!$is_assigned ||
349 # ($is_part && !$this_unit && ($all_units->{$this_unit} && ($all_units->{$this_unit}->{"base_unit"} eq $all_units->{"kg"}->{"base_unit"})))) {
353 # my $price_factor_select;
354 # if (0 < scalar @{ $form->{ALL_PRICE_FACTORS} }) {
355 # my @values = ('', map { $_->{id} } @{ $form->{ALL_PRICE_FACTORS} });
356 # my %labels = map { $_->{id} => $_->{description} } @{ $form->{ALL_PRICE_FACTORS} };
358 # $price_factor_select =
359 # NTI($cgi->popup_menu('-name' => "price_factor_id_$i",
360 # '-default' => $form->{"price_factor_id_$i"},
361 # '-values' => \@values,
362 # '-labels' => \%labels,
363 # '-style' => 'width:90px'))
367 # $column_data{"unit"} = "<td>" .
368 # $price_factor_select .
369 # AM->unit_select_html($is_part || $is_assembly ? $dimension_units :
370 # $is_assigned ? $service_units : $all_units,
371 # "unit_$i", $this_unit,
372 # $is_assigned ? $form->{"unit_$i"} : undef)
375 # # build in drop down list for pricesgroups
376 # if ($form->{"prices_$i"}) {
377 # if ($form->{"new_pricegroup_$i"} != $form->{"old_pricegroup_$i"}) {
378 # $price_tmp = $form->format_amount(\%myconfig, $form->{"price_new_$i"}, $decimalplaces);
380 # $price_tmp = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
383 # $column_data{sellprice_pg} =
384 # qq|<td align="right"><select name="sellprice_pg_$i">$form->{"prices_$i"}</select></td>|;
385 # $column_data{sellprice} =
386 # qq|<td><input name="sellprice_$i" size="10" value="$price_tmp" onBlur=\"check_right_number_format(this)\"></td>|;
389 # # for last row and report
390 # # set pricegroup drop down list from report menu
391 # if ($form->{"sellprice_$i"} != 0) {
393 # qq|<option value="$form->{"sellprice_$i"}--$form->{"pricegroup_id_$i"}" selected>$form->{"pricegroup_$i"}</option>\n|;
395 # $form->{"pricegroup_old_$i"} = $form->{"pricegroup_id_$i"};
397 # $column_data{sellprice_pg} =
398 # qq|<td align="right"><select name="sellprice_pg_$i">$prices</select></td>|;
403 # $column_data{sellprice_pg} = qq|<td align="right"> </td>|;
406 # $column_data{sellprice} =
407 # qq|<td><input name="sellprice_$i" size="10" onBlur=\"check_right_number_format(this)\" value="|
408 # . $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
412 # $column_data{discount} =
413 # qq|<td align="right"><input name="discount_$i" size=3 value="|
414 # . $form->format_amount(\%myconfig, $form->{"discount_$i"})
416 # $column_data{linetotal} =
417 # qq|<td align="right">|
418 # . $form->format_amount(\%myconfig, $linetotal, 2)
420 # $column_data{bin} = qq|<td>$form->{"bin_$i"}</td>|;
422 #########################################
423 # # Eintrag fuer Version 2.2.0 geaendert #
424 # # neue Optik im Rechnungsformular #
425 #########################################
426 # # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
427 # # $column_data{license} = qq|<td><select name="licensenumber_$i">$form->{"lizenzen_$i"}></select></td>|;
430 # # if ($form->{type} !~ /_quotation/) {
431 # # $column_data{serialnr} = qq|<td><input name="serialnumber_$i" size=10 value="$form->{"serialnumber_$i"}"></td>|;
434 # # $column_data{projectnr} = qq|<td><input name="projectnumber_$i" size=10 value="$form->{"projectnumber_$i"}"></td>|;
435 ############### ENDE Neueintrag ##################
439 # <tr valign="top" class="listrow$j">|;
441 # map { print "\n$column_data{$_}" } @column_index;
444 # $cgi->hidden("-name" => "unit_old_$i",
445 # "-value" => $form->{"selected_unit_$i"})
447 # $cgi->hidden("-name" => "price_new_$i",
448 # "-value" => $form->format_amount(\%myconfig, $form->{"price_new_$i"}))
450 # map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_}) . "\n"); }
451 # ("orderitems_id_$i", "bo_$i", "pricegroup_old_$i", "price_old_$i",
452 # "id_$i", "inventory_accno_$i", "bin_$i", "partsgroup_$i", "partnotes_$i",
453 # "income_accno_$i", "expense_accno_$i", "listprice_$i", "assembly_$i",
454 # "taxaccounts_$i", "ordnumber_$i", "transdate_$i", "cusordnumber_$i",
455 # "longdescription_$i", "basefactor_$i", "marge_total_$i", "marge_percent_$i", "lastcost_$i",
456 # "marge_price_factor_$i"));
458 #########################################
459 # # Eintrag fuer Version 2.2.0 geaendert #
460 # # neue Optik im Rechnungsformular #
461 #########################################
463 # my $row_style_attr =
464 # 'style="display:none;"' if (!$form->{"show_details"});
468 # <tr class="listrow$j" $row_style_attr>
469 # <td colspan="$colspan">
471 # if ($lizenzen && $form->{type} eq "invoice" && $form->{vc} eq "customer") {
472 # my $selected = $form->{"licensenumber_$i"};
473 # my $lizenzen_quoted;
474 # $form->{"lizenzen_$i"} =~ s/ selected//g;
475 # $form->{"lizenzen_$i"} =~
476 # s/value="${selected}"\>/value="${selected}" selected\>/;
477 # $lizenzen_quoted = $form->{"lizenzen_$i"};
478 # $lizenzen_quoted =~ s/\"/"/g;
480 # <b>Lizenz\#</b> <select name="licensenumber_$i" size="1">
481 # $form->{"lizenzen_$i"}
483 # <input type="hidden" name="lizenzen_$i" value="${lizenzen_quoted}">
486 # if ($form->{type} !~ /_quotation/) {
488 # <b>$serialnumber</b> <input name="serialnumber_$i" size="15" value="$form->{"serialnumber_$i"}">|;
491 # print qq|<b>$projectnumber</b> | .
492 # NTI($cgi->popup_menu('-name' => "project_id_$i",
493 # '-values' => \@projectnumber_values,
494 # '-labels' => \%projectnumber_labels,
495 # '-default' => $form->{"project_id_$i"}));
497 # if ($form->{type} eq 'invoice' or $form->{type} =~ /order/) {
499 # ($form->{type} eq 'invoice')
501 # : 'reqdate'; # invoice uses a different term for the same thing.
503 # <b>${$reqdate_term}</b> <input name="${reqdate_term}_$i" size="11" onBlur="check_right_date_format(this)" value="$form->{"${reqdate_term}_$i"}">
506 # my $subtotalchecked = ($form->{"subtotal_$i"}) ? "checked" : "";
508 # <b>|.$locale->text('Subtotal').qq|</b> <input type="checkbox" name="subtotal_$i" value="1" $subtotalchecked>
511 # if ($form->{"id_$i"} && $is_sales) {
512 # my $marge_price_factor;
514 # $form->{"marge_price_factor_$i"} *= 1;
516 # if ($form->{"marge_price_factor_$i"} && (1 != $form->{"marge_price_factor_$i"})) {
517 # $marge_price_factor = '/' . $form->format_amount(\%myconfig, $form->{"marge_price_factor_$i"});
521 # ${marge_font_start}<b>| . $locale->text('Ertrag') . qq|</b> $form->{"marge_total_$i"} $form->{"marge_percent_$i"} % ${marge_font_end}|;
524 # <b>| . $locale->text('LP') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2) . qq|
525 # <b>| . $locale->text('EK') . qq|</b> | . $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) . $marge_price_factor;
533 ############### ENDE Neueintrag ##################
535 # map { $form->{"${_}_base"} += $linetotal }
536 # (split(/ /, $form->{"taxaccounts_$i"}));
538 # $form->{invsubtotal} += $linetotal;
547 # if (0 != ($form->{sellprice_total} * 1)) {
548 # $form->{marge_percent} = ($form->{sellprice_total} - $form->{lastcost_total}) / $form->{sellprice_total} * 100;
551 # $main::lxdebug->leave_sub();
555 $main::lxdebug->enter_sub();
557 my $form = $main::form;
558 my %myconfig = %main::myconfig;
559 my $locale = $main::locale;
561 my $rowcount = shift;
562 for my $j (1 .. $rowcount) {
563 my $pricegroup_old = $form->{"pricegroup_old_$j"};
564 if ($form->{PRICES}{$j}) {
566 my $prices = '<option value="--">' . $locale->text("none (pricegroup)") . '</option>';
568 foreach my $item (@{ $form->{PRICES}{$j} }) {
570 #$price = $form->round_amount($myconfig, $item->{price}, 5);
571 #$price = $form->format_amount($myconfig, $item->{price}, 2);
572 my $price = $item->{price};
573 my $pricegroup_id = $item->{pricegroup_id};
574 my $pricegroup = $item->{pricegroup};
576 # build drop down list for pricegroups
578 qq|<option value="$price--$pricegroup_id"$item->{selected}>$pricegroup</option>\n|;
583 # $form->{"${_}_$j"} =
584 # $form->format_amount(\%myconfig, $form->{"${_}_$j"})
585 # } qw(sellprice price_new price_old);
587 # set new selectedpricegroup_id and prices for "Preis"
588 if ($item->{selected} && ($pricegroup_id != 0)) {
589 $form->{"pricegroup_old_$j"} = $pricegroup_id;
590 $form->{"price_new_$j"} = $price;
591 $form->{"sellprice_$j"} = $price;
593 if ($pricegroup_id == 0) {
594 $form->{"price_new_$j"} = $form->{"sellprice_$j"};
597 $form->{"prices_$j"} = $prices;
600 $main::lxdebug->leave_sub();
604 $main::lxdebug->enter_sub();
606 my $form = $main::form;
607 my %myconfig = %main::myconfig;
609 $main::auth->assert('part_service_assembly_edit | vendor_invoice_edit | sales_order_edit | invoice_edit |' .
610 'request_quotation_edit | sales_quotation_edit | purchase_order_edit | '.
611 'purchase_delivery_order_edit | sales_delivery_order_edit');
614 retrieve_partunits() if ($form->{type} =~ /_delivery_order$/);
616 my $new_rowcount = $form->{"rowcount"} * 1 + 1;
617 $form->{"project_id_${new_rowcount}"} = $form->{"globalproject_id"};
619 $form->language_payment(\%myconfig);
621 # if we have a display_form
622 if ($form->{display_form}) {
623 call_sub($form->{"display_form"});
627 Common::webdav_folder($form) if ($main::webdav);
629 # if ( $form->{print_and_post}
630 # && $form->{second_run}
631 # && ($form->{action} eq "display_form")) {
632 # for (keys %$form) { $old_form->{$_} = $form->{$_} }
633 # $old_form->{rowcount}++;
635 # #$form->{rowcount}--;
636 # #$form->{rowcount}--;
638 # $form->{print_and_post} = 0;
640 # &print_form($old_form);
644 # $form->{action} = "";
645 # $form->{resubmit} = 0;
647 # if ($form->{print_and_post} && !$form->{second_run}) {
648 # $form->{second_run} = 1;
649 # $form->{action} = "display_form";
650 # $form->{rowcount}--;
651 # my $rowcount = $form->{rowcount};
653 # # get pricegroups for parts
654 # IS->get_pricegroups_for_parts(\%myconfig, \%$form);
656 # # build up html code for prices_$i
657 # set_pricegroup($rowcount);
659 # $form->{resubmit} = 1;
667 my $numrows = ++$form->{rowcount};
668 my $subroutine = "display_row";
670 if ($form->{item} eq 'part') {
672 #set preisgruppenanzahl
673 $numrows = $form->{price_rows};
674 $subroutine = "price_row";
676 &{$subroutine}($numrows);
678 $numrows = ++$form->{makemodel_rows};
679 $subroutine = "makemodel_row";
681 if ($form->{item} eq 'assembly') {
682 $numrows = $form->{price_rows};
683 $subroutine = "price_row";
685 &{$subroutine}($numrows);
687 $numrows = ++$form->{makemodel_rows};
688 $subroutine = "makemodel_row";
690 # create makemodel rows
691 &{$subroutine}($numrows);
693 $numrows = ++$form->{assembly_rows};
694 $subroutine = "assembly_row";
696 if ($form->{item} eq 'service') {
697 $numrows = $form->{price_rows};
698 $subroutine = "price_row";
700 &{$subroutine}($numrows);
706 &{$subroutine}($numrows) if $numrows;
711 $main::lxdebug->leave_sub();