fix amount 5

This commit is contained in:
2026-06-09 12:43:41 +03:30
parent a8dd0071e2
commit e83afb89d5
4 changed files with 122 additions and 45 deletions
@@ -92,7 +92,12 @@ class ProductController extends SuperController
// return 1;
$data = $this->filterProductData($request->all());
if (isset($data["price"])){
$clearingReadingMethod = array_key_exists('reading_method', $data)
&& ($data['reading_method'] === null || $data['reading_method'] === '');
if ($clearingReadingMethod) {
$data['reading_method'] = null;
}
if (isset($data["price"])) {
$data["reading_method"] = null;
if (Product::hasPriceOffsetColumn()) {
$data['price_offset_percent'] = 0;
@@ -121,6 +126,7 @@ class ProductController extends SuperController
Product::hasPriceOffsetColumn()
&& $product->reading_method
&& array_key_exists('price_offset_percent', $data)
&& !$clearingReadingMethod
) {
ProductPriceService::reapplyOffsetPercent(
$product,
@@ -150,7 +156,11 @@ class ProductController extends SuperController
$products = Product::with(['file'])->where('active', 1)->get();
if (Product::hasPriceOffsetColumn() && str_contains(request()->path(), '/customer/')) {
$products->each->makeHidden(['price_offset_percent']);
$products->each(function (Product $product) {
if ($product->reading_method) {
$product->makeHidden(['price_offset_percent']);
}
});
}
return response()->json($products);