X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=77ad46b178c7e3ee38e756388b3ed91cf2a39e87;hb=6770b19ab3f0dc0d8b00f70d8aab74149354a181;hp=66e9b08a165404769a8698f2ff80ea9de78c4d18;hpb=f260a8cc8d1edc734c3816035f94c2658523c84b;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 66e9b08a1..77ad46b17 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -220,6 +220,15 @@ 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; + + if ($form->{id}) { + my $invoice = SL::DB::Manager::PurchaseInvoice->find_by(id => $form->{id}); + $has_sepa_exports = 1 if ($invoice->find_sepa_export_items()->[0]); + } for my $bar ($::request->layout->get('actionbar')) { $bar->add( @@ -263,7 +272,10 @@ sub setup_ir_action_bar { submit => [ '#form', { action => "storno" } ], checks => [ 'kivi.validate_form' ], confirm => t8('Do you really want to cancel this invoice?'), - disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, + 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'), submit => [ '#form', { action => "delete" } ], @@ -273,6 +285,8 @@ sub setup_ir_action_bar { : $form->{locked} ? t8('The billing period has already been locked.') : $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"