_description; } /** * Устанавливает наименование товара. * * @param string|null $description Наименование товара * * @return self */ public function setDescription(?string $description = null): self { $this->_description = $this->validatePropertyValue('_description', $description); return $this; } /** * Возвращает количество товара. * * @return float|null Количество купленного товара */ 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 Сумма стоимости покупаемого товара */ public function getAmount(): int { return (int) round($this->_amount?->getIntegerValue() * $this->_quantity); } /** * Возвращает цену товара. * * @return AmountInterface Цена товара */ public function getPrice(): AmountInterface { return $this->_amount; } /** * Устанавливает цену товара. * * @param AmountInterface|array $amount Цена товара * * @return self */ public function setPrice(mixed $amount): self { $this->_amount = $this->validatePropertyValue('_amount', $amount); return $this; } /** * Возвращает ставку НДС * * @return null|int Ставка НДС, число 1-12, или null, если ставка не задана */ public function getVatCode(): ?int { return $this->_vat_code; } /** * Устанавливает ставку НДС * * @param null|int $value Ставка НДС, число 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 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|ListObjectInterface|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 string|null Дополнительный реквизит предмета расчета */ public function getAdditionalPaymentSubjectProps(): ?string { return $this->_additional_payment_subject_props; } /** * Устанавливает дополнительный реквизит предмета расчета. * * @param string|null $additional_payment_subject_props Дополнительный реквизит предмета расчета */ public function setAdditionalPaymentSubjectProps(?string $additional_payment_subject_props): void { $this->_additional_payment_subject_props = $this->validatePropertyValue( '_additional_payment_subject_props', $additional_payment_subject_props ); } /** * Возвращает код страны происхождения товара по общероссийскому классификатору стран мира. * * @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; } /** * Устанавливает флаг доставки для текущего объекта айтема в чеке. * * @param bool $value True если айтем является доставкой, false если нет * * @return self * */ public function setIsShipping(bool $value): self { $this->_shipping = $value; return $this; } /** * Возвращает информацию о поставщике товара или услуги. * * @return Supplier|null */ public function getSupplier(): ?Supplier { 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; } /** * Устанавливает тип посредника, реализующего товар или услугу. * * @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; } /** * Возвращает тип посредника, реализующего товар или услугу. * * @return string|null Тип посредника */ public function getAgentType(): ?string { return $this->_agent_type; } /** * Проверяет, является ли текущий элемент чека доставкой. * * @return bool True если доставка, false если обычный товар */ public function isShipping(): bool { return $this->_shipping; } /** * Применяет для товара скидку. * * @param float|null $coefficient Множитель скидки */ public function applyDiscountCoefficient(?float $coefficient): void { $this->_amount->multiply($coefficient); } /** * Увеличивает цену товара на указанную величину. * * @param float|null $value Сумма на которую цену товара увеличиваем */ public function increasePrice(?float $value): void { $this->_amount->increase($value); } /** * Уменьшает количество покупаемого товара на указанное, возвращает объект позиции в чеке с уменьшаемым количеством * * @param float|null $count Количество на которое уменьшаем позицию в чеке * * @throws EmptyPropertyValueException Выбрасывается если было передано пустое значение * @throws InvalidPropertyValueException Выбрасывается если в качестве аргумента был передан ноль * или отрицательное число, или число больше текущего количества покупаемого товара * @throws InvalidPropertyValueTypeException Выбрасывается если в качестве аргумента было передано не число */ public function fetchItem(?float $count): ReceiptItem { if (null === $count) { throw new EmptyPropertyValueException( 'Empty quantity value in ReceiptItem in fetchItem method', 0, 'ReceiptItem.quantity' ); } if (!is_numeric($count)) { throw new InvalidPropertyValueTypeException( 'Invalid quantity value type in ReceiptItem in fetchItem method', 0, 'ReceiptItem.quantity', $count ); } if ($count <= 0.0 || $count >= $this->_quantity) { throw new InvalidPropertyValueException( 'Invalid quantity value in ReceiptItem in fetchItem method', 0, 'ReceiptItem.quantity', $count ); } $result = clone $this; $result->setPrice(clone $this->getPrice()); $result->setQuantity($count); $this->_quantity -= $count; return $result; } /** * Устанавливает значения свойств текущего объекта из массива. * * @param array|Traversable $sourceArray Ассоциативный массив с настройками */ public function fromArray(iterable $sourceArray): void { if (isset($sourceArray['amount'])) { if (is_array($sourceArray['amount'])) { $sourceArray['price'] = new ReceiptItemAmount($sourceArray['amount']); } elseif ($sourceArray['amount'] instanceof AmountInterface) { $sourceArray['price'] = $sourceArray['amount']; } unset($sourceArray['amount']); } parent::fromArray($sourceArray); } /** * {@inheritdoc} */ public function jsonSerialize(): array { $result = parent::jsonSerialize(); $result['amount'] = $result['price']; unset($result['price'], $result['title']); return $result; } }