]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-370] поправка getPriceDynamic с новым параметром regionId
authorAlexander Smirnov <fredeom@mail.ru>
Wed, 12 Mar 2025 20:31:32 +0000 (23:31 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Wed, 12 Mar 2025 20:31:32 +0000 (23:31 +0300)
erp24/records/WriteOffs.php

index 970346303a83649951d974db346a58c7a87a586d..ed50e996ffd25c81e900ce10b2b52fd43d9ff983 100755 (executable)
@@ -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();