Browse Source

Prix spécifiques : correctif filtre prix dans ProductPrice

refactoring
Guillaume Bourgeois 2 years ago
parent
commit
fd3b0cb6b2
2 changed files with 15 additions and 8 deletions
  1. +7
    -8
      common/models/Product.php
  2. +8
    -0
      common/models/ProductPrice.php

+ 7
- 8
common/models/Product.php View File

public function getSpecificPricesFilterByPriorityMatch($specificPrices, $user, $pointSale) public function getSpecificPricesFilterByPriorityMatch($specificPrices, $user, $pointSale)
{ {
$priorityMatchSpecificPrice = ProductPrice::getPriorityMatchOfSpecificPriceArray($specificPrices, $user, $pointSale); $priorityMatchSpecificPrice = ProductPrice::getPriorityMatchOfSpecificPriceArray($specificPrices, $user, $pointSale);
$specificPricesFilter = [];


if($priorityMatchSpecificPrice) {
foreach($specificPrices as $keySpecificPrice => $specificPrice) {
if(!$specificPrice->$priorityMatchSpecificPrice($user, $pointSale)) {
unset($specificPrices[$keySpecificPrice]);
}
}
foreach($specificPrices as $keySpecificPrice => $specificPrice) {
if(($priorityMatchSpecificPrice && $specificPrice->$priorityMatchSpecificPrice($user, $pointSale))
|| $specificPrice->matchFromQuantityOnly()) {


return $specificPrices;
$specificPricesFilter[] = $specificPrice;
}
} }


return [];
return $specificPricesFilter;
} }


public function getPrice($params = []) public function getPrice($params = [])

+ 8
- 0
common/models/ProductPrice.php View File

&& $this->id_point_sale == $pointSale->id && $this->id_point_sale == $pointSale->id
&& $this->id_user == $user->id; && $this->id_user == $user->id;
} }

public function matchFromQuantityOnly()
{
return !$this->id_user
&& !$this->id_point_sale
&& !$this->id_user_group
&& $this->from_quantity;
}
} }

Loading…
Cancel
Save