Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorG. Richardson <information@lx-office-hosting.de>
Fri, 21 Sep 2012 13:16:11 +0000 (15:16 +0200)
committerG. Richardson <information@lx-office-hosting.de>
Fri, 21 Sep 2012 13:16:11 +0000 (15:16 +0200)
SL/Controller/DeliveryPlan.pm
SL/Form.pm
SL/IS.pm
SL/InstallationCheck.pm
bin/mozilla/cp.pl
bin/mozilla/ct.pl
locale/de/all
scripts/installation_check.pl
t/form/format_amount.t
templates/webpages/is/form_footer.html
templates/webpages/oe/edit_periodic_invoices_config.html

index 5ce462b..5937c5b 100644 (file)
@@ -26,19 +26,20 @@ __PACKAGE__->make_paginated(
 );
 
 __PACKAGE__->make_sorted(
-  MODEL       => 'OrderItem',
-  ONLY        => [ qw(list) ],
-
-  DEFAULT_BY  => 'reqdate',
-  DEFAULT_DIR => 1,
-
-  reqdate     => t8('Reqdate'),
-  description => t8('Description'),
-  partnumber  => t8('Part Number'),
-  qty         => t8('Qty'),
-  shipped_qty => t8('shipped'),
-  ordnumber   => t8('Order'),
-  customer    => t8('Customer'),
+  MODEL             => 'OrderItem',
+  ONLY              => [ qw(list) ],
+
+  DEFAULT_BY        => 'reqdate',
+  DEFAULT_DIR       => 1,
+
+  reqdate           => t8('Reqdate'),
+  description       => t8('Description'),
+  partnumber        => t8('Part Number'),
+  qty               => t8('Qty'),
+  shipped_qty       => t8('shipped'),
+  not_shipped_qty   => t8('not shipped'),
+  ordnumber         => t8('Order'),
+  customer          => t8('Customer'),
 );
 
 sub action_list {
@@ -131,21 +132,22 @@ sub prepare_report {
   my $report      = SL::ReportGenerator->new(\%::myconfig, $::form);
   $self->{report} = $report;
 
-  my @columns     = qw(reqdate customer ordnumber partnumber description qty shipped_qty);
+  my @columns     = qw(reqdate customer ordnumber partnumber description qty shipped_qty not_shipped_qty);
   my @sortable    = qw(reqdate customer ordnumber partnumber description                );
 
   my %column_defs = (
-    reqdate       => {      sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date                         } },
-    description   => {      sub => sub { $_[0]->description                                                              },
-                       obj_link => sub { $self->link_to($_[0]->part)                                                     } },
-    partnumber    => {      sub => sub { $_[0]->part->partnumber                                                         },
-                       obj_link => sub { $self->link_to($_[0]->part)                                                     } },
-    qty           => {      sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit                                        } },
-    shipped_qty   => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
-    ordnumber     => {      sub => sub { $_[0]->order->ordnumber                                                         },
-                       obj_link => sub { $self->link_to($_[0]->order)                                                    } },
-    customer      => {      sub => sub { $_[0]->order->customer->name                                                    },
-                       obj_link => sub { $self->link_to($_[0]->order->customer)                                          } },
+    reqdate           => {      sub => sub { $_[0]->reqdate_as_date || $_[0]->order->reqdate_as_date                         } },
+    description       => {      sub => sub { $_[0]->description                                                              },
+                            obj_link => sub { $self->link_to($_[0]->part)                                                     } },
+    partnumber        => {      sub => sub { $_[0]->part->partnumber                                                         },
+                            obj_link => sub { $self->link_to($_[0]->part)                                                     } },
+    qty               => {      sub => sub { $_[0]->qty_as_number . ' ' . $_[0]->unit                                        } },
+    shipped_qty       => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
+    not_shipped_qty   => {      sub => sub { $::form->format_amount(\%::myconfig, $_[0]->qty - $_[0]->shipped_qty, 2) . ' ' . $_[0]->unit } },
+    ordnumber         => {      sub => sub { $_[0]->order->ordnumber                                                         },
+                            obj_link => sub { $self->link_to($_[0]->order)                                                    } },
+    customer          => {      sub => sub { $_[0]->order->customer->name                                                    },
+                            obj_link => sub { $self->link_to($_[0]->order->customer)                                          } },
   );
 
   map { $column_defs{$_}->{text} = $::locale->text( $self->get_sort_spec->{$_}->{title} ) } keys %column_defs;
