Zahlungsbedingungen obsolet setzen
authorG. Richardson <information@kivitendo-premium.de>
Tue, 27 Dec 2016 10:25:01 +0000 (11:25 +0100)
committerG. Richardson <information@kivitendo-premium.de>
Tue, 27 Dec 2016 12:35:03 +0000 (13:35 +0100)
Damit können alte und ungenutzte Zahlungsbedingungen für neue
Belege/CV/Artikel ausgeblendet werden.

Außerdem Umstellung von generic/multibox auf L.select_tag in den Masken

SL/Controller/CustomerVendor.pm
SL/Controller/Order.pm
SL/Controller/Part.pm
SL/DB/MetaSetup/PaymentTerm.pm
SL/Form.pm
bin/mozilla/oe.pl
sql/Pg-upgrade2/payment_terms_obsolete.sql [new file with mode: 0644]
templates/webpages/is/form_footer.html
templates/webpages/oe/form_footer.html
templates/webpages/payment_term/form.html
templates/webpages/payment_term/list.html

index 325fa58..5404373 100644 (file)
@@ -901,7 +901,8 @@ sub _pre_render {
     $self->{all_salesmen} = SL::DB::Manager::Employee->get_all(query => [ or => [ id => $self->{cv}->salesman_id,  deleted => 0 ] ]);
   }
 
-  $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all();
+  $self->{all_payment_terms} = SL::DB::Manager::PaymentTerm->get_all_sorted(where => [ or => [ id       => $self->{cv}->payment_id,
+                                                                                               obsolete => 0 ] ]);
 
   $self->{all_delivery_terms} = SL::DB::Manager::DeliveryTerm->get_all();
 
