From 57d6293d271283b4873d98379e8432b8bb509c01 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 11 Jul 2013 09:25:36 +0200 Subject: [PATCH] SL::DB::Invoice: invnumber in before_save-Hook erzeugen --- SL/DB/Invoice.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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}); -- 2.20.1