From: Sven Schöling Date: Tue, 31 Jul 2007 13:40:55 +0000 (+0000) Subject: Kosmetikmerge aus Revisionen 5187, 5191, 5193, 5194, 5218, 5219, 5222, 5228, 5229 X-Git-Tag: release-2.6.0beta1~540 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=52983c089cf1b4f1a4451e57ffa76f846c4791ba;p=kivitendo-erp.git Kosmetikmerge aus Revisionen 5187, 5191, 5193, 5194, 5218, 5219, 5222, 5228, 5229 --- diff --git a/SL/IR.pm b/SL/IR.pm index 5854f97dd..ab092de52 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -678,16 +678,15 @@ sub retrieve_invoice { # get default accounts and last invoice number - $query= - qq|SELECT - (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, - (SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, - (SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, - (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, - (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, - d.curr AS currencies - $q_invdate - FROM defaults d|; + $query = qq|SELECT + (SELECT c.accno FROM chart c WHERE d.inventory_accno_id = c.id) AS inventory_accno, + (SELECT c.accno FROM chart c WHERE d.income_accno_id = c.id) AS income_accno, + (SELECT c.accno FROM chart c WHERE d.expense_accno_id = c.id) AS expense_accno, + (SELECT c.accno FROM chart c WHERE d.fxgain_accno_id = c.id) AS fxgain_accno, + (SELECT c.accno FROM chart c WHERE d.fxloss_accno_id = c.id) AS fxloss_accno, + d.curr AS currencies + $q_invdate + FROM defaults d|; $ref = selectfirst_hashref_query($form, $dbh, $query); map { $form->{$_} = $ref->{$_} } keys %$ref; @@ -699,17 +698,16 @@ sub retrieve_invoice { } # retrieve invoice - $query = - qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, - orddate, quodate, globalproject_id, - ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, - intnotes, curr AS currency - FROM ap - WHERE id = ?|; + $query = qq|SELECT cp_id, invnumber, transdate AS invdate, duedate, + orddate, quodate, globalproject_id, + ordnumber, quonumber, paid, taxincluded, notes, taxzone_id, storno, gldate, + intnotes, curr AS currency + FROM ap + WHERE id = ?|; $ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id})); map { $form->{$_} = $ref->{$_} } keys %$ref; - $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell"); + $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "sell"); # get shipto $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AP')|; @@ -725,39 +723,18 @@ sub retrieve_invoice { # retrieve individual items $query = qq|SELECT - c1.accno AS inventory_accno, - c1.new_chart_id AS inventory_new_chart, - date($transdate) - c1.valid_from AS inventory_valid, - - c2.accno AS income_accno, - c2.new_chart_id AS income_new_chart, - date($transdate) - c2.valid_from AS income_valid, + c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from AS inventory_valid, + c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from AS income_valid, + c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid, - c3.accno AS expense_accno, - c3.new_chart_id AS expense_new_chart, - date($transdate) - c3.valid_from AS expense_valid, - - i.description, i.qty, i.fxsellprice AS sellprice, - i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, - - p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, - pr.projectnumber, - pg.partsgroup + i.description, i.qty, i.fxsellprice AS sellprice, i.parts_id AS id, i.unit, i.deliverydate, i.project_id, i.serialnumber, + p.partnumber, p.inventory_accno_id AS part_inventory_accno_id, p.bin, pr.projectnumber, pg.partsgroup FROM invoice i JOIN parts p ON (i.parts_id = p.id) - LEFT JOIN chart c1 ON - ((SELECT inventory_accno_id - FROM buchungsgruppen - WHERE id = p.buchungsgruppen_id) = c1.id) - LEFT JOIN chart c2 ON - ((SELECT income_accno_id_${taxzone_id} - FROM buchungsgruppen - WHERE id = p.buchungsgruppen_id) = c2.id) - LEFT JOIN chart c3 ON - ((SELECT expense_accno_id_${taxzone_id} - FROM buchungsgruppen - WHERE id = p.buchungsgruppen_id) = c3.id) + LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) + LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id) + LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id) LEFT JOIN project pr ON (i.project_id = pr.id) LEFT JOIN partsgroup pg ON (pg.id = p.partsgroup_id) @@ -767,37 +744,24 @@ sub retrieve_invoice { $sth = prepare_execute_query($form, $dbh, $query, conv_i($form->{id})); while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - if (!$ref->{"part_inventory_accno_id"}) { - map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)); - } + map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"}; delete($ref->{"part_inventory_accno_id"}); foreach my $type (qw(inventory income expense)) { while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) { - my $query = - qq|SELECT accno, new_chart_id, date($transdate) - valid_from - FROM chart - WHERE id = ?|; - ($ref->{"${type}_accno"}, - $ref->{"${type}_new_chart"}, - $ref->{"${type}_valid"}) - = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); + my $query = qq|SELECT accno, new_chart_id, date($transdate) - valid_from FROM chart WHERE id = ?|; + @$ref{ map $type.$_, qw(_accno _new_chart _valid) } = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); } } # get tax rates and description my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; $query = - qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber - FROM tax t + qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber FROM tax t LEFT JOIN chart c ON (c.id = t.chart_id) WHERE t.id in - (SELECT tk.tax_id - FROM taxkeys tk - WHERE tk.chart_id = - (SELECT id - FROM chart - WHERE accno = ?) + (SELECT tk.tax_id FROM taxkeys tk + WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) AND (startdate <= $transdate) ORDER BY startdate DESC LIMIT 1) diff --git a/SL/IS.pm b/SL/IS.pm index 2632a727d..f51b536b6 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -1376,8 +1376,7 @@ sub retrieve_invoice { map { $form->{$_} = $ref->{$_} } keys %{ $ref }; - $form->{exchangerate} = - $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy"); + $form->{exchangerate} = $form->get_exchangerate($dbh, $form->{currency}, $form->{invdate}, "buy"); # get shipto $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module = 'AR')|; @@ -1387,30 +1386,25 @@ sub retrieve_invoice { foreach my $vc (qw(customer vendor)) { next if !$form->{"delivery_${vc}_id"}; - ($form->{"delivery_${vc}_string"}) - = selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id); + ($form->{"delivery_${vc}_string"}) = selectrow_query($form, $dbh, qq|SELECT name FROM customer WHERE id = ?|, $id); } # get printed, emailed - $query = - qq|SELECT printed, emailed, spoolfile, formname - FROM status - WHERE trans_id = ?|; + $query = qq|SELECT printed, emailed, spoolfile, formname FROM status WHERE trans_id = ?|; $sth = prepare_execute_query($form, $dbh, $query, $id); while ($ref = $sth->fetchrow_hashref(NAME_lc)) { $form->{printed} .= "$ref->{formname} " if $ref->{printed}; $form->{emailed} .= "$ref->{formname} " if $ref->{emailed}; - $form->{queued} .= "$ref->{formname} $ref->{spoolfile} " - if $ref->{spoolfile}; + $form->{queued} .= "$ref->{formname} $ref->{spoolfile} " if $ref->{spoolfile}; } $sth->finish; map { $form->{$_} =~ s/ +$//g } qw(printed emailed queued); - my $transdate = - $form->{deliverydate} ? $dbh->quote($form->{deliverydate}) : - $form->{invdate} ? $dbh->quote($form->{invdate}) : - "current_date"; + my $transdate = $form->{deliverydate} ? $dbh->quote($form->{deliverydate}) + : $form->{invdate} ? $dbh->quote($form->{invdate}) + : "current_date"; + my $taxzone_id = $form->{taxzone_id} *= 1; $taxzone_id = 0 if (0 > $taxzone_id) || (3 < $taxzone_id); @@ -1418,29 +1412,14 @@ sub retrieve_invoice { # retrieve individual items $query = qq|SELECT - c1.accno AS inventory_accno, - c1.new_chart_id AS inventory_new_chart, - date($transdate) - c1.valid_from AS inventory_valid, - - c2.accno AS income_accno, - c2.new_chart_id AS income_new_chart, - date($transdate) - c2.valid_from as income_valid, - - c3.accno AS expense_accno, - c3.new_chart_id AS expense_new_chart, - date($transdate) - c3.valid_from AS expense_valid, + c1.accno AS inventory_accno, c1.new_chart_id AS inventory_new_chart, date($transdate) - c1.valid_from AS inventory_valid, + c2.accno AS income_accno, c2.new_chart_id AS income_new_chart, date($transdate) - c2.valid_from as income_valid, + c3.accno AS expense_accno, c3.new_chart_id AS expense_new_chart, date($transdate) - c3.valid_from AS expense_valid, - i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, - i.discount, i.parts_id AS id, i.unit, i.deliverydate, - i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, - i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost, - - p.partnumber, p.assembly, p.bin, p.notes AS partnotes, - p.inventory_accno_id AS part_inventory_accno_id, p.formel, - - pr.projectnumber, - pg.partsgroup, - prg.pricegroup + i.description, i.longdescription, i.qty, i.fxsellprice AS sellprice, i.discount, i.parts_id AS id, i.unit, i.deliverydate, + i.project_id, i.serialnumber, i.id AS invoice_pos, i.pricegroup_id, i.ordnumber, i.transdate, i.cusordnumber, i.subtotal, i.lastcost, + p.partnumber, p.assembly, p.bin, p.notes AS partnotes, p.inventory_accno_id AS part_inventory_accno_id, p.formel, + pr.projectnumber, pg.partsgroup, prg.pricegroup FROM invoice i LEFT JOIN parts p ON (i.parts_id = p.id) @@ -1448,65 +1427,41 @@ sub retrieve_invoice { LEFT JOIN partsgroup pg ON (p.partsgroup_id = pg.id) LEFT JOIN pricegroup prg ON (i.pricegroup_id = prg.id) - LEFT JOIN chart c1 ON - ((SELECT inventory_accno_id - FROM buchungsgruppen - WHERE id = p.buchungsgruppen_id) = c1.id) - LEFT JOIN chart c2 ON - ((SELECT income_accno_id_${taxzone_id} - FROM buchungsgruppen - WHERE id=p.buchungsgruppen_id) = c2.id) - LEFT JOIN chart c3 ON - ((SELECT expense_accno_id_${taxzone_id} - FROM buchungsgruppen - WHERE id = p.buchungsgruppen_id) = c3.id) - - WHERE (i.trans_id = ?) - AND NOT (i.assemblyitem = '1') - ORDER BY i.id|; + LEFT JOIN chart c1 ON ((SELECT inventory_accno_id FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c1.id) + LEFT JOIN chart c2 ON ((SELECT income_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c2.id) + LEFT JOIN chart c3 ON ((SELECT expense_accno_id_${taxzone_id} FROM buchungsgruppen WHERE id = p.buchungsgruppen_id) = c3.id) + + WHERE (i.trans_id = ?) AND NOT (i.assemblyitem = '1') ORDER BY i.id|; $sth = prepare_execute_query($form, $dbh, $query, $id); while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - if (!$ref->{"part_inventory_accno_id"}) { - map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)); - } + map({ delete($ref->{$_}); } qw(inventory_accno inventory_new_chart inventory_valid)) if !$ref->{"part_inventory_accno_id"}; delete($ref->{"part_inventory_accno_id"}); foreach my $type (qw(inventory income expense)) { while ($ref->{"${type}_new_chart"} && ($ref->{"${type}_valid"} >=0)) { - my $query = - qq|SELECT accno, new_chart_id, date($transdate) - valid_from - FROM chart - WHERE id = ?|; - ($ref->{"${type}_accno"}, - $ref->{"${type}_new_chart"}, - $ref->{"${type}_valid"}) - = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); + my $query = qq|SELECT accno, new_chart_id, date($transdate) - valid_from FROM chart WHERE id = ?|; + @$ref{ map $type.$_, qw(_accno _new_chart _valid) } = selectrow_query($form, $dbh, $query, $ref->{"${type}_new_chart"}); } } # get tax rates and description - my $accno_id = - ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; + my $accno_id = ($form->{vc} eq "customer") ? $ref->{income_accno} : $ref->{expense_accno}; $query = - qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber - FROM tax t + qq|SELECT c.accno, t.taxdescription, t.rate, t.taxnumber FROM tax t LEFT JOIN chart c ON (c.id = t.chart_id) WHERE t.id IN - (SELECT tk.tax_id - FROM taxkeys tk - WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) + (SELECT tk.tax_id FROM taxkeys tk + WHERE tk.chart_id = (SELECT id FROM chart WHERE accno = ?) AND startdate <= date($transdate) - ORDER BY startdate DESC - LIMIT 1) + ORDER BY startdate DESC LIMIT 1) ORDER BY c.accno|; my $stw = prepare_execute_query($form, $dbh, $query, $accno_id); $ref->{taxaccounts} = ""; my $i=0; while ($ptr = $stw->fetchrow_hashref(NAME_lc)) { - # if ($customertax{$ref->{accno}}) { if (($ptr->{accno} eq "") && ($ptr->{rate} == 0)) { $i++; $ptr->{accno} = $i; @@ -1523,12 +1478,8 @@ sub retrieve_invoice { } if ($form->{lizenzen}) { - $query = - qq|SELECT l.licensenumber, l.id AS licenseid - FROM license l, licenseinvoice li - WHERE l.id = li.license_id AND li.trans_id = ?|; - my ($licensenumber, $licenseid) - = selectrow_query($form, $dbh, $query, conv_i($ref->{invoice_pos})); + $query = qq|SELECT l.licensenumber, l.id AS licenseid FROM license l, licenseinvoice li WHERE l.id = li.license_id AND li.trans_id = ?|; + my ($licensenumber, $licenseid) = selectrow_query($form, $dbh, $query, conv_i($ref->{invoice_pos})); $ref->{lizenzen} = ""; } diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 08b6f1d2f..9cdb6d7d9 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -34,6 +34,7 @@ use SL::IR; use SL::IS; use SL::PE; +use List::Util qw(max); require "bin/mozilla/io.pl"; require "bin/mozilla/arap.pl"; @@ -216,8 +217,7 @@ sub form_header { # set option selected foreach $item (qw(AP vendor currency department)) { $form->{"select$item"} =~ s/ selected//; - $form->{"select$item"} =~ - s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; + $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; @@ -232,10 +232,10 @@ sub form_header { if ($form->{currency} ne $form->{defaultcurrency}) { if ($form->{forex}) { $exchangerate .= qq| | . $locale->text('Exchangerate') . qq| - $form->{exchangerate}{exchangerate}>\n|; + $form->{exchangerate}{exchangerate}>\n|; } else { $exchangerate .= qq| | . $locale->text('Exchangerate') . qq| - {exchangerate}>\n|; + {exchangerate}>\n|; } } $exchangerate .= qq| {forex}>\n|; @@ -245,8 +245,8 @@ sub form_header { $form->get_lists("contacts" => "ALL_CONTACTS", "projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, + "all" => 0, + "old_id" => \@old_project_ids }, "taxzones" => "ALL_TAXZONES", "employees" => "ALL_SALESMEN", "currencies" => "ALL_CURRENCIES", @@ -330,8 +330,8 @@ sub form_header { (($myconfig{vclimit} <= scalar(@values)) ? qq|| : (NTI($cgi->popup_menu('-name' => 'vendor', '-default' => $form->{oldvendor}, - '-onChange' => 'document.getElementById(\'update_button\').click();', - '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq| + '-onChange' => 'document.getElementById(\'update_button\').click();', + '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')))) . qq| |; @@ -367,8 +367,7 @@ sub form_header { - -| if $form->{selectdepartment}; + \n| if $form->{selectdepartment}; $n = ($form->{creditremaining} =~ /-/) ? "0" : "1"; @@ -378,24 +377,25 @@ sub form_header { $button1 = qq| - text('button') . qq|>\n|; + text('button') . qq|>\n|; $button2 = qq| - text('button') . qq|>\n|; + text('button') . qq|>\n|; #write Trigger $jsscript = - Form->write_trigger(\%myconfig, "2", "invdate", "BL", "trigger1", + Form->write_trigger(\%myconfig, "2", + "invdate", "BL", "trigger1", "duedate", "BL", "trigger2"); - $form->{"javascript"} .= qq||; - $form->{"javascript"} .= qq||; - $form->{javascript} .= qq||; + $form->{javascript} .= qq||; + $form->{javascript} .= qq||; + $form->{javascript} .= qq||; $jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate"); $form->header; - $onload = qq|focus()|; + $onload = qq|focus()|; $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; print qq| @@ -404,9 +404,10 @@ sub form_header {
{script}> |; - $form->hide_form(qw(id title vc type level creditlimit creditremaining - closedto locked shippted storno storno_id - max_dunning_level dunning_amount)); + $form->hide_form(qw(id title vc type level creditlimit creditremaining closedto locked shippted storno storno_id + max_dunning_level dunning_amount vendor_id oldvendor selectvendor taxaccounts + fxgain_accno fxloss_accno taxpart taxservice), + map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} ); print qq|

