X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fir.pl;h=0b9a4b227361cd63317071dcd6701c2e43a1872d;hb=639c7f18be07979acb6e83d2b452cb6ecd091f9a;hp=79aa473dc34beef60d34cf050036a845068d35fd;hpb=894ac4cac779a9993350dc14534d01ab04e4a281;p=kivitendo-erp.git diff --git a/bin/mozilla/ir.pl b/bin/mozilla/ir.pl index 79aa473dc..0b9a4b227 100644 --- a/bin/mozilla/ir.pl +++ b/bin/mozilla/ir.pl @@ -35,10 +35,13 @@ use SL::FU; use SL::IR; use SL::IS; +use SL::DB::BankTransactionAccTrans; use SL::DB::Default; use SL::DB::Department; +use SL::DB::Project; use SL::DB::PurchaseInvoice; use SL::DB::Vendor; +use List::MoreUtils qw(uniq); use List::Util qw(max sum); use List::UtilsBy qw(sort_by); @@ -244,18 +247,23 @@ sub setup_ir_action_bar { my $may_edit_create = $::auth->assert('vendor_invoice_edit', 1); 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]); } + my $is_linked_bank_transaction; + if ($::form->{id} + && SL::DB::Default->get->payments_changeable != 0 + && SL::DB::Manager::BankTransactionAccTrans->find_by(ap_id => $::form->{id})) { + + $is_linked_bank_transaction = 1; + } for my $bar ($::request->layout->get('actionbar')) { $bar->add( action => [ t8('Update'), submit => [ '#form', { action => "update" } ], - checks => [ 'kivi.validate_form' ], id => 'update_button', accesskey => 'enter', disabled => !$may_edit_create ? t8('You must not change this invoice.') : undef, @@ -272,15 +280,17 @@ sub setup_ir_action_bar { : $form->{storno} ? t8('A canceled invoice cannot be posted.') : ($form->{id} && $change_never) ? t8('Changing invoices has been disabled in the configuration.') : ($form->{id} && $change_on_same_day_only) ? t8('Invoices can only be changed on the day they are posted.') + : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.') : undef, ], action => [ t8('Post Payment'), submit => [ '#form', { action => "post_payment" } ], checks => [ 'kivi.validate_form' ], - disabled => !$may_edit_create ? t8('You must not change this invoice.') - : !$form->{id} ? t8('This invoice has not been posted yet.') - : undef, + disabled => !$may_edit_create ? t8('You must not change this invoice.') + : !$form->{id} ? t8('This invoice has not been posted yet.') + : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.') + : undef, ], action => [ t8('Mark as paid'), @@ -309,13 +319,14 @@ sub setup_ir_action_bar { submit => [ '#form', { action => "delete" } ], checks => [ 'kivi.validate_form' ], confirm => t8('Do you really want to delete this object?'), - disabled => !$may_edit_create ? t8('You must not change this invoice.') - : !$form->{id} ? t8('This invoice has not been posted yet.') - : $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.') + disabled => !$may_edit_create ? t8('You must not change this invoice.') + : !$form->{id} ? t8('This invoice has not been posted yet.') + : $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.') + : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.') : undef, ], ], # end of combobox "Storno" @@ -338,7 +349,7 @@ sub setup_ir_action_bar { action => [ t8('more') ], action => [ t8('History'), - call => [ 'set_history_window', $::form->{id} * 1, 'id', 'glid' ], + call => [ 'set_history_window', $::form->{id} * 1, 'glid' ], disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], action => [ @@ -384,8 +395,10 @@ sub form_header { $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); - my @old_project_ids = ($form->{"globalproject_id"}); - map { push @old_project_ids, $form->{"project_id_$_"} if $form->{"project_id_$_"}; } 1..$form->{"rowcount"}; + my @old_project_ids = uniq grep { $_ } map { $_ * 1 } ($form->{"globalproject_id"}, map { $form->{"project_id_$_"} } 1..$form->{"rowcount"}); + my @conditions = @old_project_ids ? (id => \@old_project_ids) : (); + $TMPL_VAR{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => [ or => [ active => 1, @conditions ]]); + $form->{ALL_PROJECTS} = $TMPL_VAR{ALL_PROJECTS}; # make projects available for second row drop-down in io.pl $form->get_lists("taxzones" => ($form->{id} ? "ALL_TAXZONES" : "ALL_ACTIVE_TAXZONES"), "currencies" => "ALL_CURRENCIES", @@ -438,7 +451,7 @@ sub form_header { shiptoemail shiptodepartment_1 shiptodepartment_2 message email subject cc bcc taxaccounts cursor_fokus convert_from_do_ids convert_from_oe_ids convert_from_ap_ids show_details gldate useasnew ), @custom_hiddens, - map { $_.'_rate', $_.'_description', $_.'_taxnumber' } split / /, $form->{taxaccounts}]; + map { $_.'_rate', $_.'_description', $_.'_taxnumber', $_.'_tax_id' } split / /, $form->{taxaccounts}]; $TMPL_VAR{payment_terms_obj} = get_payment_terms_for_invoice(); $form->{duedate} = $TMPL_VAR{payment_terms_obj}->calc_date(reference_date => $form->{invdate}, due_date => $form->{duedate})->to_kivitendo if $TMPL_VAR{payment_terms_obj}; @@ -485,12 +498,6 @@ sub form_footer { $form->{invtotal} = $form->{invsubtotal}; $form->{oldinvtotal} = $form->{invtotal}; - # note rows - $form->{rows} = max 2, - $form->numtextrows($form->{notes}, 26, 8), - $form->numtextrows($form->{intnotes}, 35, 8); - - # tax, total and subtotal calculations my ($tax, $subtotal); $form->{taxaccounts_array} = [ split / /, $form->{taxaccounts} ]; @@ -928,7 +935,12 @@ sub post { $form->save_history; } # /saving the history - $form->{callback} = 'ir.pl?action=add'; + # I keep the old default / comment for refactorer, pls check instance_conf: + #if ($::instance_conf->get_ir_add_doc && $::instance_conf->get_doc_storage) { + # my $add_doc_url = build_std_url("script=ir.pl", 'action=edit', 'id=' . E($form->{id})); + # print $form->redirect_header($add_doc_url); + #} + $form->{callback} = 'ir.pl?action=edit&id=' . $form->{id}; $form->redirect( $locale->text('Invoice') . " $form->{invnumber} " . ", " . $locale->text('ID')