X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FPeriodicInvoicesConfig.pm;fp=SL%2FDB%2FPeriodicInvoicesConfig.pm;h=14fa5786a59ae59669378e3e1f5043f6dee70648;hb=efeb61e04032ded4fdc9719a4bf5a031c4a042d1;hp=0d66085650e65de1fc16f521b56b109a84bf0695;hpb=6e594d280bad75ff06bd9bfb4ffdb61f159036b5;p=kivitendo-erp.git diff --git a/SL/DB/PeriodicInvoicesConfig.pm b/SL/DB/PeriodicInvoicesConfig.pm index 0d6608565..14fa5786a 100644 --- a/SL/DB/PeriodicInvoicesConfig.pm +++ b/SL/DB/PeriodicInvoicesConfig.pm @@ -11,7 +11,7 @@ __PACKAGE__->meta->initialize; # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; -our %PERIOD_LENGTHS = ( m => 1, q => 3, b => 6, y => 12 ); +our %PERIOD_LENGTHS = ( o => 0, m => 1, q => 3, b => 6, y => 12 ); our %ORDER_VALUE_PERIOD_LENGTHS = ( %PERIOD_LENGTHS, 2 => 24, 3 => 36, 4 => 48, 5 => 60 ); our @PERIODICITIES = keys %PERIOD_LENGTHS; our @ORDER_VALUE_PERIODICITIES = keys %ORDER_VALUE_PERIOD_LENGTHS; @@ -128,6 +128,20 @@ sub is_last_bill_date_in_order_value_cycle { return $date_itr == $next_billing_date; } +sub disable_one_time_config { + my $self = shift; + + _log_msg("check one time for " . $self->id . "\n"); + + # 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; + return $self->order->ordnumber; + } + return undef; +} 1; __END__ @@ -235,6 +249,12 @@ date given by the C parameter plus the billing period length equals one of those dates then the given date is indeed the date of 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). +Returns undef if the periodicity is not 'one time' otherwise the +order number of the deactivated periodic order. =back =head1 BUGS