Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a05eead3

Von Sven Schöling vor mehr als 17 Jahren hinzugefügt

  • ID a05eead353b55ba228a5eec40f90c0f2c330092a
  • Vorgänger 82c41aac
  • Nachfolger 6ca711a5

Kosmetik, merge aus -r5105,5106,5118,5120,5124

Unterschiede anzeigen:

SL/IR.pm
38 38
use SL::Common;
39 39
use SL::DBUtils;
40 40
use SL::MoreCommon;
41
use List::Util qw(min);
41 42

  
42 43
sub post_invoice {
43 44
  $main::lxdebug->enter_sub();
......
59 60
  if (!$payments_only) {
60 61
    if ($form->{id}) {
61 62
      &reverse_invoice($dbh, $form);
62

  
63 63
    } else {
64 64
      ($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('glid')|);
65

  
66 65
      do_query($form, $dbh, qq|INSERT INTO ap (id, invnumber) VALUES (?, '')|, $form->{id});
67 66
    }
68 67
  }
......
73 72
  if ($form->{currency} eq $defaultcurrency) {
74 73
    $form->{exchangerate} = 1;
75 74
  } else {
76
    $exchangerate =
77
      $form->check_exchangerate($myconfig, $form->{currency},
78
                                $form->{transdate}, 'sell');
75
    $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{transdate}, 'sell');
79 76
  }
80 77

  
81
  $form->{exchangerate} =
82
    ($exchangerate)
83
    ? $exchangerate
84
    : $form->parse_amount($myconfig, $form->{exchangerate});
85

  
78
  $form->{exchangerate} = $exchangerate || $form->parse_amount($myconfig, $form->{exchangerate});
86 79
  $form->{exchangerate} = 1 unless ($form->{exchangerate} * 1);
87 80

  
88 81
  my %item_units;
......
92 85
  for my $i (1 .. $form->{rowcount}) {
93 86
    next unless $form->{"id_$i"};
94 87

  
95
    $form->{"qty_$i"} = $form->parse_amount($myconfig, $form->{"qty_$i"});
88
    $form->{"qty_$i"}  = $form->parse_amount($myconfig, $form->{"qty_$i"});
89
    $form->{"qty_$i"} *= -1 if $form->{storno};
96 90

  
97
    if ($form->{storno}) {
98
      $form->{"qty_$i"} *= -1;
99
    }
100

  
101
    if ($main::eur) {
102
      $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"};
103
    }
91
    $form->{"inventory_accno_$i"} = $form->{"expense_accno_$i"} if $main::eur;
104 92

  
105 93
    # get item baseunit
106 94
    if (!$item_units{$form->{"id_$i"}}) {
......
111 99
    my $item_unit = $item_units{$form->{"id_$i"}};
112 100

  
113 101
    if (defined($all_units->{$item_unit}->{factor})
114
        && ($all_units->{$item_unit}->{factor} ne '')
115
        && ($all_units->{$item_unit}->{factor} * 1 != 0)) {
102
            && ($all_units->{$item_unit}->{factor} ne '')
103
            && ($all_units->{$item_unit}->{factor} * 1 != 0)) {
116 104
      $basefactor = $all_units->{$form->{"unit_$i"}}->{factor} / $all_units->{$item_unit}->{factor};
117 105
    } else {
118 106
      $basefactor = 1;
......
125 113
    $taxrate     = 0;
126 114

  
127 115
    $form->{"sellprice_$i"} = $form->parse_amount($myconfig, $form->{"sellprice_$i"});
128
    my $fxsellprice = $form->{"sellprice_$i"};
129

  
130
    my ($dec) = ($fxsellprice =~ /\.(\d+)/);
131
    $dec = length $dec;
116
    (my $fxsellprice = $form->{"sellprice_$i"}) =~ /\.(\d+)/;
117
    my $dec = length $1;
132 118
    my $decimalplaces = ($dec > 2) ? $dec : 2;
133 119

  
134 120
    map { $taxrate += $form->{"${_}_rate"} } @taxaccounts;
......
175 161
      $form->{amount}{ $form->{id} }{ $form->{"inventory_accno_$i"} } -= $linetotal;
176 162

  
177 163
      # adjust and round sellprice
178
      $form->{"sellprice_$i"} =
179
        $form->round_amount($form->{"sellprice_$i"} * $form->{exchangerate}, $decimalplaces);
164
      $form->{"sellprice_$i"} = $form->round_amount($form->{"sellprice_$i"} * $form->{exchangerate}, $decimalplaces);
180 165

  
181 166
      $lastinventoryaccno = $form->{"inventory_accno_$i"};
182 167

  
......
187 172
      @values = ($form->{"sellprice_$i"}, conv_i($form->{"id_$i"}));
188 173
      do_query($form, $dbh, $query, @values);
189 174

  
190
      if (!$form->{shipped}) {
191
        $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, $baseqty, $form->{"id_$i"})
192
      }
175
      $form->update_balance($dbh, "parts", "onhand", qq|id = ?|, $baseqty, $form->{"id_$i"}) if !$form->{shipped};
193 176

  
194 177
      # check if we sold the item already and
195 178
      # make an entry for the expense and inventory
......
207 190
      my $totalqty = $base_qty;
208 191

  
209 192
      while (my $ref = $sth->fetchrow_hashref(NAME_lc)) {
210

  
211
        my $qty = $ref->{base_qty} + $ref->{allocated};
212

  
213
        if (($qty - $totalqty) > 0) {
214
          $qty = $totalqty;
215
        }
216

  
193
        my $qty    = min $totalqty, ($ref->{base_qty} + $ref->{allocated});
217 194
        $linetotal = $form->round_amount(($form->{"sellprice_$i"} * $qty) / $basefactor, 2);
218 195

  
219 196
        if ($ref->{allocated} < 0) {
......
233 210

  
234 211
        } elsif ($linetotal != 0) {
235 212
          # add entry for inventory, this one is for the sold item
236
          $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey)
237
                      VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?))|;
238
          @values = ($ref->{trans_id},  $ref->{inventory_accno_id}, $linetotal,
239
                     $ref->{transdate}, $ref->{inventory_accno_id});
213
          $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE id = ?))|;
