Merge branch 'master' of vc.linet-services.de:public/lx-office-erp
authorNiclas Zimmermann <niclas@lx-office-hosting.de>
Thu, 20 Sep 2012 13:55:57 +0000 (15:55 +0200)
committerNiclas Zimmermann <niclas@lx-office-hosting.de>
Thu, 20 Sep 2012 13:55:57 +0000 (15:55 +0200)
SL/Controller/DeliveryPlan.pm
SL/IS.pm
bin/mozilla/cp.pl
bin/mozilla/ir.pl
bin/mozilla/is.pl
locale/de/all
templates/webpages/ir/_payments.html
templates/webpages/is/_payments.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 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 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 7d5c36a..f909d86 100644 (file)
@@ -316,7 +316,8 @@ sub form_header {
   my @values = map { $_       } @{ $form->{ALL_CURRENCIES} };
   my %labels = map { $_ => $_ } @{ $form->{ALL_CURRENCIES} };
   $form->{currency}            = $form->{defaultcurrency} unless $form->{currency};
-  $TMPL_VAR{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
+  # show_exchangerate is also later needed in another template
+  $form->{show_exchangerate} = $form->{currency} ne $form->{defaultcurrency};
   $TMPL_VAR{currencies}        = NTI($cgi->popup_menu('-name' => 'currency', '-default' => $form->{"currency"},
                                                       '-values' => \@values, '-labels' => \%labels,
                                                       '-onchange' => "document.getElementById('update_button').click();"
index 4716f60..56162d5 100644 (file)
@@ -517,6 +517,9 @@ sub update {
   for my $i (1 .. $form->{paidaccounts}) {
     next unless $form->{"paid_$i"};
     map { $form->{"${_}_$i"} = $form->parse_amount(\%myconfig, $form->{"${_}_$i"}) } qw(paid exchangerate);
+    if (!$form->{"forex_$i"}) {   #read exchangerate from input field (not hidden)
+      $form->{exchangerate} = $form->{"exchangerate_$i"};
+    } 
     $form->{"forex_$i"}        = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{"datepaid_$i"}, 'buy');
     $form->{"exchangerate_$i"} = $form->{"forex_$i"} if $form->{"forex_$i"};
   }
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 1677219..6d7db5e 100644 (file)
@@ -75,9 +75,9 @@
      <td align="center">
   [% SET forex        = 'forex_'        _ i %]
   [% SET exchangerate = 'exchangerate_' _ i %]
-  [% IF forex %]
+  [% IF $forex %]
         <input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
-        [% LxERP.format_amount(exchangerate, 2) %]
+        [% LxERP.format_amount($forex, 2) %]
   [% ELSE %]
      [% IF $changeable %]
         <input name="exchangerate_[% i %]" size="10" value="[% LxERP.format_amount($exchangerate, 2, 1) %]">
@@ -86,7 +86,7 @@
         [% LxERP.format_amount($exchangerate, 2, 1) %]
      [% END %]
   [% END %]
-        <input type="hidden" name="forex_[% i %]" value="[% $forex %]">;
+        <input type="hidden" name="forex_[% i %]" value="[% $forex %]">
      </td>
 [% END %]
 
index a872215..41b0186 100644 (file)
@@ -78,7 +78,7 @@
      <td align="center">
   [% SET forex        = 'forex_'        _ i %]
   [% SET exchangerate = 'exchangerate_' _ i %]
-  [% IF forex %]
+  [% IF $forex %]
         <input type="hidden" name="exchangerate_[% i %]" value="[% LxERP.format_amount($exchangerate, 2) %]">
         [% LxERP.format_amount($forex, 2) %]
   [% ELSE %]