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/IS.pm
34 34

  
35 35
package IS;
36 36

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

  
37 39
use SL::AM;
38 40
use SL::Common;
39 41
use SL::DBUtils;
......
154 156
        $position = int($position);
155 157
        $position++;
156 158
      }
157
      push(@{ $form->{runningnumber} }, $position);
158
      push(@{ $form->{number} },        qq|$form->{"partnumber_$i"}|);
159
      push(@{ $form->{serialnumber} },  qq|$form->{"serialnumber_$i"}|);
160
      push(@{ $form->{bin} },           qq|$form->{"bin_$i"}|);
161
      push(@{ $form->{"partnotes"} },   qq|$form->{"partnotes_$i"}|);
162
      push(@{ $form->{description} },   qq|$form->{"description_$i"}|);
163
      push(@{ $form->{longdescription} },   qq|$form->{"longdescription_$i"}|);
164
      push(@{ $form->{qty} },
165
           $form->format_amount($myconfig, $form->{"qty_$i"}));
166
      push(@{ $form->{unit} },            qq|$form->{"unit_$i"}|);
167
      push(@{ $form->{deliverydate_oe} }, qq|$form->{"deliverydate_$i"}|);
168

  
169
      push(@{ $form->{sellprice} },    $form->{"sellprice_$i"});
170
      push(@{ $form->{ordnumber_oe} }, qq|$form->{"ordnumber_$i"}|);
171
      push(@{ $form->{transdate_oe} }, qq|$form->{"transdate_$i"}|);
172
      push(@{ $form->{invnumber} }, qq|$form->{"invnumber"}|);
173
      push(@{ $form->{invdate} }, qq|$form->{"invdate"}|);
159

  
160
      push @{ $form->{runningnumber} },   $position;
161
      push @{ $form->{number} },          $form->{"partnumber_$i"};
162
      push @{ $form->{serialnumber} },    $form->{"serialnumber_$i"};
163
      push @{ $form->{bin} },             $form->{"bin_$i"};
164
      push @{ $form->{"partnotes"} },     $form->{"partnotes_$i"};
165
      push @{ $form->{description} },     $form->{"description_$i"};
166
      push @{ $form->{longdescription} }, $form->{"longdescription_$i"};
167
      push @{ $form->{qty} },             $form->format_amount($myconfig, $form->{"qty_$i"});
168
      push @{ $form->{unit} },            $form->{"unit_$i"};
169
      push @{ $form->{deliverydate_oe} }, $form->{"deliverydate_$i"};
170
      push @{ $form->{sellprice} },       $form->{"sellprice_$i"};
171
      push @{ $form->{ordnumber_oe} },    $form->{"ordnumber_$i"};
172
      push @{ $form->{transdate_oe} },    $form->{"transdate_$i"};
173
      push @{ $form->{invnumber} },       $form->{"invnumber"};
174
      push @{ $form->{invdate} },         $form->{"invdate"};
