# Delay access check to after the invoice's been loaded so that
# project-specific invoice rights can be evaluated.
# Delay access check to after the invoice's been loaded so that
# project-specific invoice rights can be evaluated.
$form->restore_vars(qw(id));
IS->retrieve_invoice(\%myconfig, \%$form);
$form->restore_vars(qw(id));
IS->retrieve_invoice(\%myconfig, \%$form);
my $payments_balanced = ($::form->{oldtotalpaid} == 0);
my $has_storno = ($::form->{storno} && !$::form->{storno_id});
my $may_edit_create = $::auth->assert('invoice_edit', 1);
my $payments_balanced = ($::form->{oldtotalpaid} == 0);
my $has_storno = ($::form->{storno} && !$::form->{storno_id});
my $may_edit_create = $::auth->assert('invoice_edit', 1);
if ($::form->{id}
&& SL::DB::Default->get->payments_changeable != 0
&& SL::DB::Manager::BankTransactionAccTrans->find_by(ar_id => $::form->{id})) {
$is_linked_bank_transaction = 1;
}
if ($::form->{id}
&& SL::DB::Default->get->payments_changeable != 0
&& SL::DB::Manager::BankTransactionAccTrans->find_by(ar_id => $::form->{id})) {
$is_linked_bank_transaction = 1;
}
t8('Post'),
submit => [ '#form', { action => "post" } ],
checks => [ 'kivi.validate_form' ],
t8('Post'),
submit => [ '#form', { action => "post" } ],
checks => [ 'kivi.validate_form' ],
disabled => !$may_edit_create ? t8('You must not change this invoice.')
: $form->{locked} ? t8('The billing period has already been locked.')
: $form->{storno} ? t8('A canceled invoice cannot be posted.')
disabled => !$may_edit_create ? t8('You must not change this invoice.')
: $form->{locked} ? t8('The billing period has already been locked.')
: $form->{storno} ? t8('A canceled invoice cannot be posted.')
disabled => !$may_edit_create ? t8('You must not change this invoice.')
: $form->{locked} ? t8('The billing period has already been locked.')
: $form->{storno} ? t8('A canceled invoice cannot be posted.')
disabled => !$may_edit_create ? t8('You must not change this invoice.')
: $form->{locked} ? t8('The billing period has already been locked.')
: $form->{storno} ? t8('A canceled invoice cannot be posted.')
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
IS->get_customer(\%myconfig, $form);
$::form->{salesman_id} = SL::DB::Manager::Employee->current->id if exists $::form->{salesman_id};
IS->get_customer(\%myconfig, $form);