Änderbarkeit bei Zahlungen f. Kreditorenbuchungen konfigurierbar machen.
authorBernd Blessmann <bibi@online.de>
Wed, 31 Aug 2011 13:28:51 +0000 (15:28 +0200)
committerBernd Blessmann <bibi@online.de>
Thu, 1 Sep 2011 11:53:10 +0000 (13:53 +0200)
Nie, immer oder am selben Tag, einstellbar in der lx_office.conf

SL/AP.pm
SL/Form.pm
bin/mozilla/ap.pl
config/lx_office.conf.default

index 7b0bc12..2f52c62 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -249,6 +249,11 @@ sub post_transaction {
 
   # add paid transactions
   for my $i (1 .. $form->{paidaccounts}) {
+
+    if ($form->{"acc_trans_id_$i"} && $payments_only &&  ($::lx_office_conf{features}->{payments_changeable} == 0)) {
+      next;
+    }
+
     if ($form->{"paid_$i"} != 0) {
       my $project_id = conv_i($form->{"paid_project_id_$i"});
 
@@ -566,10 +571,12 @@ sub post_payment {
   $old_form = save_form();
 
   # Delete all entries in acc_trans from prior payments.
-  $self->_delete_payments($form, $dbh);
+  if ($::lx_office_conf{features}->{payments_changeable} != 0) {
+    $self->_delete_payments($form, $dbh);
+  }
 
   # Save the new payments the user made before cleaning up $form.
-  my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AP_paid_\d+$|^paidaccounts$';
+  my $payments_re = '^datepaid_\d+$|^gldate_\d+$|^acc_trans_id_\d+$|^memo_\d+$|^source_\d+$|^exchangerate_\d+$|^paid_\d+$|^paid_project_id_\d+$|^AP_paid_\d+$|^paidaccounts$';
   map { $payments{$_} = $form->{$_} } grep m/$payments_re/, keys %{ $form };
 
   # Clean up $form so that old content won't tamper the results.
@@ -648,6 +655,7 @@ sub setup_form {
       if ($key eq "AP_paid") {
         $j++;
         $form->{"AP_paid_$j"}         = "$form->{acc_trans}{$key}->[$i-1]->{accno}--$form->{acc_trans}{$key}->[$i-1]->{description}";
+        $form->{"acc_trans_id_$j"}    = $form->{acc_trans}{$key}->[$i - 1]->{acc_trans_id};
         $form->{"paid_$j"}            = $form->{acc_trans}{$key}->[$i - 1]->{amount};
         $form->{"datepaid_$j"}        = $form->{acc_trans}{$key}->[$i - 1]->{transdate};
         $form->{"gldate_$j"}          = $form->{acc_trans}{$key}->[$i - 1]->{gldate};
index e841771..409bcd6 100644 (file)
@@ -842,6 +842,7 @@ sub _prepare_html_template {
   $additional_params->{"conf_parts_image_css"}        = $::lx_office_conf{features}->{parts_image_css};
   $additional_params->{"conf_parts_listing_images"}   = $::lx_office_conf{features}->{parts_listing_images};
   $additional_params->{"conf_parts_show_image"}       = $::lx_office_conf{features}->{parts_show_image};
+  $additional_params->{"conf_payments_changeable"}    = $::lx_office_conf{features}->{payments_changeable};
   $additional_params->{"INSTANCE_CONF"}               = $::instance_conf;
 
   if (%main::debug_options) {
@@ -2991,7 +2992,7 @@ sub create_links {
     $query =
       qq|SELECT
            c.accno, c.description,
-           a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey,
+           a.acc_trans_id, a.source, a.amount, a.memo, a.transdate, a.gldate, a.cleared, a.project_id, a.taxkey,
            p.projectnumber,
            t.rate, t.id
          FROM acc_trans a
index bc2986c..c974608 100644 (file)
@@ -693,10 +693,17 @@ $jsscript
         $form->format_amount(\%myconfig, $form->{"exchangerate_$i"});
     }
 
+    print qq|<input type=hidden name="acc_trans_id_$i" value=$form->{"acc_trans_id_$i"}>\n|;
     print qq|<input type=hidden name="gldate_$i" value=$form->{"gldate_$i"}>\n|;
-    my $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
-    $form->{"payment_readonly_$i"} = ($changeable)? 0 : 1;
-    print qq|<input type=hidden name="payment_readonly_$i" value=$form->{"payment_readonly_$i"}>\n|;
+    my $changeable = 1;
+    if ($::lx_office_conf{features}->{payments_changeable} == 0) {
+      # never
+      $changeable = ($form->{"acc_trans_id_$i"})? 0 : 1;
+    }
+    if ($::lx_office_conf{features}->{payments_changeable} == 2) {
+      # on the same day
+      $changeable = (($form->{"gldate_$i"} eq '') || $form->current_date(\%myconfig) eq $form->{"gldate_$i"});
+    }
 
     $exchangerate = qq|&nbsp;|;
     if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) {
@@ -1183,7 +1190,7 @@ sub use_as_template {
 
   $main::auth->assert('general_ledger');
 
-  map { delete $form->{$_} } qw(printed emailed queued invnumber invdate deliverydate id datepaid_1 gldate_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno);
+  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);
   $form->{paidaccounts} = 1;
   $form->{rowcount}--;
   $form->{invdate} = $form->current_date(\%myconfig);
index 9df72a4..b0c3e66 100644 (file)
@@ -86,6 +86,9 @@ parts_image_css = border:0;float:left;max-width:250px;margin-top:20px:margin-rig
 # Show the picture in the results when you search for parts
 parts_listing_images = 0
 
+# Should payments be changeable after posting (0 = never; 1 = every time; 2 = on the same day)
+payments_changeable = 1
+
 [paths]
 # path to temporary files (must be writeable by the web server)
 userspath = users