]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Тестирование и исправление ошибок feature_fomichev_erp-470_add_analitycs_business_operations_to_shift_transfer_documents origin/feature_fomichev_erp-470_add_analitycs_business_operations_to_shift_transfer_documents
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 14 Oct 2025 14:22:12 +0000 (17:22 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 14 Oct 2025 14:22:12 +0000 (17:22 +0300)
erp24/api2/controllers/DataController.php
erp24/controllers/WriteOffsErpController.php
erp24/records/AnalystsBusinessOperations.php
erp24/records/WriteOffsErp.php

index 475c2e3d0a6834ce9dff912eba172ffedc4f6c2a..c1a50ebbbeea6e2480fd06121f0c7910b71b66be 100644 (file)
@@ -73,8 +73,8 @@ class DataController extends BaseController
 
     const OUT_DIR =
 //        __DIR__ . "/../json";
-            "/www/api2/json";
-        //"/var/www/erp24/api2/json";
+         //   "/www/api2/json";
+        "/var/www/erp24/api2/json";
 
 //          "/var/www/www-root/data/www/api.bazacvetov24.ru/data/json";
     private static function getPathJson()
@@ -434,6 +434,7 @@ class DataController extends BaseController
                     'number',
                     'date',
                     'write_offs_type',
+                    'type_guid',
                     'comment',
                     'quantity',
                     'summ'
@@ -478,16 +479,17 @@ class DataController extends BaseController
                     }
                 }
                 $analytics = AnalystsBusinessOperations::find()
-                    ->select(['guid'])
+                    ->select(['id', 'name'])
                     ->where(['type_id' => 2])
                     ->andWhere(['active' => 1])
                     ->andWhere(['show' => 1])
                     ->indexBy('name')
                     ->asArray()
                     ->all();
+
                 foreach ($writeOff as $row) {
                     $typeWithPrefix = $this->setPrefixToWriteOffsType($row['write_offs_type']);
-                    $analyticGuid = $analytics[$typeWithPrefix]['guid'] ?? '';
+                    $analyticGuid = $row['type_guid'] ?? ($analytics[$typeWithPrefix]['id'] ?? null);
                     $writeOffResult[] = [
                         'id' => $row['guid'],
                         'store_id' => $row['store_guid'],
index 7bc84482ec2cdee452ea6b04ace223f16f4f7499..59019f6078576e7eddba62a35ba79caabc642fbd 100644 (file)
@@ -427,6 +427,7 @@ class WriteOffsErpController extends Controller
                 $model->setStatusCreated();
                 $model->setCreatedDate();
                 $model->setStoreGuidCreated();
+                $model->setTypeGuidCreated();
                 $model->setCreatedAt();
                 $model->setCauseGroupId();
                 $model->setCreatedAdminId($adminId);
index a9409b67d175c048323169e11077f41603efc71f..856c64c887fc4540a903bdfb37991cd09df75272 100644 (file)
@@ -10,8 +10,8 @@ use Yii;
  * @property string $id GUID аналитики
  * @property string $name Название аналитики
  * @property int $type Вид использования хозяйственной операции
- * @property int|null $type_id Активность записи
- * @property int|null $active ID Вида
+ * @property int|null $type_id ID Вида
+ * @property int|null $active Активность записи
  * @property int $show Видимость типа бизнес операции
  * @property string $created_at
  */
index 8d97104bbf2fe0c11a31f9b090382fb38c698203..92341f3481d5cab3dd2fa3b779de2b29d569f674 100644 (file)
@@ -502,6 +502,24 @@ class WriteOffsErp extends \yii\db\ActiveRecord
         return $this;
     }
 
+    /**
+     * @return object
+     */
+    public function setTypeGuidCreated(): object
+    {
+        $analytics = \yii_app\records\AnalystsBusinessOperations::find()
+            ->where(['type_id' => 2])
+            ->andWhere(['active' => 1])
+            ->andWhere(['show' => 1])
+            ->one();
+
+        if ($analytics) {
+            $this->type_guid = $analytics->id;
+        }
+
+        return $this;
+    }
+
     public function get1cStoreGuid(int $store_id): ?string
     {
         $query = CityStore::find()->with('storeGuid')->andWhere(['id' => $store_id]);
@@ -832,6 +850,7 @@ class WriteOffsErp extends \yii\db\ActiveRecord
         $new->setStatusCreated();
         $new->setCreatedDate();
         $new->setStoreGuidCreated();
+        $new->setTypeGuidCreated();
         $new->setCreatedAt();
         $new->setCauseGroupId();
         $new->setCreatedAdminId($adminId);