Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 1668bc2d

Von Sven Schöling vor etwa 15 Jahren hinzugefügt

  • ID 1668bc2dc1d0ead3507a3713e820e251c6be4259
  • Vorgänger 9707dd46
  • Nachfolger 9fbf7096

ir strict

- $i und $invdate in post_payment sehen dodgy aus.

Unterschiede anzeigen:

bin/mozilla/ir.pl
43 43
require "bin/mozilla/common.pl";
44 44
require "bin/mozilla/drafts.pl";
45 45

  
46
use strict;
47

  
46 48
1;
47 49

  
48 50
# end of main
49 51

  
50 52
sub add {
51
  $lxdebug->enter_sub();
53
  $main::lxdebug->enter_sub();
54

  
55
  my $form     = $main::form;
56
  my $locale   = $main::locale;
52 57

  
53
  $auth->assert('vendor_invoice_edit');
58
  $main::auth->assert('vendor_invoice_edit');
54 59

  
55
  return $lxdebug->leave_sub() if (load_draft_maybe());
60
  return $main::lxdebug->leave_sub() if (load_draft_maybe());
56 61

  
57 62
  $form->{title} = $locale->text('Add Vendor Invoice');
58 63

  
......
60 65
  &prepare_invoice;
61 66
  &display_form;
62 67

  
63
  $lxdebug->leave_sub();
68
  $main::lxdebug->leave_sub();
64 69
}
65 70

  
66 71
sub edit {
67
  $lxdebug->enter_sub();
72
  $main::lxdebug->enter_sub();
68 73

  
69
  $auth->assert('vendor_invoice_edit');
74
  my $form     = $main::form;
75
  my $locale   = $main::locale;
76

  
77
  $main::auth->assert('vendor_invoice_edit');
70 78

  
71 79
  # show history button
72 80
  $form->{javascript} = qq|<script type=text/javascript src=js/show_history.js></script>|;
......
78 86
  &prepare_invoice;
79 87
  &display_form;
80 88

  
81
  $lxdebug->leave_sub();
89
  $main::lxdebug->leave_sub();
82 90
}
83 91

  
84 92
sub invoice_links {
85
  $lxdebug->enter_sub();
93
  $main::lxdebug->enter_sub();
94

  
95
  my $form     = $main::form;
96
  my %myconfig = %main::myconfig;
86 97

  
87
  $auth->assert('vendor_invoice_edit');
98
  $main::auth->assert('vendor_invoice_edit');
88 99

  
89 100
  # create links
90
  $form->{webdav}   = $webdav;
101
  $form->{webdav}   = $main::webdav;
91 102
  $form->{jsscript} = 1;
92 103

  
93 104
  $form->create_links("AP", \%myconfig, "vendor");
94 105

  
95 106
  #quote all_vendor Bug 133
96
  foreach $ref (@{ $form->{all_vendor} }) {
107
  foreach my $ref (@{ $form->{all_vendor} }) {
97 108
    $ref->{name} = $form->quote($ref->{name});
98 109
  }
99 110

  
......
102 113
      $form->{vendor_id} = $form->{all_vendor}->[0]->{id};
103 114
    }
104 115
  }
116

  
117
  my ($payment_id, $language_id, $taxzone_id);
105 118
  if ($form->{payment_id}) {
106 119
    $payment_id = $form->{payment_id};
107 120
  }
......
112 125
    $taxzone_id = $form->{taxzone_id};
113 126
  }
114 127

  
115
  $cp_id = $form->{cp_id};
128
  my $cp_id = $form->{cp_id};
116 129
  IR->get_vendor(\%myconfig, \%$form);
117 130
  IR->retrieve_invoice(\%myconfig, \%$form);
118 131
  $form->{cp_id} = $cp_id;
......
127 140
    $form->{taxzone_id} = $taxzone_id;
128 141
  }
129 142

  
143
  my @curr = split(/:/, $form->{currencies}); #seems to be missing
130 144
  map { $form->{selectcurrency} .= "<option>$_\n" } @curr;
131 145

  
132 146
  $form->{oldvendor} = "$form->{vendor}--$form->{vendor_id}";
......
144 158

  
145 159
  # forex
