From 7a9df994dcf984598e3602591d93e7d3cc09c378 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 8 Nov 2021 04:22:24 +0100 Subject: [PATCH] DeliveryOrder: Lagermengen Spalte --- SL/Controller/DeliveryOrder.pm | 17 +++++++++++++++++ .../webpages/delivery_order/tabs/_row.html | 6 ++++++ .../delivery_order/tabs/basic_data.html | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/SL/Controller/DeliveryOrder.pm b/SL/Controller/DeliveryOrder.pm index 9789710bc..653342549 100644 --- a/SL/Controller/DeliveryOrder.pm +++ b/SL/Controller/DeliveryOrder.pm @@ -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]); } diff --git a/templates/webpages/delivery_order/tabs/_row.html b/templates/webpages/delivery_order/tabs/_row.html index be552e71e..9361f207f 100644 --- a/templates/webpages/delivery_order/tabs/_row.html +++ b/templates/webpages/delivery_order/tabs/_row.html @@ -85,6 +85,12 @@ value_key = 'name', class = 'unitselect') %] + + + [% SELF.calculate_stock_in_out(ITEM) %] + + + diff --git a/templates/webpages/delivery_order/tabs/basic_data.html b/templates/webpages/delivery_order/tabs/basic_data.html index ed2f753c9..d3ff15518 100644 --- a/templates/webpages/delivery_order/tabs/basic_data.html +++ b/templates/webpages/delivery_order/tabs/basic_data.html @@ -222,6 +222,12 @@ [%- END -%] [%- 'Qty' | $T8 %] [%- 'Unit' | $T8 %] + [% IF inout == 'in' %] + [%- 'Transfer To Stock' | $T8 %] + [% END %] + [% IF inout == 'out' %] + [%- 'Release From Stock' | $T8 %] + [% END %] -- 2.20.1