Merge pull request #3 from komantnick/develop

Исправление багов при отправке сырого JSON для чека коррекции с исправлениями
This commit is contained in:
Anthony Axenov 2021-05-24 10:55:09 +08:00 committed by GitHub
commit 929bf84c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 4 deletions

View File

@ -68,7 +68,7 @@ class CorrectionInfo extends Entity
*/ */
public function getNumber(): ?string public function getNumber(): ?string
{ {
return $this->base_name; return $this->base_number;
} }
/** /**
@ -165,7 +165,7 @@ class CorrectionInfo extends Entity
'type' => $this->getType() ?? '', // обязателен 'type' => $this->getType() ?? '', // обязателен
'base_date' => $this->getDate() ?? '', // обязателен 'base_date' => $this->getDate() ?? '', // обязателен
'base_number' => $this->getNumber() ?? '', // обязателен 'base_number' => $this->getNumber() ?? '', // обязателен
'base_name' => $this->getName() ?? '' // обязателен 'base_name' => $this->getName() ?? '' // не обязателен
]; ];
} }
} }

View File

@ -362,6 +362,14 @@ class Document extends Entity
$array['client']['inn'] ?? null $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'])) { if (isset($array['items'])) {
foreach ($array['items'] as $ar_item) { foreach ($array['items'] as $ar_item) {
$item = new Item( $item = new Item(
@ -391,6 +399,18 @@ class Document extends Entity
$doc->payments->add($payment); $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()) { if (isset($array['total']) && $array['total'] != $doc->calcTotal()) {
throw new AtolException('Real total sum not equals to provided in JSON one'); throw new AtolException('Real total sum not equals to provided in JSON one');
} }

View File

@ -50,7 +50,8 @@ class Vat extends Entity
} }
/** /**
* Устанавливает размер НДС от суммы в копейках * Устанавливает:
* размер НДС от суммы в копейках
* *
* @param string $type Тип ставки НДС * @param string $type Тип ставки НДС
* @param int $kopeks Копейки * @param int $kopeks Копейки