214
          @values = ($ref->{trans_id},  $ref->{inventory_accno_id}, $linetotal, $ref->{transdate}, $ref->{inventory_accno_id});
240 215
          do_query($form, $dbh, $query, @values);
241 216

  
242 217
          # add expense
243
          $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey)
244
                      VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?))|;
245
          @values = ($ref->{trans_id},  $ref->{expense_accno_id}, ($linetotal * -1),
246
                     $ref->{transdate}, $ref->{expense_accno_id});
218
          $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey) VALUES (?, ?, ?, ?, (SELECT taxkey from tax WHERE chart_id = ?))|;
219
          @values = ($ref->{trans_id},  $ref->{expense_accno_id}, ($linetotal * -1), $ref->{transdate}, $ref->{expense_accno_id});
247 220
          do_query($form, $dbh, $query, @values);
248 221
        }
249 222

  
......
252 225

  
253 226
        $allocated += $qty;
254 227

  
255
        last if (($totalqty -= $qty) <= 0);
228
        last if ($totalqty -= $qty) <= 0;
256 229
      }
257 230

  
258 231
      $sth->finish();
......
274 247
      if ($form->round_amount($taxrate, 7) == 0) {
275 248
        if ($form->{taxincluded}) {
276 249
          foreach $item (@taxaccounts) {
277
            $taxamount =
278
              $linetotal * $form->{"${item}_rate"}
279
              / (1 + abs($form->{"${item}_rate"}));
250
            $taxamount = $linetotal * $form->{"${item}_rate"} / (1 + abs($form->{"${item}_rate"}));
280 251
            $totaltax += $taxamount;
281 252
            $form->{amount}{ $form->{id} }{$item} -= $taxamount;
282 253
          }
283

  
284 254
        } else {
285 255
          map { $form->{amount}{ $form->{id} }{$_} -= $linetotal * $form->{"${_}_rate"} } @taxaccounts;
286 256
        }
287

  
288 257
      } else {
289 258
        map { $form->{amount}{ $form->{id} }{$_} -= $taxamount * $form->{"${_}_rate"} / $taxrate } @taxaccounts;
290 259
      }
......
341 310
  for my $i (1 .. $form->{paidaccounts}) {
342 311
    $form->{"paid_$i"}  = $form->parse_amount($myconfig, $form->{"paid_$i"});
343 312
    $form->{paid}      += $form->{"paid_$i"};
344
    $form->{datepaid}   = $form->{"datepaid_$i"} if ($form->{"datepaid_$i"});
313
    $form->{datepaid}   = $form->{"datepaid_$i"} if $form->{"datepaid_$i"};
345 314
  }
346 315

  
347 316
  my ($tax, $paiddiff) = (0, 0);
......
368 337
    $expensediff += $paiddiff;
369 338

  
370 339
    ######## this only applies to tax included
371
    if ($lastinventoryaccno) {
372
      $form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff;
373
    }
374
    if ($lastexpenseaccno) {
375
      $form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $expensediff;
376
    }
340
    
341
    $form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff if $lastinventoryaccno;
342
    $form->{amount}{ $form->{id} }{$lastexpenseaccno}   -= $expensediff if $lastexpenseaccno;
377 343

  
378 344
  } else {
379 345
    $amount    = $form->round_amount($netamount * $form->{exchangerate}, 2);
......
392 358

  
393 359
  $form->{amount}{ $form->{id} }{ $form->{AP} } = $netamount + $tax;
394 360

  
395
  if ($form->{paid} != 0) {
396
    $form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2);
397
  }
361
  
362
  $form->{paid} = $form->round_amount($form->{paid} * $form->{exchangerate} + $paiddiff, 2) if $form->{paid} != 0;
398 363

  
399 364
  # update exchangerate
400
  if (($form->{currency} ne $defaultcurrency) && !$exchangerate) {
401
    $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate});
402
  }
365
  
366
  $form->update_exchangerate($dbh, $form->{currency}, $form->{invdate}, 0, $form->{exchangerate})
367
    if ($form->{currency} ne $defaultcurrency) && !$exchangerate;
403 368

  
404 369
  # record acc_trans transactions
405 370
  foreach my $trans_id (keys %{ $form->{amount} }) {
406 371
    foreach my $accno (keys %{ $form->{amount}{$trans_id} }) {
407 372
      $form->{amount}{$trans_id}{$accno} = $form->round_amount($form->{amount}{$trans_id}{$accno}, 2);
408 373

  
409
      next if ($payments_only || !$form->{amount}{$trans_id}{$accno});
374
      next if $payments_only || !$form->{amount}{$trans_id}{$accno};
410 375

  
411 376
      $query = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, taxkey, project_id)
412 377
                  VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?,
......
426 391
  }
427 392

  
428 393
  # force AP entry if 0
429
  if ($form->{amount}{ $form->{id} }{ $form->{AP} } == 0) {
430
    $form->{amount}{ $form->{id} }{ $form->{AP} } = $form->{paid};
431
  }
394
  
395
  $form->{amount}{ $form->{id} }{ $form->{AP} } = $form->{paid} if $form->{amount}{$form->{id}}{$form->{AP}} == 0;
432 396

  
433 397
  # record payments and offsetting AP
434 398
  for my $i (1 .. $form->{paidaccounts}) {
435
    next if ($form->{"paid_$i"} == 0);
399
    next if $form->{"paid_$i"} == 0;
436 400

  
437 401
    my ($accno)            = split /--/, $form->{"AP_paid_$i"};
438 402
    $form->{"datepaid_$i"} = $form->{invdate} unless ($form->{"datepaid_$i"});
......
463 427
    if ($form->{currency} eq $defaultcurrency) {
464 428
      $form->{"exchangerate_$i"} = 1;
465 429
    } else {
466
      $exchangerate = $form->check_exchangerate($myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell');
467

  
468
      $form->{"exchangerate_$i"} =
469
        ($exchangerate)
470
        ? $exchangerate
471
        : $form->parse_amount($myconfig, $form->{"exchangerate_$i"});
430
      $exchangerate              = $form->check_exchangerate($myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell');
431
      $form->{"exchangerate_$i"} = $exchangerate || $form->parse_amount($myconfig, $form->{"exchangerate_$i"});
472 432
    }
473 433

  
474 434
    # exchangerate difference
475
    $form->{fx}{$accno}{ $form->{"datepaid_$i"} } +=
476
      $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $paiddiff;
435
    $form->{fx}{$accno}{ $form->{"datepaid_$i"} } += $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $paiddiff;
477 436

  
478 437
    # gain/loss
479 438
    $amount =
......
481 440
      ($form->{"paid_$i"} * $form->{"exchangerate_$i"});
482 441
    if ($amount > 0) {
483 442
      $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } += $amount;
484

  
485 443
    } else {
486 444
      $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } += $amount;
487 445
    }
......
489 447
    $paiddiff = 0;
490 448

  
491 449
    # update exchange rate
492
    if (($form->{currency} ne $defaultcurrency) && !$exchangerate) {
493
      $form->update_exchangerate($dbh, $form->{currency},
494
                                 $form->{"datepaid_$i"},
495
                                 0, $form->{"exchangerate_$i"});
496
    }
450
    $form->update_exchangerate($dbh, $form->{currency}, $form->{"datepaid_$i"}, 0, $form->{"exchangerate_$i"})
451
      if ($form->{currency} ne $defaultcurrency) && !$exchangerate;
497 452
  }
498 453

  
499 454
  # record exchange rate differences and gains/losses
......
529 484
  $form->{department_id} = (split /--/, $form->{department})[1];
530 485
  $form->{invnumber}     = $form->{id} unless $form->{invnumber};
531 486

  
532
  $taxzone_id = 0 if ((3 < $taxzone_id) || (0 > $taxzone_id));
487
  $taxzone_id = 0 if (3 < $taxzone_id) || (0 > $taxzone_id);
533 488

  
534 489
  # save AP record
535 490
  $query = qq|UPDATE ap SET
536
                invnumber = ?,
537
                ordnumber = ?,
538
                quonumber = ?,
539
                transdate = ?,
540
                orddate = ?,
541
                quodate = ?,
542
                vendor_id = ?,
543
                amount = ?,
544
                netamount = ?,
545
                paid = ?,
546
                datepaid = ?,
547
                duedate = ?,
548
                invoice = '1',
549
                taxzone_id = ?,
550
                taxincluded = ?,
551
                notes = ?,
552
                intnotes = ?,
553
                curr = ?,
554
                department_id = ?,
555
                storno = ?,
556
                storno_id = ?,
557
                globalproject_id = ?,
558
                cp_id = ?,
559
                employee_id = ?
491
                invnumber    = ?, ordnumber   = ?, quonumber     = ?, transdate   = ?,
492
                orddate      = ?, quodate     = ?, vendor_id     = ?, amount      = ?,
493
                netamount    = ?, paid        = ?, duedate       = ?, datepaid    = ?,
494
                invoice      = ?, taxzone_id  = ?, notes         = ?, taxincluded = ?,
495
                intnotes     = ?, curr        = ?, storno_id     = ?, storno      = ?,
496
                cp_id        = ?, employee_id = ?, department_id = ?, 
497
                globalproject_id = ?
560 498
              WHERE id = ?|;
561
  @values = ($form->{invnumber}, $form->{ordnumber}, $form->{quonumber},
562
             conv_date($form->{invdate}), conv_date($form->{orddate}), conv_date($form->{quodate}),
563
             conv_i($form->{vendor_id}), $amount, $netamount, $form->{paid},
564
             $form->{paid} ? conv_date($form->{datepaid}) : undef,
565
             conv_date($form->{duedate}), $taxzone_id,
566
             $form->{taxincluded} ? 't' : 'f',
567
             $form->{notes}, $form->{intnotes}, $form->{currency}, conv_i($form->{department_id}),
568
             $form->{storno} ? 't' : 'f', conv_i($form->{storno_id}),
569
             conv_i($form->{globalproject_id}), conv_i($form->{cp_id}),
570
             conv_i($form->{employee_id}),
571
             conv_i($form->{id}));
