Merge branch 'master' of lx-office.linet-services.de:lx-office-erp
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 7 Oct 2011 13:13:58 +0000 (15:13 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Fri, 7 Oct 2011 13:13:58 +0000 (15:13 +0200)
SL/AP.pm
SL/AR.pm
bin/mozilla/am.pl
bin/mozilla/ap.pl
locale/de/all
locale/en/all
sql/Pg-upgrade2/customer_add_constraints.sql [new file with mode: 0644]
sql/Pg-upgrade2/vendor_add_constraints.sql [new file with mode: 0644]
templates/webpages/am/edit_accounts.html

index 08ec7a3..3c29ca8 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -591,7 +591,7 @@ sub post_payment {
 
   # Set up the content of $form in the way that AR::post_transaction() expects.
 
-  $self->setup_form($form);
+  $self->setup_form($form, 1);
 
   $form->{exchangerate}    = $form->format_amount($myconfig, $form->{exchangerate});
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
@@ -625,7 +625,7 @@ sub post_payment {
 sub setup_form {
   $main::lxdebug->enter_sub();
 
-  my ($self, $form) = @_;
+  my ($self, $form, $for_post_payments) = @_;
 
   my ($exchangerate, $i, $j, $k, $key, $akey, $ref, $index, $taxamount, $totalamount, $totaltax, $totalwithholding, $withholdingrate,
       $taxincluded, $tax, $diff);
@@ -645,11 +645,16 @@ sub setup_form {
 
     $form->{$key} = $form->{"select$key"};
 
-    # if there is a value we have an old entry
     $j = 0;
     $k = 0;
 
+    # if there is a value we have an old entry
     next unless $form->{acc_trans}{$key};
+
+    # do not use old entries for payments. They come from the form
+    # even if they are not changeable (then they are in hiddens)
+    next if $for_post_payments && $key eq "AP_paid";
+
     for $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
 
       if ($key eq "AP_paid") {
index 7aa709d..a39481b 100644 (file)
--- a/SL/AR.pm
+++ b/SL/AR.pm
@@ -354,7 +354,7 @@ sub post_payment {
 
   # Set up the content of $form in the way that AR::post_transaction() expects.
 
-  $self->setup_form($form);
+  $self->setup_form($form, 1);
 
   $form->{exchangerate}    = $form->format_amount($myconfig, $form->{exchangerate});
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
@@ -560,7 +560,7 @@ sub get_transdate {
 sub setup_form {
   $main::lxdebug->enter_sub();
 
-  my ($self, $form) = @_;
+  my ($self, $form, $for_post_payments) = @_;
 
   my ($exchangerate, $akey, $j, $k, $index, $taxamount, $totaltax, $taxrate, $diff, $totalwithholding, $withholdingrate,
       $totalamount, $taxincluded, $tax);
@@ -570,12 +570,16 @@ sub setup_form {
   $exchangerate  = $form->{exchangerate} ? $form->{exchangerate} : 1;
 
   foreach my $key (keys %{ $form->{AR_links} }) {
-    # if there is a value we have an old entry
     $j = 0;
     $k = 0;
 
+    # if there is a value we have an old entry
     next unless $form->{acc_trans}{$key};
 
+    # do not use old entries for payments. They come from the form
+    # even if they are not changeable (then they are in hiddens)
+    next if $for_post_payments && $key eq "AR_paid";
+
     for my $i (1 .. scalar @{ $form->{acc_trans}{$key} }) {
       if ($key eq "AR_paid") {
         $j++;
index 368a627..111e14e 100644 (file)
@@ -347,11 +347,13 @@ sub account_header {
   }
 
   my $ChartTypeIsAccount = ($form->{charttype} eq "A") ? "1":"";
+  my $AccountIsPosted = ($form->{orphaned} ) ? "":"1";
 
   $form->header();
 
   my $parameters_ref = {
     ChartTypeIsAccount         => $ChartTypeIsAccount,
+    AccountIsPosted            => $AccountIsPosted,
     select_category            => $select_category,
     select_charttype           => $select_charttype,
     select_bwa                 => $select_bwa,
index bcd858a..361d432 100644 (file)
@@ -1079,6 +1079,8 @@ sub post {
 
   $main::auth->assert('general_ledger');
 
+  my ($inline) = @_;
+
   # check if there is a vendor, invoice and due date
   $form->isblank("transdate", $locale->text("Invoice Date missing!"));
   $form->isblank("duedate",   $locale->text("Due Date missing!"));
@@ -1153,7 +1155,7 @@ sub post {
     # /saving the history
     remove_draft() if $form->{remove_draft};
     # Dieser Text wird niemals ausgegeben: Probleme beim redirect?
-    $form->redirect($locale->text('Transaction posted!'));
+    $form->redirect($locale->text('Transaction posted!')) unless $inline;
   } else {
     $form->error($locale->text('Cannot post transaction!'));
   }
index ab51f57..5bd9658 100644 (file)
@@ -369,6 +369,7 @@ $self->{texts} = {
   'Cc'                          => 'Cc',
   'Change Lx-Office installation settings (all menu entries beneath \'System\')' => 'Ver&auml;ndern der Lx-Office-Installationseinstellungen (Men&uuml;punkte unterhalb von \'System\')',
   'Change representative to'    => 'Vertreter ändern in',
+  'Changes to Receivables and Payables are only possible if no transactions to this account are posted yet.' => 'Änderungen bei Forderungen oder Verbindlichkeiten sind nur möglich, wenn dieses Konto noch nicht bebucht wurde.',
   'Charge Number'               => 'Chargennummer',
   'Charge number'               => 'Chargennummer',
   'Charset'                     => 'Zeichensatz',
index 7627741..879d1ac 100644 (file)
@@ -360,6 +360,7 @@ $self->{texts} = {
   'Cc'                          => '',
   'Change Lx-Office installation settings (all menu entries beneath \'System\')' => '',
   'Change representative to'    => '',
+  'Changes to Receivables and Payables are only possible if no transactions to this account are posted yet.' => '',
   'Charge Number'               => '',
   'Charge number'               => '',
   'Chart'                       => '',
diff --git a/sql/Pg-upgrade2/customer_add_constraints.sql b/sql/Pg-upgrade2/customer_add_constraints.sql
new file mode 100644 (file)
index 0000000..89ca9d6
--- /dev/null
@@ -0,0 +1,12 @@
+-- @tag: customer_add_constraints
+-- @description: Zusätzliche Fremdschlüssel für Sprache, Kundentyp und Zahlungskonditionen
+-- @depends: release_2_6_3
+-- @charset: utf-8
+-- @ignore: 0
+
+-- verwaiste Zahlungsbedingungen vorher entfernen:
+update customer set payment_id = NULL where payment_id not in (select id from payment_terms);
+
+ALTER TABLE customer ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id);
+ALTER TABLE customer ADD FOREIGN KEY (language_id) REFERENCES language (id);
+ALTER TABLE customer ADD FOREIGN KEY (business_id) REFERENCES business (id);
diff --git a/sql/Pg-upgrade2/vendor_add_constraints.sql b/sql/Pg-upgrade2/vendor_add_constraints.sql
new file mode 100644 (file)
index 0000000..3d3a816
--- /dev/null
@@ -0,0 +1,13 @@
+-- @tag: vendor_add_constraints
+-- @description: Zusätzliche Fremdschlüssel für Sprache, Lieferantentyp und Zahlungskonditionen
+-- @depends: release_2_6_3
+-- @charset: utf-8
+-- @ignore: 0
+
+-- verwaiste Zahlungsbedingungen vorher entfernen
+update vendor set payment_id = NULL where payment_id not in (select id from payment_terms);
+
+
+ALTER TABLE vendor ADD FOREIGN KEY (payment_id) REFERENCES payment_terms (id);
+ALTER TABLE vendor ADD FOREIGN KEY (language_id) REFERENCES language (id);
+ALTER TABLE vendor ADD FOREIGN KEY (business_id) REFERENCES business (id);
index 6252ee1..c55e08f 100644 (file)
@@ -80,9 +80,13 @@ window.onload = function() {
     &nbsp;[% 'Inventory' | $T8 %]
 </fieldset>
 
+[% IF AccountIsPosted %]
+[%- SET DIS = ' disabled="disabled"' %]
+[% END %]
 <fieldset class="DEPENDS ON charttype BEING A">
   <legend>[% 'Include in drop-down menus' | $T8 %]</legend>
   <p style='font-weight:normal'>[% 'These will only be effective if the account is NOT a summary account AND there exists at least one taxkey. Setting the account as a summary account will erase these settings.' | $T8 %]</p>
+  <p style='font-weight:normal'>[% 'Changes to Receivables and Payables are only possible if no transactions to this account are posted yet.' | $T8 %]</p>
   <table width="100%">
     <tr>
       <th align="left">[% 'Receivables' | $T8 %]</th>
@@ -93,24 +97,24 @@ window.onload = function() {
     <tr>
       <td>
         <input name="AR_amount" type="checkbox" class="checkbox" value="AR_amount"
-          [% HTML.escape(AR_amount) %]>&nbsp;
+          [% HTML.escape(AR_amount)%][% DIS %]>&nbsp;
         [% 'Revenue' | $T8 %] <br>
         <input name="AR_paid" type="checkbox" class="checkbox" value="AR_paid"
-          [% HTML.escape(AR_paid) %]>&nbsp;
+          [% HTML.escape(AR_paid) %][% DIS %]>&nbsp;
         [% 'Receipt' | $T8 %] <br>
         <input name="AR_tax" type="checkbox" class="checkbox" value="AR_tax"
-          [% HTML.escape(AR_tax) %]>&nbsp;
+          [% HTML.escape(AR_tax) %][% DIS %]>&nbsp;
         [% 'Tax' | $T8 %]
       </td>
       <td>
         <input name="AP_amount" type="checkbox" class="checkbox" value="AP_amount"
-          [% HTML.escape(AP_amount) %]>&nbsp;
+          [% HTML.escape(AP_amount) %][% DIS %]>&nbsp;
         [% 'Expense/Asset' | $T8 %] <br>
         <input name="AP_paid" type="checkbox" class="checkbox" value="AP_paid"
-          [% HTML.escape(AP_paid) %]>&nbsp;
+          [% HTML.escape(AP_paid) %][% DIS %]>&nbsp;
         [% 'Payment' | $T8 %] <br>
         <input name="AP_tax" type="checkbox" class="checkbox" value="AP_tax"
-            [% HTML.escape(AP_tax) %]>&nbsp;
+            [% HTML.escape(AP_tax) %][% DIS %]>&nbsp;
         [% 'Tax' | $T8 %]
       </td>
       <td>