index ff7d0ef..539cd9c 100644 (file)
@@ -878,7 +878,7 @@ sub format_amount {
   # this is easy to confuse, so keep in mind: before this comment no s///, m//, concat or other strong ops on
   # $amount. after this comment no +,-,*,/,abs. it will only introduce subtle bugs.
 
-  $amount =~ s/0*$//;                                                    # cull trailing 0s
+  $amount =~ s/0*$// unless defined $places && $places == 0;             # cull trailing 0s
 
   my @d = map { s/\d//g; reverse split // } my $tmp = $myconfig->{numberformat}; # get delim chars
   my @p = split(/\./, $amount);                                          # split amount at decimal point
index 22080c7..82226ee 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -933,18 +933,16 @@ sub post_invoice {
 
       # exchangerate difference
       $form->{fx}{$accno}{ $form->{"datepaid_$i"} } +=
-      $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $diff;
+        $form->{"paid_$i"} * ($form->{"exchangerate_$i"} - 1) + $diff;
 
       # gain/loss
       $amount =
-      $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} *
-      $form->{"exchangerate_$i"};
+        $form->{"paid_$i"} * $form->{exchangerate} - $form->{"paid_$i"} *
+        $form->{"exchangerate_$i"};
       if ($amount > 0) {
-        $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } +=
-        $amount;
+        $form->{fx}{ $form->{fxgain_accno} }{ $form->{"datepaid_$i"} } += $amount;
       } else {
-        $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } +=
-        $amount;
+        $form->{fx}{ $form->{fxloss_accno} }{ $form->{"datepaid_$i"} } += $amount;
       }
 
       $diff = 0;
@@ -963,35 +961,32 @@ sub post_invoice {
 
   IO->set_datepaid(table => 'ar', id => $form->{id}, dbh => $dbh);
 
-  if ($payments_only) {
-    $query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
-    do_query($form, $dbh, $query,  $form->{paid}, conv_i($form->{id}));
-
-    $dbh->commit if !$provided_dbh;
-
-    $main::lxdebug->leave_sub();
-    return;
-  }
-
   # record exchange rate differences and gains/losses
   foreach my $accno (keys %{ $form->{fx} }) {
     foreach my $transdate (keys %{ $form->{fx}{$accno} }) {
-      if (
-          ($form->{fx}{$accno}{$transdate} =
-           $form->round_amount($form->{fx}{$accno}{$transdate}, 2)
-          ) != 0
-        ) {
+      $form->{fx}{$accno}{$transdate} = $form->round_amount($form->{fx}{$accno}{$transdate}, 2);
+      if ( $form->{fx}{$accno}{$transdate} != 0 ) {
 
         $query =
           qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, cleared, fx_transaction, taxkey, project_id)
              VALUES (?, (SELECT id FROM chart WHERE accno = ?), ?, ?, '0', '1',
              (SELECT taxkey_id FROM chart WHERE accno = ?), ?)|;
-        @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, $project_id);
+        @values = (conv_i($form->{"id"}), $accno, $form->{fx}{$accno}{$transdate}, conv_date($transdate), $accno, conv_i($project_id));
         do_query($form, $dbh, $query, @values);
       }
     }
   }
 
+  if ($payments_only) {
+    $query = qq|UPDATE ar SET paid = ? WHERE id = ?|;
+    do_query($form, $dbh, $query,  $form->{paid}, conv_i($form->{id}));
+
+    $dbh->commit if !$provided_dbh;
+
+    $main::lxdebug->leave_sub();
+    return;
+  }
+
   $amount = $netamount + $tax;
 
   # save AR record
index 397a99f..d29578b 100644 (file)
@@ -15,7 +15,7 @@ BEGIN {
   { name => "Config::Std",                         url => "http://search.cpan.org/~dconway/",   debian => 'libconfig-std-perl' },
   { name => "DateTime",                            url => "http://search.cpan.org/~drolsky/",   debian => 'libdatetime-perl' },
   { name => "DBI",             version => '1.50',  url => "http://search.cpan.org/~timb/",      debian => 'libdbi-perl' },
-  { name => "DBD::Pg",         version => '1.49',  url => "http://search.cpan.org/~dbdpg/",     debian => 'libdbd-pg' },
+  { name => "DBD::Pg",         version => '1.49',  url => "http://search.cpan.org/~dbdpg/",     debian => 'libdbd-pg-perl' },
   { name => "Email::Address",                      url => "http://search.cpan.org/~rjbs/",      debian => 'libemail-address-perl' },
   { name => "FCGI",            version => '0.72',  url => "http://search.cpan.org/~mstrout/",   debian => 'libfcgi-perl' },
   { name => "JSON",                                url => "http://search.cpan.org/~makamaka",   debian => 'libjson-perl' },
index 885c88e..a8caa52 100644 (file)
@@ -346,6 +346,9 @@ sub update {
     }
   }
 