499
  @values = (
500
                $form->{invnumber},          $form->{ordnumber},           $form->{quonumber},      conv_date($form->{invdate}),
501
      conv_date($form->{orddate}), conv_date($form->{quodate}),     conv_i($form->{vendor_id}),               $amount,
502
                $netamount,                  $form->{paid},      conv_date($form->{duedate}),       $form->{paid} ? conv_date($form->{datepaid}) : undef,
503
            '1',                             $taxzone_id,                  $form->{notes},          $form->{taxincluded} ? 't' : 'f',
504
                $form->{intnotes},           $form->{currency},     conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f',
505
         conv_i($form->{cp_id}),      conv_i($form->{employee_id}), conv_i($form->{department_id}), 
506
         conv_i($form->{globalproject_id}),
507
         conv_i($form->{id})
508
  );
572 509
  do_query($form, $dbh, $query, @values);
573 510

  
574 511
  if ($form->{storno}) {
SL/IS.pm
943 943

  
944 944
  # save AR record
945 945
  $query = qq|UPDATE ar set
946
                invnumber = ?,
947
                ordnumber = ?,
948
                quonumber = ?,
949
                cusordnumber = ?,
950
                transdate = ?,
951
                orddate = ?,
952
                quodate = ?,
953
                customer_id = ?,
954
                amount = ?,
955
                netamount = ?,
956
                paid = ?,
957
                datepaid = ?,
958
                duedate = ?,
959
                deliverydate = ?,
960
                invoice = '1',
961
                shippingpoint = ?,
962
                shipvia = ?,
963
                terms = ?,
964
                notes = ?,
965
                intnotes = ?,
966
                taxincluded = ?,
967
                curr = ?,
968
                department_id = ?,
969
                payment_id = ?,
970
                type = ?,
971
                language_id = ?,
972
                taxzone_id = ?,
973
                shipto_id = ?,
974
                delivery_customer_id = ?,
975
                delivery_vendor_id = ?,
976
                employee_id = ?,
977
                salesman_id = ?,
978
                storno = ?,
979
                storno_id = ?,
980
                globalproject_id = ?,
981
                cp_id = ?,
982
                transaction_description = ?,
983
                marge_total = ?,
984
                marge_percent = ?
946
                invnumber   = ?, ordnumber     = ?, quonumber     = ?, cusordnumber  = ?,
947
                transdate   = ?, orddate       = ?, quodate       = ?, customer_id   = ?,
948
                amount      = ?, netamount     = ?, paid          = ?, datepaid      = ?,
949
                duedate     = ?, deliverydate  = ?, invoice       = ?, shippingpoint = ?,
950
                shipvia     = ?, terms         = ?, notes         = ?, intnotes      = ?,
951
                curr        = ?, department_id = ?, payment_id    = ?, taxincluded   = ?,
952
                type        = ?, language_id   = ?, taxzone_id    = ?, shipto_id     = ?,
953
                employee_id = ?, salesman_id   = ?, storno_id     = ?, storno        = ?,
954
                cp_id       = ?, marge_total   = ?, marge_percent = ?, 
955
                globalproject_id               = ?, delivery_customer_id             = ?,
956
                transaction_description        = ?, delivery_vendor_id               = ?
985 957
              WHERE id = ?|;
986
  @values = ($form->{"invnumber"}, $form->{"ordnumber"}, $form->{"quonumber"}, $form->{"cusordnumber"},
987
             conv_date($form->{"invdate"}), conv_date($form->{"orddate"}), conv_date($form->{"quodate"}),
988
             conv_i($form->{"customer_id"}), $amount, $netamount, $form->{"paid"},
989
             conv_date($form->{"datepaid"}), conv_date($form->{"duedate"}), conv_date($form->{"deliverydate"}),
990
             $form->{"shippingpoint"}, $form->{"shipvia"}, conv_i($form->{"terms"}),
991
             $form->{"notes"}, $form->{"intnotes"}, $form->{"taxincluded"} ? 't' : 'f',
992
             $form->{"currency"}, conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}),
993
             $form->{"type"}, conv_i($form->{"language_id"}), conv_i($form->{"taxzone_id"}),
994
             conv_i($form->{"shipto_id"}),
995
             conv_i($form->{"delivery_customer_id"}), conv_i($form->{"delivery_vendor_id"}),
996
             conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}),
997
             $form->{"storno"} ? 't' : 'f', conv_i($form->{storno_id}), conv_i($form->{"globalproject_id"}),
998
             conv_i($form->{"cp_id"}), $form->{transaction_description},
999
             $form->{marge_total} * 1, $form->{marge_percent} * 1,
1000
             conv_i($form->{"id"}));
958
  @values = (          $form->{"invnumber"},           $form->{"ordnumber"},             $form->{"quonumber"},          $form->{"cusordnumber"},
959
             conv_date($form->{"invdate"}),  conv_date($form->{"orddate"}),    conv_date($form->{"quodate"}),    conv_i($form->{"customer_id"}), 
960
                       $amount,                        $netamount,                       $form->{"paid"},     conv_date($form->{"datepaid"}), 
961
             conv_date($form->{"duedate"}),  conv_date($form->{"deliverydate"}),    '1',                                $form->{"shippingpoint"},
962
                       $form->{"shipvia"},      conv_i($form->{"terms"}),                $form->{"notes"},              $form->{"intnotes"},
963
                       $form->{"currency"},     conv_i($form->{"department_id"}), conv_i($form->{"payment_id"}),        $form->{"taxincluded"} ? 't' : 'f',
964
                       $form->{"type"},         conv_i($form->{"language_id"}),   conv_i($form->{"taxzone_id"}), conv_i($form->{"shipto_id"}),
965
                conv_i($form->{"employee_id"}), conv_i($form->{"salesman_id"}),   conv_i($form->{storno_id}),           $form->{"storno"} ? 't' : 'f', 
966
                conv_i($form->{"cp_id"}),            1 * $form->{marge_total} ,      1 * $form->{marge_percent},
967
                conv_i($form->{"globalproject_id"}),                              conv_i($form->{"delivery_customer_id"}), 
968
                       $form->{transaction_description},                          conv_i($form->{"delivery_vendor_id"}),
969
                conv_i($form->{"id"}));
