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