_log_msg("Periodic invoice configuration ID " . $config->id . " extended through " . $new_end_date->strftime('%d.%m.%Y') . "\n") if $new_end_date;
}
- my (@new_invoices, @invoices_to_print, @invoices_to_email);
+ my (@new_invoices, @invoices_to_print, @invoices_to_email, @disabled_orders);
_log_msg("Number of configs: " . scalar(@{ $configs}));
# last;
}
+ # disable one time configs (periodicity is only one time).
+ my $inactive_ordnumber = $config->disable_one_time_config;
+ push @disabled_orders, $inactive_ordnumber if $inactive_ordnumber;
}
foreach my $inv ( @invoices_to_print ) { $self->_print_invoice($inv); }
[ map { $_->{invoice} } @new_invoices ],
[ map { $_->{invoice} } @invoices_to_print ],
[ map { $_->{invoice} } @invoices_to_email ],
+ \@disabled_orders ,
);
if (@{ $self->{job_errors} }) {
}
sub _send_summary_email {
- my ($self, $posted_invoices, $printed_invoices, $emailed_invoices) = @_;
-
+ my ($self, $posted_invoices, $printed_invoices, $emailed_invoices,
+ $disabled_orders) = @_;
my %config = %::lx_office_conf;
return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices };
my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/webpages") . "/oe/periodic_invoices_email.txt" );
my %params = ( POSTED_INVOICES => $posted_invoices,
PRINTED_INVOICES => $printed_invoices,
- EMAILED_INVOICES => $emailed_invoices );
+ EMAILED_INVOICES => $emailed_invoices,
+ DISABLED_ORDERS => $disabled_orders );
my $output;
$template->process($filename, \%params, \$output);
# 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;
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__
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<sub disable_one_time_config>
+
+Sets the state of the periodic_invoices_configs to inactive
+(active => false) if the periodicity is <Co> (one time).
+Returns undef if the periodicity is not 'one time' otherwise the
+order number of the deactivated periodic order.
=back
=head1 BUGS
--- /dev/null
+-- @tag: periodic_invoices_order_value_periodicity2
+-- @description:periodic_invoices_configs_valid_periodicity Wiederkehrende Rechnungen: Einstellung für Periode, auf die sich der Auftragswert bezieht
+-- @depends: release_3_4_1 periodic_invoices_order_value_periodicity
+
+-- Spalte »periodicity«: Erweiterung um Periode o (one time). Einmalige Ausführung
+ALTER TABLE periodic_invoices_configs
+DROP CONSTRAINT periodic_invoices_configs_valid_periodicity;
+
+ALTER TABLE periodic_invoices_configs
+ADD CONSTRAINT periodic_invoices_configs_valid_periodicity
+CHECK (periodicity IN ('o', 'm', 'q', 'b', 'y'));
<tr>
<th align="right" valign="top">[%- LxERP.t8('Billing Periodicity') %]</th>
<td valign="top">
- [% L.select_tag("periodicity", [ [ "m", LxERP.t8("monthly") ], [ "q", LxERP.t8("every third month") ], [ "b", LxERP.t8("semiannually") ], [ "y", LxERP.t8("yearly") ] ], default=periodicity, style=style) %]
+ [% L.select_tag("periodicity", [ [ "o", LxERP.t8("one time") ], [ "m", LxERP.t8("monthly") ], [ "q", LxERP.t8("every third month") ], [ "b", LxERP.t8("semiannually") ], [ "y", LxERP.t8("yearly") ] ], default=periodicity, style=style) %]
</td>
</tr>
[% FOREACH inv = PRINTED_INVOICES %][% inv.invnumber %] [% END %]
[%- END %]
+
+[% IF EMAILED_INVOICES.size -%]
+Davon wurden die folgenden Rechnungen automatisch per E-Mail versand:
+
+[% FOREACH inv = EMAILED_INVOICES %][% inv.invnumber %] [% END %]
+[%- END %]
+
+[% IF DISABLED_ORDERS.size -%]
+Bei folgenden Auftragsnummern, wurde die Konfiguration auf inaktiv (Periodenwahl 'einmalig') gesetzt.
+
+[% FOREACH disabled_order = DISABLED_ORDERS %][% disabled_order %] [% END %]
+[%- END %]