1 package SL::BackgroundJob::CloseProjectsBelongingToClosedSalesOrders;
5 use parent qw(SL::BackgroundJob::Base);
8 use SL::DB::ProjectStatus;
11 my ($self, $db_obj) = @_;
13 my $data = $db_obj->data_as_hash;
14 $data->{new_status} ||= 'done';
15 $data->{set_inactive} = 1 if !exists $data->{set_inactive};
17 my $new_status = SL::DB::Manager::ProjectStatus->find_by(name => $data->{new_status}) || die "No project status named '$data->{new_status}' found!";
19 my %attributes = (project_status_id => $new_status->id);
20 $attributes{active} = 0 if $data->{set_inactive};
24 SELECT oe.globalproject_id
26 WHERE (oe.globalproject_id IS NOT NULL)
27 AND (oe.customer_id IS NOT NULL)
28 AND NOT COALESCE(oe.quotation, FALSE)
29 AND COALESCE(oe.closed, FALSE)
33 SL::DB::Manager::Project->update_all(
36 '!project_status_id' => $new_status->id,
52 SL::BackgroundJob::CloseProjectsBelongingToClosedSalesOrders —
53 Background job for closing all projects which are linked to a closed
54 sales order (via C<oe.globalproject_id>)
58 This background job searches all closed sales orders for linked
59 projects. Those projects whose status is not C<done> will be modified:
60 their status will be set to C<done> and their C<active> flag will be
63 Both of these can be configured via the job's data hash: C<new_status>
64 is the new status' name (defaults to C<done>), and C<set_inactive>
65 determines whether or not the project will be set to inactive
68 The job is deactivated by default. Administrators of installations
69 where such a feature is wanted have to create a job entry manually.
73 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>