EK-Preis editierbar gemacht und marge_total repariert
authorG. Richardson <information@lx-office-hosting.de>
Tue, 13 Apr 2010 20:54:27 +0000 (22:54 +0200)
committerG. Richardson <information@lx-office-hosting.de>
Wed, 14 Apr 2010 08:27:11 +0000 (10:27 +0200)
Der EK-Preis ist jetzt in Angebot/Auftrag/Rechnung editierbar.

Dies ist praktisch für Händler/Wiederverkäufer, bei denen sich der EK-Preis
häufig ändert, und es sich nicht lohnt, diesen in den Stammdaten zu pflegen.

Der EK-Preis wird (als lastcost) zusammen mit marge_total und marge_percent für
jeden Artikel in orderitems/invoice in der DB gespeichert. (Bei marge_total gab
es hier einen Bug, der falsche Variablenname wurde benutzt und marge_total war
immer leer.)

Der Stammdaten-EK-Preis wird nicht verändert, wenn man einen abweichenden
EK-Preis eingibt.

SL/DO.pm
SL/IS.pm
SL/OE.pm
bin/mozilla/do.pl
bin/mozilla/ic.pl
bin/mozilla/io.pl
bin/mozilla/is.pl
bin/mozilla/oe.pl

index 819664e..c509a0e 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -277,11 +277,10 @@ sub save {
     }
     my $baseqty = $form->{"qty_$i"} * $basefactor;
 
-    $form->{"lastcost_$i"} *= 1;
-
     # set values to 0 if nothing entered
     $form->{"discount_$i"}  = $form->parse_amount($myconfig, $form->{"discount_$i"});
     $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
+    $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"});
 
     $price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
     my $linetotal    = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
index 59ee0dc..15a2676 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -591,8 +591,8 @@ sub post_invoice {
     my $baseqty;
 
     $form->{"marge_percent_$i"} = $form->parse_amount($myconfig, $form->{"marge_percent_$i"}) * 1;
-    $form->{"marge_total_$i"} = $form->parse_amount($myconfig, $form->{"marge_total_$i"}) * 1;
-    $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1;
+    $form->{"marge_absolut_$i"} = $form->parse_amount($myconfig, $form->{"marge_absolut_$i"}) * 1;
+    $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"}) * 1;
 
     if ($form->{storno}) {
       $form->{"qty_$i"} *= -1;
@@ -717,7 +717,7 @@ sub post_invoice {
                  $form->{"serialnumber_$i"}, conv_i($pricegroup_id),
                  $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
                  $form->{"cusordnumber_$i"}, $baseqty, $form->{"subtotal_$i"} ? 't' : 'f',
-                 $form->{"marge_percent_$i"}, $form->{"marge_total_$i"},
+                 $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"},   
                  $form->{"lastcost_$i"},
                  conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}),
                  conv_i($form->{"marge_price_factor_$i"}));
index 3217557..226da81 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -337,8 +337,9 @@ sub save {
       my $baseqty = $form->{"qty_$i"} * $basefactor;
 
       $form->{"marge_percent_$i"} = $form->parse_amount($myconfig, $form->{"marge_percent_$i"}) * 1;
-      $form->{"marge_total_$i"} = $form->parse_amount($myconfig, $form->{"marge_total_$i"}) * 1;
-      $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1;
+      $form->{"marge_absolut_$i"} = $form->parse_amount($myconfig, $form->{"marge_absolut_$i"}) * 1;
+      
+      $form->{"lastcost_$i"} = $form->parse_amount($myconfig, $form->{"lastcost_$i"});
 
       # set values to 0 if nothing entered
       $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
@@ -428,7 +429,7 @@ sub save {
            $form->{"serialnumber_$i"}, $form->{"ship_$i"}, conv_i($pricegroup_id),
            $form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
            $form->{"cusordnumber_$i"}, $form->{"subtotal_$i"} ? 't' : 'f',
-           $form->{"marge_percent_$i"}, $form->{"marge_total_$i"},
+           $form->{"marge_percent_$i"}, $form->{"marge_absolut_$i"},
            $form->{"lastcost_$i"},
            conv_i($form->{"price_factor_id_$i"}), conv_i($form->{"price_factor_id_$i"}),
            conv_i($form->{"marge_price_factor_$i"}));
index 1ce1c46..f7e859e 100644 (file)
@@ -235,6 +235,7 @@ sub prepare_order {
     $form->{"reqdate_$i"} = $form->{"deliverydate_$i"} unless $form->{"reqdate_$i"};
 
     $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
+    $form->{"lastcost_$i"} = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces);
 
     (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
     $dec_qty = length $dec_qty;
@@ -374,6 +375,7 @@ sub update_delivery_order {
 
         $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
         $form->{"sellprice_$i"}          = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
+        $form->{"lastcost_$i"}          = $form->format_amount(\%myconfig, $form->{"lastcost_$i"});
         $form->{"qty_$i"}                = $form->format_amount(\%myconfig, $form->{"qty_$i"});
       }
 
@@ -736,7 +738,7 @@ sub invoice {
       # und keinen anderen discount wert an $i ...
       $form->{"discount_$i"} ||= $form->{discount}*100; # ... nehmen wir den kundenrabatt
     }
-    map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice basefactor);
+    map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice lastcost basefactor);
   }
 
   $form->{type} = "invoice";
