$::form->{title} = t8('Stock');
+ # Sometimes we want to open stock_in with a part already selected, but only
+ # the parts_id is passed in the url (and not also warehouse, bin and unit).
+ # Setting select_default_bin in the form will make sure the default warehouse
+ # and bin of that part will already be preselected, as normally
+ # set_target_from_part is only called when a part is changed.
+ $self->set_target_from_part if $::form->{select_default_bin};
$::request->layout->focus('#part_id_name');
my $transfer_types = WH->retrieve_transfer_types('in');
map { $_->{description} = $main::locale->text($_->{description}) } @{ $transfer_types };
$row->{outcorrection}->{data} - $row->{incorrection}->{data};
$row->{averconsumed}->{data} = $row->{consumed}->{data}*30/$days ;
map { $row->{$_}->{data} = $form->format_amount($myconfig,$row->{$_}->{data},2); } $self->getnumcolumns();
- $row->{partnumber}->{link} = 'controller.pl?action=Part/edit&part.id' . $partid;
+ $row->{partnumber}->{link} = 'controller.pl?action=Part/edit&part.id=' . $partid;
}
sub action_stock {
stocktaking_cutoff_date => $::form->{cutoff_date_as_date},
});
1;
- } or do { $transfer_error = $EVAL_ERROR->error; }
+ } or do { $transfer_error = ref($EVAL_ERROR) eq 'SL::X::FormError' ? $EVAL_ERROR->error : $EVAL_ERROR; }
});
return $self->js->flash('error', $transfer_error)->render()
my $now = DateTime->now_local;
my $cutoff = DateTime->new(year => $now->year, month => 12, day => 31);
if ($now->month < 1) {
- $cutoff->substract(years => 1);
+ $cutoff->subtract(years => 1);
}
return $cutoff;
}
my ($self) = @_;
$self->warehouse($self->warehouses->[0]) if !$self->warehouse || !$self->warehouse->id;
- $self->bin ($self->warehouse->bins->[0]) if !$self->bin || !$self->bin->id;
+ $self->bin ($self->warehouse->bins_sorted_naturally->[0]) if !$self->bin || !$self->bin->id;
# foreach my $warehouse ( $self->warehouses ) {
# $warehouse->{BINS} = [];
# foreach my $bin ( $self->bins ) {
}
sub build_bin_select {
- select_tag('bin_id', [ $_[0]->warehouse->bins ],
+ select_tag('bin_id', $_[0]->warehouse->bins_sorted_naturally,
title_key => 'description',
default => $_[0]->bin->id,
);
from last_inventories
group by trans_id
order by max(itime)
- desc limit 10
+ desc limit 20
)
select unnest(ids)
from grouped_ids
SQL
my $objs = SL::DB::Manager::Inventory->get_all(
- query => [ id => [ \"$query" ] ],
+ query => [ id => [ \"$query" ] ], # " make emacs happy
with_objects => [ 'parts', 'trans_type', 'bin', 'bin.warehouse' ], # prevent lazy loading in template
sort_by => 'itime DESC',
);
my $callback = $self->stocktaking_models->get_callback;
- my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
- $self->{report} = $report;
+ my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
+ $report->{title} = t8('Stocktaking Journal');
+ $self->{report} = $report;
my @columns = qw(itime employee ean partnumber part qty unit bin chargenumber comment cutoff_date);
my @sortable = qw(itime employee ean partnumber part qty bin chargenumber comment cutoff_date);
my %bestbefore_filter;
if ($::instance_conf->get_show_bestbefore) {
- %bestbefore_filter = (bestbefore => $params{bestbefore});
+ %bestbefore_filter = (bestbefore => ($params{bestbefore} || undef));
}
SL::DB::Manager::Stocktaking->get_all(query => [and => [parts_id => $part->id,