]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/ir.pl
Kreditorenbuchungen: Warnung bei vorhandener Rechnungsnummer für diesen Kreditor
[mfinanz.git] / bin / mozilla / ir.pl
index 64180c2a95e76c24b854223797768d72ba9f900e..bf966587b934d87345c8f97af7be9b5fcf574e70 100644 (file)
@@ -220,6 +220,8 @@ sub setup_ir_action_bar {
   my $form                    = $::form;
   my $change_never            = $::instance_conf->get_ir_changeable == 0;
   my $change_on_same_day_only = $::instance_conf->get_ir_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate});
+  my $has_storno              = ($::form->{storno} && !$::form->{storno_id});
+  my $payments_balanced       = ($::form->{oldtotalpaid} == 0);
 
   my $has_sepa_exports;
 
@@ -243,6 +245,8 @@ sub setup_ir_action_bar {
           t8('Post'),
           submit   => [ '#form', { action => "post" } ],
           checks   => [ 'kivi.validate_form' ],
+          checks   => [ 'kivi.validate_form', 'kivi.AP.check_fields_before_posting', 'kivi.AP.check_duplicate_invnumber' ],
+
           disabled => $form->{locked}                           ? t8('The billing period has already been locked.')
                     : $form->{storno}                           ? t8('A canceled invoice cannot be posted.')
                     : ($form->{id} && $change_never)            ? t8('Changing invoices has been disabled in the configuration.')
@@ -272,6 +276,7 @@ sub setup_ir_action_bar {
           confirm  => t8('Do you really want to cancel this invoice?'),
           disabled => !$form->{id}          ? t8('This invoice has not been posted yet.')
                       : $has_sepa_exports   ? t8('This invoice has been linked with a sepa export, undo this first.')
+                      : !$payments_balanced ? t8('Cancelling is disallowed. Either undo or balance the current payments until the open amount matches the invoice amount')
                       : undef,
         ],
         action => [ t8('Delete'),
@@ -283,6 +288,7 @@ sub setup_ir_action_bar {
                     : $change_never            ? t8('Changing invoices has been disabled in the configuration.')
                     : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
                     : $has_sepa_exports        ? t8('This invoice has been linked with a sepa export, undo this first.')
+                    : $has_storno              ? t8('Can only delete the "Storno zu" part of the cancellation pair.')
                     :                            undef,
         ],
       ], # end of combobox "Storno"
@@ -321,7 +327,8 @@ sub setup_ir_action_bar {
       ], # end of combobox "more"
     );
   }
-  $::request->layout->add_javascripts('kivi.Validator.js');
+  $::request->layout->add_javascripts('kivi.Validator.js', 'kivi.AP.js');
+
 }
 
 sub form_header {
@@ -388,6 +395,7 @@ sub form_header {
     $form->{"select$item"} =~ s/option>\Q$form->{$item}\E/option selected>$form->{$item}/;
   }
 
+  # TODO There is no credit_note for vendor invoices (remove template code)
   $TMPL_VAR{is_type_credit_note} = $form->{type}   eq "credit_note";
   $TMPL_VAR{is_format_html}      = $form->{format} eq 'html';
   $TMPL_VAR{dateformat}          = $myconfig{dateformat};