Исправление багов при отправке сырого JSON чека коррекции

pull/2/head
Nikita Saiapin 2021-05-22 21:48:12 +08:00
parent d321205ac9
commit 4c40bebe14
3 changed files with 27 additions and 5 deletions

View File

@ -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() ?? '' // не обязателен
];
}
}
}

View File

@ -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');
}

View File

@ -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: