Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b6dc5623

Von Sven Schöling vor fast 17 Jahren hinzugefügt

  • ID b6dc5623d93c1be1c54248d4512e80f495af2899
  • Vorgänger ac517355
  • Nachfolger 270df900
  • Auslagerung der OE-Masken in Templates *

Diese Patch ist ein Merge der Revisionen
2866, 5349, 5365, 5370, 5408, 5413, 5470, 5473, 5475, 5519, 5520, 5521, 5524, 5526, 5591, 5618, 5622, 5814, 5881, 5882 und 5961
in das Unstable.

Hintergrund ist die Auslagerung der OE-Masken, das heisst aller Masken, die fuer Auftraege, Angebote und teilweise Rechnungen zustaendig sind.
Dadurch vereinfacht sich der Code an vielen Stellen deutlich, ausserdem konnten viele Berechnungen verkleinert werden, weil der Code fuer Angebote/Auftraege jetzt getrennt von Rechnungen liegt.

Ein Grossteil der bin/mozilla/io.pl wurde dafuer dubliziert, die Methoden die fuer Auftraege noetig sind liegen jetzt in der bin/mozilla/oe.pl (vor allem display_form und display_row, aber auch ein paar andere), ihr jeweiliges Pendant fuer Rechnungen wurde unveraendert in eine Datei invoice_io.pl ausgelagert die von den Skripten die sie benoetigen zusaetzlich zur io.pl eingelesen wird.

Wie der Name der Templates andeutet ist der Patch im Verkaufsbaum entstanden, im Verlauf der Programmierung habe cih aber nicht genug Unterschiede gefunden um separate Templates fuer Verkauf und Einkauf zu rechtfertigen. Eventuell werden die Templates noch umbenannt.

Komplexe Maskenaenderungen wie der Austausch von Drop-Down Menues bei zu grosser Anzahl durch Eingabefelder werden ebenfalls noch manuell gemacht.
Auch das wird in der naechsten Version ausgelagert um den Backend Code schlanker zu machen.

Die Berechnung fuer Units und Steuern wurde vereinfacht, und dabei einige unschoene Bugs gefixt, die aus der unvollstaendigen Abdeckung von Verzweigungen resultierten.

Zuletzt wurden noch fast alle serverseitigen Datenformatierungen ausgelagert in ein Templateplugin, welches Zahlen waehrend des Templatings formatiert (mehr dazu in der Dakumentation zu Template.pm).

Der Patch beinhaltet ausserdem die ueblichen Codekosmetika.

Unterschiede anzeigen:

SL/OE.pm
244 244

  
245 245
  for my $i (1 .. $form->{rowcount}) {
246 246

  
247
    map({ $form->{"${_}_$i"} =
248
            $form->parse_amount($myconfig, $form->{"${_}_$i"}) } qw(qty ship));
247
    map({ $form->{"${_}_$i"} = $form->parse_amount($myconfig, $form->{"${_}_$i"}) } qw(qty ship));
249 248

  
250 249
    if ($form->{"id_$i"}) {
251 250

  
......
256 255
      my $basefactor = 1;
257 256
      if (defined($all_units->{$item_unit}->{factor}) &&
258 257
          (($all_units->{$item_unit}->{factor} * 1) != 0)) {
259
        $basefactor = $all_units->{$form->{"unit_$i"}}->{factor} /
260
          $all_units->{$item_unit}->{factor};
258
        $basefactor = $all_units->{$form->{"unit_$i"}}->{factor} / $all_units->{$item_unit}->{factor};
261 259
      }
262 260
      my $baseqty = $form->{"qty_$i"} * $basefactor;
263 261

  
......
266 264
      $form->{"lastcost_$i"} = $form->{"lastcost_$i"} * 1;
267 265

  
268 266
      # set values to 0 if nothing entered
269
      $form->{"discount_$i"} =
270
        $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
267
      $form->{"discount_$i"} = $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100;
271 268

  
272
      $form->{"sellprice_$i"} =
273
        $form->parse_amount($myconfig, $form->{"sellprice_$i"});
269
      $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
274 270
      $fxsellprice = $form->{"sellprice_$i"};
275 271

  
276 272
      my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
277 273
      $dec = length($dec);
278 274
      my $decimalplaces = ($dec > 2) ? $dec : 2;
279 275

  
280
      $discount =
281
        $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"},
282
                            $decimalplaces);
283
      $form->{"sellprice_$i"} =
284
        $form->round_amount($form->{"sellprice_$i"} - $discount,
285
                            $decimalplaces);
276
      $discount = $form->round_amount($form->{"sellprice_$i"} * $form->{"discount_$i"}, $decimalplaces);
277
      $form->{"sellprice_$i"} = $form->round_amount($form->{"sellprice_$i"} - $discount, $decimalplaces);
286 278

  
287 279
      $form->{"inventory_accno_$i"} *= 1;
288 280
      $form->{"expense_accno_$i"}   *= 1;
......
311 303
      if ($form->round_amount($taxrate, 7) == 0) {
312 304
        if ($form->{taxincluded}) {
313 305
          foreach $item (@taxaccounts) {
314
            $taxamount =
315
              $form->round_amount($linetotal * $form->{"${item}_rate"} /
316
                                    (1 + abs($form->{"${item}_rate"})),
317
                                  2);
318

  
306
            $taxamount = $form->round_amount($linetotal * $form->{"${item}_rate"} / (1 + abs($form->{"${item}_rate"})), 2);
319 307
            $taxaccounts{$item} += $taxamount;
320 308
            $taxdiff            += $taxamount;
321

  
322
            $taxbase{$item} += $taxbase;
309
            $taxbase{$item}     += $taxbase;
323 310
          }
324 311
          $taxaccounts{ $taxaccounts[0] } += $taxdiff;
325 312
        } else {
......
330 317
        }
331 318
      } else {
332 319
        foreach $item (@taxaccounts) {
333
          $taxaccounts{$item} +=
334
            $taxamount * $form->{"${item}_rate"} / $taxrate;
320
          $taxaccounts{$item} += $taxamount * $form->{"${item}_rate"} / $taxrate;
335 321
          $taxbase{$item} += $taxbase;
336 322
        }
337 323
      }
338 324

  
339 325
      $netamount += $form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor;
340 326

  
341
      $reqdate =
342
        ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
327
      $reqdate = ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
343 328

  
344 329
      # get pricegroup_id and save ist
345 330
      ($null, my $pricegroup_id) = split(/--/, $form->{"sellprice_pg_$i"});
......
362 347
      }
363 348
      $query .= qq|?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
364 349
                   (SELECT factor FROM price_factors WHERE id = ?), ?)|;
365
		  push(@values,
350
        push(@values,
366 351
           conv_i($form->{id}), conv_i($form->{"id_$i"}),
367 352
           $form->{"description_$i"}, $form->{"longdescription_$i"},
368 353
           $form->{"qty_$i"}, $baseqty,
......
394 379
  if ($form->{currency} eq $form->{defaultcurrency}) {
395 380
    $form->{exchangerate} = 1;
396 381
  } else {
397
    $exchangerate =
398
      $form->check_exchangerate($myconfig,
399
                                $form->{currency},
400
                                $form->{transdate},
401
                                ($form->{vc} eq 'customer') ? 'buy' : 'sell');
382
    $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, ($form->{vc} eq 'customer') ? 'buy' : 'sell');
402 383
  }
403 384

  
404
  $form->{exchangerate} =
405
    ($exchangerate)
406
    ? $exchangerate
407
    : $form->parse_amount($myconfig, $form->{exchangerate});
385
  $form->{exchangerate} = ($exchangerate) ? $exchangerate : $form->parse_amount($myconfig, $form->{exchangerate});
408 386

  
409 387
  my $quotation = $form->{type} =~ /_order$/ ? 'f' : 't';
410 388

  
......
456 434

  
457 435
  if (($form->{currency} ne $form->{defaultcurrency}) && !$exchangerate) {
458 436
    if ($form->{vc} eq 'customer') {
459
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate},
460
                                 $form->{exchangerate}, 0);
437
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, $form->{exchangerate}, 0);
461 438
    }
462 439
    if ($form->{vc} eq 'vendor') {
463
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate},
464
                                 0, $form->{exchangerate});
440
      $form->update_exchangerate($dbh, $form->{currency}, $form->{transdate}, 0, $form->{exchangerate});
465 441
    }
466 442
  }
467 443

  
......
471 447
    &adj_onhand($dbh, $form, $ml * -1);
472 448
  }
473 449

  
474
  my $rc = $dbh->commit;
475
  $dbh->disconnect;
