From: Bernd Bleßmann Date: Mon, 15 Nov 2021 12:01:45 +0000 (+0100) Subject: Anzahlungs-Rg.: Workflow Anzahlungs-Rg. -> Anzahlungs-Rg. X-Git-Tag: kivitendo-mebil_0.1-0~10^2~2^2~217^2~40 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a198dfae6de24a4932609b2fb72c23879b7df1bf;p=kivitendo-erp.git Anzahlungs-Rg.: Workflow Anzahlungs-Rg. -> Anzahlungs-Rg. --- diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index a8b62a4a3..f54f85401 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -38,7 +38,7 @@ use SL::OE; use SL::MoreCommon qw(restore_form save_form); use Data::Dumper; use DateTime; -use List::MoreUtils qw(uniq); +use List::MoreUtils qw(any uniq); use List::Util qw(max sum); use List::UtilsBy qw(sort_by); use English qw(-no_match_vars); @@ -309,6 +309,14 @@ sub setup_is_action_bar { if ($::instance_conf->get_warn_no_delivery_order_for_invoice && !$form->{id}) { $warn_unlinked_delivery_order = 1 unless $form->{convert_from_do_ids}; } + + my $has_further_invoice_for_advance_payment; + if ($form->{id} && $form->{type} eq "invoice_for_advance_payment") { + my $invoice_obj = SL::DB::Invoice->load_cached($form->{id}); + my $lr = $invoice_obj->linked_records(direction => 'to', to => ['Invoice']); + $has_further_invoice_for_advance_payment = any {'SL::DB::Invoice' eq ref $_ && "invoice_for_advance_payment" eq $_->type} @$lr; + } + for my $bar ($::request->layout->get('actionbar')) { $bar->add( action => [ @@ -393,6 +401,16 @@ sub setup_is_action_bar { : !$form->{id} ? t8('This invoice has not been posted yet.') : undef, ], + action => [ + t8('Further Invoice for Advance Payment'), + submit => [ '#form', { action => "further_invoice_for_advance_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.') + : $has_further_invoice_for_advance_payment ? t8('This invoice has already a further invoice for advanced payment.') + : undef, + only_if => $form->{type} eq "invoice_for_advance_payment", + ], action => [ t8('Credit Note'), submit => [ '#form', { action => "credit_note" } ], @@ -1129,6 +1147,29 @@ sub use_as_new { $main::lxdebug->leave_sub(); } +sub further_invoice_for_advance_payment { + my $form = $main::form; + my %myconfig = %main::myconfig; + + $main::auth->assert('invoice_edit'); + + delete @{ $form }{qw(printed emailed queued invnumber invdate exchangerate forex deliverydate datepaid_1 gldate_1 acc_trans_id_1 source_1 memo_1 paid_1 exchangerate_1 AP_paid_1 storno locked)}; + $form->{convert_from_ar_ids} = $form->{id}; + $form->{id} = ''; + $form->{rowcount}--; + $form->{paidaccounts} = 1; + $form->{invdate} = $form->current_date(\%myconfig); + my $terms = get_payment_terms_for_invoice(); + $form->{duedate} = $terms ? $terms->calc_date(reference_date => $form->{invdate})->to_kivitendo : $form->{invdate}; + $form->{employee_id} = SL::DB::Manager::Employee->current->id; + $form->{forex} = $form->check_exchangerate(\%myconfig, $form->{currency}, $form->{invdate}, 'buy'); + $form->{exchangerate} = $form->{forex} if $form->{forex}; + + $form->{"converted_from_invoice_id_$_"} = delete $form->{"invoice_id_$_"} for 1 .. $form->{"rowcount"}; + + &display_form; +} + sub storno { $main::lxdebug->enter_sub(); @@ -1258,7 +1299,6 @@ sub credit_note { &prepare_invoice; - &display_form; $main::lxdebug->leave_sub(); diff --git a/locale/de/all b/locale/de/all index 1ffd12f6f..f456c5756 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1622,6 +1622,7 @@ $self->{texts} = { 'Function block actions' => 'Funktionsblockaktionen', 'Function block number format' => 'Format der Funktionsblocknummerierung', 'Function/position' => 'Funktion/Position', + 'Further Invoice for Advance Payment' => 'Weitere Anzahlungsrechnung', 'GL Transaction' => 'Dialogbuchung', 'GL Transaction (abbreviation)' => 'DB', 'GL Transactions' => 'Dialogbuchungen', @@ -3849,6 +3850,7 @@ $self->{texts} = { 'This group is valid for the following clients' => 'Diese Gruppe ist für die folgenden Mandanten gültig', 'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => 'Das wurde in dieser Version umgestellt, bitte ändern Sie die Freitext-Lagerplätze auf vorhandene Lagerplätze.', 'This has been changed in this version.' => 'Ab dieser Version ist dies nicht mehr so.', + 'This invoice has already a further invoice for advanced payment.' => 'Diese Rechnung hat schon eine weitere Anzahlungsrechnung.', 'This invoice has already been posted.' => 'Die Rechnung wurde bereits gebucht.', 'This invoice has been canceled already.' => 'Die Rechnung wurde bereits storniert.', 'This invoice has been linked with a sepa export, undo this first.' => 'Diese Rechnung ist mit einem SEPA-Export verknüpft. Bitte diese Verknüpfung zuerst aufheben.', diff --git a/locale/en/all b/locale/en/all index 7682db7ac..900c36592 100644 --- a/locale/en/all +++ b/locale/en/all @@ -1622,6 +1622,7 @@ $self->{texts} = { 'Function block actions' => '', 'Function block number format' => '', 'Function/position' => '', + 'Further Invoice for Advance Payment' => '', 'GL Transaction' => '', 'GL Transaction (abbreviation)' => '', 'GL Transactions' => '', @@ -3844,6 +3845,7 @@ $self->{texts} = { 'This group is valid for the following clients' => '', 'This has been changed in this version, therefore please change the "old" bins to some real warehouse bins.' => '', 'This has been changed in this version.' => '', + 'This invoice has already a further invoice for advanced payment.' => '', 'This invoice has already been posted.' => '', 'This invoice has been canceled already.' => '', 'This invoice has been linked with a sepa export, undo this first.' => '',