From: Moritz Bunkus Date: Wed, 16 Oct 2013 13:42:26 +0000 (+0200) Subject: Wiederkehrende Rechnungen: erstes abzurechnendes Periodendatum richtig berechnen X-Git-Tag: release-3.2.0beta~476^2~5 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f98064e017c56cb9ac8736f85d30569b34fa1c01;p=kivitendo-erp.git Wiederkehrende Rechnungen: erstes abzurechnendes Periodendatum richtig berechnen --- 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}; diff --git a/bin/mozilla/oe.pl b/bin/mozilla/oe.pl index ff759883b..7bb96a18e 100644 --- a/bin/mozilla/oe.pl +++ b/bin/mozilla/oe.pl @@ -321,7 +321,7 @@ sub form_header { && $obj->periodic_invoices_config->active && ( !$obj->periodic_invoices_config->end_date || ($obj->periodic_invoices_config->end_date > DateTime->today_local)) - && $obj->periodic_invoices_config->get_previous_invoice_date; + && $obj->periodic_invoices_config->get_previous_billed_period_start_date; $TMPL_VAR{oe_obj} = $obj; }