public function create($data)
 {
     $result = parent::create($data);
     if ($result) {
         /* update balalnces for accounts */
         if (is_array($data)) {
             $data = new Entity($data);
         }
         $value = $data->getValue();
         $creditAccid = $data->getCreditAccId();
         $debitAccId = $data->getDebitAccId();
         $this->_repoAccount->updateBalance($creditAccid, 0 + $value);
         $this->_repoAccount->updateBalance($debitAccId, 0 - $value);
     }
     return $result;
 }
 /**
  * Add operation's transaction and bind transactions ids to references (orders or customers ids).
  *
  * @param $operId
  * @param $trans
  * @param $datePerformed
  * @param $asRef
  *
  * @return array
  * @throws \Exception
  */
 public function transactions($operId, $trans, $datePerformed, $asRef = null)
 {
     $result = [];
     foreach ($trans as $one) {
         if (!$one instanceof Transaction) {
             $one = new Transaction($one);
         }
         $dateApplied = $one->getDateApplied();
         $dateApplied = $dateApplied ? $dateApplied : $datePerformed;
         $req = new AddTransactionRequest();
         $req->setOperationId($operId);
         $req->setDebitAccId($one->getDebitAccId());
         $req->setCreditAccId($one->getCreditAccId());
         $req->setValue($one->getValue());
         $req->setNote($one->getNote());
         $req->setDateApplied($dateApplied);
         /** @var  $resp AddTransactionResponse */
         $resp = $this->_callTransaction->add($req);
         if (!$resp->isSucceed()) {
             throw new \Exception("Transaction (debit acc. #{$req->getDebitAccId()}, credit acc. " . "#{$req->getCreditAccId()}) cannot be inserted . ");
         }
         $tranId = $resp->getTransactionId();
         $ref = $one->getData($asRef);
         if (!is_null($asRef) && isset($ref)) {
             /* bind new transaction ID to the reference from request */
             $result[$tranId] = $ref;
         } else {
             /* new transaction ID is bound by 'add transaction' requests order */
             $result[] = $resp->getTransactionId();
         }
     }
     return $result;
 }
 public function test_pk()
 {
     /** === Call and asserts  === */
     $pk = $this->obj->getPrimaryKeyAttrs();
     $this->assertEquals([DataEntity::ATTR_ID], $pk);
 }