From: Alexander Smirnov Date: Wed, 12 Mar 2025 20:31:32 +0000 (+0300) Subject: [ERP-370] поправка getPriceDynamic с новым параметром regionId X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5905be161972ce3b8eb219a0043b93ea0cb2e1e4;p=erp24_rep%2Fyii-erp24%2F.git [ERP-370] поправка getPriceDynamic с новым параметром regionId --- diff --git a/erp24/records/WriteOffs.php b/erp24/records/WriteOffs.php index 97034630..ed50e996 100755 --- a/erp24/records/WriteOffs.php +++ b/erp24/records/WriteOffs.php @@ -430,15 +430,13 @@ class WriteOffs extends \yii\db\ActiveRecord return $writeOffProductsWithoutRetailPriceSetCounter; } - public static function getPriceDynamic($productId, $writeOffDate) + public static function getPriceDynamic($productId, $writeOffDate, $regionId = 52) { $query = PricesDynamic::find() ->select(['price']) - ->andWhere(['product_id' => $productId]) + ->where(['region_id' => $regionId, 'product_id' => $productId]) ->andWhere(['<=', 'date_from', $writeOffDate]) - ->andWhere(['>=', 'date_to', $writeOffDate]) - ->andWhere(['<=', 'date_from', $writeOffDate]) - ->andWhere(['>=', 'date_to', $writeOffDate]) + ->andWhere(['or', 'date_to IS NULL', ['>=', 'date_to', $writeOffDate]]) ; $pricesDynamic = $query->scalar();