$form->{saved_message}

| if $form->{saved_message}; @@ -419,9 +420,6 @@ sub form_header { $vendors - - - $contact @@ -483,14 +481,7 @@ sub form_header { $jsscript -{fxgain_accno}> -{fxloss_accno}> - - - - - |; foreach $item (split / /, $form->{taxaccounts}) { @@ -854,38 +845,22 @@ sub mark_as_paid { sub update { $lxdebug->enter_sub(); - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(exchangerate creditlimit creditremaining); + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); &check_name(vendor); - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{invdate}, 'sell' - ))); + $form->{exchangerate} = $exchangerate if + $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell'); for $i (1 .. $form->{paidaccounts}) { - if ($form->{"paid_$i"}) { - map { - $form->{"${_}_$i"} = - $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) - } qw(paid exchangerate); - - $form->{"exchangerate_$i"} = $exchangerate - if ( - $form->{"forex_$i"} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell' - ))); - } + next unless $form->{"paid_$i"}; + map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); + $form->{"exchangerate_$i"} = $exchangerate if + $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); } $i = $form->{rowcount}; - $exchangerate = ($form->{exchangerate} * 1) ? $form->{exchangerate} * 1 : 1; + $exchangerate = ($form->{exchangerate} * 1) || 1; if ( ($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") @@ -912,35 +887,23 @@ sub update { # override sellprice if there is one entered $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); - map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } - qw(partnumber description unit); + map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); + map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; - map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } - keys %{ $form->{item_list}[0] }; - - $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; - - ($dec) = ($s =~ /\.(\d+)/); - $dec = length $dec; - $decimalplaces = ($dec > 2) ? $dec : 2; + ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/; + $decimalplaces = max 2, length $1; if ($sellprice) { $form->{"sellprice_$i"} = $sellprice; } else { - # if there is an exchange rate adjust sellprice $form->{"sellprice_$i"} /= $exchangerate; } - $amount = - $form->{"sellprice_$i"} * $form->{"qty_$i"} * - (1 - $form->{"discount_$i"} / 100); + $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); $form->{creditremaining} -= $amount; - $form->{"sellprice_$i"} = - $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, - $decimalplaces); - $form->{"qty_$i"} = - $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); + $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); } &display_form; diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index c0f247ce6..bfcad9e42 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -34,6 +34,7 @@ use SL::IS; use SL::PE; use Data::Dumper; +use List::Util qw(max); require "bin/mozilla/io.pl"; require "bin/mozilla/arap.pl"; @@ -467,11 +468,7 @@ sub form_header { $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } - if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { - $creditwarning = 1; - } else { - $creditwarning = 0; - } + $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0; $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); @@ -561,29 +558,21 @@ sub form_header { #write Trigger $jsscript = Form->write_trigger(\%myconfig, "3", - "invdate", "BL", - "trigger1", "duedate", - "BL", "trigger2", - "deliverydate", "BL", - "trigger3"); + "invdate", "BL", "trigger1", + "duedate", "BL", "trigger2", + "deliverydate", "BL", "trigger3"); } - if ($form->{resubmit} && ($form->{format} eq "html")) { - $onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|; - } elsif ($form->{resubmit}) { - $onload = qq|document.invoice.submit()|; - } else { - $onload = "focus()"; - } + $credittext = $locale->text('Credit Limit exceeded!!!'); + $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()| + : ($form->{resubmit}) ? qq|document.invoice.submit()| + : ($creditwarning) ? qq|alert('$credittext')| + : "focus()"; $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; - $credittext = $locale->text('Credit Limit exceeded!!!'); - if ($creditwarning) { - $onload = qq|alert('$credittext')|; - } - $form->{"javascript"} .= qq||; - $form->{javascript} .= qq||; + $form->{javascript} .= qq||; + $form->{javascript} .= qq||; $jsscript .= $form->write_trigger(\%myconfig, 2, @@ -606,7 +595,11 @@ sub form_header { $form->hide_form(qw(id action type media format queued printed emailed title vc discount creditlimit creditremaining tradediscount business closedto locked shipped storno storno_id - max_dunning_level dunning_amount)); + max_dunning_level dunning_amount + shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax + shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts), + map { $_.'_rate', $_,'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts} ); + print qq|

$form->{saved_message}

| if $form->{saved_message}; print qq| @@ -749,23 +742,11 @@ print qq| - -| . -$jsscript -. qq| - -| ; -map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } - qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail shiptodepartment_1 shiptodepartment_2)); -print qq| |; -map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } - qw(message email subject cc bcc taxaccounts)); -print qq||; + + $jsscript +|; + print qq||; - foreach $item (split(/ /, $form->{taxaccounts})) { - map({ print($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } - ("${item}_rate", "${item}_description", "${item}_taxnumber")); - } $lxdebug->leave_sub(); } @@ -1188,52 +1169,28 @@ sub mark_as_paid { sub update { $lxdebug->enter_sub(); - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(exchangerate creditlimit creditremaining); - if ($form->{second_run}) { - $form->{print_and_post} = 0; - } - + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); - if($form->{taxincluded}) { - $taxincluded = "checked"; - } + $form->{print_and_post} = 0 if $form->{second_run}; + $taxincluded = "checked" if $form->{taxincluded}; $form->{update} = 1; &check_name(customer); - if(!$form->{taxincluded}) { - $form->{taxincluded} = $taxincluded; - } - + $form->{taxincluded} ||= $taxincluded; - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{invdate}, 'buy' - ))); + $form->{exchangerate} = $exchangerate if + $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); for $i (1 .. $form->{paidaccounts}) { - if ($form->{"paid_$i"}) { - map { - $form->{"${_}_$i"} = - $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) - } qw(paid exchangerate); - - $form->{"exchangerate_$i"} = $exchangerate - if ( - $form->{"forex_$i"} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy' - ))); - } + next unless $form->{"paid_$i"}; + map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate); + $form->{"exchangerate_$i"} = $exchangerate if + $form->{"forex_$i"} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy'); } $i = $form->{rowcount}; - $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; + $exchangerate = $form->{exchangerate} || 1; # if last row empty, check the form otherwise retrieve new item if ( ($form->{"partnumber_$i"} eq "") @@ -1249,8 +1206,7 @@ sub update { $rows = scalar @{ $form->{item_list} }; - $form->{"discount_$i"} = - $form->format_amount(\%myconfig, $form->{discount} * 100); + $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100); if ($rows) { $form->{"qty_$i"} = ($form->{"qty_$i"} * 1) ? $form->{"qty_$i"} : 1; @@ -1264,27 +1220,18 @@ sub update { $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); - map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } - qw(partnumber description unit); - map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } - keys %{ $form->{item_list}[0] }; - if ($form->{"part_payment_id_$i"} ne "") { - $form->{payment_id} = $form->{"part_payment_id_$i"}; - } + map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); + map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; + + $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne ""; + $form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"}; - if ($form->{"not_discountable_$i"}) { - $form->{"discount_$i"} = 0; - } - - $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; - ($dec) = ($s =~ /\.(\d+)/); - $dec = length $dec; - $decimalplaces = ($dec > 2) ? $dec : 2; + ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/; + $decimalplaces = max 2, length $1; if ($sellprice) { $form->{"sellprice_$i"} = $sellprice; } else { - # if there is an exchange rate adjust sellprice $form->{"sellprice_$i"} *= (1 - $form->{tradediscount}); $form->{"sellprice_$i"} /= $exchangerate; @@ -1292,36 +1239,24 @@ sub update { $form->{"listprice_$i"} /= $exchangerate; - $amount = - $form->{"sellprice_$i"} * $form->{"qty_$i"} * - (1 - $form->{"discount_$i"} / 100); - map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts}); - 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"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); + map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts}; + map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"}; + map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{"taxaccounts_$i"} if !$form->{taxincluded}; $form->{creditremaining} -= $amount; - map { - $form->{"${_}_$i"} = - $form->format_amount(\%myconfig, $form->{"${_}_$i"}, - $decimalplaces) - } qw(sellprice listprice); + map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, $decimalplaces) } qw(sellprice listprice); - $form->{"qty_$i"} = - $form->format_amount(\%myconfig, $form->{"qty_$i"}); + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}); if ($lizenzen) { if ($form->{"inventory_accno_$i"} ne "") { $form->{"lizenzen_$i"} = qq||; foreach $item (@{ $form->{LIZENZEN}{ $form->{"id_$i"} } }) { - $form->{"lizenzen_$i"} .= - qq||; + $form->{"lizenzen_$i"} .= qq||; } - $form->{"lizenzen_$i"} .= - qq||; + $form->{"lizenzen_$i"} .= qq||; } } diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index db6a934db..5cc5418d6 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -38,6 +38,7 @@ use SL::IR; use SL::IS; use SL::PE; use SL::ReportGenerator; +use List::Util qw(max); require "bin/mozilla/io.pl"; require "bin/mozilla/arap.pl"; @@ -324,25 +325,16 @@ sub prepare_order { sub form_header { $lxdebug->enter_sub(); - my $checkedclosed = $form->{"closed"} ? "checked" : ""; + my $checkedclosed = $form->{"closed"} ? "checked" : ""; my $checkeddelivered = $form->{"delivered"} ? "checked" : ""; - if ($form->{old_employee_id}) { - $form->{employee_id} = $form->{old_employee_id}; - } - if ($form->{old_salesman_id}) { - $form->{salesman_id} = $form->{old_salesman_id}; - } + $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; + $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - - if ($form->{old_employee_id}) { - $form->{employee_id} = $form->{old_employee_id}; - } - if ($form->{old_salesman_id}) { - $form->{salesman_id} = $form->{old_salesman_id}; - } + $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; + $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id}; map { $form->{$_} =~ s/\"/"/g } qw(ordnumber quonumber shippingpoint shipvia notes intnotes shiptoname @@ -365,39 +357,32 @@ sub form_header { |; #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", - "reqdate", "BL", "trigger2"); + $jsscript = Form->write_trigger(\%myconfig, "2", "transdate", "BL", "trigger1", "reqdate", "BL", "trigger2"); my @tmp; if (($form->{"type"} eq "sales_order") || ($form->{"type"} eq "purchase_order")) { - push(@tmp, qq| - - |); + push(@tmp, qq| + |); } if ($form->{id}) { - push(@tmp, qq| - - |); + push(@tmp, qq| + |); } if (@tmp) { - $openclosed .= qq| - - - -|; + $openclosed .= qq| + + \n|; } # set option selected foreach $item ($form->{vc}, currency, department, ($form->{vc} eq "customer" ? customer : vendor)) { $form->{"select$item"} =~ s/ selected//; - $form->{"select$item"} =~ - s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; + $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } #quote select[customer|vendor] Bug 133 @@ -429,8 +414,7 @@ sub form_header { my @values = (undef); foreach my $item (@{ $form->{"ALL_CONTACTS"} }) { push(@values, $item->{"cp_id"}); - $labels{$item->{"cp_id"}} = $item->{"cp_name"} . - ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); + $labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : ""); } my $contact; @@ -506,10 +490,9 @@ sub form_header { push(@values, $item->{"id"}); $labels{$item->{"id"}} = $item->{"projectnumber"}; } - my $globalprojectnumber = - NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, - '-labels' => \%labels, - '-default' => $form->{"globalproject_id"})); + my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, + '-labels' => \%labels, + '-default' => $form->{"globalproject_id"})); my $salesmen = ""; %labels = (); @@ -582,40 +565,26 @@ sub form_header { |; } - $form->{exchangerate} = - $form->format_amount(\%myconfig, $form->{exchangerate}); - - if (!$form->{exchangerate}) { - $form->{exchangerate} = ""; - } + $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); + $form->{exchangerate} = "" unless $form->{exchangerate}; - if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { - $creditwarning = 1; - } else { - $creditwarning = 0; - } + $creditwarning = (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) ? 1 : 0; - $form->{creditlimit} = - $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); - $form->{creditremaining} = - $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); + $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); + $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); - $exchangerate = qq| -{forex}> -|; + $exchangerate = qq|\n{forex}>\n|; if ($form->{currency} ne $form->{defaultcurrency}) { if ($form->{forex}) { $exchangerate .= - qq|{exchangerate}> |; } else { $exchangerate .= - qq||; } } @@ -683,10 +652,7 @@ sub form_header { |; } else { - $reqlabel = - ($form->{type} eq 'sales_quotation') - ? $locale->text('Valid until') - : $locale->text('Required by'); + $reqlabel = ($form->{type} eq 'sales_quotation') ? $locale->text('Valid until') : $locale->text('Required by'); if ($form->{type} eq 'sales_quotation') { $ordnumber = qq| @@ -707,20 +673,9 @@ sub form_header { } - $ordnumber .= qq| - - - $button1 - - - - $button2 - -|; - $creditremaining = qq| - - $shipto - |; + $ordnumber .= qq| $button1 + $button2 \n|; + $creditremaining = qq| $shipto |; } $department = qq| @@ -732,35 +687,23 @@ sub form_header { | if $form->{selectdepartment}; if ($form->{type} eq 'sales_order') { - if ($form->{selectemployee}) { - $employee .= qq| - |; - } - } else { - $employee .= qq| - |; - } - if ($form->{resubmit} && ($form->{format} eq "html")) { - $onload = - qq|window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()|; - } elsif ($form->{resubmit}) { - $onload = qq|document.oe.submit()|; + $employee .= qq|\n| if $form->{selectemployee}; } else { - $onload = "focus()"; + $employee .= qq|\n|; } $credittext = $locale->text('Credit Limit exceeded!!!'); - if ($creditwarning) { - $onload = qq|alert('$credittext')|; - } - + + $onload = ($form->{resubmit} && ($form->{format} eq "html")) ? "window.open('about:blank','Beleg'); document.oe.target = 'Beleg';document.oe.submit()" + : ($form->{resubmit}) ? "document.oe.submit()" + : ($creditwarning) ? "alert('$credittext')" + : "focus()"; + $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|; - $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; + $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|; - $form->{"javascript"} .= qq||; - # show history button js + $form->{javascript} .= qq||; $form->{javascript} .= qq||; - #/show history button js $form->{javascript} .= qq||; $form->header; @@ -778,8 +721,11 @@ sub form_header { $form->hide_form(qw(id action type vc formname media format proforma queued printed emailed title discount creditlimit creditremaining tradediscount business - max_dunning_level dunning_amount)); - + max_dunning_level dunning_amount shiptoname shiptostreet shiptozipcode + shiptocity shiptocountry shiptocontact shiptophone shiptofax + shiptodepartment_1 shiptodepartment_2 shiptoemail + message email subject cc bcc taxpart taxservice taxaccounts), + map { $_.'_rate', $_.'_description' } split / /, $form->{taxaccounts} ); print qq|
| . $locale->text('Credit Limit') . qq|
| . join("\n", @tmp) . qq| -
| . join("\n", @tmp) . qq| +
| - . $locale->text('Exchangerate') + qq|| . $locale->text('Exchangerate') . qq|$form->{exchangerate} | - . $locale->text('Exchangerate') + qq|| . $locale->text('Exchangerate') . qq|{exchangerate}>
| . $locale->text('Quotation Date') . qq|
$reqlabel
| . $locale->text('Quotation Date') . qq|
$reqlabel
@@ -858,39 +804,8 @@ print qq|
$jsscript - - - - - - - - - - - - - - - - - - - - - - - - - |; - foreach $item (split / /, $form->{taxaccounts}) { - print qq| -{"${item}_rate"}> - -|; - } $lxdebug->leave_sub(); } @@ -1190,34 +1105,24 @@ sub update { set_headings($form->{"id"} ? "edit" : "add"); - map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } - qw(exchangerate creditlimit creditremaining); + map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining); $form->{update} = 1; - if($form->{payment_id}) { - $payment_id = $form->{payment_id}; - } + $payment_id = $form->{payment_id} if $form->{payment_id}; &check_name($form->{vc}); - if($form->{payment_id} eq "") { - $form->{payment_id} = $payment_id; - } + $form->{payment_id} = $payment_id if $form->{payment_id} eq ""; $buysell = 'buy'; $buysell = 'sell' if ($form->{vc} eq 'vendor'); - $form->{exchangerate} = $exchangerate - if ( - $form->{forex} = ( - $exchangerate = - $form->check_exchangerate( - \%myconfig, $form->{currency}, $form->{transdate}, $buysell - ))); + $form->{exchangerate} = $exchangerate if + $form->{forex} = $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{transdate}, $buysell); # for pricegroups $i = $form->{rowcount}; - $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1; + $exchangerate = $form->{exchangerate} || 1; if ( ($form->{"partnumber_$i"} eq "") && ($form->{"description_$i"} eq "") @@ -1232,14 +1137,14 @@ sub update { || $form->{type} eq 'request_quotation') { IR->retrieve_item(\%myconfig, \%$form); } - if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') { + if ( $form->{type} eq 'sales_order' + || $form->{type} eq 'sales_quotation') { IS->retrieve_item(\%myconfig, \%$form); } my $rows = scalar @{ $form->{item_list} }; - $form->{"discount_$i"} = - $form->format_amount(\%myconfig, $form->{discount} * 100); + $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{discount} * 100); if ($rows) { $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"}); @@ -1251,51 +1156,31 @@ sub update { } else { - $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); - if ($form->{"not_discountable_$i"}) { - $form->{"discount_$i"} = 0; - } - map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } - qw(partnumber description unit); - map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } - keys %{ $form->{item_list}[0] }; - if ($form->{"part_payment_id_$i"} ne "") { - $form->{payment_id} = $form->{"part_payment_id_$i"}; - } - - $s = ($sellprice) ? $sellprice : $form->{"sellprice_$i"}; + $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"}); + $form->{"discount_$i"} = 0 if $form->{"not_discountable_$i"}; + map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit); + map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] }; + $form->{payment_id} = $form->{"part_payment_id_$i"} if $form->{"part_payment_id_$i"} ne ""; - ($dec) = ($s =~ /\.(\d+)/); - $dec = length $dec; - $decimalplaces = ($dec > 2) ? $dec : 2; + ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/; + $decimalplaces = max 2, length $1; if ($sellprice) { $form->{"sellprice_$i"} = $sellprice; } else { - $form->{"sellprice_$i"} *= (1 - $form->{tradediscount}); - - # if there is an exchange rate adjust sellprice - $form->{"sellprice_$i"} /= $exchangerate; + $form->{"sellprice_$i"} /= $exchangerate; # if there is an exchange rate adjust sellprice } - $amount = - $form->{"sellprice_$i"} * $form->{"qty_$i"} * - (1 - $form->{"discount_$i"} / 100); - map { $form->{"${_}_base"} = 0 } (split / /, $form->{taxaccounts}); - map { $form->{"${_}_base"} += $amount } - (split / /, $form->{"taxaccounts_$i"}); - map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } - split / /, $form->{taxaccounts} - if !$form->{taxincluded}; + $amount = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100); + map { $form->{"${_}_base"} = 0 } split / /, $form->{taxaccounts}; + map { $form->{"${_}_base"} += $amount } split / /, $form->{"taxaccounts_$i"}; + map { $amount += ($form->{"${_}_base"} * $form->{"${_}_rate"}) } split / /, $form->{taxaccounts} if !$form->{taxincluded}; $form->{creditremaining} -= $amount; - $form->{"sellprice_$i"} = - $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, - $decimalplaces); - $form->{"qty_$i"} = - $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); + $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces); + $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty); # get pricegroups for parts IS->get_pricegroups_for_parts(\%myconfig, \%$form); diff --git a/lx-erp.conf b/lx-erp.conf index b8d023099..71d1c8178 100644 --- a/lx-erp.conf +++ b/lx-erp.conf @@ -96,7 +96,7 @@ $pg_restore_exe = "pg_restore"; # # Beipiel: # $LXDebug::global_level = LXDebug::TRACE | LXDebug::QUERY; -$LXDebug::global_level = LXDebug::NONE; +$LXDebug::global_level = LXDebug::DEVEL; # Überwachung der Inhalte von $form aktiviert oder nicht? Wenn ja, # dann können einzelne Variablen mit