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

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



Revision: 5019
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5019&view=rev
Author:   einhverfr
Date:     2012-07-20 11:33:51 +0000 (Fri, 20 Jul 2012)
Log Message:
-----------
Moving Entity tree out of DBObject namespace, clarifying code, removing Maybe[]'s and auditing requirements

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Admin.pm
    trunk/LedgerSMB/Entity/Bank.pm
    trunk/LedgerSMB/Entity/Company.pm
    trunk/LedgerSMB/Entity/Contact.pm
    trunk/LedgerSMB/Entity/Credit_Account.pm
    trunk/LedgerSMB/Entity/Location.pm
    trunk/LedgerSMB/Entity/Note.pm
    trunk/LedgerSMB/Entity/Payroll/Deduction.pm
    trunk/LedgerSMB/Entity/Payroll/Wage.pm
    trunk/LedgerSMB/Entity/Person/Employee.pm
    trunk/LedgerSMB/Entity/Person.pm
    trunk/LedgerSMB/Entity/User.pm
    trunk/LedgerSMB/REST_Class/Contact.pm
    trunk/LedgerSMB/Scripts/contact.pm
    trunk/LedgerSMB/Scripts/employee.pm
    trunk/LedgerSMB/Scripts/report_aging.pm
    trunk/LedgerSMB/Scripts/setup.pm

Added Paths:
-----------
    trunk/LedgerSMB/Entity/
    trunk/LedgerSMB/Entity.pm

Removed Paths:
-------------
    trunk/LedgerSMB/DBObject/Entity/
    trunk/LedgerSMB/DBObject/Entity.pm

Modified: trunk/LedgerSMB/DBObject/Admin.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Admin.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/DBObject/Admin.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -29,7 +29,7 @@
 
 use base qw(LedgerSMB::DBObject);
 
-use LedgerSMB::DBObject::Entity::Person::Employee;
+use LedgerSMB::Entity::Person::Employee;
 use LedgerSMB::DBObject::User;
 use Log::Log4perl;
 use strict;

Deleted: trunk/LedgerSMB/DBObject/Entity.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/DBObject/Entity.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,117 +0,0 @@
-=head1 NAME
-
-LedgerSMB::DBObject::Entity -- Entity Management base classes for LedgerSMB
-
-=cut
-
-package LedgerSMB::DBObject::Entity;
-use Moose;
-with 'LedgerSMB::DBObject_Moose';
-
-=head1 SYNOPSYS
-
-This module anages basic entity management for persons and companies, both of which will
-likely inherit this class.
-
-=head1 INHERITS
-
-=over
-
-=item LedgerSMB::DBObject_Moose
-
-=back
-
-=cut
-
-
-=head1 PROPERTIES
-
-=over
-
-=item id
-
-This is the internal, system id, which is a surrogate key.  This will be undefined when
-the entity has not yet been saved to the database and set once it has been saved or 
-retrieved.
-
-=cut
-
-has 'id' => (is => 'rw', isa => 'Maybe[Str]', required => '0');
-
-=item control_code
-
-The control code is the internal handling number for the operator to use to pull up 
-an entity,
-
-=cut
-
-has 'control_code' => (is => 'rw', isa => 'Str', required => 1);
-
-=item name
-
-The unofficial name of the entity.  This is usually copied in from company.legal_name
-or prepared (using some sort of locale-specific logic) from person.first_name and
-person.last_name.
-
-=cut
-
-has 'name' => (is => 'rw', isa => 'Maybe[Str]');
-
-=item country_id
-
-ID of country of entiy.
-
-=cut
-
-has 'country_id' => (is => 'rw', isa => 'Int');
-
-=item country_name
-
-Name of country (optional)
-
-=cut
-
-has 'country_name' => (is => 'rw', isa => 'Maybe[Str]');
-
-=item entity_class
-
-Primary class of entity.  This is mostly for reporting purposes.  See entity_class
-table in database for list of valid values, but 1 is for vendors, 2 for customers, 
-3 for employees, etc.
-
-=back
-
-=cut
-
-has 'entity_class' => (is => 'rw', isa => 'Int');
-
-=head1 METHODS
-
-=over
-
-=item get($id)
-
-Returns an entity by id
-
-=cut
-
-sub get{
-    my ($id) = @_;
-    my @results =  __PACKAGE__->call_procedure(procname => 'entity__get', 
-                                                   args => [$id]);
-    return shift @results;
-}
-
-=back
-
-=head1 COPYRIGHT
-
-Copyright (C) 2012 The LedgerSMB Core Team.  This file may be reused under the
-conditions of the GNU GPL v2 or at your option any later version.  Please see the
-accompanying LICENSE.TXT for more information.
-
-=cut
-
-__PACKAGE__->meta->make_immutable;
-
-return 1;

Modified: trunk/LedgerSMB/Entity/Bank.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Bank.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Bank.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,11 +1,11 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Bank - Bank account info for customers, vendors, 
+LedgerSMB::Entity::Bank - Bank account info for customers, vendors, 
 employees, and more.
 
 =head1 SYNPOSIS
 
-  @bank_list = LedgerSMB::DBObject::Entity::Bank->list($entity_id);
+  @bank_list = LedgerSMB::Entity::Bank->list($entity_id);
   $bank->save;
 
 =head1 DESCRIPTION
@@ -16,7 +16,7 @@
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Bank;
+package LedgerSMB::Entity::Bank;
 use Moose;
 with 'LedgerSMB::DBObject_Moose';
 
@@ -39,7 +39,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item credit_id Int
 
@@ -51,7 +51,7 @@
 
 =cut
 
-has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'credit_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item id
 
@@ -59,17 +59,17 @@
 
 =cut
 
-has 'id' => (is =>'ro', isa => 'Maybe[Int]');
+has 'id' => (is =>'ro', isa => 'Int', required => 0);
 
 =item bic
 
 Banking Institution Code, such as a SWIFT code or ABA routing number.  This can
-be set to undef because there are cases where the BIC is not needed for wire
+be omitted because there are cases where the BIC is not needed for wire
 transfers.
 
 =cut
 
-has 'bic' => (is =>'rw', isa => 'Maybe[Str]');
+has 'bic' => (is =>'rw', isa => 'Str', required => 0);
 
 =item iban
 
@@ -77,7 +77,7 @@
 
 =cut
 
-has 'iban' => (is => 'rw', isa => 'Str');
+has 'iban' => (is => 'rw', isa => 'Str', required => 1);
 
 =back
 

Modified: trunk/LedgerSMB/Entity/Company.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Company.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Company.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Company -- Company (business) handling for LedgerSMB
+LedgerSMB::Entity::Company -- Company (business) handling for LedgerSMB
 
 =head1 SYNOPSIS
 
@@ -11,15 +11,15 @@
 
 =over 
 
-=item LedgerSMB::DBObject::Entity
+=item LedgerSMB::Entity
 
 =back
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Company;
+package LedgerSMB::Entity::Company;
 use Moose;
-extends 'LedgerSMB::DBObject::Entity';
+extends 'LedgerSMB::Entity';
 
 =head1 PROPERTIES
 
@@ -31,7 +31,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item legal_name
 
@@ -39,7 +39,7 @@
 
 =cut
 
-has 'legal_name' => (is => 'rw', isa => 'Str', default => '');
+has 'legal_name' => (is => 'rw', isa => 'Str', requird => 0);
 
 =item tax_id
 
@@ -47,7 +47,7 @@
 
 =cut
 
-has 'tax_id' => (is => 'rw', isa => 'Maybe[Str]', default => '');
+has 'tax_id' => (is => 'rw', isa => 'Str', required => 0);
 
 =item sales_tax_id
 
@@ -55,7 +55,7 @@
 
 =cut
 
-has 'sales_tax_id' => (is => 'rw', isa => 'Maybe[Str]', default => '');
+has 'sales_tax_id' => (is => 'rw', isa => 'Str', required => 0);
 
 =item license_number
 
@@ -63,7 +63,7 @@
 
 =cut
 
-has 'license_number' => (is => 'rw', isa => 'Maybe[Str]', default => '');
+has 'license_number' => (is => 'rw', isa => 'Str', required => 0);
 
 =item sic_code
 
@@ -71,7 +71,7 @@
 
 =cut
 
-has 'sic_code' => (is => 'rw', isa => 'Maybe[Str]', default => '');
+has 'sic_code' => (is => 'rw', isa => 'Str', required => 0);
 
 =item created 
 
@@ -81,7 +81,7 @@
 
 =cut
 
-has 'created' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
+has 'created' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
 =head1 METHODS
 
@@ -95,10 +95,9 @@
 
 sub get {
     my ($self, $id) = @_;
-    my ($ref) = LedgerSMB::DBObject::Entity->call_procedure(procname => 'company__get',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'company__get',
                                           args => [$id]);
     return undef unless $ref->{control_code};
-    __PACKAGE__->prepare_dbhash($ref);
     return __PACKAGE__->new(%$ref);
 }
 
