theo преди 3 години
родител
ревизия
44ac1533a1
променени са 2 файла, в които са добавени 11 реда и са изтрити 3 реда
  1. 1 1
      common/helpers/bonus/PerfCalc.php
  2. 10 2
      common/models/Period.php

+ 1 - 1
common/helpers/bonus/PerfCalc.php

@@ -1774,4 +1774,4 @@ class PerfCalc {
         \Yii::$app->swooleAsyncTimer->pushAsyncPercentToAdmin($percent, ['MODEL' => 'PERIOD', 'ID' => $this->_periodId, 'FIELD' => 'PERF_PERCENT']);
     }
 
-}
+}

+ 10 - 2
common/models/Period.php

@@ -580,8 +580,16 @@ class Period extends \common\components\ActiveRecord
         if($period){
             $year = $period['CALC_YEAR'];
             $month = $period['CALC_MONTH'];
-            $lastYear = Date::lastMonth($year.'-'.$month, 'Y');
-            $lastMonth = Date::lastMonth($year.'-'.$month, 'm');
+            if($month=='13'){
+                $lastYear = $year;
+                $lastMonth = '12';
+            } else if($month=='1'){
+                $lastYear = Date::lastMonth($year.'-'.$month,'Y');
+                $lastMonth = '13';
+            } else {
+                $lastYear = Date::lastMonth($year.'-'.$month, 'Y');
+                $lastMonth = Date::lastMonth($year.'-'.$month, 'm');
+            }
             return [
                 'year' => $lastYear,
                 'month' => intval($lastMonth),