From: Moritz Bunkus Date: Thu, 11 Jul 2013 07:25:36 +0000 (+0200) Subject: SL::DB::Invoice: invnumber in before_save-Hook erzeugen X-Git-Tag: release-3.1.0beta1~197 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=57d6293d271283b4873d98379e8432b8bb509c01;p=kivitendo-erp.git SL::DB::Invoice: invnumber in before_save-Hook erzeugen --- diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 526c79159..3842af6e7 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -40,6 +40,18 @@ __PACKAGE__->meta->add_relationship( __PACKAGE__->meta->initialize; +__PACKAGE__->before_save('_before_save_set_invnumber'); + +# hooks + +sub _before_save_set_invnumber { + my ($self) = @_; + + $self->create_trans_number if !$self->invnumber; + + return 1; +} + # methods sub items { goto &invoiceitems; } @@ -156,7 +168,6 @@ sub post { my %data = $self->calculate_prices_and_taxes; $self->_post_create_assemblyitem_entries($data{assembly_items}); - $self->create_trans_number; $self->save; $self->_post_add_acctrans($data{amounts_cogs});