partnumber => t8('Part Number'),
qty => t8('Qty'),
shipped_qty => t8('shipped'),
+ delivered_qty => t8('transferred out'),
not_shipped_qty => t8('not shipped'),
ordnumber => t8('Order'),
customer => t8('Customer'),
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
- my @columns = qw(reqdate customer ordnumber partnumber description qty shipped_qty not_shipped_qty);
+ my @columns = qw(reqdate customer ordnumber partnumber description qty shipped_qty not_shipped_qty delivered_qty);
my @sortable = qw(reqdate customer ordnumber partnumber description);
my %column_defs = (
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 } },
+ delivered_qty => { sub => sub { $::form->format_amount(\%::myconfig, $_[0]->delivered_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 },
return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi);
}
+sub delivered_qty {
+ my ($self) = @_;
+
+ my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder');
+ my @d_orders_delivered;
+
+ foreach (@$d_orders) {
+ push (@d_orders_delivered, $_) if $_->delivered;
+ }
+
+ my @doi_delivered = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @d_orders_delivered;
+
+ require SL::AM;
+ return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi_delivered);
+}
+
1;