diff --git a/src/AtolOnline/Entities/CorrectionInfo.php b/src/AtolOnline/Entities/CorrectionInfo.php index 185c3e5..2cbde55 100644 --- a/src/AtolOnline/Entities/CorrectionInfo.php +++ b/src/AtolOnline/Entities/CorrectionInfo.php @@ -68,7 +68,7 @@ class CorrectionInfo extends Entity */ public function getNumber(): ?string { - return $this->base_name; + return $this->base_number; } /** @@ -165,7 +165,7 @@ class CorrectionInfo extends Entity 'type' => $this->getType() ?? '', // обязателен 'base_date' => $this->getDate() ?? '', // обязателен 'base_number' => $this->getNumber() ?? '', // обязателен - 'base_name' => $this->getName() ?? '' // обязателен + 'base_name' => $this->getName() ?? '' // не обязателен ]; } -} +} \ No newline at end of file diff --git a/src/AtolOnline/Entities/Document.php b/src/AtolOnline/Entities/Document.php index 4134d51..66716fd 100644 --- a/src/AtolOnline/Entities/Document.php +++ b/src/AtolOnline/Entities/Document.php @@ -362,6 +362,14 @@ class Document extends Entity $array['client']['inn'] ?? null )); } + if (isset($array['correction_info'])) { + $doc->setCorrectionInfo(new CorrectionInfo( + $array['correction_info']['type'] ?? null, + $array['correction_info']['base_date'] ?? null, + $array['correction_info']['base_number'] ?? null, + $array['correction_info']['base_name'] ?? null, + )); + } if (isset($array['items'])) { foreach ($array['items'] as $ar_item) { $item = new Item( @@ -391,6 +399,18 @@ class Document extends Entity $doc->payments->add($payment); } } + if (isset($array['vats'])) { + foreach ($array['vats'] as $vat_payment) { + $vat = new Vat(); + if (isset($vat_payment['type'])) { + $vat->setType($vat_payment['type']); + } + if (isset($vat_payment['sum'])) { + $vat->setSum($vat_payment['sum']); + } + $doc->vats->add($vat); + } + } if (isset($array['total']) && $array['total'] != $doc->calcTotal()) { throw new AtolException('Real total sum not equals to provided in JSON one'); } diff --git a/src/AtolOnline/Entities/Vat.php b/src/AtolOnline/Entities/Vat.php index 29d81c6..bd76ca1 100644 --- a/src/AtolOnline/Entities/Vat.php +++ b/src/AtolOnline/Entities/Vat.php @@ -50,7 +50,8 @@ class Vat extends Entity } /** - * Устанавливает размер НДС от суммы в копейках + * Устанавливает: + * размер НДС от суммы в копейках * * @param string $type Тип ставки НДС * @param int $kopeks Копейки