146 160
  $form->{forex} = $form->{exchangerate};
147
  $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
161
  my $exchangerate = ($form->{exchangerate}) ? $form->{exchangerate} : 1;
148 162

  
149
  foreach $key (keys %{ $form->{AP_links} }) {
163
  foreach my $key (keys %{ $form->{AP_links} }) {
150 164

  
151
    foreach $ref (@{ $form->{AP_links}{$key} }) {
165
    foreach my $ref (@{ $form->{AP_links}{$key} }) {
152 166
      $form->{"select$key"} .= "<option>$ref->{accno}--$ref->{description}\n";
153 167
    }
154 168

  
155 169
    if ($key eq "AP_paid") {
156
      for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
170
      for my $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
157 171
        $form->{"AP_paid_$i"} =
158 172
          "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
159 173

  
......
183 197
    ($form->datetonum($form->{invdate}, \%myconfig) <=
184 198
     $form->datetonum($form->{closedto}, \%myconfig));
185 199

  
186
  $lxdebug->leave_sub();
200
  $main::lxdebug->leave_sub();
187 201
}
188 202

  
189 203
sub prepare_invoice {
190
  $lxdebug->enter_sub();
204
  $main::lxdebug->enter_sub();
205

  
206
  my $form     = $main::form;
207
  my %myconfig = %main::myconfig;
191 208

  
192
  $auth->assert('vendor_invoice_edit');
209
  $main::auth->assert('vendor_invoice_edit');
193 210

  
194 211
  if ($form->{id}) {
195 212

  
196 213
    map { $form->{$_} =~ s/\"/&quot;/g } qw(invnumber ordnumber quonumber);
197 214

  
198 215
    my $i = 0;
199
    foreach $ref (@{ $form->{invoice_details} }) {
216
    foreach my $ref (@{ $form->{invoice_details} }) {
200 217
      $i++;
201 218
      map { $form->{"${_}_$i"} = $ref->{$_} } keys %{$ref};
202 219

  
203
      ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
220
      my ($dec) = ($form->{"sellprice_$i"} =~ /\.(\d+)/);
204 221
      $dec           = length $dec;
205
      $decimalplaces = ($dec > 2) ? $dec : 2;
222
      my $decimalplaces = ($dec > 2) ? $dec : 2;
206 223

  
207 224
      $form->{"sellprice_$i"} =
208 225
        $form->format_amount(\%myconfig, $form->{"sellprice_$i"},
......
218 235
    }
219 236
  }
220 237

  
221
  $lxdebug->leave_sub();
238
  $main::lxdebug->leave_sub();
222 239
}
223 240

  
224 241
sub form_header {
225
  $lxdebug->enter_sub();
242
  $main::lxdebug->enter_sub();
243

  
244
  my $form     = $main::form;
245
  my %myconfig = %main::myconfig;
246
  my $locale   = $main::locale;
247
  my $cgi      = $main::cgi;
226 248

  
227
  $auth->assert('vendor_invoice_edit');
249
  $main::auth->assert('vendor_invoice_edit');
228 250

  
229 251
  push @{ $form->{AJAX} }, CGI::Ajax->new('set_duedate_vendor' => "$form->{script}?action=set_duedate_vendor");
230 252

  
231 253
  # set option selected
232
  foreach $item (qw(AP vendor currency department)) {
254
  foreach my $item (qw(AP vendor currency department)) {
233 255
    $form->{"select$item"} =~ s/ selected//;
234 256
    $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
235 257
  }
......
242 264
  $form->{creditlimit}     = $form->format_amount(\%myconfig, $form->{creditlimit}, 0, "0");
243 265
  $form->{creditremaining} = $form->format_amount(\%myconfig, $form->{creditremaining}, 0, "0");
244 266

  
245
  $exchangerate = "";
267
  my $exchangerate = "";
246 268
  if ($form->{currency} ne $form->{defaultcurrency}) {
247 269
    if ($form->{forex}) {
248 270
      $exchangerate .= qq| <th align=right nowrap>| . $locale->text('Exchangerate') . qq|</th>
......
316 338

  
317 339
  %labels = ();
318 340
  @values = ();
319
  my $i = 0;
320 341
  foreach my $item (@{ $form->{"ALL_SALESMEN"} }) {
321 342
    push(@values, $item->{"id"});
322 343
    $labels{$item->{"id"}} = $item->{"name"};
......
331 352

  
332 353
  %labels = ();
333 354
  @values = ();
334
  my $i = 0;
335 355
  foreach my $item (@{ $form->{"ALL_VENDORS"} }) {
336 356
    push(@values, $item->{name}.qq|--|.$item->{"id"});
337 357
    $labels{$item->{name}.qq|--|.$item->{"id"}} = $item->{"name"};
......
357 377
    $labels{$item->{"id"}} = $item->{"description"};
358 378
  }
359 379

  
380
  my $taxzone;
360 381
  if (!$form->{"id"}) {
361 382
    $taxzone = qq|
362 383
    <tr>
......
376 397
    </tr>|;
377 398
  }
378 399

  
379
  $department = qq|
400
  my $department = qq|
380 401
           <tr>
381 402
	      <th align="right" nowrap>| . $locale->text('Department') . qq|</th>
382 403
	      <td colspan="3"><select name="department" style="width: 250px">$form->{selectdepartment}</select>
......
384 405
	      </td>
385 406
	    </tr>\n| if $form->{selectdepartment};
386 407

  
387
  $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
408
  my $n = ($form->{creditremaining} =~ /-/) ? "0" : "1";
388 409

  
389 410
  # use JavaScript Calendar or not
390 411
  $form->{jsscript} = 1;
391
  $jsscript = "";
412
  my $jsscript = "";
392 413

  
393
  $button1 = qq|
414
  my $button1 = qq|
394 415
     <td nowrap>
395 416
         <input name=invdate id=invdate size=11 title="$myconfig{dateformat}" value="$form->{invdate}" onBlur=\"check_right_date_format(this)\"
396 417
                onChange="if (this.value) set_duedate_vendor(['invdate__' + this.value, 'old_duedate__' + document.getElementsByName('duedate')[0].value, 'vendor_id__' + document.getElementsByName('vendor_id')[0].value],['duedate'])">
......
398 419
     </td>\n|;
399 420

  
400 421
#, 'old_duedate__'' + document.getElementsByName('duedate')[0].value, 'vendor_id__' + document.getElementsByName('vendor_id')[0].value],['duedate'])">
401
  $button2 = qq|
422
  my $button2 = qq|
402 423
     <td width="13" nowrap>
403 424
          <input name=duedate id=duedate size=11 title="$myconfig{dateformat}" value="$form->{duedate}"  onBlur=\"check_right_date_format(this)\">
404 425
          <input type=button name=duedate id="trigger2" value=| . $locale->text('button') . qq|>
......
422 443
  $jsscript .= $form->write_trigger(\%myconfig, 2, "orddate", "BL", "trigger_orddate", "quodate", "BL", "trigger_quodate");
423 444

  
424 445
  $form->header;
425
  $onload  = qq|focus()|;
446
  my $onload  = qq|focus()|;
426 447
  $onload .= qq|;setupDateFormat('|. $myconfig{dateformat} .qq|', '|. $locale->text("Falsches Datumsformat!") .qq|')|;
427 448
  $onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
428 449
  print qq|
......
509 530

  
510 531
$jsscript
511 532

  
512
<input type=hidden name=webdav value=$webdav>
533
<input type=hidden name=webdav value=$main::webdav>
513 534
|;
514 535

  
515
  foreach $item (split / /, $form->{taxaccounts}) {
536
  foreach my $item (split / /, $form->{taxaccounts}) {
516 537
    print qq|
517 538
<input type=hidden name="${item}_rate" value=$form->{"${item}_rate"}>
518 539
<input type=hidden name="${item}_description" value="$form->{"${item}_description"}">
519 540
|;
520 541
  }
521 542

  
522
  $lxdebug->leave_sub();
543
  $main::lxdebug->leave_sub();
523 544
}
524 545

  
525 546
sub form_footer {
526
  $lxdebug->enter_sub();
547
  $main::lxdebug->enter_sub();
548

  
549
  my $form     = $main::form;
550
  my %myconfig = %main::myconfig;
551
  my $locale   = $main::locale;
552
  my $cgi      = $main::cgi;
527 553

  
528
  $auth->assert('vendor_invoice_edit');
554
  $main::auth->assert('vendor_invoice_edit');
529 555

  
530 556
  $form->{invtotal} = $form->{invsubtotal};
531 557

  
558
  my ($rows, $introws);
532 559
  if (($rows = $form->numtextrows($form->{notes}, 25, 8)) < 2) {
533 560
    $rows = 2;
534 561
  }
......
536 563
    $introws = 2;
537 564
  }
538 565
  $rows = ($rows > $introws) ? $rows : $introws;
539
  $notes =
566
  my $notes =
540 567
    qq|<textarea name=notes rows=$rows cols=25 wrap=soft>$form->{notes}</textarea>|;
541
  $intnotes =
568
  my $intnotes =
542 569
    qq|<textarea name=intnotes rows=$rows cols=35 wrap=soft>$form->{intnotes}</textarea>|;
543 570

  
544 571
  $form->{taxincluded} = ($form->{taxincluded}) ? "checked" : "";
545 572

  
546
  $taxincluded = "";
573
  my $taxincluded = "";
547 574
  if ($form->{taxaccounts}) {
548 575
    $taxincluded = qq|
549 576
		<input name=taxincluded class=checkbox type=checkbox value=1 $form->{taxincluded}> <b>|
......
551 578
|;
552 579
  }
553 580

  
581
  my ($tax, $subtotal);
554 582
  if (!$form->{taxincluded}) {
555 583

  
556
    foreach $item (split / /, $form->{taxaccounts}) {
584
    foreach my $item (split / /, $form->{taxaccounts}) {
557 585
      if ($form->{"${item}_base"}) {
558 586
        $form->{invtotal} += $form->{"${item}_total"} =
559 587
          $form->round_amount(
......
585 613
  }
586 614

  
587 615
  if ($form->{taxincluded}) {
588
    foreach $item (split / /, $form->{taxaccounts}) {
616
    foreach my $item (split / /, $form->{taxaccounts}) {
589 617
      if ($form->{"${item}_base"}) {
590 618
        $form->{"${item}_total"} =
591 619
          $form->round_amount(
......
638 666
    }
639 667
  }
640 668

  
669
  our $colspan;
641 670
  print qq|
642 671
  <tr>
643 672
    <td colspan=$colspan>
......
673 702
    </td>
674 703
  </tr>
675 704
|;
676
  if ($webdav) {
705
  my $webdav_list;
706
  if ($main::webdav) {
677 707
    $webdav_list = qq|
678 708
  <tr>
679 709
    <td><hr size=3 noshade></td>
......
685 715
      <td align=left width=30%><b>Dateiname</b></td>
686 716
      <td align=left width=70%><b>Webdavlink</b></td>
687 717
|;
688
    foreach $file (@{ $form->{WEBDAV} }) {
718
    foreach my $file (@{ $form->{WEBDAV} }) {
689 719
      $webdav_list .= qq|
690 720
      <tr>
691 721
        <td align="left">$file->{name}</td>
......
709 739
	</tr>
710 740
|;
711 741

  
742
  my @column_index;
712 743
  if ($form->{currency} eq $form->{defaultcurrency}) {
713 744
    @column_index = qw(datepaid source memo paid AP_paid);
714 745
  } else {
715 746
    @column_index = qw(datepaid source memo paid exchangerate AP_paid);
716 747
  }
717 748

  
749
  my %column_data;
718 750
  $column_data{datepaid}     = "<th>" . $locale->text('Date') . "</th>";
719 751
  $column_data{paid}         = "<th>" . $locale->text('Amount') . "</th>";
720 752
  $column_data{exchangerate} = "<th>" . $locale->text('Exch') . "</th>";
......
734 766
  my $totalpaid = 0;
735 767

  
736 768
  $form->{paidaccounts}++ if ($form->{"paid_$form->{paidaccounts}"});
737
  for $i (1 .. $form->{paidaccounts}) {
769
  for my $i (1 .. $form->{paidaccounts}) {
738 770

  
739 771
    print qq|
740 772
	<tr>
......
754 786
    $form->{"exchangerate_$i"} =
755 787
      $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
756 788

  
757
    $exchangerate = qq|&nbsp;|;
789
    my $exchangerate = qq|&nbsp;|;
758 790
    if ($form->{currency} ne $form->{defaultcurrency}) {
759 791
      if ($form->{"forex_$i"}) {
760 792
        $exchangerate =
......
818 850
<br>
819 851
|;
820 852

  
821
  $invdate  = $form->datetonum($form->{invdate},  \%myconfig);
822
  $closedto = $form->datetonum($form->{closedto}, \%myconfig);
853
  my $invdate  = $form->datetonum($form->{invdate},  \%myconfig);
854
  my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
823 855

  
824 856
  print qq|<input class=submit type=submit name=action id=update_button value="|
825 857
    . $locale->text('Update') . qq|">
......
880 912
</html>
881 913
|;
882 914

  
883
  $lxdebug->leave_sub();
915
  $main::lxdebug->leave_sub();
884 916
}
885 917

  
886 918
sub mark_as_paid {
887
  $lxdebug->enter_sub();
919
  $main::lxdebug->enter_sub();
920

  
921
  my $form     = $main::form;
922
  my %myconfig = %main::myconfig;
888 923

  
889
  $auth->assert('vendor_invoice_edit');
924
  $main::auth->assert('vendor_invoice_edit');
890 925

  
891 926
  &mark_as_paid_common(\%myconfig,"ap");
892 927

  
893
  $lxdebug->leave_sub();
928
  $main::lxdebug->leave_sub();
894 929
}
895 930

  
896 931
sub update {
897
  $lxdebug->enter_sub();
932
  $main::lxdebug->enter_sub();
933

  
934
  my $form     = $main::form;
935
  my %myconfig = %main::myconfig;
898 936

  
899
  $auth->assert('vendor_invoice_edit');
937
  $main::auth->assert('vendor_invoice_edit');
900 938

  
901 939
  map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) } qw(exchangerate creditlimit creditremaining);
902 940

  
903
  &check_name(vendor);
941
  &check_name('vendor');
904 942

  
905 943
  $form->{forex}        = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'sell');
906 944
  $form->{exchangerate} = $form->{forex} if $form->{forex};
907 945

  
908
  for $i (1 .. $form->{paidaccounts}) {
946
  for my $i (1 .. $form->{paidaccounts}) {
909 947
    next unless $form->{"paid_$i"};
910 948
    map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
911 949
    $form->{"forex_$i"}        = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'sell');
912 950
    $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"};
913 951
  }
914 952

  
915
  $i            = $form->{rowcount};
916
  $exchangerate = ($form->{exchangerate} * 1) || 1;
953
  my $i            = $form->{rowcount};
954
  my $exchangerate = ($form->{exchangerate} * 1) || 1;
917 955

  
918 956
  if (   ($form->{"partnumber_$i"} eq "")
919 957
      && ($form->{"description_$i"} eq "")
......
938 976
      } else {
939 977

  
940 978
        # override sellprice if there is one entered
941
        $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
979
        my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
942 980

  
943 981
	# ergaenzung fuer bug 736 Lieferanten-Rabatt auch in Einkaufsrechnungen vorbelegen jb
944
        $form->{"discount_$i"} = $form->format_amount(\%myconfig, 
982
        $form->{"discount_$i"} = $form->format_amount(\%myconfig,
945 983
						      $form->{vendor_discount} * 100 );
946 984
        map { $form->{item_list}[$i]{$_} =~ s/\"/&quot;/g } qw(partnumber description unit);
947 985
        map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
......
949 987
        $form->{"marge_price_factor_$i"} = $form->{item_list}->[0]->{price_factor};
950 988

  
951 989
        ($sellprice || $form->{"sellprice_$i"}) =~ /\.(\d+)/;
952
        $decimalplaces = max 2, length $1;
990
        my $dec_qty       = length $1;
991
        my $decimalplaces = max 2, $dec_qty;
953 992

  
954 993
        if ($sellprice) {
955 994
          $form->{"sellprice_$i"} = $sellprice;
......
958 997
          $form->{"sellprice_$i"} /= $exchangerate;
959 998
        }
960 999

  
961
        $amount                   = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
1000
        my $amount                   = $form->{"sellprice_$i"} * $form->{"qty_$i"} * (1 - $form->{"discount_$i"} / 100);
962 1001
        $form->{creditremaining} -= $amount;
963 1002
        $form->{"sellprice_$i"}   = $form->format_amount(\%myconfig, $form->{"sellprice_$i"}, $decimalplaces);
964 1003
        $form->{"qty_$i"}         = $form->format_amount(\%myconfig, $form->{"qty_$i"},       $dec_qty);
......
984 1023
      }
985 1024
    }
986 1025
  }
987
  $lxdebug->leave_sub();
1026
  $main::lxdebug->leave_sub();
988 1027
}
989 1028

  
990 1029
sub storno {
991
  $lxdebug->enter_sub();
1030
  $main::lxdebug->enter_sub();
1031

  
1032
  my $form     = $main::form;
1033
  my %myconfig = %main::myconfig;
1034
  my $locale   = $main::locale;
992 1035

  
993
  $auth->assert('vendor_invoice_edit');
1036
  $main::auth->assert('vendor_invoice_edit');
994 1037

  
995 1038
  if ($form->{storno}) {
996 1039
    $form->error($locale->text('Cannot storno storno invoice!'));
......
1024 1067
  $form->{rowcount}++;
1025 1068
  $form->{employee_id} = $employee_id;
1026 1069
  post();
1027
  $lxdebug->leave_sub();
1070
  $main::lxdebug->leave_sub();
1028 1071

  
1029 1072
}
1030 1073

  
1031 1074
sub use_as_template {
1032
  $lxdebug->enter_sub();
1075
  $main::lxdebug->enter_sub();
1033 1076

  
1034
  $auth->assert('vendor_invoice_edit');
1077
  my $form     = $main::form;
1078
  my %myconfig = %main::myconfig;
1079

  
1080
  $main::auth->assert('vendor_invoice_edit');
1035 1081

  
1036 1082
  map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
1037 1083
  $form->{paidaccounts} = 1;
......
1039 1085
  $form->{invdate} = $form->current_date(\%myconfig);
1040 1086
  &display_form;
1041 1087

  
1042
  $lxdebug->leave_sub();
1088
  $main::lxdebug->leave_sub();
1043 1089
}
1044 1090

  
1045 1091
sub post_payment {
1046
  $lxdebug->enter_sub();
1092
  $main::lxdebug->enter_sub();
1093

  
1094
  my $form     = $main::form;
1095
  my %myconfig = %main::myconfig;
1096
  my $locale   = $main::locale;
1047 1097

  
1048
  $auth->assert('vendor_invoice_edit');
1098
  $main::auth->assert('vendor_invoice_edit');
1049 1099

  
1050 1100
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
1051
  for $i (1 .. $form->{paidaccounts}) {
1101
  for my $i (1 .. $form->{paidaccounts}) {
1052 1102
    if ($form->{"paid_$i"}) {
1053
      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1103
      my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1054 1104

  
1055 1105
      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1056 1106

  
......
1058 1108
        if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
1059 1109

  
1060 1110
      if ($form->{currency} ne $form->{defaultcurrency}) {
1061
        $form->{"exchangerate_$i"} = $form->{exchangerate}
1062
          if ($invdate == $datepaid);
1063
        $form->isblank("exchangerate_$i",
1064
                       $locale->text('Exchangerate for payment missing!'));
1111
#        $form->{"exchangerate_$i"} = $form->{exchangerate} if ($invdate == $datepaid); # invdate isn't set here
1112
        $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!'));
1065 1113
      }
1066 1114
    }
1067 1115
  }
......
1083 1131

  
1084 1132
  $form->error($locale->text('Cannot post payment!'));
1085 1133

  
1086
  $lxdebug->leave_sub();
1134
  $main::lxdebug->leave_sub();
1087 1135
}
1088 1136

  
1089 1137
sub post {
1090
  $lxdebug->enter_sub();
1138
  $main::lxdebug->enter_sub();
1139

  
1140
  my $form     = $main::form;
1141
  my %myconfig = %main::myconfig;
1142
  my $locale   = $main::locale;
1091 1143

  
1092
  $auth->assert('vendor_invoice_edit');
1144
  $main::auth->assert('vendor_invoice_edit');
1093 1145

  
1094 1146
  $form->{defaultcurrency} = $form->get_default_currency(\%myconfig);
1095 1147

  
......
1101 1153
  $form->{invnumber} =~ s/\s*$//g;
1102 1154

  
1103 1155
  # if the vendor changed get new values
1104
  if (&check_name(vendor)) {
1156
  if (&check_name('vendor')) {
1105 1157
    &update;
1106 1158
    exit;
1107 1159
  }
1108 1160

  
1109 1161
  &validate_items;
1110 1162

  
1111
  $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1112
  $invdate  = $form->datetonum($form->{invdate},  \%myconfig);
1163
  my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
1164
  my $invdate  = $form->datetonum($form->{invdate},  \%myconfig);
1165
  my $i        = $form->{rowcount};
1113 1166

  
1114 1167
  $form->error($locale->text('Cannot post invoice for a closed period!'))
1115 1168
    if ($form->date_closed($form->{"datepaid_$i"}, \%myconfig));
......
1119 1172

  
1120 1173
  for $i (1 .. $form->{paidaccounts}) {
1121 1174
    if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) {
1122
      $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1175
      my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig);
1123 1176

  
1124 1177
      $form->isblank("datepaid_$i", $locale->text('Payment date missing!'));
1125 1178

  
......
1159 1212
  }
1160 1213
  $form->error($locale->text('Cannot post invoice!'));
1161 1214

  
1162
  $lxdebug->leave_sub();
1215
  $main::lxdebug->leave_sub();
1163 1216
}
1164 1217

  
1165 1218
sub delete {
1166
  $lxdebug->enter_sub();
1219
  $main::lxdebug->enter_sub();
1167 1220

  
1168
  $auth->assert('vendor_invoice_edit');
1221
  my $form     = $main::form;
1222
  my $locale   = $main::locale;
1223

  
1224
  $main::auth->assert('vendor_invoice_edit');
1169 1225

  
1170 1226
  $form->header;
1171 1227
  print qq|
......
1177 1233
  # delete action variable
1178 1234
  map { delete $form->{$_} } qw(action header);
1179 1235

  
1180
  foreach $key (keys %$form) {
1236
  foreach my $key (keys %$form) {
1181 1237
    next if (($key eq 'login') || ($key eq 'password') || ('' ne ref $form->{$key}));
1182 1238
    $form->{$key} =~ s/\"/&quot;/g;
1183 1239
    print qq|<input type=hidden name=$key value="$form->{$key}">\n|;
......
1195 1251
</form>
1196 1252
|;
1197 1253

  
1198
  $lxdebug->leave_sub();
1254
  $main::lxdebug->leave_sub();
1199 1255
}
1200 1256

  
1201 1257
sub yes {
1202
  $lxdebug->enter_sub();
1258
  $main::lxdebug->enter_sub();
1259

  
1260
  my $form     = $main::form;
1261
  my %myconfig = %main::myconfig;
1262
  my $locale   = $main::locale;
1203 1263

  
1204
  $auth->assert('vendor_invoice_edit');
1264
  $main::auth->assert('vendor_invoice_edit');
1205 1265

  
1206 1266
  if (IR->delete_invoice(\%myconfig, \%$form)) {
1207 1267
    # saving the history
......
1215 1275
  }
1216 1276
  $form->error($locale->text('Cannot delete invoice!'));
1217 1277

  
1218
  $lxdebug->leave_sub();
1278
  $main::lxdebug->leave_sub();
1219 1279
}
1220 1280

  
1221 1281
sub set_duedate_vendor {
1222
  $lxdebug->enter_sub();
1282
  $main::lxdebug->enter_sub();
1283

  
1284
  my $form     = $main::form;
1223 1285

  
1224 1286
  print $form->ajax_response_header(), IR->get_duedate('vendor_id' => $form->{vendor_id},
1225 1287
                                                       'invdate'   => $form->{invdate},
1226 1288
                                                       'default'   => $form->{old_duedate});
1227 1289

  
1228
  $lxdebug->leave_sub();
1290
  $main::lxdebug->leave_sub();
1229 1291
}

Auch abrufbar als: Unified diff