X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/180e8de7adfb39c1a2b9f5476c5e28d6b142811a..766f5705ecb9cd56adfbffd94c871959bb64c6fd:/SL/DB/PeriodicInvoicesConfig.pm diff --git a/SL/DB/PeriodicInvoicesConfig.pm b/SL/DB/PeriodicInvoicesConfig.pm index dba27952d..074d4e317 100644 --- a/SL/DB/PeriodicInvoicesConfig.pm +++ b/SL/DB/PeriodicInvoicesConfig.pm @@ -60,20 +60,19 @@ sub handle_automatic_extension { return $end_date; } -sub get_previous_invoice_date { +sub get_previous_billed_period_start_date { my $self = shift; my $query = <dbh->selectrow_array($query, undef, $self->id); + my ($date) = $self->dbh->selectrow_array($query, undef, $self->id); - return undef unless $max_transdate; - return ref $max_transdate ? $max_transdate : $self->db->parse_date($max_transdate); + return undef unless $date; + return ref $date ? $date : $self->db->parse_date($date); } sub calculate_invoice_dates { @@ -82,8 +81,8 @@ sub calculate_invoice_dates { my $period_len = $self->get_period_length; my $cur_date = $self->first_billing_date || $self->start_date; my $end_date = $self->end_date || DateTime->today_local->add(years => 10); - my $start_date = $params{past_dates} ? undef : $self->get_previous_invoice_date; - $start_date = $start_date ? $start_date->subtract(days => 1) : $cur_date->clone; + my $start_date = $params{past_dates} ? undef : $self->get_previous_billed_period_start_date; + $start_date = $start_date ? $start_date->add(days => 1) : $cur_date->clone; $start_date = max($start_date, $params{start_date}) if $params{start_date}; $end_date = min($end_date, $params{end_date}) if $params{end_date};