X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fdo.pl;h=f69da647bb5df0396a43d4d855bf7fa9b214d63f;hb=baf226d0b65e64f9475dea46b35d88d52fed1cc6;hp=c43acce325ad5b332182f9defc3a206b5f3faf88;hpb=263971ba6ce308b3f058705d51e265c3577338d6;p=kivitendo-erp.git
diff --git a/bin/mozilla/do.pl b/bin/mozilla/do.pl
index c43acce32..f69da647b 100644
--- a/bin/mozilla/do.pl
+++ b/bin/mozilla/do.pl
@@ -24,7 +24,8 @@
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1335, USA.
#======================================================================
#
# Delivery orders
@@ -264,9 +265,9 @@ sub form_header {
my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
$form->get_lists($vc => "ALL_VC",
"price_factors" => "ALL_PRICE_FACTORS",
- "departments" => "ALL_DEPARTMENTS",
"business_types" => "ALL_BUSINESS_TYPES",
);
+ $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
# Projects
my @old_project_ids = uniq grep { $_ } map { $_ * 1 } ($form->{"globalproject_id"}, map { $form->{"project_id_$_"} } 1..$form->{"rowcount"});
@@ -301,7 +302,6 @@ sub form_header {
]
]);
- map { $_->{value} = "$_->{description}--$_->{id}" } @{ $form->{ALL_DEPARTMENTS} };
map { $_->{value} = "$_->{name}--$_->{id}" } @{ $form->{ALL_VC} };
$form->{SHOW_VC_DROP_DOWN} = $myconfig{vclimit} > scalar @{ $form->{ALL_VC} };
@@ -501,11 +501,10 @@ sub search {
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
"all" => 1 },
- "departments" => "ALL_DEPARTMENTS",
"$form->{vc}s" => "ALL_VC",
"business_types" => "ALL_BUSINESS_TYPES");
$form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all_sorted(query => [ deleted => 0 ]);
-
+ $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
$form->{SHOW_VC_DROP_DOWN} = $myconfig{vclimit} > scalar @{ $form->{ALL_VC} };
$form->{title} = $locale->text('Delivery Orders');
@@ -526,7 +525,6 @@ sub orders {
my $locale = $main::locale;
my $cgi = $::request->{cgi};
- $form->{department_id} = (split /--/, $form->{department})[-1];
($form->{ $form->{vc} }, $form->{"$form->{vc}_id"}) = split(/--/, $form->{ $form->{vc} });
report_generator_set_default_sort('transdate', 1);
@@ -611,9 +609,8 @@ sub orders {
if ($form->{cp_name}) {
push @options, $locale->text('Contact Person') . " : $form->{cp_name}";
}
- if ($form->{department}) {
- my ($department) = split /--/, $form->{department};
- push @options, $locale->text('Department') . " : $department";
+ if ($form->{department_id}) {
+ push @options, $locale->text('Department') . " : " . SL::DB::Department->new(id => $form->{department_id})->load->description;
}
if ($form->{donumber}) {
push @options, $locale->text('Delivery Order Number') . " : $form->{donumber}";
@@ -828,7 +825,10 @@ sub invoice {
}
for my $i (1 .. $form->{rowcount}) {
+ map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice lastcost basefactor discount);
# für bug 1284
+ # adds a customer/vendor discount, unless we have a workflow case
+ # CAVEAT: has to be done, after the above parse_amount
unless ($form->{"ordnumber"}) {
if ($form->{discount}) { # Falls wir einen Lieferanten-/Kundenrabatt haben
# und rabattfähig sind, dann
@@ -837,7 +837,6 @@ sub invoice {
}
}
}
- map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice lastcost basefactor discount);
$form->{"donumber_$i"} = $form->{donumber};
$form->{"converted_from_delivery_order_items_id_$i"} = delete $form->{"delivery_order_items_id_$i"};
}
@@ -915,7 +914,7 @@ sub invoice_multi {
my @do_ids = map { $form->{"trans_id_$_"} } grep { $form->{"multi_id_$_"} } (1..$form->{rowcount});
if (!scalar @do_ids) {
- $form->show_generic_error($locale->text('You have not selected any delivery order.'), 'back_button' => 1);
+ $form->show_generic_error($locale->text('You have not selected any delivery order.'));
}
map { delete $form->{$_} } grep { m/^(?:trans|multi)_id_\d+/ } keys %{ $form };
@@ -1358,7 +1357,7 @@ sub transfer_in {
my $locale = $main::locale;
if ($form->{id} && DO->is_marked_as_delivered(id => $form->{id})) {
- $form->show_generic_error($locale->text('The parts for this delivery order have already been transferred in.'), 'back_button' => 1);
+ $form->show_generic_error($locale->text('The parts for this delivery order have already been transferred in.'));
}
save(no_redirect => 1);
@@ -1428,7 +1427,7 @@ sub transfer_out {
my $locale = $main::locale;
if ($form->{id} && DO->is_marked_as_delivered(id => $form->{id})) {
- $form->show_generic_error($locale->text('The parts for this delivery order have already been transferred out.'), 'back_button' => 1);
+ $form->show_generic_error($locale->text('The parts for this delivery order have already been transferred out.'));
}
save(no_redirect => 1);
@@ -1654,7 +1653,7 @@ sub transfer_in_out_default {
my $base_unit_factor = $units->{ $part_info_map{$form->{"id_$i"}}->{unit} }->{factor} || 1;
my $qty = $form->parse_amount(\%myconfig, $form->{"qty_$i"}) * $units->{$form->{"unit_$i"}}->{factor} / $base_unit_factor;
- $form->show_generic_error($locale->text("Cannot transfer negative entries." ), 'back_button' => 1) if ($qty < 0);
+ $form->show_generic_error($locale->text("Cannot transfer negative entries." )) if ($qty < 0);
# if we do not want to transfer services and this part is a service, set qty to zero
# ... and do not create a hash entry in %qty_parts below (will skip check for bins for the transfer == out case)
# ... and push only a empty (undef) element to @all_requests (will skip check for bin_id and warehouse_id and will not alter the row)
@@ -1741,7 +1740,7 @@ sub transfer_in_out_default {
}
} else {
#$main::lxdebug->message(0, 'Fehlertext: ' . $fehlertext);
- $form->show_generic_error($locale->text("Cannot transfer.
Reason:
#1", $fehlertext ), 'back_button' => 1);
+ $form->show_generic_error($locale->text("Cannot transfer.
Reason:
#1", $fehlertext ));
}
}
}
@@ -1796,6 +1795,11 @@ sub sort {
# hashify partnumbers, positions. key is delivery_order_items_id
for my $i (1 .. ($form->{rowcount}) ) {
$temp_hash{$form->{"delivery_order_items_id_$i"}} = { runningnumber => $form->{"runningnumber_$i"}, partnumber => $form->{"partnumber_$i"} };
+ if ($form->{id} && $form->{"discount_$i"}) {
+ # prepare_order assumes a db value if there is a form->id and multiplies *100
+ # We hope for new controller code (no more format_amount/parse_amount distinction)
+ $form->{"discount_$i"} /=100;
+ }
}
# naturally sort partnumbers and get a sorted array of doi_ids
my @sorted_doi_ids = sort { Sort::Naturally::ncmp($temp_hash{$a}->{"partnumber"}, $temp_hash{$b}->{"partnumber"}) } keys %temp_hash;
@@ -1807,6 +1811,12 @@ sub sort {
$form->{"runningnumber_$temp_hash{$_}->{runningnumber}"} = $new_number;
$new_number++;
}
+ # all parse_amounts changes are in form (i.e. , to .) therefore we need
+ # another format_amount to change it back, for the next save ;-(
+ # works great except for row discounts (see above comment)
+ prepare_order();
+
+
$main::lxdebug->leave_sub();
save();
}