From: Sven Schöling Date: Thu, 19 Jul 2007 15:56:43 +0000 (+0000) Subject: Kosmetik, merge aus -r5105,5106,5118,5120,5124 X-Git-Tag: release-2.6.0beta1~559 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a05eead353b55ba228a5eec40f90c0f2c330092a;p=kivitendo-erp.git Kosmetik, merge aus -r5105,5106,5118,5120,5124 --- diff --git a/SL/IR.pm b/SL/IR.pm index 690c20d84..5854f97dd 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -38,6 +38,7 @@ use SL::AM; use SL::Common; use SL::DBUtils; use SL::MoreCommon; +use List::Util qw(min); sub post_invoice { $main::lxdebug->enter_sub(); @@ -59,10 +60,8 @@ sub post_invoice { if (!$payments_only) { if ($form->{id}) { &reverse_invoice($dbh, $form); - } else { ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|); - do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber) VALUES (?, '')|, $form->{id}); } } @@ -73,16 +72,10 @@ sub post_invoice { if ($form->{currency} eq $defaultcurrency) { $form->{exchangerate} = 1; } else { - $exchangerate = - $form->check_exchangerate($myconfig, $form->{currency}, - $form->{transdate}, 'sell'); + $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'sell'); } - $form->{exchangerate} = - ($exchangerate) - ? $exchangerate - : $form->parse_amount($myconfig, $form->{exchangerate}); - + $form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate}); $form->{exchangerate} = 1 unless ($form->{exchangerate} * 1); my %item_units; @@ -92,15 +85,10 @@ sub post_invoice { for my $i (1 .. $form->{rowcount}) { next unless $form->{"id_$i"}; - $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); + $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"}); + $form->{"qty_$i"} *= -1 if $form->{storno}; - if ($form->{storno}) { - $form->{"qty_$i"} *= -1; - } - - if ($main::eur) { - $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"}; - } + $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"} if $main::eur; # get item baseunit if (!$item_units{$form->{"id_$i"}}) { @@ -111,8 +99,8 @@ sub post_invoice { my $item_unit = $item_units{$form->{"id_$i"}}; if (defined($all_units->{$item_unit}->{factor}) - && ($all_units->{$item_unit}->{factor} ne '') - && ($all_units->{$item_unit}->{factor} * 1 != 0)) { + && ($all_units->{$item_unit}->{factor} ne '') + && ($all_units->{$item_unit}->{factor} * 1 != 0)) { $basefactor = $all_units->{$form->{"unit_$i"}}->{factor} / $all_units->{$item_unit}->{factor}; } else { $basefactor = 1; @@ -125,10 +113,8 @@ sub post_invoice { $taxrate = 0; $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"}); - my $fxsellprice = $form->{"sellprice_$i"}; - - my ($dec) = ($fxsellprice =~ /\.(\d+)/); - $dec = length $dec; + (my $fxsellprice = $form->{"sellprice_$i"}) =~ /\.(\d+)/; + my $dec = length $1; my $decimalplaces = ($dec > 2) ? $dec : 2; map { $taxrate += $form->{"${_}_rate"} } @taxaccounts; @@ -175,8 +161,7 @@ sub post_invoice { $form->{amount}{ $form->{id} }{ $form->{"inventory_accno_$i"} } -= $linetotal; # adjust and round sellprice - $form->{"sellprice_$i"} = - $form->round_amount($form->{"sellprice_$i"} * $form->{exchangerate}, $decimalplaces); + $form->{"sellprice_$i"} = $form->round_amount($form->{"sellprice_$i"} * $form->{exchangerate}, $decimalplaces); $lastinventoryaccno = $form->{"inventory_accno_$i"}; @@ -187,9 +172,7 @@ sub post_invoice { @values = ($form->{"sellprice_$i"}, conv_i($form->{"id_$i"})); do_query($form, $dbh, $query, @values); - if (!$form->{shipped}) { - $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, $baseqty, $form->{"id_$i"}) - } + $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, $baseqty, $form->{"id_$i"}) if !$form->{shipped}; # check if we sold the item already and # make an entry for the expense and inventory @@ -207,13 +190,7 @@ sub post_invoice { my $totalqty = $base_qty; while (my $ref = $sth->fetchrow_hashref(NAME_lc)) { - - my $qty = $ref->{base_qty} + $ref->{allocated}; - - if (($qty - $totalqty) > 0) { - $qty = $totalqty; - } - + my $qty = min $totalqty, ($ref->{base_qty} + $ref->{allocated}); $linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2); if ($ref->{allocated} < 0) { @@ -233,17 +210,13 @@ sub post_invoice { } elsif ($linetotal != 0) { # add entry for inventory, this one is for the sold item - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) - VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?))|; - @values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, - $ref->{transdate}, $ref->{inventory_accno_id}); + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?))|; + @values = ($ref->{trans_id}, $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id}); do_query($form, $dbh, $query, @values); # add expense - $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) - VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?))|; - @values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), - $ref->{transdate}, $ref->{expense_accno_id}); + $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?))|; + @values = ($ref->{trans_id}, $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id}); do_query($form, $dbh, $query, @values); } @@ -252,7 +225,7 @@ sub post_invoice { $allocated += $qty; - last if (($totalqty -= $qty) <= 0); + last if ($totalqty -= $qty) <= 0; } $sth->finish(); @@ -274,17 +247,13 @@ sub post_invoice { if ($form->round_amount($taxrate, 7) == 0) { if ($form->{taxincluded}) { foreach $item (@taxaccounts) { - $taxamount = - $linetotal * $form->{"${item}_rate"} - / (1 + abs($form->{"${item}_rate"})); + $taxamount = $linetotal * $form->{"${item}_rate"} / (1 + abs($form->{"${item}_rate"})); $totaltax += $taxamount; $form->{amount}{ $form->{id} }{$item} -= $taxamount; } - } else { map { $form->{amount}{ $form->{id} }{$_} -= $linetotal * $form->{"${_}_rate"} } @taxaccounts; } - } else { map { $form->{amount}{ $form->{id} }{$_} -= $taxamount * $form->{"${_}_rate"} / $taxrate } @taxaccounts; } @@ -341,7 +310,7 @@ sub post_invoice { for my $i (1 .. $form->{paidaccounts}) { $form->{"paid_$i"} = $form->parse_amount($myconfig, $form->{"paid_$i"}); $form->{paid} += $form->{"paid_$i"}; - $form->{datepaid} = $form->{"datepaid_$i"} if ($form->{"datepaid_$i"}); + $form->{datepaid} = $form->{"datepaid_$i"} if $form->{"datepaid_$i"}; } my ($tax, $paiddiff) = (0, 0); @@ -368,12 +337,9 @@ sub post_invoice { $expensediff += $paiddiff; ######## this only applies to tax included - if ($lastinventoryaccno) { - $form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff; - } - if ($lastexpenseaccno) { - $form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $expensediff; - } + + $form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff if $lastinventoryaccno; + $form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $expensediff if $lastexpenseaccno; } else { $amount = $form->round_amount($netamount * $form->{exchangerate}, 2); @@ -392,21 +358,20 @@ sub post_invoice { $form->{amount}{ $form->{id} }{ $form->{AP} } = $netamount + $tax; - if ($form->{paid} != 0) { - $form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2); - } + + $form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2) if $form->{paid} != 0; # update exchangerate - if (($form->{currency} ne $defaultcurrency) && !$exchangerate) { - $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate}); - } + + $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate}) + if ($form->{currency} ne $defaultcurrency) && !$exchangerate; # record acc_trans transactions foreach my $trans_id (keys %{ $form->{amount} }) { foreach my $accno (keys %{ $form->{amount}{$trans_id} }) { $form->{amount}{$trans_id}{$accno} = $form->round_amount($form->{amount}{$trans_id}{$accno}, 2); - next if ($payments_only || !$form->{amount}{$trans_id}{$accno}); + next if $payments_only || !$form->{amount}{$trans_id}{$accno}; $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id) VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, @@ -426,13 +391,12 @@ sub post_invoice { } # force AP entry if 0 - if ($form->{amount}{ $form->{id} }{ $form->{AP} } == 0) { - $form->{amount}{ $form->{id} }{ $form->{AP} } = $form->{paid}; - } + + $form->{amount}{ $form->{id} }{ $form->{AP} } = $form->{paid} if $form->{amount}{$form->{id}}{$form->{AP}} == 0; # record payments and offsetting AP for my $i (1 .. $form->{paidaccounts}) { - next if ($form->{"paid_$i"} == 0); + next if $form->{"paid_$i"} == 0; my ($accno) = split /--/, $form->{"AP_paid_$i"}; $form->{"datepaid_$i"} = $form->{invdate} unless ($form->{"datepaid_$i"}); @@ -463,17 +427,12 @@ sub post_invoice { if ($form->{currency} eq $defaultcurrency) { $form->{"exchangerate_$i"} = 1; } else { - $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); - - $form->{"exchangerate_$i"} = - ($exchangerate) - ? $exchangerate - : $form->parse_amount($myconfig, $form->{"exchangerate_$i"}); + $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell'); + $form->{"exchangerate_$i"} = $exchangerate || $form->parse_amount($myconfig, $form->{"exchangerate_$i"}); } # exchangerate difference - $form->{fx}{$accno}{ $form->{"datepaid_$i"} } += - $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $paiddiff; + $form->{fx}{$accno}{ $form->{"datepaid_$i"} } += $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $paiddiff; # gain/loss $amount = @@ -481,7 +440,6 @@ sub post_invoice { ($form->{"paid_$i"} * $form->{"exchangerate_$i"}); if ($amount > 0) { $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } += $amount; - } else { $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } += $amount; } @@ -489,11 +447,8 @@ sub post_invoice { $paiddiff = 0; # update exchange rate - if (($form->{currency} ne $defaultcurrency) && !$exchangerate) { - $form->update_exchangerate($dbh, $form->{currency}, - $form->{"datepaid_$i"}, - 0, $form->{"exchangerate_$i"}); - } + $form->update_exchangerate($dbh, $form->{currency}, $form->{"datepaid_$i"}, 0, $form->{"exchangerate_$i"}) + if ($form->{currency} ne $defaultcurrency) && !$exchangerate; } # record exchange rate differences and gains/losses @@ -529,46 +484,28 @@ sub post_invoice { $form->{department_id} = (split /--/, $form->{department})[1]; $form->{invnumber} = $form->{id} unless $form->{invnumber}; - $taxzone_id = 0 if ((3 < $taxzone_id) || (0 > $taxzone_id)); + $taxzone_id = 0 if (3 < $taxzone_id) || (0 > $taxzone_id); # save AP record $query = qq|UPDATE ap SET - invnumber = ?, - ordnumber = ?, - quonumber = ?, - transdate = ?, - orddate = ?, - quodate = ?, - vendor_id = ?, - amount = ?, - netamount = ?, - paid = ?, - datepaid = ?, - duedate = ?, - invoice = '1', - taxzone_id = ?, - taxincluded = ?, - notes = ?, - intnotes = ?, - curr = ?, - department_id = ?, - storno = ?, - storno_id = ?, - globalproject_id = ?, - cp_id = ?, - employee_id = ? + invnumber = ?, ordnumber = ?, quonumber = ?, transdate = ?, + orddate = ?, quodate = ?, vendor_id = ?, amount = ?, + netamount = ?, paid = ?, duedate = ?, datepaid = ?, + invoice = ?, taxzone_id = ?, notes = ?, taxincluded = ?, + intnotes = ?, curr = ?, storno_id = ?, storno = ?, + cp_id = ?, employee_id = ?, department_id = ?, + globalproject_id = ? WHERE id = ?|; - @values = ($form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, - conv_date($form->{invdate}), conv_date($form->{orddate}), conv_date($form->{quodate}), - conv_i($form->{vendor_id}), $amount, $netamount, $form->{paid}, - $form->{paid} ? conv_date($form->{datepaid}) : undef, - conv_date($form->{duedate}), $taxzone_id, - $form->{taxincluded} ? 't' : 'f', - $form->{notes}, $form->{intnotes}, $form->{currency}, conv_i($form->{department_id}), - $form->{storno} ? 't' : 'f', conv_i($form->{storno_id}), - conv_i($form->{globalproject_id}), conv_i($form->{cp_id}), - conv_i($form->{employee_id}), - conv_i($form->{id})); + @values = ( + $form->{invnumber}, $form->{ordnumber}, $form->{quonumber}, conv_date($form->{invdate}), + conv_date($form->{orddate}), conv_date($form->{quodate}), conv_i($form->{vendor_id}), $amount, + $netamount, $form->{paid}, conv_date($form->{duedate}), $form->{paid} ? conv_date($form->{datepaid}) : undef, + '1', $taxzone_id, $form->{notes}, $form->{taxincluded} ? 't' : 'f', + $form->{intnotes}, $form->{currency}, conv_i($form->{storno_id}), $form->{storno} ? 't' : 'f', + conv_i($form->{cp_id}), conv_i($form->{employee_id}), conv_i($form->{department_id}), + conv_i($form->{globalproject_id}), + conv_i($form->{id}) + ); do_query($form, $dbh, $query, @values); if ($form->{storno}) { diff --git a/SL/IS.pm b/SL/IS.pm index ec744df2e..2632a727d 100644 --- a/SL/IS.pm +++ b/SL/IS.pm @@ -943,61 +943,30 @@ sub post_invoice { # save AR record $query = qq|UPDATE ar set - invnumber = ?, - ordnumber = ?, - quonumber = ?, - cusordnumber = ?, - transdate = ?, - orddate = ?, - quodate = ?, - customer_id = ?, - amount = ?, - netamount = ?, - paid = ?, - datepaid = ?, - duedate = ?, - deliverydate = ?, - invoice = '1', - shippingpoint = ?, - shipvia = ?, - terms = ?, - notes = ?, - intnotes = ?, - taxincluded = ?, - curr = ?, - department_id = ?, - payment_id = ?, - type = ?, - language_id = ?, - taxzone_id = ?, - shipto_id = ?, - delivery_customer_id = ?, - delivery_vendor_id = ?, - employee_id = ?, - salesman_id = ?, - storno = ?, - storno_id = ?, - globalproject_id = ?, - cp_id = ?, - transaction_description = ?, - marge_total = ?, - marge_percent = ? + invnumber = ?, ordnumber = ?, quonumber = ?, cusordnumber = ?, + transdate = ?, orddate = ?, quodate = ?, customer_id = ?, + amount = ?, netamount = ?, paid = ?, datepaid = ?, + duedate = ?, deliverydate = ?, invoice = ?, shippingpoint = ?, + shipvia = ?, terms = ?, notes = ?, intnotes = ?, + curr = ?, department_id = ?, payment_id = ?, taxincluded = ?, + type = ?, language_id = ?, taxzone_id = ?, shipto_id = ?, + employee_id = ?, salesman_id = ?, storno_id = ?, storno = ?, + cp_id = ?, marge_total = ?, marge_percent = ?, + globalproject_id = ?, delivery_customer_id = ?, + transaction_description = ?, delivery_vendor_id = ? WHERE id = ?|; - @values = ($form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"}, - conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), - conv_i($form->{"customer_id"}), $amount, $netamount, $form->{"paid"}, - conv_date($form->{"datepaid"}), conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), - $form->{"shippingpoint"}, $form->{"shipvia"}, conv_i($form->{"terms"}), - $form->{"notes"}, $form->{"intnotes"}, $form->{"taxincluded"} ? 't' : 'f', - $form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}), - $form->{"type"}, conv_i($form->{"language_id"}), conv_i($form->{"taxzone_id"}), - conv_i($form->{"shipto_id"}), - conv_i($form->{"delivery_customer_id"}), conv_i($form->{"delivery_vendor_id"}), - conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}), - $form->{"storno"} ? 't' : 'f', conv_i($form->{storno_id}), conv_i($form->{"globalproject_id"}), - conv_i($form->{"cp_id"}), $form->{transaction_description}, - $form->{marge_total} * 1, $form->{marge_percent} * 1, - conv_i($form->{"id"})); + @values = ( $form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"}, + conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}), conv_i($form->{"customer_id"}), + $amount, $netamount, $form->{"paid"}, conv_date($form->{"datepaid"}), + conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}), '1', $form->{"shippingpoint"}, + $form->{"shipvia"}, conv_i($form->{"terms"}), $form->{"notes"}, $form->{"intnotes"}, + $form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}), $form->{"taxincluded"} ? 't' : 'f', + $form->{"type"}, conv_i($form->{"language_id"}), conv_i($form->{"taxzone_id"}), conv_i($form->{"shipto_id"}), + conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}), conv_i($form->{storno_id}), $form->{"storno"} ? 't' : 'f', + conv_i($form->{"cp_id"}), 1 * $form->{marge_total} , 1 * $form->{marge_percent}, + conv_i($form->{"globalproject_id"}), conv_i($form->{"delivery_customer_id"}), + $form->{transaction_description}, conv_i($form->{"delivery_vendor_id"}), + conv_i($form->{"id"})); do_query($form, $dbh, $query, @values); if($form->{"formname"} eq "credit_note") { diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 7e610f3e5..3851492ea 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -221,66 +221,43 @@ sub form_header { s/option>\Q$form->{$item}\E/option selected>$form->{$item}/; } - 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); - - - $form->{radier} = - ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; - - $form->{exchangerate} = - $form->format_amount(\%myconfig, $form->{exchangerate}); - - $form->{creditlimit} = - $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); - $form->{creditremaining} = - $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); + $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; + $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); + $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); + $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); $exchangerate = ""; if ($form->{currency} ne $form->{defaultcurrency}) { if ($form->{forex}) { - $exchangerate .= qq| - | - . $locale->text('Exchangerate') . qq| - $form->{exchangerate}{exchangerate}> -|; + $exchangerate .= qq| | . $locale->text('Exchangerate') . qq| + $form->{exchangerate}{exchangerate}>\n|; } else { - $exchangerate .= qq| - | - . $locale->text('Exchangerate') . qq| - {exchangerate}> -|; + $exchangerate .= qq| | . $locale->text('Exchangerate') . qq| + {exchangerate}>\n|; } } - $exchangerate .= qq| -{forex}> -|; + $exchangerate .= qq| {forex}>\n|; my @old_project_ids = ($form->{"globalproject_id"}); - map({ push(@old_project_ids, $form->{"project_id_$_"}) - if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"}; - $form->get_lists("contacts" => "ALL_CONTACTS", - "projects" => { "key" => "ALL_PROJECTS", - "all" => 0, + $form->get_lists("contacts" => "ALL_CONTACTS", + "projects" => { "key" => "ALL_PROJECTS", + "all" => 0, "old_id" => \@old_project_ids }, - "taxzones" => "ALL_TAXZONES", - "employees" => "ALL_SALESMEN", + "taxzones" => "ALL_TAXZONES", + "employees" => "ALL_SALESMEN", "currencies" => "ALL_CURRENCIES", - "vendors" => "ALL_VENDORS"); + "vendors" => "ALL_VENDORS"); my %labels; 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; @@ -288,10 +265,8 @@ sub form_header { $contact = qq| | . $locale->text('Contact Person') . qq| - | . - NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px', - '-labels' => \%labels, '-default' => $form->{"cp_id"})) - . qq| + | . NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px', + '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq| |; } @@ -302,10 +277,8 @@ 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"})); %labels = (); @values = (); @@ -321,9 +294,8 @@ sub form_header { $currencies = qq| | . $locale->text('Currency') . qq| - | . - NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, - '-values' => \@values, '-labels' => \%labels)) . qq| + | . NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, + '-values' => \@values, '-labels' => \%labels)) . qq| |; } @@ -336,13 +308,12 @@ sub form_header { $labels{$item->{"id"}} = $item->{"name"}; } my $employees = qq| - + | . $locale->text('Employee') . qq| - | . - NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"}, - '-values' => \@values, '-labels' => \%labels)) . qq| + | . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| - |; + |; %labels = (); @values = (); @@ -376,12 +347,10 @@ sub form_header { $taxzone = qq| | . $locale->text('Steuersatz') . qq| - | . - NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, - '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')) . qq| + | . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, + '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')) . qq| |; - } else { $taxzone = qq| @@ -394,7 +363,7 @@ sub form_header { } $department = qq| - + | . $locale->text('Department') . qq| @@ -410,14 +379,10 @@ sub form_header { $button1 = qq| - text('button') . qq|> - |; + text('button') . qq|>\n|; $button2 = qq| - text('button') . qq|> - |; + text('button') . qq|>\n|; #write Trigger $jsscript = @@ -428,10 +393,7 @@ sub form_header { $form->{"javascript"} .= qq||; $form->{javascript} .= qq||; - $jsscript .= - $form->write_trigger(\%myconfig, 2, - "orddate", "BL", "trigger_orddate", - "quodate", "BL", "trigger_quodate"); + $jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate"); $form->header; $onload = qq|focus()|; diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index b603f773a..fe0c3ea81 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -279,32 +279,20 @@ sub prepare_invoice { sub form_header { $lxdebug->enter_sub(); - 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}; if ($edit) { - if ($form->{type} eq "credit_note") { $form->{title} = $locale->text('Edit Credit Note'); - - if ($form->{storno}) { - $form->{title} = $locale->text('Edit Storno Credit Note'); - } + $form->{title} = $locale->text('Edit Storno Credit Note') if $form->{storno}; } else { $form->{title} = $locale->text('Edit Sales Invoice'); - - if ($form->{storno}) { - $form->{title} = $locale->text('Edit Storno Invoice'); - } + $form->{title} = $locale->text('Edit Storno Invoice') if $form->{storno}; } } $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - $form->{radier} = - ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; + $form->{radier} = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; $payment = qq||; foreach $item (@{ $form->{payment_terms} }) { @@ -315,42 +303,37 @@ sub form_header { } } - my $set_duedate_url = - "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate"; + my $set_duedate_url = "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate"; my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url ); push(@ { $form->{AJAX} }, $pjx); my @old_project_ids = ($form->{"globalproject_id"}); - map({ push(@old_project_ids, $form->{"project_id_$_"}) - if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); - - $form->get_lists("contacts" => "ALL_CONTACTS", - "shipto" => "ALL_SHIPTO", - "projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, - "employees" => "ALL_SALESMEN", - "taxzones" => "ALL_TAXZONES", + map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"}; + + $form->get_lists("contacts" => "ALL_CONTACTS", + "shipto" => "ALL_SHIPTO", + "projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }, + "employees" => "ALL_SALESMEN", + "taxzones" => "ALL_TAXZONES", "currencies" => "ALL_CURRENCIES", - "customers" => "ALL_CUSTOMERS"); + "customers" => "ALL_CUSTOMERS"); my %labels; 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; if (scalar @values > 1) { $contact = qq| | . $locale->text('Contact Person') . qq| - | . - NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px', - '-labels' => \%labels, '-default' => $form->{"cp_id"})) - . qq| + | . NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px', + '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq| |; } @@ -365,9 +348,8 @@ sub form_header { my $employees = qq| | . $locale->text('Employee') . qq| - | . - NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"}, - '-values' => \@values, '-labels' => \%labels)) . qq| + | . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"}, + '-values' => \@values, '-labels' => \%labels)) . qq| |; @@ -404,10 +386,9 @@ sub form_header { $shipto = qq| | . $locale->text('Shipping Address') . qq| - | . - NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px', - '-labels' => \%labels, '-default' => $form->{"shipto_id"})) - . qq||; + | . NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px', + '-labels' => \%labels, '-default' => $form->{"shipto_id"})). qq| + |; } %labels = (); @@ -423,9 +404,8 @@ sub form_header { $currencies = qq| | . $locale->text('Currency') . qq| - | . - NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, - '-values' => \@values, '-labels' => \%labels)) . qq| + | . NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"}, + '-values' => \@values, '-labels' => \%labels)) . qq| |; } @@ -436,10 +416,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"})); %labels = (); @values = (); @@ -449,13 +428,11 @@ sub form_header { } $salesman = - qq| - | . $locale->text('Salesman') . qq| - | . - NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id}, - '-values' => \@values, '-labels' => \%labels)) - . qq| - |; + qq| | . $locale->text('Salesman') . qq| + | . NTI($cgi->popup_menu('-name' => 'salesman_id', '-values' => \@values, '-labels' => \%labels, + '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id})) . qq| + + |; %labels = (); @values = (); @@ -468,9 +445,8 @@ sub form_header { $taxzone = qq| | . $locale->text('Steuersatz') . qq| - | . - NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, - '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq| + | . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"}, + '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq| |; @@ -488,8 +464,7 @@ sub form_header { # set option selected foreach $item (qw(AR customer currency department employee)) { $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}/; } if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) { @@ -498,37 +473,27 @@ sub form_header { $creditwarning = 0; } - $form->{exchangerate} = - $form->format_amount(\%myconfig, $form->{exchangerate}); - - $form->{creditlimit} = - $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); - $form->{creditremaining} = - $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); + $form->{exchangerate} = $form->format_amount(\%myconfig, $form->{exchangerate}); + $form->{creditlimit} = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0"); + $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0"); $exchangerate = ""; if ($form->{currency} ne $form->{defaultcurrency}) { if ($form->{forex}) { - $exchangerate .= - qq|| - . $locale->text('Exchangerate') - . qq|$form->{exchangerate}|; + $exchangerate .= qq|| . $locale->text('Exchangerate') . qq| + $form->{exchangerate}|; } else { - $exchangerate .= - qq|| - . $locale->text('Exchangerate') - . qq||; + $exchangerate .= qq|| . $locale->text('Exchangerate') . qq| + |; } } - $exchangerate .= qq| - -|; + $exchangerate .= qq|\n\n|; $department = qq| | . $locale->text('Department') . qq| - + | if $form->{selectdepartment}; @@ -604,8 +569,7 @@ sub form_header { } if ($form->{resubmit} && ($form->{format} eq "html")) { - $onload = - qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|; + $onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|; } elsif ($form->{resubmit}) { $onload = qq|document.invoice.submit()|; } else { diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index cb55f0714..92cfb69f9 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -2137,23 +2137,19 @@ sub invoice { # also copy deliverydate from the order $form->{deliverydate} = $form->{reqdate} if $form->{reqdate}; - $form->{orddate} = $form->{transdate}; + $form->{orddate} = $form->{transdate}; } else { $form->isblank("quonumber", $locale->text('Quotation Number missing!')); $form->isblank("transdate", $locale->text('Quotation Date missing!')); - $form->{ordnumber} = ""; - $form->{quodate} = $form->{transdate}; + $form->{ordnumber} = ""; + $form->{quodate} = $form->{transdate}; } - if($form->{payment_id}) { - $payment_id = $form->{payment_id}; - } + $payment_id = $form->{payment_id} if $form->{payment_id}; # if the name changed get new values if (&check_name($form->{vc})) { - if($form->{payment_id} eq "") { - $form->{payment_id} = $payment_id; - } + $form->{payment_id} = $payment_id if $form->{payment_id} eq ""; &update; exit; } @@ -2161,10 +2157,9 @@ sub invoice { $form->{cp_id} *= 1; for $i (1 .. $form->{rowcount}) { - map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, - $form->{"${_}_${i}"}) - if ($form->{"${_}_${i}"}) } - qw(ship qty sellprice listprice basefactor)); + for (qw(ship qty sellprice listprice basefactor)) { + $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"}; + } } if ( $form->{type} =~ /_order/ @@ -2174,9 +2169,7 @@ sub invoice { $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell"; $orddate = $form->current_date(\%myconfig); - $exchangerate = - $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate, - $buysell); + $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate, $buysell); if (!$exchangerate) { &backorder_exchangerate($orddate, $buysell); @@ -2197,8 +2190,7 @@ sub invoice { } $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig); - $form->{duedate} = - $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); + $form->{duedate} = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1); $form->{id} = ''; $form->{closed} = 0; @@ -2219,7 +2211,9 @@ sub invoice { $script = "ir"; $buysell = 'sell'; } - if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') { + + if ( $form->{type} eq 'sales_order' + || $form->{type} eq 'sales_quotation') { $form->{title} = $locale->text('Add Sales Invoice'); $form->{script} = 'is.pl'; $script = "is"; @@ -2227,8 +2221,7 @@ sub invoice { } # bo creates the id, reset it - map { delete $form->{$_} } - qw(id subject message cc bcc printed emailed queued); + map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued); $form->{ $form->{vc} } =~ s/--.*//g; $form->{type} = "invoice";