X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FSepaExportItem.pm;h=0bcab3e3f2877324d48111477f6e1c1647ea5bf2;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hp=75701166024de8280df01b982fc28524648117e2;hpb=c8e0c77f4da1fe14f1294a3be2e437c24f40eaea;p=kivitendo-erp.git diff --git a/SL/DB/SepaExportItem.pm b/SL/DB/SepaExportItem.pm index 757011660..0bcab3e3f 100644 --- a/SL/DB/SepaExportItem.pm +++ b/SL/DB/SepaExportItem.pm @@ -1,9 +1,12 @@ package SL::DB::SepaExportItem; use strict; +use SL::DB::SepaExport; use SL::DB::MetaSetup::SepaExportItem; +__PACKAGE__->meta->initialize; + # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; @@ -18,4 +21,28 @@ sub compare_to { return $result || ($self->sepa_export_id <=> $other->sepa_export_id) || ($self->id <=> $other->id); } +sub set_executed { + my ($self) = @_; + + $self->executed(1); # does execution date also need to be set? + $self->save; + # if all the sepa_export_items in the sepa_export are closed (executed), close the sepa_export + if ( SL::DB::Manager::SepaExportItem->get_all_count( where => [ sepa_export_id => $self->sepa_export_id, executed => 0] ) == 0 ) { + my $sepa_export = SL::DB::Manager::SepaExport->find_by(id => $self->sepa_export_id); + $sepa_export->executed(1); + $sepa_export->closed(1); + $sepa_export->save(changes_only=>1); + }; +}; + + +sub arap_id { + my ($self) = @_; + if ( $self->ar_id ) { + return $self->ar_id; + } else { + return $self->ap_id; + }; +}; + 1;