@@ -111,11 +110,10 @@
 
 sub get_by_cc {
     my ($self, $cc) = @_;
-    my ($ref) = $self->call_procedure(procname => 'company__get_by_cc',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'company__get_by_cc',
                                           args => [$cc]);
     return undef unless $ref->{control_code};
-    $self->prepare_dbhash($ref);
-    return $self->new(%$ref);
+    return __PACKAGE__->new(%$ref);
 }
 
 
@@ -128,11 +126,11 @@
 sub save {
     my ($self) = @_;
     my ($ref) = $self->exec_method({funcname => 'company__save'});
-    $self->prepare_dbhash($ref);
     $ref->{control_code} = $self->{control_code};
     $ref->{entity_class} = $self->{entity_class};
     $ref->{country_id} = $self->{country_id};
     $self = $self->new(%$ref);
+    return ($self);
 }
 
 =back

Modified: trunk/LedgerSMB/Entity/Contact.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Contact.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Contact.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,10 +1,10 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Contact - Contact info handling for LSMB
+LedgerSMB::Entity::Contact - Contact info handling for LSMB
 
 =head1 SYNPOSIS
 
-  @contact_list = LedgerSMB::DBObject::Entity::Contact->list(
+  @contact_list = LedgerSMB::Entity::Contact->list(
          {entity_id = $entity_id, credit_id = $credit_id }
   );
 
@@ -18,22 +18,14 @@
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Contact;
+package LedgerSMB::Entity::Contact;
 use Moose;
 with 'LedgerSMB::DBObject_Moose';
 
-=head1 INHERITS
+=head1 PROPERTIES
 
 =over
 
-=item LedgerSMB::DBObject_Moose;
-
-=back
-
-head1 PROPERTIES
-
-=over
-
 =item entity_id Int
 
 If set this is attached to an entity.  This can optionally be set to a contact
@@ -41,7 +33,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item credit_id Int
 
@@ -50,7 +42,7 @@
 
 =cut
 
-has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'credit_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item class_id Int
 
@@ -80,7 +72,7 @@
 
 =cut
 
-has 'class_id' => (is => 'rw', isa => 'Int');
+has 'class_id' => (is => 'rw', isa => 'Int', required => 1);
 
 =item class Str
 
@@ -89,7 +81,7 @@
 
 =cut
 
-has 'class' => (is => 'ro', isa => 'Maybe[Str]');
+has 'class' => (is => 'ro', isa => 'Str', required => 0);
 
 =item description Str
 
@@ -97,7 +89,7 @@
 
 =cut
 
-has 'description' => (is => 'rw', isa => 'Maybe[Str]');
+has 'description' => (is => 'rw', isa => 'Str', required => 0);
 
 =item contact Str
 
@@ -106,7 +98,7 @@
 
 =cut
 
-has 'contact' => (is => 'rw', isa => 'Str');
+has 'contact' => (is => 'rw', isa => 'Str', required => 1);
 
 
 =item old_class_id
@@ -118,9 +110,9 @@
 
 =cut
 
-has 'old_class_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'old_class_id' => (is => 'rw', isa => 'Int', required => 0);
 
-has 'old_contact' => (is => 'rw', isa => 'Maybe[Str]');
+has 'old_contact' => (is => 'rw', isa => 'Str', required => 0);
 
 =back
 
@@ -139,19 +131,18 @@
 
     my @results;
 
-    for my $ref ($self->call_procedure(procname => 'entity__list_contacts',
+    for my $ref (__PACKAGE__->call_procedure(procname => 'entity__list_contacts',
                                              args => [$args->{entity_id}])
     ){
        $self->prepare_dbhash($ref);
        push @results, $self->new($ref);
     }
 
-    for my $ref ($self->call_procedure(procname => 'eca__list_contacts',
+    for my $ref (__PACKAGE__->call_procedure(procname => 'eca__list_contacts',
                                              args => [$args->{credit_id}])
     ){
-       $self->prepare_dbhash($ref);
        $ref->{credit_id} = $args->{credit_id};
-       push @results, $self->new($ref);
+       push @results, __PACKAGE__->new($ref);
     }
     return @results;
 }
@@ -198,7 +189,7 @@
 =cut
 
 sub list_classes {
-    return LedgerSMB::DBObject_Moose->call_procedure(
+    return __PACKAGE__->call_procedure(
           procname => 'contact_class__list'
     );
 }

Modified: trunk/LedgerSMB/Entity/Credit_Account.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Credit_Account.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Credit_Account.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,28 +1,33 @@
 =head1 NAME 
 
-LedgerSMB::DBObject::Entity::Credit_Account - Customer/Vendor Acct Management for LSMB
+LedgerSMB::Entity::Credit_Account - Customer/Vendor Acct Management for LSMB
 
 =head1 SYNOPSYS
 
-This module provides customer/vendor credit account management features for
-LedgerSMB.  These include credit limit, credit limit remaining, terms, discounts
-and the like.
+To get by ID:
 
-=head1 DESCRIPTION
+ my $eca = LedgerSMB::Entity::Credit_Account->get_by_id($id);
 
-TODO
+To get by customer/vendor number:
 
-=head1 INHERITS
+ my $eca = LedgerSMB::Entity::Credit_Account->get_by_meta_number(
+          $customernumber, $entity_class
+ );
 
-=over
+To save
 
-=item LedgerSMB::DBObject_Moose
+ $eca->save;
 
-=back
+=head1 DESCRIPTION
 
+This module provides customer/vendor credit account management features for
+LedgerSMB.  These include credit limit, credit limit remaining, terms, discounts
+and the like.
+
+
 =cut
 
-package LedgerSMB::DBObject::Entity::Credit_Account;
+package LedgerSMB::Entity::Credit_Account;
 use Moose;
 with 'LedgerSMB::DBObject_Moose';
 
@@ -38,7 +43,7 @@
 
 =cut
 
-has 'id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item entity_id
 
@@ -46,7 +51,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'ro', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'ro', isa => 'Int', required => 0);
 
 =item entity_class
 
@@ -55,7 +60,7 @@
 
 =cut
 
-has 'entity_class' => (is => 'ro', isa => 'Maybe[Int]');
+has 'entity_class' => (is => 'ro', isa => 'Int', required => 1);
 
 =item pay_to_name
 
@@ -63,7 +68,7 @@
 
 =cut
 
-has 'pay_to_name' => (is => 'rw', isa => 'Maybe[Str]');
+has 'pay_to_name' => (is => 'rw', isa => 'Str', required => 0);
 
 =item discount
 
@@ -71,7 +76,7 @@
 
 =cut
 
-has 'discount' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGNumber]');
+has 'discount' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Number');
 
 =item description
 
@@ -79,7 +84,7 @@
 
 =cut
 
-has 'description' => (is => 'rw', isa => 'Maybe[Str]');
+has 'description' => (is => 'rw', isa => 'Str', required => 0);
 
 =item discount_terms
 
@@ -87,7 +92,7 @@
 
 =cut
 
-has 'discount_terms' => (is => 'rw', isa => 'Maybe[Int]');
+has 'discount_terms' => (is => 'rw', isa => 'Int', required => 0);
 
 =item discount_account_id
 
@@ -95,7 +100,7 @@
 
 =cut
 
-has 'discount_account_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'discount_account_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item taxincluded
 
@@ -103,7 +108,7 @@
 
 =cut
 
-has 'taxincluded' => (is => 'rw', isa => 'Maybe[Bool]');
+has 'taxincluded' => (is => 'rw', isa => 'Bool');
 
 =item creditlimit
 
@@ -111,7 +116,7 @@
 
 =cut
 
-has 'creditlimit' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGNumber]');
+has 'creditlimit' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Number');
 
 =item current_debt
 
@@ -121,7 +126,8 @@
 
 =cut
 
-has 'current_debt' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGNumber]');
+has 'current_debt' => (is => 'rw', isa => 'LedgerSMB::Moose::Number'.
+                       coerce => 1, lazy => 1, builder => 'get_current_debt');
 
 =item terms
 
@@ -129,7 +135,7 @@
 
 =cut
 
-has 'terms' => (is => 'rw', isa => 'Maybe[Int]');
+has 'terms' => (is => 'rw', isa => 'Int', required => 0);
 
 =item meta_number
 
@@ -137,7 +143,7 @@
 
 =cut
 
-has 'meta_number' => (is => 'rw', isa => 'Maybe[Str]');
+has 'meta_number' => (is => 'rw', isa => 'Str', required => 0);
 
 =item business_id
 
@@ -149,8 +155,8 @@
 
 =cut
 
-has 'business_id'   => (is => 'rw', isa => 'Maybe[Int]');
-has 'business_type' => (is => 'rw', isa => 'Maybe[Str]');
+has 'business_id'   => (is => 'rw', isa => 'Int', required => 0);
+has 'business_type' => (is => 'rw', isa => 'Str', required => 0);
 
 =item language_code
 
@@ -160,7 +166,7 @@
 
 =cut
 
-has 'language_code' => (is => 'rw', isa => 'Maybe[Str]');
+has 'language_code' => (is => 'rw', isa => 'Str', required => 0);
 
 =item pricegroup_id
 
@@ -169,7 +175,7 @@
 
 =cut
 
-has 'pricegroup_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'pricegroup_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item curr
 
@@ -178,7 +184,7 @@
 
 =cut
 
-has 'curr' => (is => 'ro', isa => 'Maybe[Str]');
+has 'curr' => (is => 'ro', isa => 'Str', requird => 1);
 
 =item startdate
 
@@ -190,8 +196,8 @@
 
 =cut
 
-has 'startdate' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
-has 'enddate'   => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
+has 'startdate' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
+has 'enddate'   => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
 =item threshold
 
@@ -199,7 +205,7 @@
 
 =cut
 
-has 'threshold' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGNumber]');
+has 'threshold' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Number');
 
 =item employee_id
 
