Vergabe von Kunden-/Lieferantennummer beim Speichern eines VC-Objektes implementiert
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Mar 2011 09:40:06 +0000 (10:40 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 16 Jun 2011 06:44:18 +0000 (08:44 +0200)
SL/DB/Customer.pm
SL/DB/Helper/TransNumberGenerator.pm
SL/DB/Vendor.pm

index 27683b3..55a1ee4 100644 (file)
@@ -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) = @_;
 
index 0505268..3f58aba 100644 (file)
@@ -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 {
index 11e23fe..e8ec8bc 100644 (file)
@@ -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;