X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=SL%2FDB%2FSepaExportItem.pm;fp=SL%2FDB%2FSepaExportItem.pm;h=0bcab3e3f2877324d48111477f6e1c1647ea5bf2;hp=b75e0537699f8e571bd75c928fe5802da2a02147;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hpb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44 diff --git a/SL/DB/SepaExportItem.pm b/SL/DB/SepaExportItem.pm index b75e05376..0bcab3e3f 100644 --- a/SL/DB/SepaExportItem.pm +++ b/SL/DB/SepaExportItem.pm @@ -1,6 +1,7 @@ package SL::DB::SepaExportItem; use strict; +use SL::DB::SepaExport; use SL::DB::MetaSetup::SepaExportItem; @@ -20,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;