@@ -208,7 +214,7 @@
 
 =cut
 
-has 'employee_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'employee_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item ar_ap_account_id
 
@@ -216,7 +222,7 @@
 
 =cut
 
-has 'ar_ap_account_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'ar_ap_account_id' => (is => 'rw', isa => 'Int', required => 1);
 
 =item cash_account_id
 
@@ -224,7 +230,7 @@
 
 =cut
 
-has 'cash_account_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'cash_account_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item bank_account
 
@@ -238,7 +244,7 @@
 
 =cut
 
-has 'tax_ids' => (is => 'rw', isa => 'Maybe[ArrayRef[Int]]');
+has 'tax_ids' => (is => 'rw', isa => 'ArrayRef[Int]', required => 0);
 
 =item bank_account
 
@@ -246,7 +252,7 @@
 
 =cut
 
-has 'bank_account' => (is => 'rw', isa => 'Maybe[Int]');
+has 'bank_account' => (is => 'rw', isa => 'Int', required => 0);
 
 =item taxform_id   
 
@@ -254,7 +260,7 @@
 
 =cut
 
-has 'taxform_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'taxform_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =back
 
@@ -297,11 +303,10 @@
 
 sub get_by_id {
     my ($self, $id) = @_;
-    my ($ref) = $self->call_procedure(procname => 'entity_credit__get',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'entity_credit__get',
                                           args => [$id]);
     $ref->{tax_ids} = $self->_get_tax_ids($id);
-    $self->prepare_dbhash($ref);
-    return $self->new(%$ref);
+    return __PACKAGE__->new(%$ref);
 }
 
 =item get_by_meta_number($meta_number string, $entity_class int)
@@ -313,12 +318,11 @@
 
 sub get_by_meta_number {
     my ($self, $meta_number, $entity_class) = @_;
-    my ($ref) = $self->call_procedure(procname => 'eca__get_by_met_number',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'eca__get_by_met_number',
                                           args => [$meta_number, 
                                                    $entity_class]);
-    $self->prepare_dbhash($ref);
-    $ref->{tax_ids} = $self->_set_tax_ids($ref->{id});
-    return $self->new(%$ref);
+    $ref->{tax_ids} = __PACKAGE__->_set_tax_ids($ref->{id});
+    return __PACKAGE__->new(%$ref);
 }
 
 # Private methid _get_tax_ids
@@ -327,7 +331,7 @@
 sub _get_tax_ids {
     my ($self, $id) = @_;
     my @tax_ids;
-    my @results = $self->call_procedure(procname => 'eca__get_taxes',
+    my @results = __PACKAGE__->call_procedure(procname => 'eca__get_taxes',
                                             args => [$id]);
     for my $ref (@results){
         push @tax_ids, $ref->{chart_id};
@@ -344,13 +348,12 @@
 
 sub list_for_entity {
     my ($self, $entity_id, $entity_class) = @_;
-    my @results = $self->call_procedure(procname => 'entity__list_credit',
+    my @results = __PACKAGE__->call_procedure(procname => 'entity__list_credit',
                                             args => [$entity_id, $entity_class]
     );
     for my $ref (@results){
         $ref->{tax_ids} = $self->_get_tax_ids($ref->{id});
-        $self->prepare_dbhash($ref);
-        $ref = $self->new(%$ref);
+        $ref = __PACKAGE__->new(%$ref);
     }
     return @results;
 }
@@ -381,8 +384,8 @@
     if (@{$self->{tax_ids}}){
         $self->exec_method(funcname => 'eca__set_taxes');
     }
-    $self->prepare_dbhash($ref);
     $self = $self->new(%$ref);
+    return $self;
 }
 
 =item get_pricematrix
@@ -416,7 +419,7 @@
     my $self = shift @_;
     my ($entry_id) = @_;
     my ($retval) = $self->exec_method(funcname => 'eca__delete_pricematrix', 
-                           args => [$self->{credit_id}, $entry_id]
+                           args => [$self->credit_id, $entry_id]
     );
     return $retval;
 }

Modified: trunk/LedgerSMB/Entity/Location.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Location.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Location.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,24 +1,23 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Location - Address Handling for LedgerSMB Contacts
+LedgerSMB::Entity::Location - Address Handling for LedgerSMB Contacts
 
 =head1 SYNPOSIS
 
+ my $loc = LedgerSMB::Entity::Location->new(%$request);
+ $loc->save;
+
+=head1 DESCRIPTION
+
 This contains a the basic handling of addresses for LedgerSMB contacts.
 
 Addresses may be tacked for billing, marketing, and shipping, and may be
 attached either to the entity (person or company) or credit account
 (customer/vendor account).
 
-=head1 INHERITS
-
-=over
-
-=item LedgerSMB::DBObject_Moose
-
 =cut
 
-package LedgerSMB::DBObject::Entity::Location;
+package LedgerSMB::Entity::Location;
 use Moose;
 use LedgerSMB::App_State;
 use LedgerSMB::Locale;
@@ -42,7 +41,7 @@
 
 =cut
 
-has 'active' => (is => 'rw', isa => 'Maybe[Bool]');
+has 'active' => (is => 'rw', isa => 'Bool');
 
 =item inactive_date
 
@@ -50,7 +49,7 @@
 
 =cut
 
-has 'inactive_date' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
+has 'inactive_date' => (is => 'rw', coerce => 1isa => 'LedgerSMB::Moose::Date');
 
 =item id
 
@@ -58,7 +57,7 @@
 
 =cut
 
-has 'id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item entity_id
 
@@ -67,7 +66,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'ro', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'ro', isa => 'Int', required => 0);
 
 =item credit_id
 
@@ -76,7 +75,7 @@
 
 =cut
 
-has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'credit_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item location_class
 
@@ -94,7 +93,7 @@
 
 =cut
 
-has 'location_class' => (is => 'ro', isa => 'Maybe[Int]');
+has 'location_class' => (is => 'ro', isa => 'Int', required => 1);
 
 =item old_location_class
 
@@ -102,7 +101,7 @@
 
 =cut
 
-has 'old_location_class' => (is => 'ro', isa => 'Maybe[Int]');
+has 'old_location_class' => (is => 'ro', isa => 'Int', required => 1);
 
 =item class_name
 
@@ -116,7 +115,7 @@
                  3 => $locale->text('Shipping'),
 );
 
-has 'class_name' => (is => 'rw', isa => 'Maybe[Str]');
+has 'class_name' => (is => 'rw', isa => 'Str', required => 0);
 
 =item line_one
 
@@ -124,7 +123,7 @@
 
 =cut
 
-has 'line_one' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'line_one' => (is => 'rw', 'isa' => 'Str', required => 1);
 
 =item line_two
 
@@ -132,7 +131,7 @@
 
 =cut
 
-has 'line_two' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'line_two' => (is => 'rw', 'isa' => 'Str', required => 0);
 
 =item line_three
 
@@ -140,7 +139,7 @@
 
 =cut
 
-has 'line_three' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'line_three' => (is => 'rw', 'isa' => 'Str', required => 0);
 
 =item city
 
@@ -148,7 +147,7 @@
 
 =cut
 
-has 'city' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'city' => (is => 'rw', 'isa' => 'Str', required => 1);
 
 =item state
 
@@ -156,7 +155,7 @@
 
 =cut
 
-has 'state' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'state' => (is => 'rw', 'isa' => 'Str', required => 1);
 
 =item mail_code
 
@@ -164,7 +163,7 @@
 
 =cut
 
-has 'mail_code' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'mail_code' => (is => 'rw', 'isa' => 'Str', required => 0);
 
 =item country_id
 
@@ -172,7 +171,7 @@
 
 =cut
 
-has 'country_id' => (is => 'rw', 'isa' => 'Maybe[Int]');
+has 'country_id' => (is => 'rw', 'isa' => 'Int', required => 1);
 
 =item counry_name
 
@@ -180,7 +179,7 @@
 
 =cut
 
-has 'country_name' => (is => 'rw', 'isa' => 'Maybe[Str]');
+has 'country_name' => (is => 'rw', 'isa' => 'Str', required => 0);
 
 =back
 
@@ -213,24 +212,22 @@
 sub get_active {
     my ($self, $args) = @_;
     my @results;
-    for my $ref ($self->call_procedure(procname => 'entity__list_locations',
+    for my $ref (__PACKAGE__->call_procedure(procname => 'entity__list_locations',
                                            args => [$args->{entity_id}]))
     {
        next if ($args->{only_class}) 
                and ($args->{only_class} != $ref->{location_class});
-        $self->prepare_dbhash($ref);
-        push @results, $self->new(%$ref);
+        push @results, __PACKAGE__->new(%$ref);
     }
     return @results unless $args->{credit_id};
 
-    for my $ref ($self->call_procedure(procname => 'eca__list_locations',
+    for my $ref (__PACKAGE__->call_procedure(procname => 'eca__list_locations',
                                            args => [$args->{credit_id}]))
     {
        next if ($args->{only_class}) 
                and ($args->{only_class} != $ref->{location_class});
         $ref->{credit_id} = $args->{credit_id};
-        $self->prepare_dbhash($ref);
-        push @results, $self->new(%$ref);
+        push @results, __PACKAGE__->new(%$ref);
     }
 
     return @results;

Modified: trunk/LedgerSMB/Entity/Note.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Note.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Note.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,11 +1,11 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Note - Notes handling for customers, vendors, 
+LedgerSMB::Entity::Note - Notes handling for customers, vendors, 
 employees, etc.
 
 =head1 SYNPOSIS
 
-  @notes = LedgerSMB::DBObject::Entity::Bank->list($entity_id, [$credit_id]);
+  @notes = LedgerSMB::Entity::Bank->list($entity_id, [$credit_id]);
   $note->add;
 
 =head1 DESCRIPTION
@@ -19,7 +19,7 @@
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Note;
+package LedgerSMB::Entity::Note;
 use Moose;
 with 'LedgerSMB::DBObject_Moose';
 
@@ -42,7 +42,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item credit_id Int
 
@@ -51,7 +51,7 @@
 
 =cut
 
-has 'credit_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'credit_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item id
 
@@ -59,7 +59,7 @@
 
 =cut
 
-has 'id' => (is =>'ro', isa => 'Maybe[Int]');
+has 'id' => (is =>'ro', isa => 'Int', required => 0);
 
 =item subject
 
@@ -67,7 +67,7 @@
 
 =cut
 
-has 'subject' => (is =>'rw', isa => 'Maybe[Str]');
+has 'subject' => (is =>'rw', isa => 'Str', required => 0);
 
 =item note
 
@@ -75,7 +75,7 @@
 
 =cut
 
-has 'note' => (is => 'rw', isa => 'Str');
+has 'note' => (is => 'rw', isa => 'Str', required => 1);
 
 =item 'note_class'
 
@@ -83,7 +83,7 @@
 
 =cut
 
-has 'note_class'  => (is => 'rw', isa => 'Maybe[Int]');
+has 'note_class'  => (is => 'rw', isa => 'Int', required => 1);
 
 =back
 
@@ -102,15 +102,14 @@
     my ($self, $entity_id, $credit_id) = @_;
     my @results;
     if ($credit_id){
-        @results = $self->call_procedure(procname =>
+        @results = __PACKAGE__->call_procedure(procname =>
              'eca__list_notes', args => [$credit_id]);
     } else {
-        @results = $self->call_procedure(procname =>
+        @results = __PACKAGE__->call_procedure(procname =>
              'entity__list_notes', args => [$entity_id]);
     }
     for my $row(@results){
-        $self->prepare_dbhash($row); 
-        $row = $self->new(%$row);
+        $row = __PACKAGE__->new(%$row);
     }
     return @results;
 }

Modified: trunk/LedgerSMB/Entity/Payroll/Deduction.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Payroll/Deduction.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Payroll/Deduction.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,29 +1,29 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Payroll::Deduction - Payroll Deduction handling for
+LedgerSMB::Entity::Payroll::Deduction - Payroll Deduction handling for
 LedgerSMB
 
 =head1 SYNPOSIS
 
 To retrieve a list of deductions for an entity:
 
-  my @deducts = LedgerSMB::DBObject::Entity::Person::Deductions->list(
+  my @deducts = LedgerSMB::Entity::Person::Deductions->list(
              $entity_id
   );
 
 To retrieve a list of deduction categories for selection:
-  my @types = LedgerSMB::DBObject::Entity::Person::Deduction->types(
+  my @types = LedgerSMB::Entity::Person::Deduction->types(
               $country_id
   );
 
 To save a new deduction:
 
-  my $deduct= LedgerSMB::DBObject::Entity::Person::Deduction->new(%$request);
+  my $deduct= LedgerSMB::Entity::Person::Deduction->new(%$request);
   $deduct->save;
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Payroll::Deduction;
+package LedgerSMB::Entity::Payroll::Deduction;
 use Moose;
 with 'LedgerSMB::DBObject_Moose';
 
@@ -37,7 +37,7 @@
 
 =cut
 
-has entry_id => (is => 'rw', isa => 'Maybe[Int]');
+has entry_id => (is => 'rw', isa => 'Int', required => 0);
 
 =item type_id
 
@@ -45,7 +45,7 @@
 
 =cut
 
-has type_id => (is => 'rw', isa => 'Int');
+has type_id => (is => 'rw', isa => 'Int', required => 1);
 
 =item rate
 
@@ -55,7 +55,8 @@
 
 =cut 
 
-has rate => (is => 'rw', isa => 'Num');
+has rate => (is => 'rw', coerce => 1., isa => 'LedgerSMB::Moose::Number', 
+             required => 1);
 
 =back
 
@@ -71,7 +72,7 @@
 
 sub list {
     my ($self, $entity_id) = @_;
-    return $self->call_procedure(procname => 'deduction__list_for_entity',
+    return __PACKAGE__->call_procedure(procname => 'deduction__list_for_entity',
                                      args => [$entity_id]);
 }
 
@@ -83,7 +84,7 @@
 
 sub types{
     my ($self, $country_id) = @_;
-    return $self->call_procedure(procname => 'deduction__list_types', 
+    return __PACKAGE__->call_procedure(procname => 'deduction__list_types', 
                                      args => [$country_id]);
 }
 

Modified: trunk/LedgerSMB/Entity/Payroll/Wage.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Payroll/Wage.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Payroll/Wage.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,25 +1,25 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Payroll::Wage - Wages and Salary Handling 
+LedgerSMB::Entity::Payroll::Wage - Wages and Salary Handling 
 for LedgerSMB
 
 =head1 SYNPOSIS
 
 To retrieve a list of wages for an entity:
 
-  my @wages = LedgerSMB::DBObject::Entity::Person::Wage->list($entity_id);
+  my @wages = LedgerSMB::Entity::Person::Wage->list($entity_id);
 
 To retrieve a list of wage categories for selection:
-  my @classes = LedgerSMB::DBObject::Entity::Person::Wage->classes($entity_id);
+  my @classes = LedgerSMB::Entity::Person::Wage->classes($entity_id);
 
 To save a new wage:
 
-  my $wage = LedgerSMB::DBObject::Entity::Person::Wage->new(%$request);
+  my $wage = LedgerSMB::Entity::Person::Wage->new(%$request);
   $wage->save;
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Payroll::Wage;
+package LedgerSMB::Entity::Payroll::Wage;
 use Moose;
 with 'LedgerSMB::DBObject_Moose';
 
@@ -33,7 +33,7 @@
 
 =cut
 
-has entry_id => (is => 'rw', isa => 'Maybe[Int]');
+has entry_id => (is => 'rw', isa => 'Int', required => 0);
 
 =item type_id
 
@@ -41,7 +41,7 @@
 
 =cut
 
-has type_id => (is => 'rw', isa => 'Int');
+has type_id => (is => 'rw', isa => 'Int'. required => 1);
 
 =item rate
 
@@ -50,7 +50,8 @@
 
 =cut 
 
-has rate => (is => 'rw', isa => 'Num');
+has rate => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Number',
+             required => 1);
 
 =back
 
@@ -66,7 +67,7 @@
 
 sub list {
     my ($self, $entity_id) = @_;
-    return $self->call_procedure(procname => 'wage__list_for_entity',
+    return __PACKAGE__->call_procedure(procname => 'wage__list_for_entity',
                                      args => [$entity_id]);
 }
 
@@ -78,7 +79,7 @@
 
 sub types{
     my ($self, $country_id) = @_;
-    return $self->call_procedure(procname => 'wage__list_types', 
+    return __PACKAGE__->call_procedure(procname => 'wage__list_types', 
                                      args => [$country_id]);
 }
 

Modified: trunk/LedgerSMB/Entity/Person/Employee.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Person/Employee.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Person/Employee.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,36 +1,36 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Person::Employee -- Employee handling for LedgerSMB
+LedgerSMB::Entity::Person::Employee -- Employee handling for LedgerSMB
 
 =head1 SYNOPSIS
 
 To save:
 
- my $emp = LedgerSMB::DBObject::Entity::Person::Employee(\%$request);
+ my $emp = LedgerSMB::Entity::Person::Employee(\%$request);
  $emp->save;
 
 To get by entity id:
 
- my $emp = LedgerSMB::DBObject::Entity::Person::Employee->get($entity_id);
+ my $emp = LedgerSMB::Entity::Person::Employee->get($entity_id);
 
 To get by control code:
 
  my $emp 
-     = LedgerSMB::DBObject::Entity::Person::Employee->get_by_cc($control_code);
+     = LedgerSMB::Entity::Person::Employee->get_by_cc($control_code);
 
 =head1 INHERITS
 
 =over 
 
-=item LedgerSMB::DBObject::Entity::Person
+=item LedgerSMB::Entity::Person
 
 =back
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Person::Employee;
+package LedgerSMB::Entity::Person::Employee;
 use Moose;
-extends 'LedgerSMB::DBObject::Entity::Person';
+extends 'LedgerSMB::Entity::Person';
 
 use LedgerSMB::App_State;
 my $locale = $LedgerSMB::App_State::Locale;
@@ -45,7 +45,7 @@
 
 =cut
 
-has start_date => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
+has start_date => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
 =item end_date
 
@@ -53,7 +53,7 @@
 
 =cut
 
-has end_date => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
+has end_date => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
 =item dob
 
@@ -61,7 +61,7 @@
 
 =cut
 
-has dob => (is => 'rw', isa => 'LedgerSMB::PGDate');
+has dob => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
 =item role
 
@@ -69,7 +69,7 @@
 
 =cut
 
-has role => (is => 'rw', isa => 'Maybe[Str]');
+has role => (is => 'rw', isa => 'Str', required => 0);
 
 =item ssn
 
@@ -77,7 +77,7 @@
 
 =cut
 
-has ssn => (is => 'rw', isa => 'Str');
+has ssn => (is => 'rw', isa => 'Str', required => 1);
 
 =item sales
 
@@ -93,7 +93,7 @@
 
 =cut
 
-has manager_id => (is => 'rw', isa => 'Maybe[Int]');
+has manager_id => (is => 'rw', isa => 'Int', required => 0);
 
 =item employeenumber
 
@@ -101,7 +101,7 @@
 
 =cut
 
-has employeenumber => (is => 'rw', isa => 'Str');
+has employeenumber => (is => 'rw', isa => 'Str', required => 1);
 
 =back
 
@@ -118,11 +118,10 @@
 
 sub get {
     my ($self, $id) = @_;
-    my ($ref) = $self->call_procedure(procname => 'employee__get',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'employee__get',
                                           args => [$id]);
     return undef unless $ref->{control_code};
-    $self->prepare_dbhash($ref);
-    return $self->new(%$ref);
+    return __PACKAGE__->new(%$ref);
 }
 
 =item get_by_cc($control_code);
@@ -134,7 +133,7 @@
 
 sub get_by_cc {
     my ($self, $cc) = @_;
-    my ($ref) = $self->call_procedure(procname => 'person__get_by_cc',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'person__get_by_cc',
                                           args => [$cc]);
     return undef unless $ref->{control_code};
     return get($ref->{id});

Modified: trunk/LedgerSMB/Entity/Person.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/Person.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/Person.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,35 +1,35 @@
 =head1 NAME
 
-LedgerSMB::DBObject::Entity::Person -- Natural Person handling for LedgerSMB
+LedgerSMB::Entity::Person -- Natural Person handling for LedgerSMB
 
 =head1 SYNOPSIS
 
 To save:
 
- my $person = LedgerSMB::DBObject::Entity::Person->new(\%$request);
+ my $person = LedgerSMB::Entity::Person->new(\%$request);
  $person->save;
 
 To get by entity id:
 
- my $person = LedgerSMB::DBObject::Entity::Person->get($entity_id);
+ my $person = LedgerSMB::Entity::Person->get($entity_id);
 
 To get by control code:
 
- my $person = LedgerSMB::DBObject::Entity::Person->get_by_cc($control_code);
+ my $person = LedgerSMB::Entity::Person->get_by_cc($control_code);
 
 =head1 INHERITS
 
 =over 
 
-=item LedgerSMB::DBObject::Entity
+=item LedgerSMB::Entity
 
 =back
 
 =cut
 
-package LedgerSMB::DBObject::Entity::Person;
+package LedgerSMB::Entity::Person;
 use Moose;
-extends 'LedgerSMB::DBObject::Entity';
+extends 'LedgerSMB::Entity';
 
 use LedgerSMB::App_State;
 my $locale = $LedgerSMB::App_State::Locale;
@@ -44,7 +44,7 @@
 
 =cut
 
-has 'entity_id' => (is => 'rw', isa => 'Maybe[Int]');
+has 'entity_id' => (is => 'rw', isa => 'Int', required => 0);
 
 =item first_name
 
@@ -52,7 +52,7 @@
 
 =cut
 
-has 'first_name' => (is => 'rw', isa => 'Str');
+has 'first_name' => (is => 'rw', isa => 'Str', required => 1);
 
 =item middle_name
 
@@ -60,7 +60,7 @@
 
 =cut
 
-has 'middle_name' => (is => 'rw', isa => 'Maybe[Str]');
+has 'middle_name' => (is => 'rw', isa => 'Str', required => 0);
 
 =item last_name
 
@@ -68,7 +68,7 @@
 
 =cut
 
-has 'last_name' => (is => 'rw', isa => 'Maybe[Str]');
+has 'last_name' => (is => 'rw', isa => 'Str', required => 1);
 
 =item salutation_id
 
@@ -87,7 +87,7 @@
 
 =cut
 
-has 'salutation_id' => (is => 'rw', isa => 'Int');
+has 'salutation_id' => (is => 'rw', isa => 'Int', required => 1);
 
 =item salutations
 
@@ -114,7 +114,7 @@
 
 =cut
 
-has 'created' => (is => 'rw', isa => 'Maybe[LedgerSMB::PGDate]');
+has 'created' => (is => 'rw', coerce => 1, isa => 'LedgerSMB::Moose::Date');
 
 =head1 METHODS
 
@@ -128,11 +128,10 @@
 
 sub get {
     my ($self, $id) = @_;
-    my ($ref) = $self->call_procedure(procname => 'person__get',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'person__get',
                                           args => [$id]);
     return undef unless $ref->{control_code};
-    $self->prepare_dbhash($ref);
-    return $self->new(%$ref);
+    return __PACKAGE__->new(%$ref);
 }
 
 =item get_by_cc($cc)
@@ -144,11 +143,10 @@
 
 sub get_by_cc {
     my ($self, $cc) = @_;
-    my ($ref) = $self->call_procedure(procname => 'person__get_by_cc',
+    my ($ref) = __PACKAGE__->call_procedure(procname => 'person__get_by_cc',
                                           args => [$cc]);
     return undef unless $ref->{control_code};
-    $self->prepare_dbhash($ref);
-    return $self->new(%$ref);
+    return __PACKAGE__->new(%$ref);
 }
 
 

Modified: trunk/LedgerSMB/Entity/User.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Entity/User.pm	2012-07-19 12:00:57 UTC (rev 5015)
+++ trunk/LedgerSMB/Entity/User.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -1,10 +1,10 @@
 =head1 NAME 
 
-LedgerSMB::DBObject::Entity::User - User management Logic for LedgerSMB
+LedgerSMB::Entity::User - User management Logic for LedgerSMB
 
 =cut
 
-package LedgerSMB::DBObject::Entity::User;
+package LedgerSMB::Entity::User;
 use Moose;
 use LedgerSMB::App_State;
 with 'LedgerSMB::DBObject_Moose';
@@ -12,15 +12,15 @@
 =head1 SYNOPSYS
 
 Resetting a password (expires in 24 hrs):
-  my $user = LedgerSMB::DBObject::Entity::User->get($entity_id);
+  my $user = LedgerSMB::Entity::User->get($entity_id);
   my $user->reset_password('temporary_password');
 
 Creating a new user:
-  my $user = LedgerSMB::DBObject::Entity::User->new(%$request); 
+  my $user = LedgerSMB::Entity::User->new(%$request); 
   $user->save;
 
 Saving permissions:
-  my $user = LedgerSMB::DBObject::Entity::User->new(%$request);
+  my $user = LedgerSMB::Entity::User->new(%$request);
   $user->set_roles($request);
 
 =head1 PROPERTIES
@@ -33,7 +33,7 @@
 
 =cut 
 
-has entity_id => (is => 'ro', isa => 'Int');
+has entity_id => (is => 'ro', isa => 'Int', required => 1);
 
 =item username
 
@@ -41,7 +41,7 @@
 
 =cut
 
-has username => (is => 'rw', isa => 'Str');
+has username => (is => 'rw', isa => 'Str', required => 1);
 
 =item pls_import
 
@@ -59,7 +59,7 @@
 
 =cut
 
-has password => (is => 'rw', isa => 'Maybe[Str]');
+has password => (is => 'rw', isa => 'Str', required => 0);
 
 =item role_list
 
@@ -67,7 +67,7 @@
 
 =cut
 
-has role_list => (is => 'rw', isa => 'Maybe[ArrayRef[Str]]');
+has role_list => (is => 'rw', isa => 'ArrayRef[Str]', required => 0);
 
 
 =back

Copied: trunk/LedgerSMB/Entity.pm (from rev 5015, trunk/LedgerSMB/DBObject/Entity.pm)
===================================================================
--- trunk/LedgerSMB/Entity.pm	                        (rev 0)
+++ trunk/LedgerSMB/Entity.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -0,0 +1,106 @@
+=head1 NAME
+
+LedgerSMB::Entity -- Entity Management base classes for LedgerSMB
+
+=cut
+
+package LedgerSMB::Entity;
+use Moose;
+with 'LedgerSMB::DBObject_Moose';
+
+=head1 SYNOPSYS
+
+This module anages basic entity management for persons and companies, both of which will
+likely inherit this class.
+
+=head1 PROPERTIES
+
+=over
+
+=item id
+
+This is the internal, system id, which is a surrogate key.  This will be undefined when
+the entity has not yet been saved to the database and set once it has been saved or 
+retrieved.
+
+=cut
+
+has 'id' => (is => 'rw', isa => 'Str', required => '0');
+
+=item control_code
+
+The control code is the internal handling number for the operator to use to pull up 
+an entity,
+
+=cut
+
+has 'control_code' => (is => 'rw', isa => 'Str', required => 1);
+
+=item name
+
+The unofficial name of the entity.  This is usually copied in from company.legal_name
+or prepared (using some sort of locale-specific logic) from person.first_name and
+person.last_name.
+
+=cut
+
+has 'name' => (is => 'rw', isa => 'Str', required => 1);
+
+=item country_id
+
+ID of country of entiy.
+
+=cut
+
+has 'country_id' => (is => 'rw', isa => 'Int', required => 1);
+
+=item country_name
+
+Name of country (optional)
+
+=cut
+
+has 'country_name' => (is => 'rw', isa => 'Str', required => 0);
+
+=item entity_class
+
+Primary class of entity.  This is mostly for reporting purposes.  See entity_class
+table in database for list of valid values, but 1 is for vendors, 2 for customers, 
+3 for employees, etc.
+
+=back
+
+=cut
+
+has 'entity_class' => (is => 'rw', isa => 'Int', required => 1);
+
+=head1 METHODS
+
+=over
+
+=item get($id)
+
+Returns an entity by id
+
+=cut
+
+sub get{
+    my ($id) = @_;
+    my @results =  __PACKAGE__->call_procedure(procname => 'entity__get', 
+                                                   args => [$id]);
+    return shift @results;
+}
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2012 The LedgerSMB Core Team.  This file may be reused under the
+conditions of the GNU GPL v2 or at your option any later version.  Please see the
+accompanying LICENSE.TXT for more information.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+return 1;

Modified: trunk/LedgerSMB/REST_Class/Contact.pm
===================================================================
--- trunk/LedgerSMB/REST_Class/Contact.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/REST_Class/Contact.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -5,14 +5,14 @@
 =cut
 
 package LedgerSMB::REST_Class::Contact;
-use LedgerSMB::DBObject::Entity;
-use LedgerSMB::DBObject::Entity::Credit_Account;
-use LedgerSMB::DBObject::Entity::Location;
-use LedgerSMB::DBObject::Entity::Contact;
-use LedgerSMB::DBObject::Entity::Company;
-use LedgerSMB::DBObject::Entity::Person;
-use LedgerSMB::DBObject::Entity::Bank;
-use LedgerSMB::DBObject::Report::Contact::Search;
+use LedgerSMB::Entity;
+use LedgerSMB::Entity::Credit_Account;
+use LedgerSMB::Entity::Location;
+use LedgerSMB::Entity::Contact;
+use LedgerSMB::Entity::Company;
+use LedgerSMB::Entity::Person;
+use LedgerSMB::Entity::Bank;
+use LedgerSMB::Report::Contact::Search;
 
 =head1 SYNOPSIS
 
@@ -51,7 +51,7 @@
           return $data;
        } else {
             my @results = ();
-            for $ref (LedgerSMB::DBObject::Entity->call_procedure(
+            for $ref (LedgerSMB::Entity->call_procedure(
                           procname => 'entity__list_classes'
                       )
             ){
@@ -66,7 +66,7 @@
     my ($request, $entity_class) = @_;
     my $args = $request->{args};
     $args->{entity_class} = $entity_class;
-    my $report = LedgerSMB::DBObject::Report::Contact::Search->new(%$args);
+    my $report = LedgerSMB::Report::Contact::Search->new(%$args);
     $report->run_report;
     my @results;
     for my $r (@{$report->rows}){
@@ -79,12 +79,12 @@
 
 sub _get_entity {
     my ($request, $id) = @_;
-    my $company = LedgerSMB::DBObject::Entity::Company->get($id);
+    my $company = LedgerSMB::Entity::Company->get($id);
     if ($company){
        $data= $company;
        $data->{entity_type} = 'Company';
     } else {
-       my $person = LedgerSMB::DBObject::Entity::Person->get($id);
+       my $person = LedgerSMB::Entity::Person->get($id);
        if ($person){
           $data= $person;
           $data->{entity_type} = 'Person';
@@ -93,13 +93,13 @@
        }
     }
     @{$data->{credit_accounts}} = 
-       LedgerSMB::DBObject::Entity::Credit_Account->list_for_entity($id);
+       LedgerSMB::Entity::Credit_Account->list_for_entity($id);
     @{$data->{locations}} = 
-      LedgerSMB::DBObject::Entity::Location->get_active({entity_id => $id});
+      LedgerSMB::Entity::Location->get_active({entity_id => $id});
     @{$data->{contact}} =
-      LedgerSMB::DBObject::Entity::Contact->list({{entity_id => $id}});
+      LedgerSMB::Entity::Contact->list({{entity_id => $id}});
     @{$data->{bank_accounts}} = 
-      LedgerSMB::DBObject::Entity::Bank-> list($id);
+      LedgerSMB::Entity::Bank-> list($id);
     return $data;
 }
 
@@ -113,7 +113,7 @@
     my ($request, $id) = @_;
     if ($id or $request->{payload}->{entity_id}){
         $request->{payload}->{entity_id} = $id if $id;
-        if (LedgerSMB::DBObject::Entity->get($id)){
+        if (LedgerSMB::Entity->get($id)){
             die '409 Conflict';
         }
     }
@@ -131,14 +131,14 @@
     my $payload = $request->{payload};
     $payload->{entity_id} = $id;
     if (lc($payload->{entity_type}) eq 'person') {
-        LedgerSMB::DBObject::Entity::Company->new(%$payload)->save();
+        LedgerSMB::Entity::Company->new(%$payload)->save();
     } elsif (lc($payload->{entity_type}) eq 'company'){
-        LedgerSMB::DBObject::Entity::Person->new(%$payload)->save();
+        LedgerSMB::Entity::Person->new(%$payload)->save();
     } else {
         die '400 Bad Request:  Must Specify entity_type';
     }
     for $act (@{$payload->{credit_accounts}}){
-        LedgerSMB::DBObject::Entity::Credit_Account->new(%$payload)->save();
+        LedgerSMB::Entity::Credit_Account->new(%$payload)->save();
     }
     if ($id){ 
         die "303 Contact/$id.$request->{format}";

Modified: trunk/LedgerSMB/Scripts/contact.pm
===================================================================
--- trunk/LedgerSMB/Scripts/contact.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/Scripts/contact.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -16,13 +16,13 @@
 
 package LedgerSMB::Scripts::contact;
 
-use LedgerSMB::DBObject::Entity::Company;
-use LedgerSMB::DBObject::Entity::Person;
-use LedgerSMB::DBObject::Entity::Credit_Account;
-use LedgerSMB::DBObject::Entity::Location;
-use LedgerSMB::DBObject::Entity::Contact;
-use LedgerSMB::DBObject::Entity::Bank;
-use LedgerSMB::DBObject::Entity::Note;
+use LedgerSMB::Entity::Company;
+use LedgerSMB::Entity::Person;
+use LedgerSMB::Entity::Credit_Account;
+use LedgerSMB::Entity::Location;
+use LedgerSMB::Entity::Contact;
+use LedgerSMB::Entity::Bank;
+use LedgerSMB::Entity::Note;
 use LedgerSMB::File;
 use LedgerSMB::App_State;
 use LedgerSMB::Template;
@@ -54,12 +54,12 @@
 sub get_by_cc {
     my ($request) = @_;
     my $entity = 
-           LedgerSMB::DBObject::Entity::Company->get_by_cc($request->{control_code});
-    $entity ||=  LedgerSMB::DBObject::Entity::Person->get_by_cc($request->{control_code});
+           LedgerSMB::Entity::Company->get_by_cc($request->{control_code});
+    $entity ||=  LedgerSMB::Entity::Person->get_by_cc($request->{control_code});
     my ($company, $person) = (undef, undef);
-    if (eval {$entity->isa('LedgerSMB::DBObject::Entity::Company')}){
+    if (eval {$entity->isa('LedgerSMB::Entity::Company')}){
        $company = $entity;
-    } elsif (eval {$entity->isa('LedgerSMB::DBObject::Entity::Person')}){
+    } elsif (eval {$entity->isa('LedgerSMB::Entity::Person')}){
        $person = $entity;
     }
     _main_screen($request, $company, $person);
@@ -78,12 +78,12 @@
 
 sub get {
     my ($request) = @_;
-    my $entity = LedgerSMB::DBObject::Entity::Company->get($request->{entity_id});
-    $entity ||= LedgerSMB::DBObject::Entity::Person->get($request->{entity_id});
+    my $entity = LedgerSMB::Entity::Company->get($request->{entity_id});
+    $entity ||= LedgerSMB::Entity::Person->get($request->{entity_id});
     my ($company, $person) = (undef, undef);
-    if ($entity->isa('LedgerSMB::DBObject::Entity::Company')){
+    if ($entity->isa('LedgerSMB::Entity::Company')){
        $company = $entity;
-    } elsif ($entity->isa('LedgerSMB::DBObject::Entity::Person')){
+    } elsif ($entity->isa('LedgerSMB::Entity::Person')){
        $person = $entity;
     }
     _main_screen($request, $company, $person);
@@ -131,7 +131,7 @@
     my $entity_id = $company->{entity_id};
     $entity_id ||= $person->{entity_id};
     my @credit_list = 
-       LedgerSMB::DBObject::Entity::Credit_Account->list_for_entity(
+       LedgerSMB::Entity::Credit_Account->list_for_entity(
                           $entity_id,
                           $request->{entity_class}
         );
@@ -152,22 +152,22 @@
     $entity_class ||= $company->{entity_class};
     $entity_class ||= $request->{entity_class};
     $entity_class ||= $request->{account_class};
-    my @locations = LedgerSMB::DBObject::Entity::Location->get_active(
+    my @locations = LedgerSMB::Entity::Location->get_active(
                        {entity_id => $entity_id,
                         credit_id => $credit_act->{id}}
           );
 
     my @contact_class_list =
-          LedgerSMB::DBObject::Entity::Contact->list_classes;
+          LedgerSMB::Entity::Contact->list_classes;
 
-    my @contacts = LedgerSMB::DBObject::Entity::Contact->list(
+    my @contacts = LedgerSMB::Entity::Contact->list(
               {entity_id => $entity_id,
                credit_id => $credit_act->{id}}
     );
     my @bank_account = 
-         LedgerSMB::DBObject::Entity::Bank->list($entity_id);
+         LedgerSMB::Entity::Bank->list($entity_id);
     my @notes =
-         LedgerSMB::DBObject::Entity::Note->list($entity_id,
+         LedgerSMB::Entity::Note->list($entity_id,
                                                  $credit_act->{id});
 
     # Globals for the template
@@ -444,7 +444,7 @@
 
 sub save_company {
     my ($request) = @_;
-    my $company = LedgerSMB::DBObject::Entity::Company->new(%$request);
+    my $company = LedgerSMB::Entity::Company->new(%$request);
     $request->{target_div} = 'credit_div';
     _main_screen($request, $company->save);
 }
@@ -457,7 +457,7 @@
 
 sub save_person {
     my ($request) = @_;
-    my $person = LedgerSMB::DBObject::Entity::Person->new(
+    my $person = LedgerSMB::Entity::Person->new(
               %$request
     );
     use Data::Dumper;
@@ -494,8 +494,7 @@
         }  
     }
     if ($request->close_form){
-        LedgerSMB::DBObject::Entity::Credit_Account->prepare_input($request);
-        my $credit = LedgerSMB::DBObject::Entity::Credit_Account->new(%$request);
+        my $credit = LedgerSMB::Entity::Credit_Account->new(%$request);
         $credit = $credit->save();
         $request->{meta_number} = $credit->{meta_number};
     }
@@ -524,7 +523,7 @@
 sub save_location {
     my ($request) = @_;
 
-    my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
+    my $location = LedgerSMB::Entity::Location->new(%$request);
     if ($request->{attach_to} eq '1'){
        $location->credit_id(undef);
     }
@@ -566,7 +565,7 @@
 
 sub delete_location {
     my ($request) = @_;
-    my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
+    my $location = LedgerSMB::Entity::Location->new(%$request);
     $location->id($request->{location_id});
     if (!$request->{is_for_credit}){
        $location->credit_id(undef);
@@ -584,7 +583,7 @@
 
 sub save_contact {
     my ($request) = @_;
-    my $contact = LedgerSMB::DBObject::Entity::Contact->new(%$request);
+    my $contact = LedgerSMB::Entity::Contact->new(%$request);
     if ($request->{attach_to} == 1){
        $contact->credit_id(undef);
     }
@@ -603,7 +602,7 @@
 
 sub delete_contact {
     my ($request) = @_;
-    my $contact = LedgerSMB::DBObject::Entity::Contact->new(%$request);
+    my $contact = LedgerSMB::Entity::Contact->new(%$request);
     $contact->credit_id($request->{for_credit});
     $contact->delete;
     $request->{target_div} = 'contact_info_div';
@@ -623,7 +622,7 @@
 
 sub delete_bank_account{
     my ($request) = @_;
-    my $account = LedgerSMB::DBObject::Entity::Bank->new(%$request);
+    my $account = LedgerSMB::Entity::Bank->new(%$request);
     $account->delete;
     $request->{target_div} = 'bank_act_div';
     get($request);
@@ -637,7 +636,7 @@
 
 sub save_bank_account {
     my ($request) = @_;
-    my $bank = LedgerSMB::DBObject::Entity::Bank->new(%$request);
+    my $bank = LedgerSMB::Entity::Bank->new(%$request);
     $bank->save;
     $request->{target_div} = 'bank_act_div';
     get($request);
@@ -652,7 +651,7 @@
 
 sub save_notes {
     my ($request) = @_;
-    my $note = LedgerSMB::DBObject::Entity::Note->new(%$request);
+    my $note = LedgerSMB::Entity::Note->new(%$request);
     if ($request->{note_class} == 1){
        $note->credit_id(undef);
     }
@@ -668,7 +667,7 @@
 
 sub get_pricelist {
     my ($request) = @_;
-    my $credit = LedgerSMB::DBObject::Entity::Credit_Account->get_by_id(
+    my $credit = LedgerSMB::Entity::Credit_Account->get_by_id(
        $request->{credit_id}
     );
     my $pricelist = $credit->get_pricematrix;

Modified: trunk/LedgerSMB/Scripts/employee.pm
===================================================================
--- trunk/LedgerSMB/Scripts/employee.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/Scripts/employee.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -16,14 +16,14 @@
 
 package LedgerSMB::Scripts::employee;
 
-use LedgerSMB::DBObject::Entity::Person::Employee;
-use LedgerSMB::DBObject::Entity::Payroll::Wage;
-use LedgerSMB::DBObject::Entity::Payroll::Deduction;
-use LedgerSMB::DBObject::Entity::Location;
-use LedgerSMB::DBObject::Entity::Contact;
-use LedgerSMB::DBObject::Entity::Bank;
-use LedgerSMB::DBObject::Entity::Note;
-use LedgerSMB::DBObject::Entity::User;
+use LedgerSMB::Entity::Person::Employee;
+use LedgerSMB::Entity::Payroll::Wage;
+use LedgerSMB::Entity::Payroll::Deduction;
+use LedgerSMB::Entity::Location;
+use LedgerSMB::Entity::Contact;
+use LedgerSMB::Entity::Bank;
+use LedgerSMB::Entity::Note;
+use LedgerSMB::Entity::User;
 use LedgerSMB::App_State;
 use LedgerSMB::Template;
 use LedgerSMB::File;
@@ -54,7 +54,7 @@
 
 sub get_by_cc {
     my ($request) = @_;
-    my $emp = LedgerSMB::DBObject::Entity::Person::Employee->get_by_cc(
+    my $emp = LedgerSMB::Entity::Person::Employee->get_by_cc(
                             $request->{control_code}
     );
     _main_screen($request, $emp);
@@ -71,7 +71,7 @@
 
 sub get {
     my ($request) = @_;
-    my $emp = LedgerSMB::DBObject::Entity::Person::Employee->get(
+    my $emp = LedgerSMB::Entity::Person::Employee->get(
                           $request->{entity_id}
     );
     _main_screen($request, $emp);
@@ -87,7 +87,7 @@
     my $user;
     my @entity_files;
     if ($employee->{entity_id}){
-        $user = LedgerSMB::DBObject::Entity::User->get($employee->{entity_id});
+        $user = LedgerSMB::Entity::User->get($employee->{entity_id});
         @entity_files = LedgerSMB::File->list(
                {ref_key => $employee->{entity_id}, file_class => '4'}
         );
@@ -128,22 +128,22 @@
 
     my $entity_class = 3;
 
-    my @locations = LedgerSMB::DBObject::Entity::Location->get_active(
+    my @locations = LedgerSMB::Entity::Location->get_active(
                        {entity_id => $entity_id,
                         credit_id => undef}
           );
 
     my @contact_class_list =
-          LedgerSMB::DBObject::Entity::Contact->list_classes;
+          LedgerSMB::Entity::Contact->list_classes;
 
-    my @contacts = LedgerSMB::DBObject::Entity::Contact->list(
+    my @contacts = LedgerSMB::Entity::Contact->list(
               {entity_id => $entity_id,
                credit_id => undef}
     );
     my @bank_account = 
-         LedgerSMB::DBObject::Entity::Bank->list($entity_id);
+         LedgerSMB::Entity::Bank->list($entity_id);
     my @notes =
-         LedgerSMB::DBObject::Entity::Note->list($entity_id,
+         LedgerSMB::Entity::Note->list($entity_id,
                                                  undef);
 
     # Globals for the template
@@ -203,22 +203,20 @@
     my @entity_classes = $request->call_procedure(
                       procname => 'entity__list_classes'
     );
-    my @roles = LedgerSMB::DBObject::Entity::User->list_roles;
+    my @roles = LedgerSMB::Entity::User->list_roles;
 
-    my @wage_types = LedgerSMB::DBObject::Entity::Payroll::Wage->types(
-                  $employee->country_id
+    my @wage_types = LedgerSMB::Entity::Payroll::Wage->types(
+                    $employee->country_id
           ) if $employee->can('country_id');
  
     my @deduction_types = 
-          LedgerSMB::DBObject::Entity::Payroll::Deduction->types(
-                 $employee->country_id
-          ) if $employee->can('country_id');
+          LedgerSMB::Entity::Payroll::Deduction->types($employee->country_id) 
+                if $employee->can('country_id');
 
-    my @wages = LedgerSMB::DBObject::Entity::Payroll::Wage->list(
-                 $employee->entity_id
-          ) if $employee->can('entity_id');  
+    my @wages = LedgerSMB::Entity::Payroll::Wage->list($employee->entity_id)
+                if $employee->can('entity_id');  
 
-    my @deductions = LedgerSMB::DBObject::Entity::Payroll::Deduction->list(
+    my @deductions = LedgerSMB::Entity::Payroll::Deduction->list(
                  $employee->entity_id
           ) if $employee->can('entity_id');  
 
@@ -295,7 +293,7 @@
          $request->{$key} = LedgerSMB::PGDate->from_input($request->{$key});
     }
     $request->{control_code} = $request->{employeenumber};
-    my $employee = LedgerSMB::DBObject::Entity::Person::Employee->new(%$request);
+    my $employee = LedgerSMB::Entity::Person::Employee->new(%$request);
     $request->{target_div} = 'credit_div';
     $employee->save;
     _main_screen($request, $employee);
@@ -310,7 +308,7 @@
 sub save_location {
     my ($request) = @_;
 
-    my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
+    my $location = LedgerSMB::Entity::Location->new(%$request);
     if ($request->{attach_to} eq '1'){
        $location->credit_id(undef);
     }
@@ -352,7 +350,7 @@
 
 sub delete_location {
     my ($request) = @_;
-    my $location = LedgerSMB::DBObject::Entity::Location->new(%$request);
+    my $location = LedgerSMB::Entity::Location->new(%$request);
     $location->id($request->{location_id});
     if (!$request->{is_for_credit}){
        $location->credit_id(undef);
@@ -370,7 +368,7 @@
 
 sub save_contact {
     my ($request) = @_;
-    my $contact = LedgerSMB::DBObject::Entity::Contact->new(%$request);
+    my $contact = LedgerSMB::Entity::Contact->new(%$request);
     if ($request->{attach_to} == 1){
        $contact->credit_id(undef);
     }
@@ -389,7 +387,7 @@
 
 sub delete_contact {
     my ($request) = @_;
-    my $contact = LedgerSMB::DBObject::Entity::Contact->new(%$request);
+    my $contact = LedgerSMB::Entity::Contact->new(%$request);
     $contact->credit_id($request->{for_credit});
     $contact->delete;
     $request->{target_div} = 'contact_info_div';
@@ -409,7 +407,7 @@
 
 sub delete_bank_account{
     my ($request) = @_;
-    my $account = LedgerSMB::DBObject::Entity::Bank->new(%$request);
+    my $account = LedgerSMB::Entity::Bank->new(%$request);
     $account->delete;
     $request->{target_div} = 'bank_act_div';
     get($request);
@@ -423,7 +421,7 @@
 
 sub save_bank_account {
     my ($request) = @_;
-    my $bank = LedgerSMB::DBObject::Entity::Bank->new(%$request);
+    my $bank = LedgerSMB::Entity::Bank->new(%$request);
     $bank->save;
     $request->{target_div} = 'bank_act_div';
     get($request);
@@ -438,7 +436,7 @@
 
 sub save_notes {
     my ($request) = @_;
-    my $note = LedgerSMB::DBObject::Entity::Note->new(%$request);
+    my $note = LedgerSMB::Entity::Note->new(%$request);
     if ($request->{note_class} == 1){
        $note->credit_id(undef);
     }
@@ -455,7 +453,7 @@
 sub create_user {
     my ($request) = @_;
     if ($request->close_form){
-       my $user = LedgerSMB::DBObject::Entity::User->new(%$request);
+       my $user = LedgerSMB::Entity::User->new(%$request);
        $user->create;
     }
     get($request);
@@ -470,7 +468,7 @@
 sub reset_password {
     my ($request) = @_;
     if ($request->close_form){
-       my $user = LedgerSMB::DBObject::Entity::User->new(%$request);
+       my $user = LedgerSMB::Entity::User->new(%$request);
        $user->reset_password($request->{password});
     }
     get($request);
@@ -485,7 +483,7 @@
 sub save_roles {
     my ($request) = @_;
     if ($request->close_form){
-       my $user = LedgerSMB::DBObject::Entity::User->get($request->{entity_id});
+       my $user = LedgerSMB::Entity::User->get($request->{entity_id});
        my $roles;
        for my $key(keys %$request){
            if ($key =~ $request->{_role_prefix} and $request->{key}){

Modified: trunk/LedgerSMB/Scripts/report_aging.pm
===================================================================
--- trunk/LedgerSMB/Scripts/report_aging.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/Scripts/report_aging.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -63,10 +63,10 @@
 
 sub generate_statement {
     my ($request) = @_;
-    use LedgerSMB::DBObject::Entity::Company;
-    use LedgerSMB::DBObject::Entity::Credit_Account;
-    use LedgerSMB::DBObject::Entity::Location;
-    use LedgerSMB::DBObject::Entity::Contact;
+    use LedgerSMB::Entity::Company;
+    use LedgerSMB::Entity::Credit_Account;
+    use LedgerSMB::Entity::Location;
+    use LedgerSMB::Entity::Contact;
 
     my $rtype = $request->{report_type}; # in case we need it later
     $request->{report_type} = 'detail'; # needed to generate statement
@@ -94,7 +94,7 @@
                        only_class => 1}
         );
         my $location = pop @loc;
-        my @contact_info = LedgerSMB::DBObject::Entity::Contact->list(
+        my @contact_info = LedgerSMB::Entity::Contact->list(
                  {entity_id => $entity_id, credit_id => $credit_act->{id} }
         );
         $request->{meta_number} = $meta_number;

Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm	2012-07-20 08:42:20 UTC (rev 5018)
+++ trunk/LedgerSMB/Scripts/setup.pm	2012-07-20 11:33:51 UTC (rev 5019)
@@ -692,8 +692,8 @@
 
 sub save_user {
     my ($request) = @_;
-    use LedgerSMB::DBObject::Entity::Person::Employee;
-    use LedgerSMB::DBObject::Entity::User;
+    use LedgerSMB::Entity::Person::Employee;
+    use LedgerSMB::Entity::User;
     use LedgerSMB::PGDate;
     my $creds = LedgerSMB::Auth::get_credentials('setup');
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",
@@ -704,10 +704,10 @@
     $LedgerSMB::App_State::DBH = $request->{dbh};
     $request->{control_code} = $request->{employeenumber};
     $request->{dob} = LedgerSMB::PGDate->from_input($request->{dob});
-    my $emp = LedgerSMB::DBObject::Entity::Person::Employee->new(%$request);
+    my $emp = LedgerSMB::Entity::Person::Employee->new(%$request);
     $emp->save;
     $request->{entity_id} = $emp->entity_id;
-    my $user = LedgerSMB::DBObject::Entity::User->new(%$request);
+    my $user = LedgerSMB::Entity::User->new(%$request);
     if (8 == $user->create){ # Told not to import but user exists in db
         $request->{notice} = $request->{_locale}->text(
                        'User already exists. Import?'

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