DeliveryOrder: Lagermengen Spalte
authorSven Schöling <s.schoeling@googlemail.com>
Mon, 8 Nov 2021 03:22:24 +0000 (04:22 +0100)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 14:02:19 +0000 (15:02 +0100)
SL/Controller/DeliveryOrder.pm
templates/webpages/delivery_order/tabs/_row.html
templates/webpages/delivery_order/tabs/basic_data.html

index 9789710..6533425 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 use parent qw(SL::Controller::Base);
 
 use SL::Helper::Flash qw(flash_later);
+use SL::Helper::Number qw(_format_number_units);
 use SL::Presenter::Tag qw(select_tag hidden_tag div_tag);
 use SL::Locale::String qw(t8);
 use SL::SessionFile::Random;
@@ -1930,6 +1931,22 @@ sub store_pdf_to_webdav_and_filemanagement {
   return @errors;
 }
 
+sub calculate_stock_in_out {
+  my ($self, $item) = @_;
+
+  return "" if !$item->part || !$item->part->unit;
+
+  my $in_out   = $self->type_data->properties("transfer");
+
+  my $do_qty   = $item->qty;
+  my $sum      = sum0 map { $_->unit_obj->convert_to($_->qty, $item->unit_obj) } @{ $item->delivery_order_stock_entries };
+
+  my $matches  = $do_qty == $sum;
+  my $content  = _format_number_units($sum, 2, $item->unit_obj, $item->part->unit_obj);
+
+  return $content;
+}
+
 sub init_type_data {
   SL::Controller::DeliveryOrder::TypeData->new($_[0]);
 }
index be552e7..9361f20 100644 (file)
                       value_key = 'name',
                       class = 'unitselect') %]
     </td>
+
+    <td>
+      <span id="stock_[% ID %]">[% SELF.calculate_stock_in_out(ITEM) %]</span>
+      <input type=hidden id='stock_in_out_qty_matches_[% ID %]' value='$matches'>
+      <input type="button" onclick="kivi.DeliveryOrder.open_stock_in_out_window('[% in_out %]', ID);" value="?">
+    </td>
   </tr>
 
   <tr [%- IF !MYCONFIG.show_form_details -%]style="display:none"[%- END -%]>
index ed2f753..d3ff155 100644 (file)
                 [%- END -%]
                 <th id="qty_header_id"          class="listheading" nowrap width="5" ><a href='#' onClick='javascript:kivi.DeliveryOrder.reorder_items("qty")'>        [%- 'Qty'         | $T8 %]</a></th>
                 <th class="listheading" nowrap width="5" >[%- 'Unit'         | $T8 %] </th>
+                [% IF inout == 'in' %]
+                <th class="listheading" nowrap width="5" >[%- 'Transfer To Stock' | $T8 %] </th>
+                [% END %]
+                [% IF inout == 'out' %]
+                <th class="listheading" nowrap width="5" >[%- 'Release From Stock' | $T8 %] </th>
+                [% END %]
               </tr>
             </thead>