+  if (!$form->{forex}) {        # read exchangerate from input field (not hidden)
+    $form->{exchangerate} = $form->parse_amount(\%myconfig, $form->{exchangerate});
+  }
   $form->{forex}        = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{datepaid}, $buysell);
   $form->{exchangerate} = $form->{forex} if $form->{forex};
 
index 31c70d0..b1634cb 100644 (file)
@@ -521,9 +521,7 @@ sub form_footer {
 }
 
 sub _do_save {
-  $main::auth->assert('customer_vendor_edit & ' .
-                      '(general_ledger         | invoice_edit         | vendor_invoice_edit | ' .
-                      ' request_quotation_edit | sales_quotation_edit | sales_order_edit    | purchase_order_edit)');
+  $main::auth->assert('customer_vendor_edit');
 
   $::form->isblank("name", $::locale->text("Name missing!"));
 
index 5740fd0..9fbd29b 100644 (file)
@@ -2336,6 +2336,7 @@ $self->{texts} = {
   'not logged in'               => 'nicht eingeloggt',
   'not running'                 => 'läuft nicht',
   'not set'                     => 'nicht gesetzt',
+  'not shipped'                 => 'nicht geliefert',
   'not transferred in yet'      => 'noch nicht eingelagert',
   'not transferred out yet'     => 'noch nicht ausgelagert',
   'not yet executed'            => 'Noch nicht ausgeführt',
index a50d184..2bec003 100755 (executable)
@@ -13,9 +13,29 @@ BEGIN {
   $master_templates = './templates/print/';
 }
 
+unless (eval { require Config::Std; 1 }){
+  print STDERR <<EOL ;
++------------------------------------------------------------------------------+
+  Perl Modul Config::Std could not be loaded.
+
+  Debian: you may install the needed *.deb package with:
+    apt-get install libconfig-std-perl
+
+  RPM: There is a rpm package "perl-Config-Std"
+
+  Suse: you may install the needed *.rpm package with:
+    zypper install perl-Config-Std
+
++------------------------------------------------------------------------------+
+EOL
+
+  exit 72;
+}
+
 use SL::InstallationCheck;
 use SL::LxOfficeConf;
 
+
 my %check;
 Getopt::Long::Configure ("bundling");
 GetOptions(
index 58a7c17..229c88c 100644 (file)
@@ -32,6 +32,7 @@ is($::form->format_amount($config, 1.00045, -5), '1.00045', 'negative places 2')
 is($::form->format_amount($config, 1, -2), '1.00', 'negative places 3');
 
 # bugs amd edge cases
+$config->{numberformat} = '1.000,00';
 
 is($::form->format_amount({ numberformat => '1.000,00' }, 0.00005), '0,00005', 'messing with small numbers and no precision');
 is($::form->format_amount({ numberformat => '1.000,00' }, undef), '0', 'undef');
@@ -44,6 +45,12 @@ is($::form->format_amount($config, -0.545, 0), '-1', 'neg rounding up with preci
 
 is($::form->format_amount($config, 1.00), '1', 'autotrim to 0 places');
 
+is($::form->format_amount($config, 10), '10', 'autotrim does not harm integers');
+is($::form->format_amount($config, 10, 2), '10,00' , 'autotrim does not harm integers 2');
+is($::form->format_amount($config, 10, -2), '10,00' , 'autotrim does not harm integers 3');
+is($::form->format_amount($config, 10, 0), '10', 'autotrim does not harm integers 4');
+
+is($::form->format_amount($config, 0, 0), '0' , 'trivial zero');
 
 # dash stuff
 
index cf5c7d4..e0ef583 100644 (file)
     <input class="submit" type="submit" name="action" value="[% 'Delete' | $T8 %]">
     <input class="submit" type="submit" name="action" value="[% 'Post' | $T8 %]">
 [% END %]
-
-  [%- UNLESS locked %]
-       <input class="submit" type="submit" name="action" value="[% 'Order' | $T8 %]">
-  [%- END %]
-
+    <input class="submit" type="submit" name="action" value="[% 'Order' | $T8 %]">
     <input type="button" class="submit" onclick="follow_up_window()" value="[% 'Follow-Up' | $T8 %]">
 
  [% ELSE # no id %]
index 2df969e..ff45868 100644 (file)
@@ -56,7 +56,7 @@
     <tr>
      <th align="right">[%- LxERP.t8('Record in') %]</th>
      <td valign="top">
-      [% L.select_tag("ar_chart_id", AR, title_key => 'description', default => ar_chart_id)) %]
+      [% L.select_tag("ar_chart_id", AR, title_key => 'description', default => ar_chart_id) %]
      </td>
     </tr>