From: Moritz Bunkus Date: Tue, 1 Mar 2011 09:40:06 +0000 (+0100) Subject: Vergabe von Kunden-/Lieferantennummer beim Speichern eines VC-Objektes implementiert X-Git-Tag: release-2.7.0beta1~396^2~53 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=930e5ecb0d071e20e9fc57e6050859a0a7a5a98d;p=kivitendo-erp.git Vergabe von Kunden-/Lieferantennummer beim Speichern eines VC-Objektes implementiert --- diff --git a/SL/DB/Customer.pm b/SL/DB/Customer.pm index 27683b3c1..55a1ee434 100644 --- a/SL/DB/Customer.pm +++ b/SL/DB/Customer.pm @@ -3,6 +3,8 @@ package SL::DB::Customer; use strict; use SL::DB::MetaSetup::Customer; +use SL::DB::Manager::Customer; +use SL::DB::Helper::TransNumberGenerator; use SL::DB::VC; @@ -24,6 +26,14 @@ __PACKAGE__->meta->add_relationship( __PACKAGE__->meta->make_manager_class; __PACKAGE__->meta->initialize; +__PACKAGE__->before_save('_before_save_set_customernumber'); + +sub _before_save_set_customernumber { + my ($self) = @_; + + $self->create_trans_number if $self->customernumber eq ''; +} + sub short_address { my ($self) = @_; diff --git a/SL/DB/Helper/TransNumberGenerator.pm b/SL/DB/Helper/TransNumberGenerator.pm index 050526841..3f58aba56 100644 --- a/SL/DB/Helper/TransNumberGenerator.pm +++ b/SL/DB/Helper/TransNumberGenerator.pm @@ -25,6 +25,8 @@ my %specs = ( ar => { number_column => 'invnumber', purchase_order => { number_column => 'ordnumber', number_range_column => 'ponumber', scoping => $oe_scoping, }, sales_delivery_order => { number_column => 'donumber', number_range_column => 'sdonumber', scoping => $do_scoping, fill_holes_in_range => 1 }, purchase_delivery_order => { number_column => 'donumber', number_range_column => 'pdonumber', scoping => $do_scoping, fill_holes_in_range => 1 }, + customer => { number_column => 'customernumber', number_range_column => 'customernumber', }, + vendor => { number_column => 'vendornumber', number_range_column => 'vendornumber', }, ); sub get_next_trans_number { diff --git a/SL/DB/Vendor.pm b/SL/DB/Vendor.pm index 11e23fe51..e8ec8bca0 100644 --- a/SL/DB/Vendor.pm +++ b/SL/DB/Vendor.pm @@ -3,6 +3,7 @@ package SL::DB::Vendor; use strict; use SL::DB::MetaSetup::Vendor; +use SL::DB::Helper::TransNumberGenerator; use SL::DB::VC; @@ -24,4 +25,12 @@ __PACKAGE__->meta->add_relationship( __PACKAGE__->meta->make_manager_class; __PACKAGE__->meta->initialize; +__PACKAGE__->before_save('_before_save_set_vendornumber'); + +sub _before_save_set_vendornumber { + my ($self) = @_; + + $self->create_trans_number if $self->vendornumber eq ''; +} + 1;