Merge branch 'master' of github.com:kivitendo/kivitendo-erp
authorNiclas Zimmermann <niclas@kivitendo-premium.de>
Mon, 10 Jun 2013 15:34:16 +0000 (17:34 +0200)
committerNiclas Zimmermann <niclas@kivitendo-premium.de>
Mon, 10 Jun 2013 15:34:16 +0000 (17:34 +0200)
15 files changed:
SL/AM.pm
SL/AP.pm
SL/DB/Helper/FlattenToForm.pm
SL/DB/MetaSetup/Default.pm
SL/Form.pm
SL/InstanceConfiguration.pm
bin/mozilla/ap.pl
bin/mozilla/ar.pl
bin/mozilla/gl.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
locale/de/all
sql/Pg-upgrade2/defaults_add_max_future_booking_date.sql [new file with mode: 0644]
templates/webpages/am/audit_control.html
templates/webpages/ir/form_footer.html

index 4934d86..5a9f236 100644 (file)
--- a/SL/AM.pm
+++ b/SL/AM.pm
@@ -1313,11 +1313,11 @@ sub closedto {
 
   my $dbh = $form->dbconnect($myconfig);
 
-  my $query = qq|SELECT closedto, revtrans FROM defaults|;
+  my $query = qq|SELECT closedto, max_future_booking_interval, revtrans FROM defaults|;
   my $sth   = $dbh->prepare($query);
   $sth->execute || $form->dberror($query);
 
-  ($form->{closedto}, $form->{revtrans}) = $sth->fetchrow_array;
+  ($form->{closedto}, $form->{max_future_booking_interval}, $form->{revtrans}) = $sth->fetchrow_array;
 
   $sth->finish;
 
@@ -1339,8 +1339,8 @@ sub closebooks {
     $query = qq|UPDATE defaults SET closedto = NULL, revtrans = '1'|;
 
   } elsif ($form->{closedto}) {
-    $query = qq|UPDATE defaults SET closedto = ?, revtrans = '0'|;
-    @values = (conv_date($form->{closedto}));
+    $query = qq|UPDATE defaults SET closedto = ?, max_future_booking_interval = ?, revtrans = '0'|;
+    @values = (conv_date($form->{closedto}), conv_date($form->{max_future_booking_interval}));
 
   } else {
     $query = qq|UPDATE defaults SET closedto = NULL, revtrans = '0'|;
index bc5a362..7a148d6 100644 (file)
--- a/SL/AP.pm
+++ b/SL/AP.pm
@@ -170,9 +170,10 @@ sub post_transaction {
       $uid = substr($uid, 2, 75);
 
       $query =
-        qq|INSERT INTO ap (invnumber, employee_id) | .
-        qq|VALUES (?, (SELECT e.id FROM employee e WHERE e.login = ?))|;
-      do_query($form, $dbh, $query, $uid, $form->{login});
+        qq|INSERT INTO ap (invnumber, employee_id,currency_id) | .
+        qq|VALUES (?, (SELECT e.id FROM employee e WHERE e.login = ?),
+                      (SELECT id FROM currencies WHERE name = ?) )|;
+      do_query($form, $dbh, $query, $uid, $form->{login}, $form->{currency});
 
       $query = qq|SELECT a.id FROM ap a
                   WHERE a.invnumber = ?|;
index 198aae5..80633b6 100644 (file)
@@ -29,9 +29,11 @@ sub flatten_to_form {
 
   $form->{vc} = $vc if ref($self) =~ /^SL::DB::.*Invoice/;
 
-  my @vc_fields          = (qw(account_number bank bank_code bic business city contact country creditlimit discount
-                               email fax homepage iban language name payment_terms phone street taxnumber zipcode),
-                            "${vc}number");
+  my @vc_fields          = (qw(account_number bank bank_code bic business city contact country creditlimit
+                               department_1 department_2 discount email fax homepage iban language name
+                               payment_terms phone street taxnumber ustid zipcode),
+                            "${vc}number",
+                            ($vc eq 'customer')? 'c_vendor_id': 'v_customer_id');
   my @vc_prefixed_fields = qw(email fax notes number phone);
 
   _copy($self,                          $form, '',              '', 1, qw(amount netamount marge_total marge_percent container_remaining_weight container_remaining_volume paid));
index cbacbf4..6e75bc5 100644 (file)
@@ -10,73 +10,74 @@ __PACKAGE__->meta->setup(
   table   => 'defaults',
 
   columns => [
-    inventory_accno_id                  => { type => 'integer' },
-    income_accno_id                     => { type => 'integer' },
-    expense_accno_id                    => { type => 'integer' },
-    fxgain_accno_id                     => { type => 'integer' },
-    fxloss_accno_id                     => { type => 'integer' },
-    invnumber                           => { type => 'text' },
-    sonumber                            => { type => 'text' },
-    weightunit                          => { type => 'varchar', length => 5 },
-    businessnumber                      => { type => 'text' },
-    version                             => { type => 'varchar', length => 8 },
-    closedto                            => { type => 'date' },
-    revtrans                            => { type => 'boolean', default => 'false' },
-    ponumber                            => { type => 'text' },
-    sqnumber                            => { type => 'text' },
-    rfqnumber                           => { type => 'text' },
-    customernumber                      => { type => 'text' },
-    vendornumber                        => { type => 'text' },
-    audittrail                          => { type => 'boolean', default => 'false' },
-    articlenumber                       => { type => 'text' },
-    servicenumber                       => { type => 'text' },
-    coa                                 => { type => 'text' },
-    itime                               => { type => 'timestamp', default => 'now()' },
-    mtime                               => { type => 'timestamp' },
-    rmanumber                           => { type => 'text' },
-    cnnumber                            => { type => 'text' },
-    dunning_ar_amount_fee               => { type => 'integer' },
-    dunning_ar_amount_interest          => { type => 'integer' },
-    dunning_ar                          => { type => 'integer' },
-    pdonumber                           => { type => 'text' },
-    sdonumber                           => { type => 'text' },
-    ar_paid_accno_id                    => { type => 'integer' },
-    id                                  => { type => 'serial', not_null => 1 },
-    language_id                         => { type => 'integer' },
-    accounting_method                   => { type => 'text' },
-    inventory_system                    => { type => 'text' },
-    profit_determination                => { type => 'text' },
-    datev_check_on_sales_invoice        => { type => 'boolean', default => 'true' },
-    datev_check_on_purchase_invoice     => { type => 'boolean', default => 'true' },
-    datev_check_on_ar_transaction       => { type => 'boolean', default => 'true' },
-    datev_check_on_ap_transaction       => { type => 'boolean', default => 'true' },
-    datev_check_on_gl_transaction       => { type => 'boolean', default => 'true' },
-    payments_changeable                 => { type => 'integer', default => '0', not_null => 1 },
-    is_changeable                       => { type => 'integer', default => 2, not_null => 1 },
-    ir_changeable                       => { type => 'integer', default => 2, not_null => 1 },
-    ar_changeable                       => { type => 'integer', default => 2, not_null => 1 },
-    ap_changeable                       => { type => 'integer', default => 2, not_null => 1 },
-    gl_changeable                       => { type => 'integer', default => 2, not_null => 1 },
-    show_bestbefore                     => { type => 'boolean', default => 'false' },
-    sales_order_show_delete             => { type => 'boolean', default => 'true' },
-    purchase_order_show_delete          => { type => 'boolean', default => 'true' },
-    sales_delivery_order_show_delete    => { type => 'boolean', default => 'true' },
-    purchase_delivery_order_show_delete => { type => 'boolean', default => 'true' },
-    is_show_mark_as_paid                => { type => 'boolean', default => 'true' },
-    ir_show_mark_as_paid                => { type => 'boolean', default => 'true' },
-    ar_show_mark_as_paid                => { type => 'boolean', default => 'true' },
-    ap_show_mark_as_paid                => { type => 'boolean', default => 'true' },
-    assemblynumber                      => { type => 'text' },
-    warehouse_id                        => { type => 'integer' },
-    bin_id                              => { type => 'integer' },
-    currency_id                         => { type => 'integer', not_null => 1 },
-    show_weight                         => { type => 'boolean', default => 'false', not_null => 1 },
+    inventory_accno_id                      => { type => 'integer' },
+    income_accno_id                         => { type => 'integer' },
+    expense_accno_id                        => { type => 'integer' },
+    fxgain_accno_id                         => { type => 'integer' },
+    fxloss_accno_id                         => { type => 'integer' },
+    invnumber                               => { type => 'text' },
+    sonumber                                => { type => 'text' },
+    weightunit                              => { type => 'varchar', length => 5 },
+    businessnumber                          => { type => 'text' },
+    version                                 => { type => 'varchar', length => 8 },
+    closedto                                => { type => 'date' },
+    revtrans                                => { type => 'boolean', default => 'false' },
+    ponumber                                => { type => 'text' },
+    sqnumber                                => { type => 'text' },
+    rfqnumber                               => { type => 'text' },
+    customernumber                          => { type => 'text' },
+    vendornumber                            => { type => 'text' },
+    audittrail                              => { type => 'boolean', default => 'false' },
+    articlenumber                           => { type => 'text' },
+    servicenumber                           => { type => 'text' },
+    coa                                     => { type => 'text' },
+    itime                                   => { type => 'timestamp', default => 'now()' },
+    mtime                                   => { type => 'timestamp' },
+    rmanumber                               => { type => 'text' },
+    cnnumber                                => { type => 'text' },
+    dunning_ar_amount_fee                   => { type => 'integer' },
+    dunning_ar_amount_interest              => { type => 'integer' },
+    dunning_ar                              => { type => 'integer' },
+    pdonumber                               => { type => 'text' },
+    sdonumber                               => { type => 'text' },
+    ar_paid_accno_id                        => { type => 'integer' },
+    id                                      => { type => 'serial', not_null => 1 },
+    language_id                             => { type => 'integer' },
+    accounting_method                       => { type => 'text' },
+    inventory_system                        => { type => 'text' },
+    profit_determination                    => { type => 'text' },
+    datev_check_on_sales_invoice            => { type => 'boolean', default => 'true' },
+    datev_check_on_purchase_invoice         => { type => 'boolean', default => 'true' },
+    datev_check_on_ar_transaction           => { type => 'boolean', default => 'true' },
+    datev_check_on_ap_transaction           => { type => 'boolean', default => 'true' },
+    datev_check_on_gl_transaction           => { type => 'boolean', default => 'true' },
+    payments_changeable                     => { type => 'integer', default => '0', not_null => 1 },
+    is_changeable                           => { type => 'integer', default => 2, not_null => 1 },
+    ir_changeable                           => { type => 'integer', default => 2, not_null => 1 },
+    ar_changeable                           => { type => 'integer', default => 2, not_null => 1 },
+    ap_changeable                           => { type => 'integer', default => 2, not_null => 1 },
+    gl_changeable                           => { type => 'integer', default => 2, not_null => 1 },
+    show_bestbefore                         => { type => 'boolean', default => 'false' },
+    sales_order_show_delete                 => { type => 'boolean', default => 'true' },
+    purchase_order_show_delete              => { type => 'boolean', default => 'true' },
+    sales_delivery_order_show_delete        => { type => 'boolean', default => 'true' },
+    purchase_delivery_order_show_delete     => { type => 'boolean', default => 'true' },
+    is_show_mark_as_paid                    => { type => 'boolean', default => 'true' },
+    ir_show_mark_as_paid                    => { type => 'boolean', default => 'true' },
+    ar_show_mark_as_paid                    => { type => 'boolean', default => 'true' },
+    ap_show_mark_as_paid                    => { type => 'boolean', default => 'true' },
+    max_future_booking_interval             => { type => 'integer', default => 360 },
+    assemblynumber                          => { type => 'text' },
+    warehouse_id                            => { type => 'integer' },
+    bin_id                                  => { type => 'integer' },
+    show_weight                             => { type => 'boolean', default => 'false', not_null => 1 },
     transfer_default                        => { type => 'boolean', default => 'true' },
     transfer_default_use_master_default_bin => { type => 'boolean', default => 'false' },
     transfer_default_ignore_onhand          => { type => 'boolean', default => 'false' },
     warehouse_id_ignore_onhand              => { type => 'integer' },
     bin_id_ignore_onhand                    => { type => 'integer' },
- ],
+    currency_id                             => { type => 'integer', not_null => 1 },
+  ],
 
   primary_key_columns => [ 'id' ],
 
index 5a2b38d..07702fb 100644 (file)
@@ -1,4 +1,4 @@
-#====================================================================
+#========= ===========================================================
 # LX-Office ERP
 # Copyright (C) 2004
 # Based on SQL-Ledger Version 2.1.9
@@ -1455,6 +1455,24 @@ sub date_closed {
   return $closed;
 }
 
+# prevents bookings to the to far away future
+sub date_max_future {
+  $main::lxdebug->enter_sub();
+
+  my ($self, $date, $myconfig) = @_;
+  my $dbh = $self->dbconnect($myconfig);
+
+  my $query = "SELECT 1 FROM defaults WHERE ? - current_date > max_future_booking_interval";
+  my $sth = prepare_execute_query($self, $dbh, $query, conv_date($date));
+
+  my ($max_future_booking_interval) = $sth->fetchrow_array;
+
+  $main::lxdebug->leave_sub();
+
+  return $max_future_booking_interval;
+}
+
+
 sub update_balance {
   $main::lxdebug->enter_sub();
 
index 97ece86..d0b6b3a 100644 (file)
@@ -178,6 +178,12 @@ sub get_transfer_default_ignore_onhand {
   my ($self) = @_;
   return ($self->{data}->{transfer_default_ignore_onhand});
 }
+# currently unused - value is set via audit_control (Bücherkontrolle)
+sub get_max_future_booking_interval {
+  my ($self) = @_;
+  return ($self->{data}->{max_future_booking_interval});
+}
+
 
 
 1;
@@ -320,6 +326,9 @@ current stock quantity
 
 Returns the default behavior for the transfer out default feature (true or false)
 
+=item C<get_max_future_booking_interval>
+
+Returns the maximum interval value for future bookings
 
 =back
 
index 923e140..e566ea6 100644 (file)
@@ -621,6 +621,9 @@ sub post {
 
   my $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
   my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+
+  $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+    if ($form->date_max_future($form->{"transdate"}, \%myconfig));
   $form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig));
 
   my $zero_amount_posting = 1;
index f5ea6c4..e1b10f6 100644 (file)
@@ -669,6 +669,9 @@ sub post {
 
   my $closedto  = $form->datetonum($form->{closedto},  \%myconfig);
   my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
+
+  $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+    if ($form->date_max_future($transdate, \%myconfig));
   $form->error($locale->text('Cannot post transaction for a closed period!')) if ($form->date_closed($form->{"transdate"}, \%myconfig));
 
   $form->error($locale->text('Zero amount posting!'))
index 4c97bd0..c508ff1 100644 (file)
@@ -1115,6 +1115,9 @@ sub post_transaction {
   $form->{taxincluded} = 0 if !$taxtotal;
 
   # this is just for the wise guys
+
+  $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+    if ($form->date_max_future($form->{"transdate"}, \%myconfig));
   $form->error($locale->text('Cannot post transaction for a closed period!'))
     if ($form->date_closed($form->{"transdate"}, \%myconfig));
   if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
index 4209fdf..b226bb0 100644 (file)
@@ -722,6 +722,8 @@ sub post {
   my $invdate      = $form->datetonum($form->{invdate},  \%myconfig);
   my $max_datepaid = _max_datepaid();
 
+  $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+    if ($form->date_max_future($invdate, \%myconfig));
   $form->error($locale->text('Cannot post invoice for a closed period!')) if $max_datepaid && $form->date_closed($max_datepaid, \%myconfig);
 
   $form->isblank("exchangerate", $locale->text('Exchangerate missing!'))
index cbddde6..220c993 100644 (file)
@@ -716,6 +716,8 @@ sub post {
   my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
   my $invdate  = $form->datetonum($form->{invdate},  \%myconfig);
 
+  $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+    if ($form->date_max_future($invdate, \%myconfig));
   $form->error($locale->text('Cannot post invoice for a closed period!'))
     if ($invdate <= $closedto);
 
index d786c2e..a292a2a 100755 (executable)
@@ -388,6 +388,7 @@ $self->{texts} = {
   'Cannot post payment for a closed period!' => 'Es können keine Zahlungen für abgeschlossene Bücher gebucht werden!',
   'Cannot post payment!'        => 'Zahlung kann nicht gebucht werden!',
   'Cannot post storno for a closed period!' => 'Für einen geschlossenen Zeitraum können keine Stornos gebucht werden!',
+  'Cannot post transaction above the maximum future booking date!' => 'Das Buchungsdatum liegt oberhalb des maximal zulässigen Werts. Bitte korrigieren oder Wert erhöhen',
   'Cannot post transaction for a closed period!' => 'Für einen bereits abgeschlossenen Zeitraum kann keine Buchung angelegt werden!',
   'Cannot post transaction with a debit and credit entry for the same account!' => 'Kann Soll und Haben nicht auf dasselbe Konto buchen!',
   'Cannot post transaction!'    => 'Rechnung kann nicht gebucht werden!',
@@ -825,7 +826,7 @@ $self->{texts} = {
   'Employee'                    => 'Bearbeiter',
   'Employee #1 saved!'          => 'Benutzer #1 gespeichert!',
   'Employees'                   => 'Benutzer',
-  'Empty selection for warehouse will not be added, even if the old bin is still visible (use back and forth to edit again).' => '',
+  'Empty selection for warehouse will not be added, even if the old bin is still visible (use back and forth to edit again).' => 'Leere Lager-Auswahl wird ignoriert, selbst wenn noch ein Lagerplatz ausgewählt ist. Alle Daten können durch zurück und vorwärts korrigiert werden.',
   'Empty transaction!'          => 'Buchung ist leer!',
   'End date'                    => 'Enddatum',
   'Enter a description for this new draft.' => 'Geben Sie eine Beschreibung f&uuml;r diesen Entwurf ein.',
@@ -1225,6 +1226,7 @@ $self->{texts} = {
   'Master Data'                 => 'Stammdaten',
   'Master Data Bin Text Deleted' => 'Gelöschte Stammdaten Freitext-Lagerplätze',
   'Max. Dunning Level'          => 'höchste Mahnstufe',
+  'Maximum future booking interval' => 'Maximale Anzahl von Tagen an denen Buchungen in der Zukunft erlaubt sind.',
   'May'                         => 'Mai',
   'May '                        => 'Mai',
   'May set the BCC field when sending emails' => 'Beim Verschicken von Emails das Feld \'BCC\' setzen',
diff --git a/sql/Pg-upgrade2/defaults_add_max_future_booking_date.sql b/sql/Pg-upgrade2/defaults_add_max_future_booking_date.sql
new file mode 100644 (file)
index 0000000..ad77a82
--- /dev/null
@@ -0,0 +1,6 @@
+-- @tag: defaults_add_max_future_booking_intervall
+-- @description: Fehleingaben für Buchungen in der Zukunft verhindern (s.a. 1897)
+-- @depends: release_3_0_0
+-- @charset: utf-8
+
+ALTER TABLE defaults ADD COLUMN  max_future_booking_interval integer DEFAULT 360;
index 761cc0e..bd127f2 100644 (file)
     <th>[% 'Close Books up to' | $T8 %]</th>
     <td>[% L.date_tag('closedto', closedto) %]</td>
   </tr>
+  <tr>
+    <th>[% 'Maximum future booking interval' | $T8 %]</th>
+    <td><input type="text" name="max_future_booking_interval" id="max_future_booking_interval" value="[% HTML.escape(max_future_booking_interval) %]"></td>
+  </tr>
 </table>
 
 <hr size=3 noshade>
index 6675800..6d3b643 100644 (file)
     <input type="button" class="submit" onclick="follow_up_window()" value="[% 'Follow-Up' | $T8 %]">
 
  [% ELSE # no id %]
-   [% UNLESS locked %]
       <input class="submit" type="submit" name="action" id="update_button" value="[% 'Update' | $T8 %]">
+   [% UNLESS locked %]
       <input class="submit" type="submit" name="action" value="[% 'Post' | $T8 %]">
-      <input class="submit" type="submit" name="action" value="[% 'Save Draft' | $T8 %]">
    [%- END %]
+      <input class="submit" type="submit" name="action" value="[% 'Save Draft' | $T8 %]">
  [% END # id %]
 
   [% IF id %]