Revision f98064e0
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/DB/PeriodicInvoicesConfig.pm | ||
---|---|---|
60 | 60 |
return $end_date; |
61 | 61 |
} |
62 | 62 |
|
63 |
sub get_previous_invoice_date {
|
|
63 |
sub get_previous_billed_period_start_date {
|
|
64 | 64 |
my $self = shift; |
65 | 65 |
|
66 | 66 |
my $query = <<SQL; |
67 |
SELECT MAX(ar.transdate)
|
|
67 |
SELECT MAX(period_start_date)
|
|
68 | 68 |
FROM periodic_invoices |
69 |
LEFT JOIN ar ON (ar.id = periodic_invoices.ar_id) |
|
70 |
WHERE periodic_invoices.config_id = ? |
|
69 |
WHERE config_id = ? |
|
71 | 70 |
SQL |
72 | 71 |
|
73 |
my ($max_transdate) = $self->dbh->selectrow_array($query, undef, $self->id);
|
|
72 |
my ($date) = $self->dbh->selectrow_array($query, undef, $self->id); |
|
74 | 73 |
|
75 |
return undef unless $max_transdate;
|
|
76 |
return ref $max_transdate ? $max_transdate : $self->db->parse_date($max_transdate);
|
|
74 |
return undef unless $date; |
|
75 |
return ref $date ? $date : $self->db->parse_date($date);
|
|
77 | 76 |
} |
78 | 77 |
|
79 | 78 |
sub calculate_invoice_dates { |
... | ... | |
82 | 81 |
my $period_len = $self->get_period_length; |
83 | 82 |
my $cur_date = $self->first_billing_date || $self->start_date; |
84 | 83 |
my $end_date = $self->end_date || DateTime->today_local->add(years => 10); |
85 |
my $start_date = $params{past_dates} ? undef : $self->get_previous_invoice_date;
|
|
86 |
$start_date = $start_date ? $start_date->subtract(days => 1) : $cur_date->clone;
|
|
84 |
my $start_date = $params{past_dates} ? undef : $self->get_previous_billed_period_start_date;
|
|
85 |
$start_date = $start_date ? $start_date->add(days => 1) : $cur_date->clone;
|
|
87 | 86 |
|
88 | 87 |
$start_date = max($start_date, $params{start_date}) if $params{start_date}; |
89 | 88 |
$end_date = min($end_date, $params{end_date}) if $params{end_date}; |
bin/mozilla/oe.pl | ||
---|---|---|
321 | 321 |
&& $obj->periodic_invoices_config->active |
322 | 322 |
&& ( !$obj->periodic_invoices_config->end_date |
323 | 323 |
|| ($obj->periodic_invoices_config->end_date > DateTime->today_local)) |
324 |
&& $obj->periodic_invoices_config->get_previous_invoice_date;
|
|
324 |
&& $obj->periodic_invoices_config->get_previous_billed_period_start_date;
|
|
325 | 325 |
|
326 | 326 |
$TMPL_VAR{oe_obj} = $obj; |
327 | 327 |
} |
Auch abrufbar als: Unified diff
Wiederkehrende Rechnungen: erstes abzurechnendes Periodendatum richtig berechnen