476

  
477 450
  $form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ?
478 451
                                       "quonumber" : "ordnumber"};
479 452

  
480 453
  Common::webdav_folder($form) if ($main::webdav);
481 454

  
455
  my $rc = $dbh->commit;
456
  $dbh->disconnect;
457

  
482 458
  $main::lxdebug->leave_sub();
483 459

  
484 460
  return $rc;
......
918 894
    $sth->finish();
919 895
  }
920 896

  
921
  $form->{"globalprojectnumber"} =
922
    $projectnumbers{$form->{"globalproject_id"}};
897
  $form->{"globalprojectnumber"} = $projectnumbers{$form->{"globalproject_id"}};
923 898

  
924 899
  my @arrays =
925 900
    qw(runningnumber number description longdescription qty ship unit bin
......
1041 1016

  
1042 1017
      if ($taxamount != 0) {
1043 1018
        foreach my $item (split / /, $form->{"taxaccounts_$i"}) {
1044
          $taxaccounts{$item} +=
1045
            $taxamount * $form->{"${item}_rate"} / $taxrate;
1046
          $taxbase{$item} += $taxbase;
1019
          $taxaccounts{$item} += $taxamount * $form->{"${item}_rate"} / $taxrate;
1020
          $taxbase{$item}     += $taxbase;
1047 1021
        }
1048 1022
      }
1049 1023

  
......
1056 1030
        # get parts and push them onto the stack
1057 1031
        my $sortorder = "";
1058 1032
        if ($form->{groupitems}) {
1059
          $sortorder =
1060
            qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|;
1033
          $sortorder = qq|ORDER BY pg.partsgroup, a.$oid{$myconfig->{dbdriver}}|;
1061 1034
        } else {
1062 1035
          $sortorder = qq|ORDER BY a.$oid{$myconfig->{dbdriver}}|;
1063 1036
        }
......
1075 1048

  
1076 1049
        while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
1077 1050
          if ($form->{groupitems} && $ref->{partsgroup} ne $sameitem) {
1078
            map({ push(@{ $form->{$_} }, "") }
1079
                grep({ $_ ne "description" } @arrays));
1051
            map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
1080 1052
            $sameitem = ($ref->{partsgroup}) ? $ref->{partsgroup} : "--";
1081 1053
            push(@{ $form->{description} }, $sameitem);
1082 1054
          }
1083 1055

  
1084
          push(@{ $form->{description} },
1085
               $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}
1086
                 )
1087
                 . qq|, $ref->{partnumber}, $ref->{description}|);
1088

  
1089
          map({ push(@{ $form->{$_} }, "") }
1090
              grep({ $_ ne "description" } @arrays));
1056
          push(@{ $form->{description} }, $form->format_amount($myconfig, $ref->{qty} * $form->{"qty_$i"}) . qq|, $ref->{partnumber}, $ref->{description}|); 
1057
          map({ push(@{ $form->{$_} }, "") } grep({ $_ ne "description" } @arrays));
1091 1058
        }
1092 1059
        $sth->finish;
1093 1060
      }
......
1195 1162
      my ($item_unit) = selectrow_query($form, $dbh, $query, $ref->{parts_id});
1196 1163

  
1197 1164
      my $basefactor = 1;
1198
      if (defined($all_units->{$item_unit}->{factor}) &&
1199
          (($all_units->{$item_unit}->{factor} * 1) != 0)) {
1200
        $basefactor = $all_units->{$ref->{unit}}->{factor} /
1201
          $all_units->{$item_unit}->{factor};
1165
      if (defined($all_units->{$item_unit}->{factor}) && (($all_units->{$item_unit}->{factor} * 1) != 0)) {
1166
        $basefactor = $all_units->{$ref->{unit}}->{factor} / $all_units->{$item_unit}->{factor};
1202 1167
      }
1203 1168
      my $baseqty = $ref->{ship} * $basefactor;
1204 1169

  
1205 1170
      # adjust onhand in parts table
1206
      $form->update_balance($dbh, "parts", "onhand",
1207
                            qq|id = $ref->{parts_id}|,
1208
                            $baseqty * $ml);
1171
      $form->update_balance($dbh, "parts", "onhand", qq|id = $ref->{parts_id}|, $baseqty * $ml);
1209 1172
    }
1210 1173
  }
1211 1174

  

Auch abrufbar als: Unified diff