Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d9c9bc22

Von Moritz Bunkus vor etwa 17 Jahren hinzugefügt

  • ID d9c9bc227fbf8518ff8d63428d181d479ed848d8
  • Vorgänger f5c548f0
  • Nachfolger a596e63e

Bugfix Rabattberechnung: Berechnung so umgestellt, dass der Rabatt von der Zeilensumme genommen wird und nicht vom Einzelpreis (Rundung). Fix für Bug 325.
Bugfix Zwischensummen: Bei Belegen aus OE.pm (Angebote, Aufträge, Anfragen) wurde die Variable <%runningnumber%> innerhalb eines Zwischensummenblocks nicht "1.1, 1.2, 1.3" etc hochgezählt, sondern normal "1, 2, 3" etc.
Bugfix Zwischensummen: Bei manchen Browsern wurden die Checkboxen "Zwischensumme" nach "Erneuern" oder neuem Aufrufen eines Beleges nicht richtig vorausgewählt, auch wenn der Status in der Datenbank richtig war.
Kosmetik: Einrückung, Ausrichtung.

Unterschiede anzeigen:

SL/OE.pm
34 34

  
35 35
package OE;
36 36

  
37
use List::Util qw(max);
38

  
37 39
use SL::AM;
38 40
use SL::Common;
39 41
use SL::DBUtils;
......
931 933
        $position++;
932 934
      }
933 935

  
934
      push(@{ $form->{runningnumber} }, $i);
935
      push(@{ $form->{number} },        qq|$form->{"partnumber_$i"}|);
936
      push(@{ $form->{description} },   qq|$form->{"description_$i"}|);
937
      push(@{ $form->{longdescription} },   qq|$form->{"longdescription_$i"}|);
938
      push(@{ $form->{qty} },
939
           $form->format_amount($myconfig, $form->{"qty_$i"}));
940
      push(@{ $form->{ship} },
941
           $form->format_amount($myconfig, $form->{"ship_$i"}));
942
      push(@{ $form->{unit} },         qq|$form->{"unit_$i"}|);
943
      push(@{ $form->{bin} },          qq|$form->{"bin_$i"}|);
944
      push(@{ $form->{"partnotes"} },  qq|$form->{"partnotes_$i"}|);
945
      push(@{ $form->{serialnumber} }, qq|$form->{"serialnumber_$i"}|);
946
      push(@{ $form->{reqdate} },      qq|$form->{"reqdate_$i"}|);
947

  
948
      push(@{ $form->{sellprice} }, $form->{"sellprice_$i"});
949

  
950
      push(@{ $form->{listprice} }, $form->{"listprice_$i"});
951

  
952
      my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
953
      my ($dec) = ($sellprice =~ /\.(\d+)/);
954
      $dec = length $dec;
955
      my $decimalplaces = ($dec > 2) ? $dec : 2;
956

  
957
      my $i_discount =
958
        $form->round_amount(
959
                            $sellprice * $form->parse_amount($myconfig,
960
                                                 $form->{"discount_$i"}) / 100,
961
                            $decimalplaces);
962

  
963
      my $discount =
964
        $form->round_amount($form->{"qty_$i"} * $i_discount, $decimalplaces);
965

  
966
      # keep a netprice as well, (sellprice - discount)
967
      #$form->{"netprice_$i"} = $sellprice - $discount;
968
      $form->{"netprice_$i"} = $sellprice - $i_discount;
969
      my $nodiscount_linetotal =
970
        $form->round_amount($form->{"qty_$i"} * $sellprice, 2);
971
      my $linetotal =
972
        $form->round_amount($form->{"qty_$i"} * $form->{"netprice_$i"}, 2);
973

  
974
      push(@{ $form->{netprice} },
975
           ($form->{"netprice_$i"} != 0)
976
           ? $form->format_amount(
977
                                 $myconfig, $form->{"netprice_$i"},
978
                                 $decimalplaces
979
             )
980
           : " ");
981

  
982
      $discount =
983
        ($discount != 0)
984
        ? $form->format_amount($myconfig, $discount * -1, $decimalplaces)
985
        : " ";
986
      $linetotal = ($linetotal != 0) ? $linetotal : " ";
987

  
988
      push(@{ $form->{discount} },   $discount);
989
      push(@{ $form->{p_discount} }, $form->{"discount_$i"});
990

  
991
      $form->{ordtotal} += $linetotal;
992
      $discount_subtotal += $linetotal;
936
      push @{ $form->{runningnumber} },   $position;
937
      push @{ $form->{number} },          $form->{"partnumber_$i"};
938
      push @{ $form->{description} },     $form->{"description_$i"};
939
      push @{ $form->{longdescription} }, $form->{"longdescription_$i"};
940
      push @{ $form->{qty} },             $form->format_amount($myconfig, $form->{"qty_$i"});
941
      push @{ $form->{ship} },            $form->format_amount($myconfig, $form->{"ship_$i"});
942
      push @{ $form->{unit} },            $form->{"unit_$i"};
943
      push @{ $form->{bin} },             $form->{"bin_$i"};
944
      push @{ $form->{partnotes} },       $form->{"partnotes_$i"};
945
      push @{ $form->{serialnumber} },    $form->{"serialnumber_$i"};
946
      push @{ $form->{reqdate} },         $form->{"reqdate_$i"};
