X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FPeriodicInvoicesConfig.pm;h=ceb532af93205a2f8535c6487f4ed3edca8db3dc;hb=0ebb8f829ac2d23b65e8d993c7d03aa0b172b637;hp=14fa5786a59ae59669378e3e1f5043f6dee70648;hpb=aa63ebae1c0a758ec438c594acb328b1f0e5e001;p=kivitendo-erp.git diff --git a/SL/DB/PeriodicInvoicesConfig.pm b/SL/DB/PeriodicInvoicesConfig.pm index 14fa5786a..ceb532af9 100644 --- a/SL/DB/PeriodicInvoicesConfig.pm +++ b/SL/DB/PeriodicInvoicesConfig.pm @@ -96,6 +96,10 @@ sub calculate_invoice_dates { $start_date = max($start_date, $params{start_date}) if $params{start_date}; $end_date = min($end_date, $params{end_date}) if $params{end_date}; + if ($self->periodicity eq 'o') { + return ($cur_date >= $start_date) && ($cur_date <= $end_date) ? ($cur_date) : (); + } + my @dates; while ($cur_date <= $end_date) { @@ -136,8 +140,16 @@ sub disable_one_time_config { # A periodicity of one time was set. Deactivate this config now. if ($self->periodicity eq 'o') { _log_msg("setting inactive\n"); - $self->active(0); - $self->save; + if (!$self->db->with_transaction(sub { + 1; # make Emacs happy + $self->active(0); + $self->order->update_attributes(closed => 1); + $self->save; + 1; + })) { + $::lxdebug->message(LXDebug->WARN(), "disalbe_one_time config failed: " . join("\n", (split(/\n/, $self->{db_obj}->db->error))[0..2])); + return undef; + } return $self->order->ordnumber; } return undef; @@ -252,9 +264,12 @@ the last invoice in that particular order value cycle. =item C Sets the state of the periodic_invoices_configs to inactive -(active => false) if the periodicity is (one time). +(active => false) and closes the source order (closed => true) +if the periodicity is (one time). + Returns undef if the periodicity is not 'one time' otherwise the order number of the deactivated periodic order. + =back =head1 BUGS