From 4c40bebe142e9070558d9cde7aaff5f31c99c056 Mon Sep 17 00:00:00 2001 From: Nikita Saiapin Date: Sat, 22 May 2021 21:48:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B5=20=D1=81=D1=8B=D1=80=D0=BE=D0=B3=D0=BE=20JSON=20=D1=87?= =?UTF-8?q?=D0=B5=D0=BA=D0=B0=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AtolOnline/Entities/CorrectionInfo.php | 6 +++--- src/AtolOnline/Entities/Document.php | 20 ++++++++++++++++++++ src/AtolOnline/Entities/Vat.php | 6 ++++-- 3 files changed, 27 insertions(+), 5 deletions(-) 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..aeb1f69 100644 --- a/src/AtolOnline/Entities/Vat.php +++ b/src/AtolOnline/Entities/Vat.php @@ -50,7 +50,9 @@ class Vat extends Entity } /** - * Устанавливает размер НДС от суммы в копейках + * Устанавливает: + * размер НДС от суммы в копейках, для НДС 10 или 20, 10/110, 20/120; + * сумму платежа, если НДС - 0 процентов или без НДС. * * @param string $type Тип ставки НДС * @param int $kopeks Копейки @@ -64,7 +66,7 @@ class Vat extends Entity switch ($type) { case VatTypes::NONE: case VatTypes::VAT0: - return 0; + return $kopeks; case VatTypes::VAT10: //return $kopeks * 10 / 100; case VatTypes::VAT110: From 5c1c4dba12e40668198d9284401c93c82ae7c8e0 Mon Sep 17 00:00:00 2001 From: Nikita Saiapin Date: Sun, 23 May 2021 22:35:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D1=80=D0=B0=20=D0=9D=D0=94=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AtolOnline/Entities/Vat.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/AtolOnline/Entities/Vat.php b/src/AtolOnline/Entities/Vat.php index aeb1f69..bd76ca1 100644 --- a/src/AtolOnline/Entities/Vat.php +++ b/src/AtolOnline/Entities/Vat.php @@ -51,8 +51,7 @@ class Vat extends Entity /** * Устанавливает: - * размер НДС от суммы в копейках, для НДС 10 или 20, 10/110, 20/120; - * сумму платежа, если НДС - 0 процентов или без НДС. + * размер НДС от суммы в копейках * * @param string $type Тип ставки НДС * @param int $kopeks Копейки @@ -66,7 +65,7 @@ class Vat extends Entity switch ($type) { case VatTypes::NONE: case VatTypes::VAT0: - return $kopeks; + return 0; case VatTypes::VAT10: //return $kopeks * 10 / 100; case VatTypes::VAT110: