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

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



Revision: 4926
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4926&view=rev
Author:   einhverfr
Date:     2012-06-20 06:44:03 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
Correcting namespace bugs in LedgerSMB/DBObject/Entity/Person.pm

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Entity/Person.pm
    trunk/LedgerSMB/DBObject/Entity.pm
    trunk/LedgerSMB/Scripts/contact.pm

Modified: trunk/LedgerSMB/DBObject/Entity/Person.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Person.pm	2012-06-20 02:29:00 UTC (rev 4925)
+++ trunk/LedgerSMB/DBObject/Entity/Person.pm	2012-06-20 06:44:03 UTC (rev 4926)
@@ -6,7 +6,7 @@
 
 To save:
 
- my $person = LedgerSMB::DBObject::Entity::Person(\%$request);
+ my $person = LedgerSMB::DBObject::Entity::Person->new(\%$request);
  $person->save;
 
 To get by entity id:
@@ -177,6 +177,6 @@
 # Not sure why but making the class immutable causes parent attributes to be 
 # lost.  Is this a bug in Class::MOP?
 #
-#__PACKAGE__->meta->make_immutable;
+__PACKAGE__->meta->make_immutable;
 
 1;

Modified: trunk/LedgerSMB/DBObject/Entity.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity.pm	2012-06-20 02:29:00 UTC (rev 4925)
+++ trunk/LedgerSMB/DBObject/Entity.pm	2012-06-20 06:44:03 UTC (rev 4926)
@@ -7,8 +7,6 @@
 package LedgerSMB::DBObject::Entity;
 use Moose;
 extends 'LedgerSMB::DBObject_Moose';
-use LedgerSMB::DBObject::Entity::Company;
-use LedgerSMB::DBObject::Entity::Person;
 
 =head1 SYNOPSYS
 
@@ -87,45 +85,6 @@
 
 has 'entity_class' => (is => 'rw', isa => 'Int');
 
-=head1 METHODS
-
-=over
-
-=item get($id)
-
-This retrieves the entity or person by id
-
-Please note, that the return value will always be either undef (not found), or
-an object of type of either LedgerSMB::DBObject::Entity::Company or
-LedgerSMB::DBObject::Entity::Person
-
-=cut
-
-sub get{
-    my ($self, $id) = @_;
-    my $entity = 
-       LedgerSMB::DBObject::Entity::Company->get($id) ||
-        LedgerSMB::DBObject::Entity::Person->get($id);
-    return $entity; 
-}
-
-=item get_by_cc($control_code)
-
-This retrieves the entity or person by control code.  It has the same return
-possibilities as get() above.
-
-=cut
-
-sub get_by_cc{
-    my ($self, $control_code) = @_;
-    my $entity = 
-       LedgerSMB::DBObject::Entity::Company->get_by_cc($control_code) ||
-        LedgerSMB::DBObject::Entity::Person->get_by_cc($control_code);
-    return $entity; 
-}
-
-=back
-
 =head1 COPYRIGHT
 
 Copyright (C) 2012 The LedgerSMB Core Team.  This file may be reused under the

Modified: trunk/LedgerSMB/Scripts/contact.pm
===================================================================
--- trunk/LedgerSMB/Scripts/contact.pm	2012-06-20 02:29:00 UTC (rev 4925)
+++ trunk/LedgerSMB/Scripts/contact.pm	2012-06-20 06:44:03 UTC (rev 4926)
@@ -53,7 +53,8 @@
 sub get_by_cc {
     my ($request) = @_;
     my $entity = 
-              LedgerSMB::DBObject::Entity->get_by_cc($request->{control_code});
+           LedgerSMB::DBObject::Entity::Company->get_by_cc($request->{control_code});
+    $entity ||=  LedgerSMB::DBObject::Entity::Person->get_by_cc($request->{control_code});
     my ($company, $person) = (undef, undef);
     if ($entity->isa('LedgerSMB::DBObject::Entity::Company')){
        $company = $entity;
@@ -76,7 +77,8 @@
 
 sub get {
     my ($request) = @_;
-    my $entity = LedgerSMB::DBObject::Entity->get($request->{entity_id});
+    my $entity = LedgerSMB::DBObject::Entity::Company->get($request->{entity_id});
+    $entity ||= LedgerSMB::DBObject::Entity::Person->get($request->{entity_id});
     my ($company, $person) = (undef, undef);
     if ($entity->isa('LedgerSMB::DBObject::Entity::Company')){
        $company = $entity;
@@ -440,7 +442,8 @@
 
 sub save_person {
     my ($request) = @_;
-    my $person = LedgerSMB::DBObject::Entity::Person->new(
+    use LedgerSMB::DBObject::Entity::Person2;
+    my $person = LedgerSMB::DBObject::Entity::Person2->new(
               %$request
     );
     use Data::Dumper;

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