Поддержка nomenclature_code у предмета расчёта + мелкофиксы
- теперь `getSum()` проверяет по `Constraints::MAX_COUNT_ITEM_SUM` вместо `MAX_COUNT_ITEM_PRICE` (как и должен был изначально) - подправил `TooLongException` - всякие phpdoc-и
This commit is contained in:
@@ -31,14 +31,13 @@ class TooLongException extends AtolException
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
* @param int $max
|
||||
* @param float $max
|
||||
*/
|
||||
public function __construct(string $value, string $message = '', int $max = 0)
|
||||
public function __construct(string $value, string $message = '', float $max = 0)
|
||||
{
|
||||
$message = ($message ?: $this->message) . ': '. $value;
|
||||
if ($max > 0 || $this->max > 0) {
|
||||
$message .= ' (макс. = ' . ($max ?? $this->max) . ', фактически = ' . mb_strlen($value) . ')';
|
||||
}
|
||||
parent::__construct($message);
|
||||
parent::__construct(
|
||||
($message ?: $this->message) . ': ' . $value . (((float)$max > 0 || (float)$this->max > 0) ?
|
||||
' (макс = ' . ($max ?: $this->max) . ', фактически = ' . mb_strlen($value) . ')' : '')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
35
src/Exceptions/TooLongItemCodeException.php
Normal file
35
src/Exceptions/TooLongItemCodeException.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
||||
*
|
||||
* This code is licensed under MIT.
|
||||
* Этот код распространяется по лицензии MIT.
|
||||
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace AtolOnline\Exceptions;
|
||||
|
||||
use AtolOnline\Constants\Constraints;
|
||||
use AtolOnline\Constants\Ffd105Tags;
|
||||
|
||||
/**
|
||||
* Исключение, возникающее при попытке указать слишком длинный код товара
|
||||
*/
|
||||
class TooLongItemCodeException extends TooLongException
|
||||
{
|
||||
protected float $max = Constraints::MAX_LENGTH_ITEM_CODE;
|
||||
protected array $ffd_tags = [Ffd105Tags::ITEM_NOMENCLATURE_CODE];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $code
|
||||
*/
|
||||
public function __construct(string $name, string $code)
|
||||
{
|
||||
parent::__construct($code, "Слишком длинный код товара '$name'");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user