From e7ca4afb3aa1f87b36b89d38678ddf5810718038 Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 17 Apr 2026 16:31:16 +0300 Subject: [PATCH] =?utf8?q?feat(ERP-292):=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB?= =?utf8?q?=D1=8C=20Products1cAutomarkPrediction=20=D0=B8=20DTO=20ParseResu?= =?utf8?q?lt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../records/Products1cAutomarkPrediction.php | 70 +++++++++++++++++++ erp24/services/automark/ParseResult.php | 40 +++++++++++ .../Products1cAutomarkPredictionTest.php | 46 ++++++++++++ 3 files changed, 156 insertions(+) create mode 100644 erp24/records/Products1cAutomarkPrediction.php create mode 100644 erp24/services/automark/ParseResult.php create mode 100644 erp24/tests/unit/records/Products1cAutomarkPredictionTest.php diff --git a/erp24/records/Products1cAutomarkPrediction.php b/erp24/records/Products1cAutomarkPrediction.php new file mode 100644 index 00000000..201c3ac2 --- /dev/null +++ b/erp24/records/Products1cAutomarkPrediction.php @@ -0,0 +1,70 @@ + 255], + [['size', 'status', 'approved_by'], 'integer'], + [['confidence'], 'number', 'min' => 0, 'max' => 1], + [['method'], 'in', 'range' => [self::METHOD_RULE, self::METHOD_SIMILARITY]], + [['status'], 'in', 'range' => [self::STATUS_PENDING, self::STATUS_APPROVED, self::STATUS_REJECTED]], + [['created_at', 'updated_at'], 'safe'], + [['category', 'subcategory', 'species', 'sort', 'type', 'color', 'approved_by', 'updated_at', 'size'], 'default', 'value' => null], + ]; + } + + public function isPending(): bool + { + return $this->status === self::STATUS_PENDING; + } + + public function isApproved(): bool + { + return $this->status === self::STATUS_APPROVED; + } + + public function getProduct(): ActiveQuery + { + return $this->hasOne(Products1c::class, ['id' => 'product_id']); + } +} diff --git a/erp24/services/automark/ParseResult.php b/erp24/services/automark/ParseResult.php new file mode 100644 index 00000000..a7ea9c96 --- /dev/null +++ b/erp24/services/automark/ParseResult.php @@ -0,0 +1,40 @@ +confidence >= $threshold; + } + + public function toArray(): array + { + return [ + 'category' => $this->category, + 'subcategory' => $this->subcategory, + 'species' => $this->species, + 'sort' => $this->sort, + 'type' => $this->type, + 'size' => $this->size, + 'color' => $this->color, + 'confidence' => $this->confidence, + 'method' => $this->method, + ]; + } +} diff --git a/erp24/tests/unit/records/Products1cAutomarkPredictionTest.php b/erp24/tests/unit/records/Products1cAutomarkPredictionTest.php new file mode 100644 index 00000000..ef6e43a0 --- /dev/null +++ b/erp24/tests/unit/records/Products1cAutomarkPredictionTest.php @@ -0,0 +1,46 @@ +assertSame('products_1c_automark_predictions', Products1cAutomarkPrediction::tableName()); + } + + public function testStatusConstants(): void + { + $this->assertSame(0, Products1cAutomarkPrediction::STATUS_PENDING); + $this->assertSame(1, Products1cAutomarkPrediction::STATUS_APPROVED); + $this->assertSame(2, Products1cAutomarkPrediction::STATUS_REJECTED); + } + + public function testMethodConstants(): void + { + $this->assertSame('rule', Products1cAutomarkPrediction::METHOD_RULE); + $this->assertSame('similarity', Products1cAutomarkPrediction::METHOD_SIMILARITY); + } + + public function testIsPendingMethod(): void + { + $model = new Products1cAutomarkPrediction(); + $model->status = Products1cAutomarkPrediction::STATUS_PENDING; + $this->assertTrue($model->isPending()); + } + + public function testIsApprovedMethod(): void + { + $model = new Products1cAutomarkPrediction(); + $model->status = Products1cAutomarkPrediction::STATUS_APPROVED; + $this->assertTrue($model->isApproved()); + } +} -- 2.39.5