1 package SL::DB::SepaExportItem;
4 use SL::DB::SepaExport;
6 use SL::DB::MetaSetup::SepaExportItem;
8 __PACKAGE__->meta->initialize;
10 # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
11 __PACKAGE__->meta->make_manager_class;
14 my ($self, $other) = @_;
16 return 1 if $self->execution_date && !$other->execution_date;
17 return -1 if !$self->execution_date && $other->execution_date;
20 $result = $self->execution_date <=> $other->execution_date if $self->execution_date;
21 return $result || ($self->sepa_export_id <=> $other->sepa_export_id) || ($self->id <=> $other->id);
27 $self->executed(1); # does execution date also need to be set?
29 # if all the sepa_export_items in the sepa_export are closed (executed), close the sepa_export
30 if ( SL::DB::Manager::SepaExportItem->get_all_count( where => [ sepa_export_id => $self->sepa_export_id, executed => 0] ) == 0 ) {
31 my $sepa_export = SL::DB::Manager::SepaExport->find_by(id => $self->sepa_export_id);
32 $sepa_export->executed(1);
33 $sepa_export->closed(1);
34 $sepa_export->save(changes_only=>1);