Beispiel #1
0
 /**
  * Initilizate account from document. If no account - throw exception.
  * @param CmlSalesOrder $salesOrder
  * @param SimpleXMLElement $order
  * @return CmlSalesOrder
  */
 private function getDocumentAccount($salesOrder, $xmlOrder)
 {
     $xmlAccount = $xmlOrder;
     if ($this->isChildExists($xmlOrder, 'Контрагенты')) {
         $xmlAccount = $xmlOrder->Контрагенты;
     }
     $this->checkMandatoryChildElement($xmlAccount, 'Контрагент', 'Not account in order! Order number - ' . $salesOrder->getNumber());
     $account = $xmlAccount->Контрагент;
     $oneEsIdentifier = $this->getMandatoryChildContent($account, 'Ид', 'Not account id in order! Order number - ' . $salesOrder->getNumber());
     /* Phisical or legal face */
     $accountName = $this->getChildContent($account, 'ПолноеНаименование');
     if ($accountName == null) {
         $accountName = $this->getMandatoryChildContent($account, 'ОфициальноеНаименование', 'Not account name in order! Order number - ' . $salesOrder->getNumber());
     }
     $accountName = $this->filter($accountName);
     $inn = $this->getChildContent($account, 'ИНН');
     $kpp = $this->getChildContent($account, 'КПП');
     $cmlAccount = new CmlAccount($accountName, $oneEsIdentifier);
     $cmlAccount->initAccountTaxInfo($inn, $kpp);
     $this->parseAccountAddress($cmlAccount, $account);
     $salesOrder->addAccount($cmlAccount);
     return $salesOrder;
 }