From 6fdb983ac2ee32a45a446025341ba1e11e066881 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Tue, 14 Oct 2025 17:22:12 +0300 Subject: [PATCH] =?utf8?q?=D0=A2=D0=B5=D1=81=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?utf8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B8=20=D0=B8=D1=81=D0=BF=D1=80?= =?utf8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8?= =?utf8?q?=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataController.php | 10 ++++++---- erp24/controllers/WriteOffsErpController.php | 1 + erp24/records/AnalystsBusinessOperations.php | 4 ++-- erp24/records/WriteOffsErp.php | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 475c2e3d..c1a50ebb 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -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'], diff --git a/erp24/controllers/WriteOffsErpController.php b/erp24/controllers/WriteOffsErpController.php index 7bc84482..59019f60 100644 --- a/erp24/controllers/WriteOffsErpController.php +++ b/erp24/controllers/WriteOffsErpController.php @@ -427,6 +427,7 @@ class WriteOffsErpController extends Controller $model->setStatusCreated(); $model->setCreatedDate(); $model->setStoreGuidCreated(); + $model->setTypeGuidCreated(); $model->setCreatedAt(); $model->setCauseGroupId(); $model->setCreatedAdminId($adminId); diff --git a/erp24/records/AnalystsBusinessOperations.php b/erp24/records/AnalystsBusinessOperations.php index a9409b67..856c64c8 100644 --- a/erp24/records/AnalystsBusinessOperations.php +++ b/erp24/records/AnalystsBusinessOperations.php @@ -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 */ diff --git a/erp24/records/WriteOffsErp.php b/erp24/records/WriteOffsErp.php index 8d97104b..92341f34 100644 --- a/erp24/records/WriteOffsErp.php +++ b/erp24/records/WriteOffsErp.php @@ -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); -- 2.39.5