/**
  *  Convert data array into entity
  *
  *  @return AccountGroup
  *  @param array $data
  *  @access public
  */
 public function build($data)
 {
     $group = new AccountGroup();
     $group->setGroupName($data['group_name']);
     $group->setGroupDescription($data['group_description']);
     $group->setDateAdded($data['group_date_added']);
     $group->setDateRemoved($data['group_date_removed']);
     $group->setGroupID($data['group_id']);
     # parent group is not included, but mapped via the marshaler
     return $group;
 }
Пример #2
0
 /**
  *  Return the parent account node tree
  *
  *  @access public
  *  @return  AccountGroupNode
  *
  */
 public function end()
 {
     $closed = new DateTime();
     $closed->setDate(3000, 1, 1);
     $closed->setTime(0, 0, 0);
     # create root AccountGroup
     $rootGroup = new AccountGroup();
     $rootGroup->setGroupName('Root Group');
     $rootGroup->setGroupDescription('Top level group');
     $rootGroup->setDateAdded($this->now);
     $rootGroup->setDateRemoved($closed);
     # add the group to the node
     $this->rootNode->setInternal($rootGroup);
     return $this->rootNode;
 }
 /**
  *  Return empty node
  *
  *  @access public
  *  @return void
  *
  */
 public function getNode()
 {
     if ($this->groupTreeNode === null) {
         $this->groupTreeNode = new AccountGroupNode(array('id' => uniqid()));
         $closed = new DateTime();
         $closed->setDate(3000, 1, 1);
         $closed->setTime(0, 0, 0);
         $rootGroup = new AccountGroup();
         $rootGroup->setGroupName('Debit');
         $rootGroup->setGroupDescription('Debit Group');
         $rootGroup->setDateAdded($this->now);
         $rootGroup->setDateRemoved($closed);
         $this->groupTreeNode->setInternal($rootGroup);
     }
     return $this->groupTreeNode;
 }
 public function testAccountGroupBuilderDemolish()
 {
     $name = 'an entity group';
     $description = 'A description of entity group';
     $dateRemoved = new DateTime();
     $dateRemoved->setDate(3000, 1, 1);
     $dateAdded = new DateTime();
     $groupID = 100;
     $parentGroup = 5;
     $builder = new AccountGroupBuilder();
     $entity = new AccountGroup();
     $entity->setName($name);
     $entity->setDescription($description);
     $entity->setDateAdded($dateAdded);
     $entity->setDateRemoved($dateRemoved);
     $entity->setGroupID($groupID);
     $entity->setParentGroupID($parentGroup);
     $columns = array('group_name' => $name, 'group_description' => $description, 'group_date_added' => $dateAdded, 'group_date_removed' => $dateRemoved, 'group_id' => $groupID, 'parent_group_id' => $parentGroup);
     $this->assertEquals($builder->demolish($entity), $columns);
 }
Пример #5
0
 /**
  * @expectedException IComeFromTheNet\Ledger\Exception\LedgerException
  * @expectedExceptionMessage Date the group added must be before the set removal date
  * 
  */
 public function testErrorAccountGroupDateAddedOccursAfterRemoval()
 {
     $account = new AccountGroup();
     $dateOpened = new DateTime();
     $dateClosed = clone $dateOpened;
     $account->setDateRemoved($dateClosed);
     $account->setDateAdded($dateOpened);
 }
 /**
  *  Return the parent NodeBuilder
  *
  *  @access public
  *  @return  NodeBuilderInterface
  *
  */
 public function end()
 {
     $group = new AccountGroup();
     $closed = new DateTime();
     $closed->setDate(3000, 1, 1);
     $closed->setTime(0, 0, 0);
     $group->setGroupName($this->groupName);
     $group->setGroupDescription($this->groupDescription);
     $group->setDateAdded($this->now);
     $group->setDateRemoved($closed);
     # attach the new accountGroup entity to the tree node
     $this->getNode()->setInternal($group);
     # add new tree node to the parent node
     $this->parentNode->getNode()->addChild($this->getNode());
     return $this->parentNode;
 }