Revision efeb61e0
Von Jan Büren vor fast 8 Jahren hinzugefügt
SL/BackgroundJob/CreatePeriodicInvoices.pm | ||
---|---|---|
36 | 36 |
_log_msg("Periodic invoice configuration ID " . $config->id . " extended through " . $new_end_date->strftime('%d.%m.%Y') . "\n") if $new_end_date; |
37 | 37 |
} |
38 | 38 |
|
39 |
my (@new_invoices, @invoices_to_print, @invoices_to_email); |
|
39 |
my (@new_invoices, @invoices_to_print, @invoices_to_email, @disabled_orders);
|
|
40 | 40 |
|
41 | 41 |
_log_msg("Number of configs: " . scalar(@{ $configs})); |
42 | 42 |
|
... | ... | |
63 | 63 |
|
64 | 64 |
# last; |
65 | 65 |
} |
66 |
# disable one time configs (periodicity is only one time). |
|
67 |
my $inactive_ordnumber = $config->disable_one_time_config; |
|
68 |
push @disabled_orders, $inactive_ordnumber if $inactive_ordnumber; |
|
66 | 69 |
} |
67 | 70 |
|
68 | 71 |
foreach my $inv ( @invoices_to_print ) { $self->_print_invoice($inv); } |
... | ... | |
72 | 75 |
[ map { $_->{invoice} } @new_invoices ], |
73 | 76 |
[ map { $_->{invoice} } @invoices_to_print ], |
74 | 77 |
[ map { $_->{invoice} } @invoices_to_email ], |
78 |
\@disabled_orders , |
|
75 | 79 |
); |
76 | 80 |
|
77 | 81 |
if (@{ $self->{job_errors} }) { |
... | ... | |
275 | 279 |
} |
276 | 280 |
|
277 | 281 |
sub _send_summary_email { |
278 |
my ($self, $posted_invoices, $printed_invoices, $emailed_invoices) = @_;
|
|
279 |
|
|
282 |
my ($self, $posted_invoices, $printed_invoices, $emailed_invoices,
|
|
283 |
$disabled_orders) = @_; |
|
280 | 284 |
my %config = %::lx_office_conf; |
281 | 285 |
|
282 | 286 |
return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices }; |
... | ... | |
298 | 302 |
my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/webpages") . "/oe/periodic_invoices_email.txt" ); |
299 | 303 |
my %params = ( POSTED_INVOICES => $posted_invoices, |
300 | 304 |
PRINTED_INVOICES => $printed_invoices, |
301 |
EMAILED_INVOICES => $emailed_invoices ); |
|
305 |
EMAILED_INVOICES => $emailed_invoices, |
|
306 |
DISABLED_ORDERS => $disabled_orders ); |
|
302 | 307 |
|
303 | 308 |
my $output; |
304 | 309 |
$template->process($filename, \%params, \$output); |
SL/DB/PeriodicInvoicesConfig.pm | ||
---|---|---|
11 | 11 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
12 | 12 |
__PACKAGE__->meta->make_manager_class; |
13 | 13 |
|
14 |
our %PERIOD_LENGTHS = ( m => 1, q => 3, b => 6, y => 12 ); |
|
14 |
our %PERIOD_LENGTHS = ( o => 0, m => 1, q => 3, b => 6, y => 12 );
|
|
15 | 15 |
our %ORDER_VALUE_PERIOD_LENGTHS = ( %PERIOD_LENGTHS, 2 => 24, 3 => 36, 4 => 48, 5 => 60 ); |
16 | 16 |
our @PERIODICITIES = keys %PERIOD_LENGTHS; |
17 | 17 |
our @ORDER_VALUE_PERIODICITIES = keys %ORDER_VALUE_PERIOD_LENGTHS; |
... | ... | |
128 | 128 |
return $date_itr == $next_billing_date; |
129 | 129 |
} |
130 | 130 |
|
131 |
sub disable_one_time_config { |
|
132 |
my $self = shift; |
|
133 |
|
|
134 |
_log_msg("check one time for " . $self->id . "\n"); |
|
135 |
|
|
136 |
# A periodicity of one time was set. Deactivate this config now. |
|
137 |
if ($self->periodicity eq 'o') { |
|
138 |
_log_msg("setting inactive\n"); |
|
139 |
$self->active(0); |
|
140 |
$self->save; |
|
141 |
return $self->order->ordnumber; |
|
142 |
} |
|
143 |
return undef; |
|
144 |
} |
|
131 | 145 |
1; |
132 | 146 |
__END__ |
133 | 147 |
|
... | ... | |
235 | 249 |
equals one of those dates then the given date is indeed the date of |
236 | 250 |
the last invoice in that particular order value cycle. |
237 | 251 |
|
252 |
=item C<sub disable_one_time_config> |
|
253 |
|
|
254 |
Sets the state of the periodic_invoices_configs to inactive |
|
255 |
(active => false) if the periodicity is <Co> (one time). |
|
256 |
Returns undef if the periodicity is not 'one time' otherwise the |
|
257 |
order number of the deactivated periodic order. |
|
238 | 258 |
=back |
239 | 259 |
|
240 | 260 |
=head1 BUGS |
sql/Pg-upgrade2/periodic_invoices_order_value_periodicity2.sql | ||
---|---|---|
1 |
-- @tag: periodic_invoices_order_value_periodicity2 |
|
2 |
-- @description:periodic_invoices_configs_valid_periodicity Wiederkehrende Rechnungen: Einstellung für Periode, auf die sich der Auftragswert bezieht |
|
3 |
-- @depends: release_3_4_1 periodic_invoices_order_value_periodicity |
|
4 |
|
|
5 |
-- Spalte »periodicity«: Erweiterung um Periode o (one time). Einmalige Ausführung |
|
6 |
ALTER TABLE periodic_invoices_configs |
|
7 |
DROP CONSTRAINT periodic_invoices_configs_valid_periodicity; |
|
8 |
|
|
9 |
ALTER TABLE periodic_invoices_configs |
|
10 |
ADD CONSTRAINT periodic_invoices_configs_valid_periodicity |
|
11 |
CHECK (periodicity IN ('o', 'm', 'q', 'b', 'y')); |
templates/webpages/oe/edit_periodic_invoices_config.html | ||
---|---|---|
23 | 23 |
<tr> |
24 | 24 |
<th align="right" valign="top">[%- LxERP.t8('Billing Periodicity') %]</th> |
25 | 25 |
<td valign="top"> |
26 |
[% 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) %] |
|
26 |
[% 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) %]
|
|
27 | 27 |
</td> |
28 | 28 |
</tr> |
29 | 29 |
|
templates/webpages/oe/periodic_invoices_email.txt | ||
---|---|---|
9 | 9 |
|
10 | 10 |
[% FOREACH inv = PRINTED_INVOICES %][% inv.invnumber %] [% END %] |
11 | 11 |
[%- END %] |
12 |
|
|
13 |
[% IF EMAILED_INVOICES.size -%] |
|
14 |
Davon wurden die folgenden Rechnungen automatisch per E-Mail versand: |
|
15 |
|
|
16 |
[% FOREACH inv = EMAILED_INVOICES %][% inv.invnumber %] [% END %] |
|
17 |
[%- END %] |
|
18 |
|
|
19 |
[% IF DISABLED_ORDERS.size -%] |
|
20 |
Bei folgenden Auftragsnummern, wurde die Konfiguration auf inaktiv (Periodenwahl 'einmalig') gesetzt. |
|
21 |
|
|
22 |
[% FOREACH disabled_order = DISABLED_ORDERS %][% disabled_order %] [% END %] |
|
23 |
[%- END %] |
Auch abrufbar als: Unified diff
Wiederkehrende Rechnungen, um neue Periode 'einmalig' erweitert.
Wiederkehrenden Rechnungen die aus einem Auftrag automatisch generiert
werden können jetzt die Periode 'einmalig' (engl. 'one time') mit dem
Zeitwert 0 haben.
Falls diese Periode angewählt wird, wird die Konfiguration des Auftrags
nach Erzeugen der einmaligen Rechnung auf inaktiv gesetzt (s.a.
perldoc SL/DB/PeriodicInvoicesConfigs.pm).
Der Empfänger der Rechnungslauf-Mail bekommt in diesem Fall zusätzlich
die Auftragsnummer, bei welchem die wiederkehrenden Rechnungen deaktiviert
wurden mitgeteilt.
Zusätzlich ist diese Benachrichtigung per Mail erweitert, sodass jetzt
auch eine Liste der versandten Rechnungen per E-Mail mitgeteilt wird.