index 82b8a2a..5562b1e 100644 (file)
@@ -1047,7 +1047,9 @@ sub _pre_render {
   $self->{all_projects}        = SL::DB::Manager::Project->get_all(where => [ or => [ id => $self->order->globalproject_id,
                                                                                       active => 1 ] ],
                                                                    sort_by => 'projectnumber');
-  $self->{all_payment_terms}   = SL::DB::Manager::PaymentTerm->get_all_sorted();
+  $self->{all_payment_terms}   = SL::DB::Manager::PaymentTerm->get_all_sorted(where => [ or => [ id => $self->order->payment_id,
+                                                                                                 obsolete => 0 ] ]);
+
   $self->{all_delivery_terms}  = SL::DB::Manager::DeliveryTerm->get_all_sorted();
 
   $self->{current_employee_id} = SL::DB::Manager::Employee->current->id;
index 9458a83..6b40493 100644 (file)
@@ -895,7 +895,8 @@ sub init_all_units {
 }
 
 sub init_all_payment_terms {
-  SL::DB::Manager::PaymentTerm->get_all_sorted;
+  my ($self) = @_;
+  SL::DB::Manager::PaymentTerm->get_all_sorted(query => [ or => [ id => $self->part->payment_id, obsolete => 0 ] ]);
 }
 
 sub init_all_price_factors {
index ed52a91..eb76471 100644 (file)
@@ -16,7 +16,8 @@ __PACKAGE__->meta->columns(
   id                       => { type => 'integer', not_null => 1, sequence => 'id' },
   itime                    => { type => 'timestamp', default => 'now()' },
   mtime                    => { type => 'timestamp' },
-  percent_skonto           => { type => 'float', precision => 4, scale => 4 },
+  obsolete                 => { type => 'boolean', default => 'false' },
+  percent_skonto           => { type => 'float', scale => 4 },
   ranking                  => { type => 'integer' },
   sortkey                  => { type => 'integer', not_null => 1 },
   terms_netto              => { type => 'integer' },
index 7a9c54e..4c8f3d7 100644 (file)
@@ -2531,9 +2531,9 @@ sub all_vc {
   # get payment terms
   $query = qq|SELECT id, description
               FROM payment_terms
-              ORDER BY sortkey|;
-
-  $self->{payment_terms} = selectall_hashref_query($self, $dbh, $query);
+              WHERE ( obsolete IS FALSE OR id = ? )
+              ORDER BY sortkey |;
+  $self->{payment_terms} = selectall_hashref_query($self, $dbh, $query, $self->{payment_id} || undef);
 
   $main::lxdebug->leave_sub();
 }
@@ -2575,6 +2575,9 @@ sub mtime_ischanged {
   }
 }
 
+# language_payment duplicates some of the functionality of all_vc (language,
+# printer, payment_terms), and at least in the case of sales invoices both
+# all_vc and language_payment are called when adding new invoices
 sub language_payment {
   $main::lxdebug->enter_sub();
 
@@ -2598,9 +2601,9 @@ sub language_payment {
   # get payment terms
   $query = qq|SELECT id, description
               FROM payment_terms
-              ORDER BY sortkey|;
-
-  $self->{payment_terms} = selectall_hashref_query($self, $dbh, $query);
+              WHERE ( obsolete IS FALSE OR id = ? )
+              ORDER BY sortkey |;
+  $self->{payment_terms} = selectall_hashref_query($self, $dbh, $query, $self->{payment_id} || undef);
 
   # get buchungsgruppen
   $query = qq|SELECT id, description
index 83cf28f..5e6f810 100644 (file)
@@ -50,6 +50,7 @@ use Data::Dumper;
 
 use SL::DB::Customer;
 use SL::DB::TaxZone;
+use SL::DB::PaymentTerm;
 
 require "bin/mozilla/io.pl";
 require "bin/mozilla/arap.pl";
@@ -352,11 +353,11 @@ sub form_header {
   my $vc = $form->{vc} eq "customer" ? "customers" : "vendors";
 
   $form->get_lists("taxzones"      => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"),
-                   "payments"      => "ALL_PAYMENTS",
                    "currencies"    => "ALL_CURRENCIES",
                    $vc             => { key   => "ALL_" . uc($vc),
                                         limit => $myconfig{vclimit} + 1 },
                    "price_factors" => "ALL_PRICE_FACTORS");
+  $form->{ALL_PAYMENTS} = SL::DB::Manager::PaymentTerm->get_all( where => [ or => [ obsolete => 0, id => $form->{payment_id} || undef ] ]);
 
   $form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
 
diff --git a/sql/Pg-upgrade2/payment_terms_obsolete.sql b/sql/Pg-upgrade2/payment_terms_obsolete.sql
new file mode 100644 (file)
index 0000000..a72ab45
--- /dev/null
@@ -0,0 +1,7 @@
+-- @tag: payment_terms_obsolete
+-- @description: Zahlungsbedingungen ungültig setzen
+-- @charset: UTF-8
+-- @depends: release_3_4_1
+-- @ignore: 0
+
+ALTER TABLE payment_terms ADD COLUMN obsolete BOOLEAN DEFAULT FALSE;
index 9101d2c..caadf3e 100644 (file)
            <table>
              <tr>
                <th align="right">[% 'Payment Terms' | $T8 %]</th>
-               <td>
-                 [%- INCLUDE 'generic/multibox.html'
-                   name          = 'payment_id',
-                   style         = 'width: 250px',
-                   DATA          = payment_terms,
-                   id_key        = 'id',
-                   label_key     = 'description',
-                   show_empty    = 1
-                   allow_textbox = 0 -%]
+               <td>[% L.select_tag('payment_id', payment_terms, default = payment_id, title_key = 'description', with_empty = 1, style="width: 250px") %]
                  <script type='text/javascript'>$('#payment_id').change(function(){ kivi.SalesPurchase.set_duedate_on_reference_date_change("invdate"); })</script>
                </td>
              </tr>
index 6c6072e..86910e0 100644 (file)
               </tr>
               <tr>
                 <th align="right">[% 'Payment Terms' | $T8 %]</th>
-                <td>
-                      [%- INCLUDE 'generic/multibox.html'
-                           name       = 'payment_id',
-                           style      = 'width: 250px',
-                           DATA       = ALL_PAYMENTS,
-                           id_key     = 'id',
-                           label_key  = 'description',
-                           show_empty = 1 -%]
-                </td>
+                <td>[% L.select_tag('payment_id', ALL_PAYMENTS, default = payment_id, title_key = 'description', with_empty = 1, style="width: 250px") %]</td>
               </tr>
               <tr>
                 <th align="right">[% 'Delivery Terms' | $T8 %]</th>
index 6cd81c8..db7fdb1 100755 (executable)
     </td>
    </tr>
 
+   [% IF SELF.payment_term.id %]
+   <tr>
+     <td>[% 'Obsolete' | $T8 %]</td>
+     <td>[% L.checkbox_tag('payment_term.obsolete', checked = SELF.payment_term.obsolete, for_submit=1) %]</td>
+   </tr>
+   </tr>
+   [% END %]
+
    <tr class="listheading">
     <th></th>
     <th>[% LxERP.t8("Texts for quotations & orders") %]</th>
index 782a067..7bedec8 100644 (file)
@@ -21,6 +21,7 @@
      <th align="right">[%- 'Netto Terms' | $T8 %]</th>
      <th align="right">[%- 'Skonto Terms' | $T8 %]</th>
      <th align="right">[%- 'Skonto' | $T8 %]</th>
+     <th align="right">[%- 'Obsolete' | $T8 %]</th>
     </tr>
     </thead>
 
@@ -39,6 +40,7 @@
      <td align="right">[%- HTML.escape(payment_term.terms_netto_as_number) %]</td>
      <td align="right">[%- HTML.escape(payment_term.terms_skonto_as_number) %]</td>
      <td align="right">[%- HTML.escape(payment_term.percent_skonto_as_percent) %] %</td>
+     <td align="right">[%- HTML.escape(payment_term.obsolete) %]</td>
     </tr>
     [%- END %]
     </tbody>