1001 970
  do_query($form, $dbh, $query, @values);
1002 971
  
1003 972
  if($form->{"formname"} eq "credit_note") {
bin/mozilla/ir.pl
221 221
      s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
222 222
  }
223 223

  
224
  if ($form->{old_employee_id}) {
225
    $form->{employee_id} = $form->{old_employee_id};
226
  }
227
  if ($form->{old_salesman_id}) {
228
    $form->{salesman_id} = $form->{old_salesman_id};
229
  }
230

  
224
  $form->{employee_id}     = $form->{old_employee_id} if $form->{old_employee_id};
225
  $form->{salesman_id}     = $form->{old_salesman_id} if $form->{old_salesman_id};
231 226
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
232

  
233

  
234
  $form->{radier} =
235
    ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
236

  
237
  $form->{exchangerate} =
238
    $form->format_amount(\%myconfig, $form->{exchangerate});
239

  
240
  $form->{creditlimit} =
241
    $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
242
  $form->{creditremaining} =
243
    $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
227
  $form->{radier}          = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
228
  $form->{exchangerate}    = $form->format_amount(\%myconfig, $form->{exchangerate});
229
  $form->{creditlimit}     = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
230
  $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
244 231

  
245 232
  $exchangerate = "";
246 233
  if ($form->{currency} ne $form->{defaultcurrency}) {
247 234
    if ($form->{forex}) {
248
      $exchangerate .= qq|
249
                <th align=right nowrap>|
250
        . $locale->text('Exchangerate') . qq|</th>
251
                <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>
252
|;
235
      $exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
236
                             <td>$form->{exchangerate}<input type=hidden name=exchangerate value=$form->{exchangerate}></td>\n|;
253 237
    } else {
254
      $exchangerate .= qq|
255
                <th align=right nowrap>|
256
        . $locale->text('Exchangerate') . qq|</th>
257
                <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>
258
|;
238
      $exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
239
                             <td><input name=exchangerate size=10 value=$form->{exchangerate}></td>\n|;
259 240
    }
260 241
  }
261
  $exchangerate .= qq|
262
<input type=hidden name=forex value=$form->{forex}>
263
|;
242
  $exchangerate .= qq| <input type=hidden name=forex value=$form->{forex}>\n|;
264 243

  
265 244
  my @old_project_ids = ($form->{"globalproject_id"});
266
  map({ push(@old_project_ids, $form->{"project_id_$_"})
267
          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
245
  map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
268 246

  
269
  $form->get_lists("contacts" => "ALL_CONTACTS",
270
                   "projects" => { "key" => "ALL_PROJECTS",
271
                                   "all" => 0,
247
  $form->get_lists("contacts"   => "ALL_CONTACTS",
248
                   "projects"   => { "key"  => "ALL_PROJECTS",
249
                                   "all"    => 0,
272 250
                                   "old_id" => \@old_project_ids },
273
                   "taxzones" => "ALL_TAXZONES",
274
                   "employees" => "ALL_SALESMEN",
251
                   "taxzones"   => "ALL_TAXZONES",
252
                   "employees"  => "ALL_SALESMEN",
275 253
                   "currencies" => "ALL_CURRENCIES",
276
                   "vendors" => "ALL_VENDORS");
254
                   "vendors"    => "ALL_VENDORS");
277 255

  
278 256
  my %labels;
279 257
  my @values = (undef);
280 258
  foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
281 259
    push(@values, $item->{"cp_id"});
282
    $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
283
      ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
260
    $labels{$item->{"cp_id"}} = $item->{"cp_name"} . ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
284 261
  }
285 262

  
286 263
  my $contact;
......
288 265
    $contact = qq|
289 266
    <tr>
290 267
      <th align="right">| . $locale->text('Contact Person') . qq|</th>
291
      <td>| .
292
      NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
293
                           '-labels' => \%labels, '-default' => $form->{"cp_id"}))
294
      . qq|
268
      <td>| .  NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
269
                                    '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq|
295 270
      </td>
296 271
    </tr>|;
297 272
  }
......
302 277
    push(@values, $item->{"id"});
303 278
    $labels{$item->{"id"}} = $item->{"projectnumber"};
304 279
  }
305
  my $globalprojectnumber =
306
    NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
307
                         '-labels' => \%labels,
308
                         '-default' => $form->{"globalproject_id"}));
280
  my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values, '-labels' => \%labels,
281
                                                 '-default' => $form->{"globalproject_id"}));
309 282
 
310 283
  %labels = ();
311 284
  @values = ();
......
321 294
    $currencies = qq|
322 295
    <tr>
323 296
      <th align="right">| . $locale->text('Currency') . qq|</th>
324
      <td>| .
325
        NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
326
                             '-values' => \@values, '-labels' => \%labels)) . qq|
297
      <td>| .  NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
298
                                    '-values' => \@values, '-labels' => \%labels)) . qq|
327 299
      </td>
328 300
    </tr>|;
329 301
  }
......
336 308
    $labels{$item->{"id"}} = $item->{"name"};
337 309
  }
338 310
  my $employees = qq|
339
      <tr>
311
    <tr>
