From: Alexander Smirnov Date: Tue, 1 Apr 2025 07:25:34 +0000 (+0300) Subject: [ERP-381] created_by from required to behavior take place X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f558b8e4a60b9ab3e7922ad5cf9f47aae518bb41;p=erp24_rep%2Fyii-erp24%2F.git [ERP-381] created_by from required to behavior take place --- diff --git a/erp24/records/BouquetComposition.php b/erp24/records/BouquetComposition.php index dc1e1a58..86a2a9f6 100644 --- a/erp24/records/BouquetComposition.php +++ b/erp24/records/BouquetComposition.php @@ -8,6 +8,7 @@ use yii\behaviors\BlameableBehavior; use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; use yii\db\Expression; +use yii\helpers\Json; use yii\web\UploadedFile; use yii_app\services\FileService; @@ -437,6 +438,9 @@ class BouquetComposition extends ActiveRecord $costModel->price = round($cost); $costModel->price_markup = $costModel->selfcost > 0 ? 100 * ($costModel->price / ($costModel->selfcost_markup_price + $costModel->selfcost) - 1) : 0; $costModel->save(); + if ($costModel->getErrors()) { + throw new Exception(Json::encode($costModel->getErrors())); + } } public function getCostModel($region_id, $data = null, $force = false) { diff --git a/erp24/records/BouquetCompositionPrice.php b/erp24/records/BouquetCompositionPrice.php index fed13915..a7f27c6c 100644 --- a/erp24/records/BouquetCompositionPrice.php +++ b/erp24/records/BouquetCompositionPrice.php @@ -56,7 +56,7 @@ class BouquetCompositionPrice extends \yii\db\ActiveRecord public function rules() { return [ - [['bouquet_id', 'region_id', 'selfcost', 'selfcost_markup_price', 'price', 'created_at', 'created_by'], 'required'], + [['bouquet_id', 'region_id', 'selfcost', 'selfcost_markup_price', 'price'], 'required'], [['bouquet_id', 'region_id', 'created_by', 'updated_by'], 'default', 'value' => null], [['bouquet_id', 'region_id', 'created_by', 'updated_by'], 'integer'], [['selfcost', 'selfcost_markup', 'selfcost_markup_price', 'price', 'price_markup'], 'number'],