check_do_access();
- $form->{vc} = $form->{type} eq 'purchase_order' ? 'vendor' : 'customer';
+ $form->{vc} = $form->{type} eq 'purchase_delivery_order' ? 'vendor' : 'customer';
$form->get_lists("projects" => { "key" => "ALL_PROJECTS",
"all" => 1 },
$lxdebug->enter_sub();
check_do_access();
- $auth->assert($form->{type} eq 'purchase_order' || $form->{type} eq 'request_quotation' ? 'vendor_invoice_edit' : 'invoice_edit');
+ $auth->assert($form->{type} eq 'purchase_delivery_order' ? 'vendor_invoice_edit' : 'invoice_edit');
$form->{deliverydate} = $form->{transdate};
$form->{transdate} = $form->{invdate} = $form->current_date(\%myconfig);
$form->{saveasnew} = 1;
$form->{closed} = 0;
+ $form->{delivered} = 0;
map { delete $form->{$_} } qw(printed emailed queued);
# Let Lx-Office assign a new order number if the user hasn't changed the
my $stock_info = [];
foreach my $i (1..$form->{rowcount}) {
+ $form->{"qty_$i"} = $form->parse_amount(\%myconfig, $form->{"qty_$i"});
push @{ $stock_info }, { map { $_ => $form->{"${_}_${i}"} } qw(warehouse_id bin_id chargenumber qty unit) };
}
- $main::lxdebug->dump(0, "si", $stock_info);
display_stock_in_form($stock_info);
my $part_info = IC->get_basic_part_info('id' => $form->{parts_id});
- my $units = AM->retrieve_units(\%myconfig, $form, "dimension");
+ my $units = AM->retrieve_units(\%myconfig, $form);
my $units_data = AM->unit_select_data($units, undef, undef, $part_info->{unit});
- my $access = $auth->check_right($form->{login}, 'all_warehouses') ? undef : $form->{login};
-
$form->get_lists('warehouses' => { 'key' => 'WAREHOUSES',
- 'bins' => 'BINS',
- 'access' => $access, });
+ 'bins' => 'BINS' });
- redo_stock_info('stock_info' => $stock_info, 'add_empty_row' => !$form->{closed});
+ redo_stock_info('stock_info' => $stock_info, 'add_empty_row' => !$form->{delivered});
get_basic_bin_wh_info($stock_info);
my $part_info = IC->get_basic_part_info('id' => $form->{parts_id});
- my $units = AM->retrieve_units(\%myconfig, $form, "dimension");
+ my $units = AM->retrieve_units(\%myconfig, $form);
my $units_data = AM->unit_select_data($units, undef, undef, $part_info->{unit});
my @contents = DO->get_item_availability('parts_id' => $form->{parts_id});
my $stock_info = DO->unpack_stock_information('packed' => $form->{stock});
- if (!$form->{closed}) {
+ if (!$form->{delivered}) {
foreach my $row (@contents) {
$row->{available_qty} = $form->format_amount_units('amount' => $row->{qty} * 1,
'part_unit' => $part_info->{unit},
$form->header();
print $form->parse_html_template('do/stock_out_form', { 'UNITS' => $units_data,
- 'WHCONTENTS' => $form->{closed} ? $stock_info : \@contents,
+ 'WHCONTENTS' => $form->{delivered} ? $stock_info : \@contents,
'PART_INFO' => $part_info, });
$lxdebug->leave_sub();
$lxdebug->leave_sub();
}
-sub transfer_in_and_close {
+sub transfer_in {
$lxdebug->enter_sub();
my @part_ids = map { $form->{"id_${_}"} } grep { $form->{"id_${_}"} && $form->{"stock_in_${_}"} } (1 .. $form->{rowcount});
my @all_requests;
if (@part_ids) {
- my $units = AM->retrieve_units(\%myconfig, $form, "dimension");
+ my $units = AM->retrieve_units(\%myconfig, $form);
my %part_info_map = IC->get_basic_part_info('id' => \@part_ids);
my %request_map;
}
if (@{ $form->{ERRORS} }) {
- push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been closed. The warehouse contents have not changed.');
+ push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been marked as delivered. The warehouse contents have not changed.');
update();
$lxdebug->leave_sub();
DO->transfer_in_out('direction' => 'in',
'requests' => \@all_requests);
- $form->{closed} = 1;
$form->{delivered} = 1;
save();
$lxdebug->leave_sub();
}
-sub transfer_out_and_close {
+sub transfer_out {
$lxdebug->enter_sub();
my @part_ids = map { $form->{"id_${_}"} } grep { $form->{"id_${_}"} && $form->{"stock_out_${_}"} } (1 .. $form->{rowcount});
my @all_requests;
if (@part_ids) {
- my $units = AM->retrieve_units(\%myconfig, $form, "dimension");
+ my $units = AM->retrieve_units(\%myconfig, $form);
my %part_info_map = IC->get_basic_part_info('id' => \@part_ids);
my %request_map;
}
if (@{ $form->{ERRORS} }) {
- push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been closed. The warehouse contents have not changed.');
+ push @{ $form->{ERRORS} }, $locale->text('The delivery order has not been marked as delivered. The warehouse contents have not changed.');
update();
$lxdebug->leave_sub();
DO->transfer_in_out('direction' => 'out',
'requests' => \@all_requests);
- $form->{closed} = 1;
$form->{delivered} = 1;
save();