- if ($print_post) {
- if (!(IS->post_invoice(\%myconfig, \%$form))) {
- $form->error($locale->text('Cannot post invoice!'));
- }
- remove_draft() if $form->{remove_draft};
- # saving the history
- if(!exists $form->{addition}) {
- $form->{addition} = "PRINTED AND POSTED";
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
-
- } else {
- if (IS->post_invoice(\%myconfig, \%$form)){
- remove_draft() if $form->{remove_draft};
- # saving the history
- if(!exists $form->{addition}) {
- if($form->{storno}) {
- $form->{addition} = "STORNO";
- }
- else {
- $form->{addition} = "POSTED";
- }
- $form->save_history($form->dbconnect(\%myconfig));
- }
- # /saving the history
-
- $form->redirect(
- $form->{label} . " $form->{invnumber} " . $locale->text('posted!'));
- }
- $form->error($locale->text('Cannot post invoice!'));
+ $form->error($locale->text('Cannot post invoice!'))
+ unless IS->post_invoice(\%myconfig, \%$form);
+ remove_draft() if $form->{remove_draft};
+
+ if(!exists $form->{addition}) {
+ $form->{addition} = $print_post ? "PRINTED AND POSTED" :
+ $form->{storno} ? "STORNO" :
+ "POSTED";
+ $form->save_history($form->dbconnect(\%myconfig));