@@ -769,10 +771,15 @@ sub invoice {
     $form->{"deliverydate_$i"} = $form->{"reqdate_$i"}
       unless $form->{"deliverydate_$i"};
 
+
     $form->{"sellprice_$i"} =
       $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
                            $decimalplaces);
 
+    $form->{"lastcost_$i"} =
+      $form->format_amount(\%myconfig, $form->{"lastcost_$i"},
+                           $decimalplaces);
+
     (my $dec_qty) = ($form->{"qty_$i"} =~ /\.(\d+)/);
     $dec_qty = length $dec_qty;
     $form->{"qty_$i"} =
index 965e4ba..ec287aa 100644 (file)
@@ -1871,7 +1871,7 @@ sub save {
       $form->{creditremaining} -= $amount;
 
       # redo number formatting, because invoice parse them!
-      map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice rop);
+      map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}) } qw(weight listprice sellprice lastcost rop);
     }
 
     $form->{"id_$i"} = $parts_id;
index cabb133..ce7ce78 100644 (file)
@@ -159,6 +159,7 @@ sub display_row {
   );
   my @column_index = map { $_->{id} } grep { $_->{display} } @HEADER;
 
+
   # cache units
   my $all_units       = AM->retrieve_units(\%myconfig, $form);
 
@@ -209,7 +210,9 @@ sub display_row {
     my %column_data = ();
 
     # undo formatting
-    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(qty discount sellprice price_new price_old) unless ($form->{simple_save});
+    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } 
+      qw(qty discount sellprice lastcost price_new price_old) 
+        unless ($form->{simple_save});
 
 # unit begin
     $form->{"unit_old_$i"}      ||= $form->{"unit_$i"};
@@ -294,6 +297,7 @@ sub display_row {
       }
       $column_data{sellprice} = $cgi->textfield(-name => "sellprice_$i", -size => 10, -onBlur => "check_right_number_format(this)", -value =>
                                                 $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces));
+
     }
     $column_data{discount}    = $cgi->textfield(-name => "discount_$i", -size => 3, -value => $form->format_amount(\%myconfig, $form->{"discount_$i"}));
     $column_data{linetotal}   = $form->format_amount(\%myconfig, $linetotal, 2);
@@ -338,7 +342,10 @@ sub display_row {
 
     map { $form->{"${_}_$i"} = $form->format_amount(\%myconfig, $form->{"${_}_$i"}, 2) } qw(marge_absolut marge_percent);
 
-    push @ROW2, { value => sprintf qq|<font %s><b>%s</b> %s &nbsp;%s%% </font> &nbsp;<b>%s</b> %s &nbsp;<b>%s</b> %s|,
+    push @ROW2, { value => sprintf qq|
+         <font %s><b>%s</b> %s &nbsp;%s%% </font> 
+        &nbsp;<b>%s</b> %s 
+        &nbsp;<b>%s</b> <input size="5" name="lastcost_$i" value="%s">|,
                    $marge_color, $locale->text('Ertrag'),$form->{"marge_absolut_$i"}, $form->{"marge_percent_$i"},
                    $locale->text('LP'), $form->format_amount(\%myconfig, $form->{"listprice_$i"}, 2),
                    $locale->text('EK'), $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, 2) }
@@ -361,8 +368,8 @@ sub display_row {
     my @hidden_vars;
 
     if ($is_delivery_order) {
-      map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount);
-      push @hidden_vars, qw(sellprice discount price_factor_id);
+      map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost);
+      push @hidden_vars, qw(sellprice discount price_factor_id lastcost);
       push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}";
     }
 
