]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавил количество
authorvladfo <fvv2011@gmail.com>
Fri, 11 Oct 2024 09:28:33 +0000 (12:28 +0300)
committervladfo <fvv2011@gmail.com>
Fri, 11 Oct 2024 09:28:33 +0000 (12:28 +0300)
erp24/actions/motivation/TestSelfCostAction.php
erp24/services/MotivationService.php
erp24/views/motivation/test-self-cost.php

index b286e9b49dd3a260f986432eaa9ca37bfb37806b..4f8eaa171c80426ce3e14017b0c369c795112625 100644 (file)
@@ -40,6 +40,7 @@ class TestSelfCostAction extends Action
 
         $data = [];
         $totalSum = 0.0;
+        $totalProductsSum = 0.0;
 
         if ($startDate && $endDate && $storeId) {
             $totalSum = MotivationService::getSelfCostSumByStore($startDate, $endDate, $storeId);
@@ -47,6 +48,11 @@ class TestSelfCostAction extends Action
             // Получаем данные о продуктах и себестоимости
             $salesProducts = MotivationService::getSalesProductsDetails($startDate, $endDate, $storeId);
             $data = $salesProducts;
+
+            // Вычисляем сумму всех товаров
+            foreach ($data as $item) {
+                $totalProductsSum += $item['price']*$item['quantity'];
+            }
         }
 
         return $this->controller->render('test-self-cost', [
@@ -54,6 +60,7 @@ class TestSelfCostAction extends Action
             'model' => $model,
             'data' => $data,
             'totalSum' => $totalSum,
+            'totalProductsSum' => $totalProductsSum,
         ]);
     }
 }
\ No newline at end of file
index 3b7bdad13a385f3859ed3caf7d2f808fd80f7f01..65534d7ecd406ba265bf17967bc8c2a862651ba1 100644 (file)
@@ -1962,10 +1962,12 @@ class MotivationService
         $salesProducts = SalesProducts::find()
             ->select(['check_id', 'product_id', 'quantity'])
             ->where(['check_id' => $salesIds])
+
             ->asArray()
             ->all();
 
-        $productIds = array_unique(array_column($salesProducts, 'product_id'));
+        $productIds = array_column($salesProducts, 'product_id');
+
         $selfCosts = SelfCostProduct::find()
             ->select(['product_guid', 'price', 'date'])
             ->where(['store_id' => $storeId, 'product_guid' => $productIds])
@@ -2001,6 +2003,7 @@ class MotivationService
                 'product_name' => $productNamesMap[$productId] ?? 'Неизвестный товар',
                 'price' => $price,
                 'date' => $checkDate,
+                'quantity' => $quantity,
             ];
         }
 
index 7c964e9bd16a14e0c7c3cbbb12da6b70dfab47f0..52d323f91c170a89225f34a5b704b1951adfb91f 100644 (file)
@@ -8,6 +8,7 @@ use kartik\select2\Select2;
 /* @var $model \yii\base\DynamicModel */
 /* @var $data array */
 /* @var $totalSum float */
+/* @var $totalProductsSum float */
 
 $this->title = 'Себестоимость товаров по магазинам';
 ?>
@@ -45,6 +46,7 @@ $this->title = 'Себестоимость товаров по магазина
                 <th>ID товара</th>
                 <th>Название</th>
                 <th>Цена</th>
+                <th>Кол-во</th>
                 <th>Дата</th>
             </tr>
             </thead>
@@ -54,11 +56,13 @@ $this->title = 'Себестоимость товаров по магазина
                     <td><?= Html::encode($item['product_id']) ?></td>
                     <td><?= Html::encode($item['product_name']) ?></td>
                     <td><?= Html::encode($item['price']) ?></td>
+                    <td><?= Html::encode($item['quantity']) ?></td>
                     <td><?= Html::encode($item['date']) ?></td>
                 </tr>
             <?php endforeach; ?>
             </tbody>
         </table>
         <h3>Общая стоимость: <?= Html::encode($totalSum) ?></h3>
+        <h3>Сумма всех товаров: <?= Html::encode($totalProductsSum) ?></h3>
     <?php endif; ?>
 </div>
\ No newline at end of file