shish пре 4 година
родитељ
комит
ae001dc37b
1 измењених фајлова са 10 додато и 6 уклоњено
  1. 10 6
      app-ghs/controllers/ProductController.php

+ 10 - 6
app-ghs/controllers/ProductController.php

@@ -373,15 +373,19 @@ class ProductController extends BaseController
                     $arrIds = json_decode($costChangeIds, true);
                     $costIds = is_array($arrIds) ? $arrIds : [];
                     if (!empty($costIds) && in_array($id, $costIds)) {
-                        $newAddPrice = bcsub($val, $product->cost, 2);
-                        $qtDiff = bcsub($product->addPrice, $product->skAddPrice, 2);
-                        $newSkAddPrice = bcsub($newAddPrice, $qtDiff, 2);
+                        $currentAddPrice = bcsub($val, $product->cost, 2);
+
+                        $skDiff = bcsub($product->skAddPrice, $product->addPrice, 2);
+                        $newSkAddPrice = bcsub($currentAddPrice, $skDiff, 2);
+
                         $hjDiff = bcsub($product->addPrice, $product->hjAddPrice, 2);
-                        $newHjAddPrice = bcsub($newAddPrice, $hjDiff, 2);
+                        $newHjAddPrice = bcsub($currentAddPrice, $hjDiff, 2);
+
                         $zsDiff = bcsub($product->addPrice, $product->zsAddPrice, 2);
-                        $newZsAddPrice = bcsub($newAddPrice, $zsDiff, 2);
+                        $newZsAddPrice = bcsub($currentAddPrice, $zsDiff, 2);
+
                         $params = [];
-                        $params['addPrice'] = $newAddPrice;
+                        $params['addPrice'] = $currentAddPrice;
                         $params['skAddPrice'] = $newSkAddPrice;
                         $params['hjAddPrice'] = $newHjAddPrice;
                         $params['zsAddPrice'] = $newZsAddPrice;