340 312
      <th align="right">| . $locale->text('Employee') . qq|</th>
341
      <td>| .
342
        NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
343
                             '-values' => \@values, '-labels' => \%labels)) . qq|
313
      <td>| .  NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
314
                                    '-values' => \@values, '-labels' => \%labels)) . qq|
344 315
      </td>
345
      </tr>|;
316
    </tr>|;
346 317

  
347 318
  %labels = ();
348 319
  @values = ();
......
376 347
    $taxzone = qq|
377 348
    <tr>
378 349
      <th align="right">| . $locale->text('Steuersatz') . qq|</th>
379
      <td>| .
380
        NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
381
                             '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')) . qq|
350
      <td>| .  NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
351
                                    '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px')) . qq|
382 352
      </td>
383 353
    </tr>|;
384

  
385 354
  } else {
386 355
    $taxzone = qq|
387 356
    <tr>
......
394 363
  }
395 364

  
396 365
  $department = qq|
397
              <tr>
366
           <tr>
398 367
	      <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
399 368
	      <td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
400 369
	      <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
......
410 379

  
411 380
  $button1 = qq|
412 381
     <td><input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\">
413
      <input type=button name=invdate id="trigger1" value=|
414
    . $locale->text('button') . qq|></td>
415
     |;
382
      <input type=button name=invdate id="trigger1" value=| . $locale->text('button') . qq|></td>\n|;
416 383
  $button2 = qq|
417 384
     <td width="13"><input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}"  onBlur=\"check_right_date_format(this)\">
418
      <input type=button name=duedate id="trigger2" value=|
419
    . $locale->text('button') . qq|></td></td>
420
   |;
385
      <input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|></td></td>\n|;
421 386

  
422 387
  #write Trigger
423 388
  $jsscript =
......
428 393
  $form->{"javascript"} .= qq|<script type="text/javascript" src="js/common.js"></script>|;
429 394
  $form->{javascript}   .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
430 395

  
431
  $jsscript .=
432
    $form->write_trigger(\%myconfig, 2,
433
                         "orddate", "BL", "trigger_orddate",
434
                         "quodate", "BL", "trigger_quodate");
396
  $jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate");
435 397

  
436 398
  $form->header;
437 399
  $onload = qq|focus()|;
bin/mozilla/is.pl
279 279
sub form_header {
280 280
  $lxdebug->enter_sub();
281 281

  
282
  if ($form->{old_employee_id}) {
283
    $form->{employee_id} = $form->{old_employee_id};
284
  }
285
  if ($form->{old_salesman_id}) {
286
    $form->{salesman_id} = $form->{old_salesman_id};
287
  }
282
  $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
283
  $form->{salesman_id} = $form->{old_salesman_id} if $form->{old_salesman_id};
288 284

  
289 285
  if ($edit) {
290

  
291 286
    if ($form->{type} eq "credit_note") {
292 287
      $form->{title} = $locale->text('Edit Credit Note');
293

  
294
      if ($form->{storno}) {
295
        $form->{title} = $locale->text('Edit Storno Credit Note');
296
      }
288
      $form->{title} = $locale->text('Edit Storno Credit Note') if $form->{storno};
297 289
    } else {
298 290
      $form->{title} = $locale->text('Edit Sales Invoice');
299

  
300
      if ($form->{storno}) {
301
        $form->{title} = $locale->text('Edit Storno Invoice');
302
      }
291
      $form->{title} = $locale->text('Edit Storno Invoice')     if $form->{storno};
303 292
    }
304 293
  }
305 294
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
306
  $form->{radier} =
307
    ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
295
  $form->{radier}          = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
308 296

  
309 297
  $payment = qq|<option value=""></option>|;
310 298
  foreach $item (@{ $form->{payment_terms} }) {
......
315 303
    }
316 304
  }
317 305

  
318
  my $set_duedate_url =
319
    "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
306
  my $set_duedate_url = "$form->{script}?login=$form->{login}&password=$form->{password}&action=set_duedate";
320 307

  
321 308
  my $pjx = new CGI::Ajax( 'set_duedate' => $set_duedate_url );
322 309
  push(@ { $form->{AJAX} }, $pjx);
323 310

  
324 311
  my @old_project_ids = ($form->{"globalproject_id"});
325
  map({ push(@old_project_ids, $form->{"project_id_$_"})
326
          if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"}));
327

  
328
  $form->get_lists("contacts" => "ALL_CONTACTS",
329
                   "shipto" => "ALL_SHIPTO",
330
                   "projects" => { "key" => "ALL_PROJECTS",
331
                                   "all" => 0,
332
                                   "old_id" => \@old_project_ids },
333
                   "employees" => "ALL_SALESMEN",
334
                   "taxzones" => "ALL_TAXZONES",
312
  map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"};
313

  
314
  $form->get_lists("contacts"   => "ALL_CONTACTS",
315
                   "shipto"     => "ALL_SHIPTO",
316
                   "projects"   => { "key"    => "ALL_PROJECTS",
317
                                     "all"    => 0,
318
                                     "old_id" => \@old_project_ids },
319
                   "employees"  => "ALL_SALESMEN",
320
                   "taxzones"   => "ALL_TAXZONES",
335 321
                   "currencies" => "ALL_CURRENCIES",
336
                   "customers" => "ALL_CUSTOMERS");
322
                   "customers"  => "ALL_CUSTOMERS");
337 323

  
338 324
  my %labels;
339 325
  my @values = (undef);
340 326
  foreach my $item (@{ $form->{"ALL_CONTACTS"} }) {
341 327
    push(@values, $item->{"cp_id"});
342
    $labels{$item->{"cp_id"}} = $item->{"cp_name"} .
343
      ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
328
    $labels{$item->{"cp_id"}} = $item->{"cp_name"} .  ($item->{"cp_abteilung"} ? " ($item->{cp_abteilung})" : "");
344 329
  }
345 330
  my $contact;
346 331
  if (scalar @values > 1) {
347 332
    $contact = qq|
348 333
    <tr>
349 334
      <th align="right">| . $locale->text('Contact Person') . qq|</th>
350
      <td>| .
351
      NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
352
                           '-labels' => \%labels, '-default' => $form->{"cp_id"}))
353
      . qq|
335
      <td>| .  NTI($cgi->popup_menu('-name' => 'cp_id', '-values' => \@values, '-style' => 'width: 250px',
336
                                    '-labels' => \%labels, '-default' => $form->{"cp_id"})) . qq|
354 337
      </td>
355 338
    </tr>|;
356 339
  }
