$form->{lastmtime} = $form->{mtime};
$form->{onhand} *= 1;
- die "part needs a part_type" unless $form->{part_type}; # TODO from part_type enum conversion
# part or service item
- $form->{item} = $form->{part_type};
- if ($form->{item} eq 'assembly') {
+ if ($form->{part_type} eq 'assembly') {
# retrieve assembly items
$query =
my $priceupdate = ', priceupdate = current_date';
if ($form->{id}) {
- my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
+ my $trans_number = SL::TransNumber->new(type => $form->{part_type}, dbh => $dbh, number => $form->{partnumber}, id => $form->{id});
if (!$trans_number->is_unique) {
$::lxdebug->leave_sub;
return 3;
# delete makemodel records
do_query($form, $dbh, qq|DELETE FROM makemodel WHERE parts_id = ?|, conv_i($form->{id}));
- if ($form->{item} eq 'assembly') {
+ if ($form->{part_type} eq 'assembly') {
# delete assembly records
do_query($form, $dbh, qq|DELETE FROM assembly WHERE id = ?|, conv_i($form->{id}));
}
$priceupdate = '' if (all { $previous_values->{$_} == $form->{$_} } qw(sellprice lastcost listprice));
} else {
- my $trans_number = SL::TransNumber->new(type => $form->{item}, dbh => $dbh, number => $form->{partnumber}, save => 1);
+ my $trans_number = SL::TransNumber->new(type => $form->{part_type}, dbh => $dbh, number => $form->{partnumber}, save => 1);
if ($form->{partnumber} && !$trans_number->is_unique) {
$::lxdebug->leave_sub;
$form->{partnumber} ||= $trans_number->create_unique;
($form->{id}) = selectrow_query($form, $dbh, qq|SELECT nextval('id')|);
- do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{item});
+ do_query($form, $dbh, qq|INSERT INTO parts (id, partnumber, unit, part_type) VALUES (?, ?, ?, ?)|, $form->{id}, $form->{partnumber}, $form->{unit}, $form->{part_type});
$form->{orphaned} = 1;
}
}
my ($subq_inventory, $subq_expense, $subq_income);
- if ($form->{"item"} eq "part") {
+ if ($form->{part_type} eq "part") {
$subq_inventory =
qq|(SELECT bg.inventory_accno_id
FROM buchungsgruppen bg
$subq_inventory = "NULL";
}
- if ($form->{"item"} ne "assembly") {
+ if ($form->{part_type} ne "assembly") {
$subq_expense =
qq|(SELECT tc.expense_accno_id
FROM taxzone_charts tc
$form->{has_sernumber} ? 't' : 'f',
$form->{not_discountable} ? 't' : 'f',
$form->{microfiche},
- $form->{item},
+ $form->{part_type},
conv_i($partsgroup_id),
conv_i($form->{price_factor_id}),
conv_i($form->{id})
}
# add assembly records
- if ($form->{item} eq 'assembly') {
+ if ($form->{part_type} eq 'assembly') {
# check additional assembly row
my $i = $form->{assembly_rows};
# if last row is not empty add them
$auth->assert('part_service_assembly_edit');
- my $title = 'Add ' . ucfirst $form->{item};
+ my $title = 'Add ' . ucfirst $form->{part_type};
$form->{title} = $locale->text($title);
- $form->{callback} = "$form->{script}?action=add&item=$form->{item}" unless $form->{callback};
+ $form->{callback} = "$form->{script}?action=add&part_type=$form->{part_type}" unless $form->{callback};
$form->{unit_changeable} = 1;
IC->get_pricegroups(\%myconfig, \%$form);
$form->{"original_partnumber"} = $form->{"partnumber"};
- my $title = 'Edit ' . ucfirst $form->{item};
+ my $title = 'Edit ' . ucfirst $form->{part_type};
$form->{title} = $locale->text($title);
&link_part;
map({ $form->{selectcurrency} .= "<option>$_\n" } $::form->get_all_currencies());
# parts and assemblies have the same links
- my $item = $form->{item};
- if ($form->{item} eq 'assembly') {
+ my $item = $form->{part_type};
+ if ($form->{part_type} eq 'assembly') {
$item = 'part';
}
}
chop $form->{taxaccounts};
- if (($form->{item} eq "part") || ($form->{item} eq "assembly")) {
+ if (($form->{part_type} eq "part") || ($form->{part_type} eq "assembly")) {
$form->{selectIC_income} = $form->{selectIC_sale};
$form->{selectIC_expense} = $form->{selectIC_cogs};
$form->{IC_income} = $form->{IC_sale};
map { $form->{selectpartsgroup} .= qq|<option value="$_->{partsgroup}--$_->{id}">$_->{partsgroup}\n| } @{ $form->{all_partsgroup} };
}
- if ($form->{item} eq 'assembly') {
+ if ($form->{part_type} eq 'assembly') {
foreach my $i (1 .. $form->{assembly_rows}) {
if ($form->{"partsgroup_id_$i"}) {
$form->{description_area} = ($form->{rows} = $form->numtextrows($form->{description}, 40)) > 1;
$form->{notes_rows} = max 4, $form->numtextrows($form->{notes}, 40), $form->numtextrows($form->{formel}, 40);
- map { $form->{"is_$_"} = ($form->{item} eq $_) } qw(part service assembly);
+ map { $form->{"is_$_"} = ($form->{part_type} eq $_) } qw(part service assembly);
map { $form->{$_} =~ s/"/"/g; } qw(unit);
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS',
IC->retrieve_buchungsgruppen(\%myconfig, $form);
@{ $form->{BUCHUNGSGRUPPEN} } = grep { $_->{id} eq $form->{buchungsgruppen_id} || ($form->{id} && $form->{orphaned}) || !$form->{id} } @{ $form->{BUCHUNGSGRUPPEN} };
- if (($form->{partnumber} ne '') && !SL::TransNumber->new(number => $form->{partnumber}, type => $form->{item}, id => $form->{id})->is_unique) {
+ if (($form->{partnumber} ne '') && !SL::TransNumber->new(number => $form->{partnumber}, type => $form->{part_type}, id => $form->{id})->is_unique) {
flash('info', $::locale->text('This partnumber is not unique. You should change it.'));
}
# parse pricegroups. and no, don't rely on check_form for this...
map { $form->{"price_$_"} = $form->parse_amount(\%myconfig, $form->{"price_$_"}) } 1 .. $form->{price_rows};
- unless ($form->{item} eq 'assembly') {
+ unless ($form->{part_type} eq 'assembly') {
# for assemblies check_form will parse sellprice and listprice, but not for parts or services
$form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(sellprice listprice ve gv);
};
- if ($form->{item} eq 'part') {
+ if ($form->{part_type} eq 'part') {
$form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) for qw(weight rop);
}
# same for makemodel lastcosts
# but parse_amount not necessary for assembly component lastcosts
- unless ($form->{item} eq "assembly") {
+ unless ($form->{part_type} eq "assembly") {
map { $form->{"lastcost_$_"} = $form->parse_amount(\%myconfig, $form->{"lastcost_$_"}) } 1 .. $form->{"makemodel_rows"};
$form->{lastcost} = $form->parse_amount(\%myconfig, $form->{lastcost});
}
- if ($form->{item} eq "assembly") {
+ if ($form->{part_type} eq "assembly") {
my $i = $form->{assembly_rows};
# if last row is empty check the form otherwise retrieve item
}
}
- } elsif (($form->{item} eq 'part') || ($form->{item} eq 'service')) {
+ } elsif (($form->{part_type} eq 'part') || ($form->{part_type} eq 'service')) {
&check_form;
}
my ($parts_id, %newform, $amount, $callback);
# check if there is a part number - commented out, cause there is an automatic allocation of numbers
- # $form->isblank("partnumber", $locale->text(ucfirst $form->{item}." Part Number missing!"));
+ # $form->isblank("partnumber", $locale->text(ucfirst $form->{part_type}." Part Number missing!"));
# check if there is a description
$form->isblank("description", $locale->text("Part Description missing!"));
- $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{item} obsolete!"))
- if $form->{obsolete} && $form->{onhand} * 1 && $form->{item} ne 'service';
+ $form->error($locale->text("Inventory quantity must be zero before you can set this $form->{part_type} obsolete!"))
+ if $form->{obsolete} && $form->{onhand} * 1 && $form->{part_type} ne 'service';
if (!$form->{buchungsgruppen_id}) {
$form->error($locale->text("Parts must have an entry type.") . " " .
$::auth->restore_form_from_session($newform{previousform}, form => $form);
$form->{taxaccounts} = $newform{taxaccount2};
- if ($form->{item} eq 'assembly') {
+ if ($form->{part_type} eq 'assembly') {
# undo number formatting
map { $form->{$_} = $form->parse_amount(\%myconfig, $form->{$_}) }
form_header();
price_row($::form->{price_rows});
- makemodel_row(++$::form->{makemodel_rows}) if $::form->{item} =~ /^(part|service)$/;
- assembly_row(++$::form->{assembly_rows}) if $::form->{item} eq 'assembly';
+ makemodel_row(++$::form->{makemodel_rows}) if $::form->{part_type} =~ /^(part|service)$/;
+ assembly_row(++$::form->{assembly_rows}) if $::form->{part_type} eq 'assembly';
form_footer();