174 175

  
175 176
      if ($form->{lizenzen}) {
176 177
        if ($form->{"licensenumber_$i"}) {
......
188 189
      # listprice
189 190
      push(@{ $form->{listprice} }, $form->{"listprice_$i"});
190 191

  
191
      my $sellprice = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
192
      my ($dec) = ($sellprice =~ /\.(\d+)/);
193
      $dec = length $dec;
194
      my $decimalplaces = ($dec > 2) ? $dec : 2;
195

  
196
      my $i_discount =
197
        $form->round_amount(
198
                            $sellprice * $form->parse_amount($myconfig,
199
                                                 $form->{"discount_$i"}) / 100,
200
                            $decimalplaces);
201

  
202
      my $discount =
203
        $form->round_amount($form->{"qty_$i"} * $i_discount, $decimalplaces);
192
      my $sellprice     = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
193
      my ($dec)         = ($sellprice =~ /\.(\d+)/);
194
      my $decimalplaces = max 2, length($dec);
204 195

  
205
      # keep a netprice as well, (sellprice - discount)
206
      $form->{"netprice_$i"} = $sellprice - $i_discount;
196
      my $discount             = $form->round_amount($form->{"qty_$i"} * $sellprice * $form->{"discount_$i"} / 100, $decimalplaces);
197
      my $linetotal            = $form->round_amount($form->{"qty_$i"} * $sellprice * (100 - $form->{"discount_$i"}) / 100, 2);
198
      my $nodiscount_linetotal = $form->round_amount($form->{"qty_$i"} * $sellprice, 2);
199
      $form->{"netprice_$i"}   = $form->round_amount($form->{"qty_$i"} ? ($linetotal / $form->{"qty_$i"}) : 0, 2);
207 200

  
208
      push(@{ $form->{netprice} },
209
           ($form->{"netprice_$i"} != 0)
210
           ? $form->format_amount(
211
                                 $myconfig, $form->{"netprice_$i"},
212
                                 $decimalplaces
213
             )
214
           : " ");
201
      push @{ $form->{netprice} }, ($form->{"netprice_$i"} != 0) ? $form->format_amount($myconfig, $form->{"netprice_$i"}, $decimalplaces) : '';
215 202

  
216
      my $linetotal =
217
        $form->round_amount($form->{"qty_$i"} * $form->{"netprice_$i"}, 2);
203
      $linetotal = ($linetotal != 0) ? $linetotal : '';
218 204

  
219
      my $nodiscount_linetotal =
220
        $form->round_amount($form->{"qty_$i"} * $sellprice, 2);
205
      push @{ $form->{discount} },   ($discount  != 0) ? $form->format_amount($myconfig, $discount * -1, $decimalplaces) : '';
206
      push @{ $form->{p_discount} }, $form->{"discount_$i"};
221 207

  
222
      $discount =
223
        ($discount != 0)
224
        ? $form->format_amount($myconfig, $discount * -1, $decimalplaces)
225
        : " ";
226
      $linetotal = ($linetotal != 0) ? $linetotal : " ";
208
      $form->{total}            += $linetotal;
209
      $form->{nodiscount_total} += $nodiscount_linetotal;
210
      $form->{discount_total}   += $discount;
227 211

  
228
      push(@{ $form->{discount} },   $discount);
229
      push(@{ $form->{p_discount} }, $form->{"discount_$i"});
230
      if (($form->{"discount_$i"} ne "") && ($form->{"discount_$i"} != 0)) {
231
        $form->{discount_p} = $form->{"discount_$i"};
212
      if ($subtotal_header) {
213
        $discount_subtotal   += $linetotal;
214
        $nodiscount_subtotal += $nodiscount_linetotal;
232 215
      }
233
      $form->{total} += $linetotal;
234
      $discount_subtotal += $linetotal;
235
      $form->{nodiscount_total} += $nodiscount_linetotal;
236
      $nodiscount_subtotal += $nodiscount_linetotal;
237
      $form->{discount_total} += $form->parse_amount($myconfig, $discount);
238 216

  
239 217
      if ($form->{"subtotal_$i"} && $subtotal_header && ($subtotal_header != $i)) {
240
        $discount_subtotal = $form->format_amount($myconfig, $discount_subtotal, 2);
241
        push(@{ $form->{discount_sub} },  $discount_subtotal);
242
        $nodiscount_subtotal = $form->format_amount($myconfig, $nodiscount_subtotal, 2);
243
        push(@{ $form->{nodiscount_sub} }, $nodiscount_subtotal);
244
        $discount_subtotal = 0;
218
        push @{ $form->{discount_sub} },   $form->format_amount($myconfig, $discount_subtotal,   2);
219
        push @{ $form->{nodiscount_sub} }, $form->format_amount($myconfig, $nodiscount_subtotal, 2);
220

  
221
        $discount_subtotal   = 0;
245 222
        $nodiscount_subtotal = 0;
246
        $subtotal_header = 0;
223
        $subtotal_header     = 0;
224

  
247 225
      } else {
248
        push(@{ $form->{discount_sub} }, "");
249
        push(@{ $form->{nodiscount_sub} }, "");
226
        push @{ $form->{discount_sub} },   "";
227
        push @{ $form->{nodiscount_sub} }, "";
250 228
      }
251 229

  
252
      if ($linetotal == $netto_linetotal) {
230
      if (!$form->{"discount_$i"}) {
253 231
        $nodiscount += $linetotal;
254 232
      }
255 233

  
256
      push(@{ $form->{linetotal} },
257
           $form->format_amount($myconfig, $linetotal, 2));
258
      push(@{ $form->{nodiscount_linetotal} },
259
           $form->format_amount($myconfig, $nodiscount_linetotal, 2));
234
      push @{ $form->{linetotal} }, $form->format_amount($myconfig, $linetotal, 2);
235
      push @{ $form->{nodiscount_linetotal} }, $form->format_amount($myconfig, $nodiscount_linetotal, 2);
260 236

  
261 237
      push(@{ $form->{projectnumber} }, $projectnumbers{$form->{"project_id_$i"}});
262 238

  
......
376 352
  else {
377 353
    $form->{subtotal} = $form->format_amount($myconfig, $form->{total}, 2);
378 354
  }
379
  $yesdiscount = $form->{nodiscount_total} - $nodiscount;
355

  
380 356
  $form->{nodiscount_subtotal} = $form->format_amount($myconfig, $form->{nodiscount_total}, 2);
381
  $form->{discount_total} = $form->format_amount($myconfig, $form->{discount_total}, 2);
382
  $form->{nodiscount} = $form->format_amount($myconfig, $nodiscount, 2);
383
  $form->{yesdiscount} = $form->format_amount($myconfig, $yesdiscount, 2);
357
  $form->{discount_total}      = $form->format_amount($myconfig, $form->{discount_total}, 2);
358
  $form->{nodiscount}          = $form->format_amount($myconfig, $nodiscount, 2);
359
  $form->{yesdiscount}         = $form->format_amount($myconfig, $form->{nodiscount_total} - $nodiscount, 2);
384 360

  
385
  $form->{invtotal} =
386
    ($form->{taxincluded}) ? $form->{total} : $form->{total} + $tax;
387
  $form->{total} =
388
    $form->format_amount($myconfig, $form->{invtotal} - $form->{paid}, 2);
361
  $form->{invtotal} = ($form->{taxincluded}) ? $form->{total} : $form->{total} + $tax;
362
  $form->{total}    = $form->format_amount($myconfig, $form->{invtotal} - $form->{paid}, 2);
389 363

  
390 364
  $form->{invtotal} = $form->format_amount($myconfig, $form->{invtotal}, 2);
391
  $form->{paid} = $form->format_amount($myconfig, $form->{paid}, 2);
365
  $form->{paid}     = $form->format_amount($myconfig, $form->{paid}, 2);
366

  
392 367
  $form->set_payment_options($myconfig, $form->{invdate});
393 368

  
394 369
  $form->{username} = $myconfig->{name};
......
581 556
      }
582 557
      $baseqty = $form->{"qty_$i"} * $basefactor;
583 558

  
584
      # undo discount formatting
585
      $form->{"discount_$i"} =
586
        $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
587

  
588 559
      my ($allocated, $taxrate) = (0, 0);
589 560
      my $taxamount;
590 561

  
562
      # add tax rates
563
      map { $taxrate += $form->{"${_}_rate"} } split(/ /, $form->{"taxaccounts_$i"});
564

  
591 565
      # keep entered selling price
592 566
      my $fxsellprice =
593 567
        $form->parse_amount($myconfig, $form->{"sellprice_$i"});
......
596 570
      $dec = length $dec;
597 571
      my $decimalplaces = ($dec > 2) ? $dec : 2;
598 572

  
599
      # deduct discount
600
      my $discount =
601
        $form->round_amount($fxsellprice * $form->{"discount_$i"},
602
                            $decimalplaces);
603
      $form->{"sellprice_$i"} = $fxsellprice - $discount;
573
      # undo discount formatting
574
      $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
604 575

  
605
      # add tax rates
606
      map({ $taxrate += $form->{"${_}_rate"} } split(/ /,
607
        $form->{"taxaccounts_$i"}));
576
      # deduct discount
577
      $form->{"sellprice_$i"} = $fxsellprice * (1 - $form->{"discount_$i"});
608 578

  
609 579
      # round linetotal to 2 decimal places
610
      $linetotal =
611
        $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
580
      $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"}, 2);
612 581

  
613 582
      if ($form->{taxincluded}) {
614 583
        $taxamount = $linetotal * ($taxrate / (1 + $taxrate));

Auch abrufbar als: Unified diff