Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4aa81611

Von Bernd Blessmann vor etwa 13 Jahren hinzugefügt

  • ID 4aa816112a8b9f2d2959c92cfaa2f2954bdeceb2
  • Vorgänger 1f42dfbe
  • Nachfolger e87f4016

Änderbarkeit der Zahlungen bei Debitorenbuchungen konfigurierbar

Unterschiede anzeigen:

SL/AR.pm
201 201

  
202 202
  # add paid transactions
203 203
  for my $i (1 .. $form->{paidaccounts}) {
204

  
205
    if ($form->{"acc_trans_id_$i"} && $payments_only && ($::lx_office_conf{features}->{payments_changeable} == 0)) {
206
      next;
207
    }
208

  
204 209
    if ($form->{"paid_$i"} != 0) {
205 210
      my $project_id = conv_i($form->{"paid_project_id_$i"});
206 211

  
......
229 234
      }
230 235

  
231 236
      if ($form->{"paid_$i"} != 0) {
232
        my $project_id = conv_i($form->{"paid_project_id_$i"});
233 237
        # add payment
238
        my $project_id = conv_i($form->{"paid_project_id_$i"});
239
        my $gldate = (conv_date($form->{"gldate_$i"}))? conv_date($form->{"gldate_$i"}) : conv_date($form->current_date($myconfig));
234 240
        $amount = $form->{"paid_$i"} * -1;
235
        $query  = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey)
236
                     VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?))|;
237
        @values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"});
241
        $query  = qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, gldate, source, memo, project_id, taxkey)
242
                     VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, ?, ?, ?, ?, (SELECT taxkey_id FROM chart WHERE accno = ?))|;
243
        @values = (conv_i($form->{id}), $form->{AR}{"paid_$i"}, $amount, conv_date($form->{"datepaid_$i"}), $gldate, $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $form->{AR}{"paid_$i"});
238 244
        do_query($form, $dbh, $query, @values);
239 245

  
240 246
        # exchangerate difference for payment
......
328 334
  $old_form = save_form();
329 335

  
330 336
  # Delete all entries in acc_trans from prior payments.
331
  $self->_delete_payments($form, $dbh);
337
  if ($::lx_office_conf{features}->{payments_changeable} != 0) {
338
    $self->_delete_payments($form, $dbh);
339
  }
332 340

  
333 341
  # Save the new payments the user made before cleaning up $form.
334
  my $payments_re = '^datepaid_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AR_paid_\d+$|^paidaccounts$';
342
  my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^acc_trans_id_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AR_paid_\d+$|^paidaccounts$';
335 343
  map { $payments{$_} = $form->{$_} } grep m/$payments_re/, keys %{ $form };
336 344

  
337 345
  # Clean up $form so that old content won't tamper the results.
......
573 581
        $j++;
574 582
        $form->{"AR_paid_$j"} = $form->{acc_trans}{$key}->[$i-1]->{accno};
575 583

  
584
        $form->{"acc_trans_id_$j"}    = $form->{acc_trans}{$key}->[$i - 1]->{acc_trans_id};
576 585
        # reverse paid
577 586
        $form->{"paid_$j"}            = $form->{acc_trans}{$key}->[$i - 1]->{amount} * -1;
578 587
        $form->{"datepaid_$j"}        = $form->{acc_trans}{$key}->[$i - 1]->{transdate};
588
        $form->{"gldate_$j"}          = $form->{acc_trans}{$key}->[$i - 1]->{gldate};
579 589
        $form->{"source_$j"}          = $form->{acc_trans}{$key}->[$i - 1]->{source};
580 590
        $form->{"memo_$j"}            = $form->{acc_trans}{$key}->[$i - 1]->{memo};
581 591
        $form->{"forex_$j"}           = $form->{acc_trans}{$key}->[$i - 1]->{exchangerate};
bin/mozilla/ar.pl
734 734
        $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
735 735
    }
736 736

  
737
    print qq|<input type=hidden name="acc_trans_id_$i" value=$form->{"acc_trans_id_$i"}>\n|;
738
    print qq|<input type=hidden name="gldate_$i" value=$form->{"gldate_$i"}>\n|;
739
    my $changeable = 1;
740
    if ($::lx_office_conf{features}->{payments_changeable} == 0) {
741
      # never
742
      $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
743
    }
744
    if ($::lx_office_conf{features}->{payments_changeable} == 2) {
745
      # on the same day
746
      $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
747
    }
748

  
737 749
    $exchangerate = qq|&nbsp;|;
738 750
    if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
739 751
      if ($form->{"forex_$i"}) {
740 752
        $exchangerate =
741 753
          qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
742 754
      } else {
743
        $exchangerate =
744
          qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
755
        if ($changeable) {
756
          $exchangerate =
757
            qq|<input name="exchangerate_$i" size=10 value=$form->{"exchangerate_$i"}>|;
758
        } else {
759
          $exchangerate =
760
            qq|<input type=hidden name="exchangerate_$i" value=$form->{"exchangerate_$i"}>$form->{"exchangerate_$i"}|;
761
        }
745 762
      }