......
365 348
  my $employees = qq|
366 349
    <tr>
367 350
      <th align="right">| . $locale->text('Employee') . qq|</th>
368
      <td>| .
369
        NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
370
                             '-values' => \@values, '-labels' => \%labels)) . qq|
351
      <td>| . NTI($cgi->popup_menu('-name' => 'employee_id', '-default' => $form->{"employee_id"},
352
                                   '-values' => \@values, '-labels' => \%labels)) . qq|
371 353
      </td>
372 354
    </tr>|;
373 355

  
......
404 386
    $shipto = qq|
405 387
    <tr>
406 388
      <th align="right">| . $locale->text('Shipping Address') . qq|</th>
407
      <td>| .
408
      NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
409
                           '-labels' => \%labels, '-default' => $form->{"shipto_id"}))
410
    . qq|</td>|;
389
      <td>| . NTI($cgi->popup_menu('-name' => 'shipto_id', '-values' => \@values, '-style' => 'width: 250px',
390
                                   '-labels' => \%labels, '-default' => $form->{"shipto_id"})). qq|
391
      </td>|;
411 392
  }
412 393

  
413 394
  %labels = ();
......
423 404
    $currencies = qq|
424 405
    <tr>
425 406
      <th align="right">| . $locale->text('Currency') . qq|</th>
426
      <td>| .
427
        NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
428
                             '-values' => \@values, '-labels' => \%labels)) . qq|
407
      <td>| . NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
408
                                   '-values' => \@values, '-labels' => \%labels)) . qq|
429 409
      </td>
430 410
    </tr>|;
431 411
  }
......
436 416
    push(@values, $item->{"id"});
437 417
    $labels{$item->{"id"}} = $item->{"projectnumber"};
438 418
  }
439
  my $globalprojectnumber =
440
    NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
441
                         '-labels' => \%labels,
442
                         '-default' => $form->{"globalproject_id"}));
419
  my $globalprojectnumber = NTI($cgi->popup_menu('-name' => 'globalproject_id', '-values' => \@values,
420
                                                 '-labels' => \%labels,
421
                                                 '-default' => $form->{"globalproject_id"}));
443 422

  
444 423
  %labels = ();
445 424
  @values = ();
......
449 428
  }
450 429

  
451 430
  $salesman =
452
    qq|<tr>
453
          <th align="right">| . $locale->text('Salesman') . qq|</th>
454
          <td>| .
455
     NTI($cgi->popup_menu('-name' => 'salesman_id', '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id},
456
                          '-values' => \@values, '-labels' => \%labels))
457
     . qq|</td>
458
         </tr>|;
431
    qq|<tr> <th align="right">| . $locale->text('Salesman') . qq|</th>
432
         <td>| . NTI($cgi->popup_menu('-name' => 'salesman_id', '-values' => \@values, '-labels' => \%labels,
433
                                      '-default' => $form->{salesman_id} ? $form->{salesman_id} : $form->{employee_id})) . qq|
434
         </td>
435
       </tr>|;
459 436

  
460 437
  %labels = ();
461 438
  @values = ();
......
468 445
    $taxzone = qq|
469 446
    <tr>
470 447
      <th align="right">| . $locale->text('Steuersatz') . qq|</th>
471
      <td>| .
472
        NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
473
                             '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
448
      <td>| . NTI($cgi->popup_menu('-name' => 'taxzone_id', '-default' => $form->{"taxzone_id"},
449
                                   '-values' => \@values, '-labels' => \%labels, '-style' => 'width: 250px',)) . qq|
474 450
      </td>
475 451
    </tr>|;
476 452

  
......
488 464
  # set option selected
489 465
  foreach $item (qw(AR customer currency department employee)) {
490 466
    $form->{"select$item"} =~ s/ selected//;
491
    $form->{"select$item"} =~
492
      s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
467
    $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
493 468
  }
494 469

  
495 470
  if (($form->{creditlimit} != 0) && ($form->{creditremaining} < 0) && !$form->{update}) {
......
498 473
    $creditwarning = 0;
499 474
  }
500 475

  
501
  $form->{exchangerate} =
502
    $form->format_amount(\%myconfig, $form->{exchangerate});
503

  
504
  $form->{creditlimit} =
505
    $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
506
  $form->{creditremaining} =
507
    $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
476
  $form->{exchangerate}    = $form->format_amount(\%myconfig, $form->{exchangerate});
477
  $form->{creditlimit}     = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
478
  $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
508 479

  
509 480
  $exchangerate = "";
