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

SF.net SVN: ledger-smb:[5293] trunk/tools/prepare-company-database.pl



Revision: 5293
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5293&view=rev
Author:   einhverfr
Date:     2012-12-01 06:54:31 +0000 (Sat, 01 Dec 2012)
Log Message:
-----------
Moving prepare-company-database.pl to new employee/user object framework 

Modified Paths:
--------------
    trunk/tools/prepare-company-database.pl

Modified: trunk/tools/prepare-company-database.pl
===================================================================
--- trunk/tools/prepare-company-database.pl	2012-11-30 06:59:19 UTC (rev 5292)
+++ trunk/tools/prepare-company-database.pl	2012-12-01 06:54:31 UTC (rev 5293)
@@ -36,7 +36,8 @@
 # Needed for creating a user
 
 use LedgerSMB;
-use LedgerSMB::DBObject::Admin;
+use LedgerSMB::Entity::User;
+use LedgerSMB::Entity::Employee;
 use DBI;
 
 # always use strict!
@@ -178,21 +179,29 @@
 $sth->execute($cc);
 my ($country_id) = $sth->fetchrow_array;
 
-# In 1.3 it is not possible really to directly invoke a new object like a new
-# user.  This is changing for some things in 1.4 so keep in mind this may change
-# to be easier to use.    However for now, this is the way it will need to be 
-# done.
+# This section is still untested and may be for some time.  Unlike in 1.3, we 
+# don't have to do $lsmb->merge() and then create new copies of the LedgerSMB 
+# archetype.  This leads to more direct, readable code, but there may still be
+# some bugs to work out --CT
 
-$lsmb->merge({
-     username    => $ADMIN_USERNAME,
-     password    => $ADMIN_PASSWORD,
+my $employee = LedgerSMB::Entity::Employee->new(
      first_name  => $ADMIN_FIRSTNAME,
      last_name   => $ADMIN_LASTNAME,
      middle_name => $ADMIN_MIDDLENAME,
      country_id  => $country_id,
+);
+
+$employee->save;
+
+my $user = LedgerSMB::Entity::User->new(
+     username    => $ADMIN_USERNAME,
+     password    => $ADMIN_PASSWORD,
      import      => 't',
-});
+     entity_id   => $employee->entity_id,
+);
 
+$user->save;
+
 my $user = LedgerSMB::DBObject::Admin->new({base => $lsmb});
 
 $user->save_user;

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