746 763
    }
747 764

  
......
749 766
<input type=hidden name="forex_$i" value=$form->{"forex_$i"}>
750 767
|;
751 768

  
752
    $column_data{paid} =
753
      qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
754
    $column_data{AR_paid} =
755
      qq|<td align=center>${selectAR_paid}</td>|;
756
    $column_data{exchangerate} = qq|<td align=center>$exchangerate</td>|;
757
    $column_data{datepaid}     =
758
      qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
769
    my $datepaid;
770
    if ($changeable) {
771
      $datepaid = qq|<td align=center><input name="datepaid_$i" id="datepaid_$i" size=11 value="$form->{"datepaid_$i"}" onBlur=\"check_right_date_format(this)\">
759 772
         <input type="button" name="datepaid_$i" id="trigger_datepaid_$i" value="?"></td>|;
760
    $column_data{source} =
761
      qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
762
    $column_data{memo} =
763
      qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
773
    } else {
774
      $datepaid = qq|<td align=center>$form->{"datepaid_$i"}</td>|.
775
        qq|<input type=hidden name="datepaid_$i" value=$form->{"datepaid_$i"}>|;
776
    }
777

  
778
    my $paid;
779
    if ($changeable) {
780
      $paid = qq|<td align=center><input name="paid_$i" size=11 value="$form->{"paid_$i"}" onBlur=\"check_right_number_format(this)\"></td>|;
781
    } else {
782
      $paid = qq|<td align=center>$form->{"paid_$i"}</td>|.
783
        qq|<input type=hidden name="paid_$i" value=$form->{"paid_$i"}>|;
784
    }
785

  
786
    my $source;
787
    if ($changeable) {
788
      $source = qq|<td align=center><input name="source_$i" size=11 value="$form->{"source_$i"}"></td>|;
789
    } else {
790
      $source = qq|<td align=center>$form->{"source_$i"}</td>|.
791
        qq|<input type=hidden name="source_$i" value=$form->{"source_$i"}>|;
792
    }
793

  
794
    my $memo;
795
    if ($changeable) {
796
      $memo = qq|<td align=center><input name="memo_$i" size=11 value="$form->{"memo_$i"}"></td>|;
797
    } else {
798
      $memo = qq|<td align=center>$form->{"memo_$i"}</td>|.
799
        qq|<input type=hidden name="memo_$i" value=$form->{"memo_$i"}>|;
800
    }
801

  
802
    my $AR_paid;
803
    if ($changeable) {
804
      $AR_paid = qq|<td align=center>${selectAR_paid}</td>|;
805
    } else {
806
      $AR_paid = qq|<td align=center>$form->{"AR_paid_$i"}</td>|.
807
        qq|<input type=hidden name="AR_paid_$i" value=$form->{"AR_paid_$i"}>|;
808
    }
764 809

  
765
    $column_data{paid_project_id} =
810
    my $paid_project_id;
811
    if ($changeable) {
812
      $paid_project_id =
766 813
      qq|<td>|
767 814
      . NTI($cgi->popup_menu('-name' => "paid_project_id_$i",
768 815
                             '-values' => \@project_values,
769 816
                             '-labels' => \%project_labels,
770 817
                             '-default' => $form->{"paid_project_id_$i"} ))
771 818
      . qq|</td>|;
819
    } else {
820
      my $projectnumber = $project_labels{$form->{"paid_project_id_$i"}};
821
      $paid_project_id = qq|<td>$projectnumber</td>|.
822
        qq|<input type=hidden name="paid_project_id_$i" value=$form->{"paid_project_id_$i"}>|;
823
    }
824

  
825
    $column_data{paid}            = $paid;
826
    $column_data{AR_paid}         = $AR_paid;
827
    $column_data{exchangerate}    = qq|<td align=center>$exchangerate</td>|;
828
    $column_data{datepaid}        = $datepaid;
829
    $column_data{source}          = $source;
830
    $column_data{memo}            = $memo;
831
    $column_data{paid_project_id} = $paid_project_id;
772 832

  
773 833
    map { print qq|$column_data{$_}\n| } @column_index;
774 834

  
775 835
    print "
776 836
        </tr>
777 837
";
778
    push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
838
    if ($changeable) {
839
      push(@triggers, "datepaid_$i", "BL", "trigger_datepaid_$i");
840
    }
779 841
  }
780 842

  
781 843
  my $paid_missing = $form->{invtotal_unformatted} - $form->{totalpaid};
......
1185 1247
  my $form     = $main::form;
1186 1248
  my %myconfig = %main::myconfig;
1187 1249

  
1188
  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);
1250
  map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
1189 1251
  $form->{paidaccounts} = 1;
1190 1252
  $form->{rowcount}--;
1191 1253
  $form->{invdate} = $form->current_date(\%myconfig);

Auch abrufbar als: Unified diff