setPrice($sourceArray['amount']); } } /** * Возвращает наименование товара. * * @return string|null Наименование товара */ public function getDescription(): ?string { return $this->_description; } /** * Устанавливает наименование товара. * * @param string|null $description Наименование товара * * @return self */ public function setDescription(?string $description): self { $this->_description = $this->validatePropertyValue('_description', $description); return $this; } /** * Возвращает количество товара. * * @return float Количество купленного товара */ public function getQuantity(): float { return $this->_quantity; } /** * Устанавливает количество покупаемого товара. * * @param float|null $quantity Количество * * @return self */ public function setQuantity(?float $quantity): self { $this->_quantity = $this->validatePropertyValue('_quantity', $quantity); return $this; } /** * Возвращает общую стоимость покупаемого товара в копейках/центах. * * @return int|null Сумма стоимости покупаемого товара */ public function getAmount(): ?int { return (int) round($this->_amount?->getIntegerValue() * $this->_quantity); } /** * Возвращает цену товара. * * @return AmountInterface|null Цена товара */ public function getPrice(): ?AmountInterface { return $this->_amount; } /** * Устанавливает цену товара. * * @param AmountInterface|array|null $value Цена товара */ public function setPrice(mixed $value): void { if (is_array($value)) { $value = $this->factoryAmount($value); } $this->_amount = $value; } /** * Возвращает ставку НДС * * @return null|int Ставка НДС, число 1-12, или null, если ставка не задана */ public function getVatCode(): ?int { return $this->_vat_code; } /** * Устанавливает ставку НДС * * @param int|null $vat_code Ставка НДС, число 1-12 * * @return self */ public function setVatCode(?int $vat_code = null): self { $this->_vat_code = $this->validatePropertyValue('_vat_code', $vat_code); return $this; } /** * Возвращает признак предмета расчета. * * @return null|string Признак предмета расчета */ public function getPaymentSubject(): ?string { return $this->_payment_subject; } /** * Устанавливает признак предмета расчета. * * @param null|string $payment_subject Признак предмета расчета * * @return self * */ public function setPaymentSubject(?string $payment_subject = null): self { $this->_payment_subject = $this->validatePropertyValue('_payment_subject', $payment_subject); return $this; } /** * Возвращает признак способа расчета. * * @return null|string Признак способа расчета */ public function getPaymentMode(): ?string { return $this->_payment_mode; } /** * Устанавливает признак способа расчета. * * @param string|null $payment_mode Признак способа расчета * * @return self */ public function setPaymentMode(?string $payment_mode = null): self { $this->_payment_mode = $this->validatePropertyValue('_payment_mode', $payment_mode); return $this; } /** * Возвращает код страны происхождения товара по общероссийскому классификатору стран мира. * * @return null|string Код страны происхождения товара */ public function getCountryOfOriginCode(): ?string { return $this->_country_of_origin_code; } /** * Устанавливает код страны происхождения товара по общероссийскому классификатору стран мира. * * @param string|null $country_of_origin_code Код страны происхождения товара * * @return self */ public function setCountryOfOriginCode(?string $country_of_origin_code = null): self { $this->_country_of_origin_code = $this->validatePropertyValue( '_country_of_origin_code', $country_of_origin_code ); return $this; } /** * Возвращает номер таможенной декларации. * * @return null|string Номер таможенной декларации (от 1 до 32 символов) */ public function getCustomsDeclarationNumber(): ?string { return $this->_customs_declaration_number; } /** * Устанавливает номер таможенной декларации (от 1 до 32 символов). * * @param string|null $customs_declaration_number Номер таможенной декларации * * @return self * */ public function setCustomsDeclarationNumber(?string $customs_declaration_number = null): self { $this->_customs_declaration_number = $this->validatePropertyValue( '_customs_declaration_number', $customs_declaration_number ); return $this; } /** * Возвращает сумму акциза товара с учетом копеек. * * @return null|float Сумма акциза товара с учетом копеек */ public function getExcise(): ?float { return $this->_excise; } /** * Устанавливает сумму акциза товара с учетом копеек. * * @param float|null $excise Сумма акциза товара с учетом копеек * * @return self * */ public function setExcise(?float $excise = null): self { $this->_excise = $this->validatePropertyValue('_excise', $excise); return $this; } /** * Возвращает код товара — уникальный номер, который присваивается экземпляру товара при маркировке. * * @return null|string Код товара */ public function getProductCode(): ?string { return $this->_product_code; } /** * Устанавливает код товара — уникальный номер, который присваивается экземпляру товара при маркировке. * * @param ProductCode|string $product_code Код товара * * @return self */ public function setProductCode(mixed $product_code): self { if ($product_code instanceof ProductCode) { $product_code = (string) $product_code; } $this->_product_code = $this->validatePropertyValue('_product_code', $product_code); return $this; } /** * Возвращает планируемый статус товара. * * @return int|null Планируемый статус товара */ public function getPlannedStatus(): ?int { return $this->_planned_status; } /** * Устанавливает планируемый статус товара. * * @param int|null $planned_status Планируемый статус товара * * @return self */ public function setPlannedStatus(?int $planned_status = null): self { $this->_planned_status = $this->validatePropertyValue('_planned_status', $planned_status); return $this; } /** * Возвращает код товара. * * @return MarkCodeInfo|null Код товара */ public function getMarkCodeInfo(): ?MarkCodeInfo { return $this->_mark_code_info; } /** * Устанавливает код товара. * * @param array|MarkCodeInfo|null $mark_code_info Код товара * * @return self */ public function setMarkCodeInfo(mixed $mark_code_info = null): self { $this->_mark_code_info = $this->validatePropertyValue('_mark_code_info', $mark_code_info); return $this; } /** * Возвращает меру количества предмета расчета. * * @return string|null Мера количества предмета расчета */ public function getMeasure(): ?string { return $this->_measure; } /** * Устанавливает меру количества предмета расчета. * * @param string|null $measure Мера количества предмета расчета * * @return self */ public function setMeasure(?string $measure): self { $this->_measure = $this->validatePropertyValue('_measure', $measure); return $this; } /** * Возвращает режим обработки кода маркировки. * * @return string|null Режим обработки кода маркировки */ public function getMarkMode(): ?string { return $this->_mark_mode; } /** * Устанавливает режим обработки кода маркировки. * * @param string|null $mark_mode Режим обработки кода маркировки * * @return self */ public function setMarkMode(?string $mark_mode = null): self { $this->_mark_mode = $this->validatePropertyValue('_mark_mode', $mark_mode); return $this; } /** * Возвращает дробное количество маркированного товара. * * @return MarkQuantity|null Дробное количество маркированного товара */ public function getMarkQuantity(): ?MarkQuantity { return $this->_mark_quantity; } /** * Устанавливает дробное количество маркированного товара. * * @param array|MarkQuantity|null $mark_quantity Дробное количество маркированного товара */ public function setMarkQuantity(mixed $mark_quantity = null): self { $this->_mark_quantity = $this->validatePropertyValue('_mark_quantity', $mark_quantity); return $this; } /** * Возвращает отраслевой реквизит чека. * * @return IndustryDetails[]|ListObjectInterface Отраслевой реквизит чека */ public function getPaymentSubjectIndustryDetails(): ListObjectInterface { if ($this->_payment_subject_industry_details === null) { $this->_payment_subject_industry_details = new ListObject(IndustryDetails::class); } return $this->_payment_subject_industry_details; } /** * Устанавливает отраслевой реквизит чека. * * @param array|IndustryDetails[]|null $payment_subject_industry_details Отраслевой реквизит чека * * @return self */ public function setPaymentSubjectIndustryDetails(mixed $payment_subject_industry_details = null): self { $this->_payment_subject_industry_details = $this->validatePropertyValue('_payment_subject_industry_details', $payment_subject_industry_details); return $this; } /** * Возвращает информацию о поставщике товара или услуги * @return SupplierInterface|null */ public function getSupplier(): ?SupplierInterface { return $this->_supplier; } /** * Устанавливает информацию о поставщике товара или услуги. * * @param array|SupplierInterface|null $supplier Информация о поставщике товара или услуги * * @return self */ public function setSupplier(mixed $supplier = null): self { $this->_supplier = $this->validatePropertyValue('_supplier', $supplier); return $this; } /** * Возвращает тип посредника, реализующего товар или услугу. * * @return string|null Тип посредника */ public function getAgentType(): ?string { return $this->_agent_type; } /** * Устанавливает тип посредника, реализующего товар или услугу. * * @param string|null $agent_type Тип посредника * * @return self */ public function setAgentType(?string $agent_type = null): self { $this->_agent_type = $this->validatePropertyValue('_agent_type', $agent_type); return $this; } /** * {@inheritdoc} */ public function jsonSerialize(): array { $result = parent::jsonSerialize(); $result['amount'] = $result['price']; unset($result['price']); return $result; } /** * Фабричный метод создания суммы. * * @param array $options Сумма в виде ассоциативного массива * * @return AmountInterface Созданный инстанс суммы */ private function factoryAmount(array $options): AmountInterface { $amount = new MonetaryAmount(null, $options['currency']); if ($options['value'] > 0) { $amount->setValue($options['value']); } return $amount; } }