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;
$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) {
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'],