@@ -372,7 +379,7 @@ sub display_row {
           map { ($cgi->hidden("-name" => $_, "-value" => $form->{$_})); } map { $_."_$i" }
             (qw(orderitems_id bo pricegroup_old price_old id inventory_accno bin partsgroup partnotes
                 income_accno expense_accno listprice assembly taxaccounts ordnumber transdate cusordnumber
-                longdescription basefactor marge_absolut marge_percent marge_price_factor lastcost), @hidden_vars)
+                longdescription basefactor marge_absolut marge_percent marge_price_factor), @hidden_vars)
     );
 
     map { $form->{"${_}_base"} += $linetotal } (split(/ /, $form->{"taxaccounts_$i"}));
index f44c580..a47b7e8 100644 (file)
@@ -263,6 +263,8 @@ sub prepare_invoice {
       (my $dec_qty)            = ($form->{"qty_$i"} =~ /\.(\d+)/);
       $dec_qty                 = length $dec_qty;
 
+      $form->{"lastcost_$i"}  = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces);
+
       $form->{"qty_$i"}        = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
 
       $form->{rowcount}        = $i;
@@ -544,7 +546,7 @@ sub update {
 
         $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 lastcost);
 
         $form->{"qty_$i"} = $form->format_amount(\%myconfig, $form->{"qty_$i"});
 
index 02bdf1b..bef2317 100644 (file)
@@ -283,6 +283,7 @@ sub prepare_order {
     $form->{"reqdate_$i"} ||= $form->{"deliverydate_$i"};
     $form->{"discount_$i"}  = $form->format_amount(\%myconfig, $form->{"discount_$i"} * ($format_discounts ? 100 : 1));
     $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"});
+    $form->{"lastcost_$i"}  = $form->format_amount(\%myconfig, $form->{"lastcost_$i"});
     $form->{"qty_$i"}       = $form->format_amount(\%myconfig, $form->{"qty_$i"});
   }
 
@@ -554,6 +555,8 @@ sub update {
     # select discount as customer_discount from customer
     $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{"$form->{vc}_discount"} * 100);
 
+    $form->{"lastcost_$i"} = $form->parse_amount(\%myconfig, $form->{"lastcost_$i"});
+
     if ($rows) {
       $form->{"qty_$i"} = 1 unless ($form->parse_amount(\%myconfig, $form->{"qty_$i"}));
 
@@ -599,6 +602,7 @@ sub update {
         $form->{creditremaining} -= $amount;
 
         $form->{"sellprice_$i"} = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
+        $form->{"lastcost_$i"}  = $form->format_amount(\%myconfig, $form->{"lastcost_$i"}, $decimalplaces);
         $form->{"qty_$i"}       = $form->format_amount(\%myconfig, $form->{"qty_$i"}, $dec_qty);
 
         # get pricegroups for parts
@@ -1761,7 +1765,7 @@ sub poso {
   # reset
   map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber);
 
-  # if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i
+  # if purchase_order was generated from sales_order, use  lastcost_$i as sellprice_$i
   if ( $form->{sales_order_to_purchase_order} ) {
     for my $i (1 .. $form->{rowcount}) {
       $form->{"sellprice_${i}"} = $form->format_amount(\%myconfig,$form->{"lastcost_${i}"});
@@ -1829,7 +1833,7 @@ sub delivery_order {
   delete @{$form}{qw(id subject message cc bcc printed emailed queued creditlimit creditremaining discount tradediscount oldinvtotal closed delivered)};
 
   for my $i (1 .. $form->{rowcount}) {
-    map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor discount);
+    map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice lastcost basefactor discount);
   }
 
   my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor);