private function insertaccount($accounts, $companyId, $parentId = null)
 {
     if (!$accounts || !count($accounts)) {
         return null;
     }
     $accountMapper = $this->getServiceLocator()->get('\\Accounting\\Model\\AccountMapper');
     foreach ($accounts as $accountArray) {
         $account = new \Accounting\Model\Account();
         $account->setCode($accountArray['code']);
         $account->setName($accountArray['name']);
         $account->setParentId($parentId);
         $account->setCompanyId($companyId);
         if (!$accountMapper->isExisted($account)) {
             $account->setStatus(\Accounting\Model\Account::STATUS_ACTIVE);
             $account->setCreatedById($this->user()->getIdentity());
             $account->setCreatedDateTime(DateBase::getCurrentDateTime());
             $accountMapper->save($account);
         }
         if (isset($accountArray['childs']) && count($accountArray['childs'])) {
             $this->insertaccount($accountArray['childs'], $companyId, $account->getId());
         }
     }
 }