947
      push @{ $form->{sellprice} },       $form->{"sellprice_$i"};
948
      push @{ $form->{listprice} },       $form->{"listprice_$i"};
949

  
950
      my $sellprice     = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
951
      my ($dec)         = ($sellprice =~ /\.(\d+)/);
952
      my $decimalplaces = max 2, length($dec);
953

  
954
      my $discount             = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100, $decimalplaces);
955
      my $linetotal            = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100, 2);
956
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice, 2);
957
      $form->{"netprice_$i"}   = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2);
958

  
959
      push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
960

  
961
      $linetotal = ($linetotal != 0) ? $linetotal : '';
962

  
963
      push @{ $form->{discount} },  ($discount  != 0) ? $form->format_amount($myconfig, $discount * -1, $decimalplaces) : '';
964
      push @{ $form->{p_discount} }, $form->{"discount_$i"};
965

  
966
      $form->{ordtotal}         += $linetotal;
993 967
      $form->{nodiscount_total} += $nodiscount_linetotal;
994
      $nodiscount_subtotal += $nodiscount_linetotal;
995
      $form->{discount_total} += $form->parse_amount($myconfig, $discount);
968
      $form->{discount_total}   += $discount;
969

  
970
      if ($subtotal_header) {
971
        $discount_subtotal   += $linetotal;
972
        $nodiscount_subtotal += $nodiscount_linetotal;
973
      }
996 974

  
997 975
      if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) {
998
        $discount_subtotal = $form->format_amount($myconfig, $discount_subtotal, 2);
999
        push(@{ $form->{discount_sub} },  $discount_subtotal);
1000
        $nodiscount_subtotal = $form->format_amount($myconfig, $nodiscount_subtotal, 2);
1001
        push(@{ $form->{nodiscount_sub} }, $nodiscount_subtotal);
1002
        $discount_subtotal = 0;
976
        push @{ $form->{discount_sub} },   $form->format_amount($myconfig, $discount_subtotal,   2);
977
        push @{ $form->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
978

  
979
        $discount_subtotal   = 0;
1003 980
        $nodiscount_subtotal = 0;
1004
        $subtotal_header = 0;
981
        $subtotal_header     = 0;
982

  
1005 983
      } else {
1006
        push(@{ $form->{discount_sub} }, "");
1007
        push(@{ $form->{nodiscount_sub} }, "");
984
        push @{ $form->{discount_sub} },   "";
985
        push @{ $form->{nodiscount_sub} }, "";
1008 986
      }
1009 987

  
1010
      if ($linetotal == $netto_linetotal) {
988
      if (!$form->{"discount_$i"}) {
1011 989
        $nodiscount += $linetotal;
1012 990
      }
1013
      push(@{ $form->{linetotal} },
1014
           $form->format_amount($myconfig, $linetotal, 2));
1015
      push(@{ $form->{nodiscount_linetotal} },
1016
           $form->format_amount($myconfig, $nodiscount_linetotal, 2));
991

  
992
      push @{ $form->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
993
      push @{ $form->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
1017 994

  
1018 995
      push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
1019 996

  
......
1101 1078
         $form->format_amount($myconfig, $form->{"${item}_rate"} * 100));
1102 1079
    push(@{ $form->{taxnumber} }, $form->{"${item}_taxnumber"});
1103 1080
  }
1104
  $yesdiscount = $form->{nodiscount_total} - $nodiscount;
1081

  
1105 1082
  $form->{nodiscount_subtotal} = $form->format_amount($myconfig, $form->{nodiscount_total}, 2);
1106
  $form->{discount_total} = $form->format_amount($myconfig, $form->{discount_total}, 2);
1107
  $form->{nodiscount} = $form->format_amount($myconfig, $nodiscount, 2);
1108
  $form->{yesdiscount} = $form->format_amount($myconfig, $yesdiscount, 2);
1083
  $form->{discount_total}      = $form->format_amount($myconfig, $form->{discount_total}, 2);
1084
  $form->{nodiscount}          = $form->format_amount($myconfig, $nodiscount, 2);
1085
  $form->{yesdiscount}         = $form->format_amount($myconfig, $form->{nodiscount_total} - $nodiscount, 2);
1109 1086

  
1110 1087
  if($form->{taxincluded}) {
1111 1088
    $form->{subtotal} = $form->format_amount($myconfig, $form->{ordtotal} - $tax, 2);
1112
  }
1113
  else {
1089
  } else {
1114 1090
    $form->{subtotal} = $form->format_amount($myconfig, $form->{ordtotal}, 2);
1115 1091
  }
1116
  $form->{ordtotal} =
1117
    ($form->{taxincluded}) ? $form->{ordtotal} : $form->{ordtotal} + $tax;
1092

  
1093
  $form->{ordtotal} = ($form->{taxincluded}) ? $form->{ordtotal} : $form->{ordtotal} + $tax;
1118 1094

  
1119 1095
  # format amounts
1120
  $form->{quototal} = $form->{ordtotal} =
1121
    $form->format_amount($myconfig, $form->{ordtotal}, 2);
1096
  $form->{quototal} = $form->{ordtotal} = $form->format_amount($myconfig, $form->{ordtotal}, 2);
1122 1097

  
1123 1098
  if ($form->{type} =~ /_quotation/) {
1124 1099
    $form->set_payment_options($myconfig, $form->{quodate});

Auch abrufbar als: Unified diff