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()
'number',
'date',
'write_offs_type',
+ 'type_guid',
'comment',
'quantity',
'summ'
}
}
$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'],
$model->setStatusCreated();
$model->setCreatedDate();
$model->setStoreGuidCreated();
+ $model->setTypeGuidCreated();
$model->setCreatedAt();
$model->setCauseGroupId();
$model->setCreatedAdminId($adminId);
* @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
*/
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]);
$new->setStatusCreated();
$new->setCreatedDate();
$new->setStoreGuidCreated();
+ $new->setTypeGuidCreated();
$new->setCreatedAt();
$new->setCauseGroupId();
$new->setCreatedAdminId($adminId);