510 481
  if ($form->{currency} ne $form->{defaultcurrency}) {
511 482
    if ($form->{forex}) {
512
      $exchangerate .=
513
          qq|<th align="right">|
514
        . $locale->text('Exchangerate')
515
        . qq|</th><td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
483
      $exchangerate .= qq|<th align="right">| . $locale->text('Exchangerate') . qq|</th>
484
                          <td>$form->{exchangerate}<input type="hidden" name="exchangerate" value="$form->{exchangerate}"></td>|;
516 485
    } else {
517
      $exchangerate .=
518
          qq|<th align="right">|
519
        . $locale->text('Exchangerate')
520
        . qq|</th><td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
486
      $exchangerate .= qq|<th align="right">| . $locale->text('Exchangerate') . qq|</th>
487
                          <td><input name="exchangerate" size="10" value="$form->{exchangerate}"></td>|;
521 488
    }
522 489
  }
523
  $exchangerate .= qq|
524
<input type="hidden" name="forex" value="$form->{forex}">
525
|;
490
  $exchangerate .= qq|\n<input type="hidden" name="forex" value="$form->{forex}">\n|;
526 491

  
527 492
  $department = qq|
528 493
              <tr>
529 494
	        <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
530 495
		<td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
531
		<input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
496
                  <input type="hidden" name="selectdepartment" value="$form->{selectdepartment}">
532 497
		</td>
533 498
	      </tr>
534 499
| if $form->{selectdepartment};
......
604 569
  }
605 570

  
606 571
  if ($form->{resubmit} && ($form->{format} eq "html")) {
607
    $onload =
608
      qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
572
    $onload = qq|window.open('about:blank','Beleg'); document.invoice.target = 'Beleg';document.invoice.submit()|;
609 573
  } elsif ($form->{resubmit}) {
610 574
    $onload = qq|document.invoice.submit()|;
611 575
  } else {
bin/mozilla/oe.pl
2137 2137

  
2138 2138
    # also copy deliverydate from the order
2139 2139
    $form->{deliverydate} = $form->{reqdate} if $form->{reqdate};
2140
    $form->{orddate} = $form->{transdate};
2140
    $form->{orddate}      = $form->{transdate};
2141 2141
  } else {
2142 2142
    $form->isblank("quonumber", $locale->text('Quotation Number missing!'));
2143 2143
    $form->isblank("transdate", $locale->text('Quotation Date missing!'));
2144
    $form->{ordnumber} = "";
2145
    $form->{quodate} = $form->{transdate};
2144
    $form->{ordnumber}    = "";
2145
    $form->{quodate}      = $form->{transdate};
2146 2146
  }
2147 2147
  
2148
  if($form->{payment_id}) { 
2149
    $payment_id = $form->{payment_id};
2150
  }
2148
  $payment_id = $form->{payment_id} if $form->{payment_id};
2151 2149
  
2152 2150
  # if the name changed get new values
2153 2151
  if (&check_name($form->{vc})) {
2154
    if($form->{payment_id} eq "") { 
2155
      $form->{payment_id} = $payment_id;
2156
    }
2152
    $form->{payment_id} = $payment_id if $form->{payment_id} eq "";
2157 2153
    &update;
2158 2154
    exit;
2159 2155
  }
......
2161 2157
  $form->{cp_id} *= 1;
2162 2158

  
2163 2159
  for $i (1 .. $form->{rowcount}) {
2164
    map({ $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig,
2165
                                                     $form->{"${_}_${i}"})
2166
            if ($form->{"${_}_${i}"}) }
2167
        qw(ship qty sellprice listprice basefactor));
2160
    for (qw(ship qty sellprice listprice basefactor)) {
2161
      $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"};
2162
    }
2168 2163
  }
2169 2164

  
2170 2165
  if (   $form->{type} =~ /_order/
......
2174 2169
    $buysell = ($form->{type} eq 'sales_order') ? "buy" : "sell";
2175 2170

  
2176 2171
    $orddate      = $form->current_date(\%myconfig);
2177
    $exchangerate =
2178
      $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate,
2179
                                $buysell);
2172
    $exchangerate = $form->check_exchangerate(\%myconfig, $form->{currency}, $orddate, $buysell);
2180 2173

  
2181 2174
    if (!$exchangerate) {
2182 2175
      &backorder_exchangerate($orddate, $buysell);
......
2197 2190
  }
2198 2191

  
2199 2192
  $form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
2200
  $form->{duedate} =
2201
    $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2193
  $form->{duedate}   = $form->current_date(\%myconfig, $form->{invdate}, $form->{terms} * 1);
2202 2194

  
2203 2195
  $form->{id}     = '';
2204 2196
  $form->{closed} = 0;
......
2219 2211
    $script         = "ir";
2220 2212
    $buysell        = 'sell';
2221 2213
  }
2222
  if ($form->{type} eq 'sales_order' || $form->{type} eq 'sales_quotation') {
2214

  
2215
  if (   $form->{type} eq 'sales_order' 
2216
      || $form->{type} eq 'sales_quotation') {
2223 2217
    $form->{title}  = $locale->text('Add Sales Invoice');
2224 2218
    $form->{script} = 'is.pl';
2225 2219
    $script         = "is";
......
2227 2221
  }
2228 2222

  
2229 2223
  # bo creates the id, reset it
2230
  map { delete $form->{$_} }
2231
    qw(id subject message cc bcc printed emailed queued);
2224
  map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued);
2232 2225
  $form->{ $form->{vc} } =~ s/--.*//g;
2233 2226
  $form->{type} = "invoice";
2234 2227

  

Auch abrufbar als: Unified diff