[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1901] trunk/LedgerSMB/DBObject



Revision: 1901
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=1901&view=rev
Author:   einhverfr
Date:     2007-11-25 11:59:02 -0800 (Sun, 25 Nov 2007)

Log Message:
-----------
More postfactoring

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Company.pm
    trunk/LedgerSMB/DBObject/Customer.pm
    trunk/LedgerSMB/DBObject/Vendor.pm

Added Paths:
-----------
    trunk/LedgerSMB/DBObject/Employee.pm

Modified: trunk/LedgerSMB/DBObject/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Company.pm	2007-11-25 19:47:40 UTC (rev 1900)
+++ trunk/LedgerSMB/DBObject/Company.pm	2007-11-25 19:59:02 UTC (rev 1901)
@@ -4,14 +4,29 @@
 use base qw(LedgerSMB::DBObject);
 use strict;
 
-sub save_credit {
+sub set_entity_class {
     my $self = shift @_;
+    if (!defined $self->{entity_class}){
+ 	       $self->error("Entity ID Not Set and No Entity Class Defined!");
+    }
+}
 
+sub save {
+    my $self = shift @_;
+    $self->set_entity_class();
     my ($ref) = $self->exec_method(funcname => 'entity_credit_save');
     $self->{entity_id} = $ref->{entity_credit_save};
     $self->{dbh}->commit;
 }
 
+sub save_location {
+    my $self = shift @_;
+    $self->{country_id} = $self->{country};
+    $self->exec_method(funcname => 'company__location_save');
+
+    $self->{dbh}->commit;
+}
+
 sub get_metadata {
     my $self = shift @_;
 
@@ -37,8 +52,15 @@
     $self->{dbh}->commit;
 }
 
-sub get_company{
+sub get {
     my $self = shift @_;
+
+    $self->set_entity_class()
+    my ($ref) = $self->exec_method(funcname => 'entity__retrieve_credit');
+    $self->merge($ref);
+
+    $self->{name} = $self->{legal_name};
+
     @{$self->{locations}} = $self->exec_method(
 		funcname => 'company__list_locations');
 

Modified: trunk/LedgerSMB/DBObject/Customer.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Customer.pm	2007-11-25 19:47:40 UTC (rev 1900)
+++ trunk/LedgerSMB/DBObject/Customer.pm	2007-11-25 19:59:02 UTC (rev 1901)
@@ -3,38 +3,16 @@
 use base qw(LedgerSMB::DBObject::Company);
 use strict;
 
-my $CUSTOMER_ENTITY_CLASS = 2;
+my $ENTITY_CLASS = 2;
 
-sub save {
+sub set_entity_class {
     my $self = shift @_;
-
-    $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
-    $self->save_credit(); # inherited from Company    
+    $self->{entity_class} = $ENTITY_CLASS;
 }
+    
 
 
-sub save_location {
-    my $self = shift @_;
-    $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
-    $self->{country_id} = $self->{country};
-    $self->exec_method(funcname => 'company__location_save');
 
-    $self->{dbh}->commit;
-}
-
-
-
-sub get {
-    my $self = shift @_;
-    $self->{entity_class} = $CUSTOMER_ENTITY_CLASS;
-    my ($ref) = $self->exec_method(funcname => 'entity__retrieve_credit');
-    $self->merge($ref);
-
-    $self->{name} = $self->{legal_name};
-    $self->get_company();
-}
-
-
 sub search {
     
     

Copied: trunk/LedgerSMB/DBObject/Employee.pm (from rev 1900, trunk/LedgerSMB/DBObject/Vendor.pm)
===================================================================
--- trunk/LedgerSMB/DBObject/Employee.pm	                        (rev 0)
+++ trunk/LedgerSMB/DBObject/Employee.pm	2007-11-25 19:59:02 UTC (rev 1901)
@@ -0,0 +1,13 @@
+package LedgerSMB::DBObject::Employee;
+
+use base qw(LedgerSMB::DBObject::Company);
+use strict;
+
+my $ENTITY_CLASS = 3;
+
+sub set_entity_class {
+    my $self = shift @_;
+    $self->{entity_class} = $ENTITY_CLASS;
+}
+    
+1;

Modified: trunk/LedgerSMB/DBObject/Vendor.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Vendor.pm	2007-11-25 19:47:40 UTC (rev 1900)
+++ trunk/LedgerSMB/DBObject/Vendor.pm	2007-11-25 19:59:02 UTC (rev 1901)
@@ -5,38 +5,9 @@
 
 my $ENTITY_CLASS = 1;
 
-sub save {
+sub set_entity_class {
     my $self = shift @_;
-
     $self->{entity_class} = $ENTITY_CLASS;
-    $self->save_credit(); # inherited from Company    
 }
-
-
-sub save_location {
-    my $self = shift @_;
-    $self->{entity_class} = $ENTITY_CLASS;
-    $self->{country_id} = $self->{country};
-    $self->exec_method(funcname => 'company__location_save');
-
-    $self->{dbh}->commit;
-}
-
-
-
-sub get {
-    my $self = shift @_;
-    $self->{entity_class} = $ENTITY_CLASS;
-    my ($ref) = $self->exec_method(funcname => 'entity__retrieve_credit');
-    $self->merge($ref);
-
-    $self->{name} = $self->{legal_name};
-    $self->get_company();
-}
-
-
-sub search {
     
-    
-}
 1;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.