return $main::lxdebug->leave_sub() if (load_draft_maybe());
- $form->{title} = $locale->text('Add Vendor Invoice');
+ $form->{title} = $locale->text('Record Vendor Invoice');
&invoice_links;
&prepare_invoice;
$main::auth->assert('invoice_edit');
- our %TMPL_VAR = ();
+ my %TMPL_VAR = ();
my @custom_hiddens;
$form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id};
my $rows = scalar @{ $form->{item_list} };
if ($rows) {
- $form->{"qty_$i"} = 1 unless ($form->{"qty_$i"});
+ $form->{"qty_$i"} = 1 unless $form->parse_amount(\%myconfig, $form->{"qty_$i"});
if ($rows > 1) {
&select_item;
- exit;
+ ::end_of_request();
} else {
# override sellprice if there is one entered
my $sellprice = $form->parse_amount(\%myconfig, $form->{"sellprice_$i"});
- # ergaenzung fuer bug 736 Lieferanten-Rabatt auch in Einkaufsrechnungen vorbelegen jb
- $form->{"discount_$i"} = $form->format_amount(\%myconfig,
- $form->{vendor_discount} * 100 );
+ # ergaenzung fuer bug 736 Lieferanten-Rabatt auch in Einkaufsrechnungen vorbelegen jb
+ $form->{"discount_$i"} = $form->format_amount(\%myconfig, $form->{vendor_discount} * 100 );
map { $form->{item_list}[$i]{$_} =~ s/\"/"/g } qw(partnumber description unit);
map { $form->{"${_}_$i"} = $form->{item_list}[0]{$_} } keys %{ $form->{item_list}[0] };
if(!exists $form->{addition} && $form->{id} ne "") {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "CANCELED";
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->save_history;
}
# /saving the history
($form->{AP}) = split /--/, $form->{AP};
($form->{AP_paid}) = split /--/, $form->{AP_paid};
if (IR->post_payment(\%myconfig, \%$form)){
- if (!exists $form->{addition} && $form->{id} ne "") {
- # saving the history
+ if (!exists $form->{addition} && $form->{id} ne "") {
+ # saving the history
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
- $form->{addition} = "PAYMENT POSTED";
+ $form->{addition} = "PAYMENT POSTED";
$form->{what_done} = $form->{currency} . qq| | . $form->{paid} . qq| | . $locale->text("POSTED");
- $form->save_history($form->dbconnect(\%myconfig));
- # /saving the history
- }
+ $form->save_history;
+ # /saving the history
+ }
$form->redirect($locale->text('Payment posted!'));
}
# if the vendor changed get new values
if (&check_name('vendor')) {
&update;
+ ::end_of_request();
+ }
+
+ if ($myconfig{mandatory_departments} && !$form->{department_id}) {
+ $form->{saved_message} = $::locale->text('You have to specify a department.');
+ update();
exit;
}
+ remove_emptied_rows();
&validate_items;
my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
relink_accounts();
if (IR->post_invoice(\%myconfig, \%$form)){
- # saving the history
- if(!exists $form->{addition} && $form->{id} ne "") {
+ # saving the history
+ if(!exists $form->{addition} && $form->{id} ne "") {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
$form->{addition} = "POSTED";
- #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber};
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
+ #$form->{what_done} = $locale->text("Rechnungsnummer") . qq| | . $form->{invnumber};
+ $form->save_history;
+ }
+ # /saving the history
remove_draft() if $form->{remove_draft};
- $form->redirect( $locale->text('Invoice')
+ $form->redirect( $locale->text('Invoice')
. " $form->{invnumber} "
. $locale->text('posted!'));
}
# saving the history
if(!exists $form->{addition}) {
$form->{snumbers} = qq|invnumber_| . $form->{invnumber};
- $form->{addition} = "DELETED";
- $form->save_history($form->dbconnect(\%myconfig));
+ $form->{addition} = "DELETED";
+ $form->save_history;
}
# /saving the history
$form->redirect($locale->text('Invoice deleted!'));