public function applyDeductAvailabilityProduct( | public function applyDeductAvailabilityProduct( | ||||
OrderShopInterface $orderShop, | OrderShopInterface $orderShop, | ||||
ProductInterface $product, | ProductInterface $product, | ||||
int $quantityOrder, | |||||
float $quantityOrder, | |||||
float $quantityProduct = null | float $quantityProduct = null | ||||
): void { | ): void { | ||||
switch ($product->getProductFamily()->getBehaviorCountStock()) { | switch ($product->getProductFamily()->getBehaviorCountStock()) { |
class CartController extends AbstractController | class CartController extends AbstractController | ||||
{ | { | ||||
protected ?ProductFamilyInterface $productFamily = null; | protected ?ProductFamilyInterface $productFamily = null; | ||||
protected int $quantityOrder = 1; | |||||
protected float $quantityOrder = 1; | |||||
protected array $orderProducts = []; | protected array $orderProducts = []; | ||||
public function addProductFamily(Request $request): JsonResponse | public function addProductFamily(Request $request): JsonResponse | ||||
$data = $form->getData(); | $data = $form->getData(); | ||||
foreach ($data as $orderProduct) { | foreach ($data as $orderProduct) { | ||||
if ($orderProduct instanceof OrderProductInterface) { | if ($orderProduct instanceof OrderProductInterface) { | ||||
// sécurité liée à la possibilité de saisir des quantités en float pour les comptes ventes complémentaires | |||||
if(!$orderShop->getUser() || !$orderShop->getUser()->getIsAdditionalSalesAccount()) { | |||||
$orderProduct->setQuantityOrder(intval($orderProduct->getQuantityOrder())); | |||||
} | |||||
$this->addOrderProduct($orderShop, $orderProduct); | $this->addOrderProduct($orderShop, $orderProduct); | ||||
} | } | ||||
} | } |
class OrderProductFactory extends AbstractFactory | class OrderProductFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(ProductInterface $product, int $quantityOrder): OrderProductInterface | |||||
public function create(ProductInterface $product, float $quantityOrder): OrderProductInterface | |||||
{ | { | ||||
$orderProduct = $this->createBase(); | $orderProduct = $this->createBase(); | ||||
public function setProduct(?ProductInterface $product): OrderProductInterface; | public function setProduct(?ProductInterface $product): OrderProductInterface; | ||||
public function getQuantityOrder(): ?int; | |||||
public function getQuantityOrder(): ?float; | |||||
public function setQuantityOrder(int $quantityOrder): OrderProductInterface; | |||||
public function setQuantityOrder(float $quantityOrder): OrderProductInterface; | |||||
public function getQuantityProduct(): ?float; | public function getQuantityProduct(): ?float; | ||||
protected $product; | protected $product; | ||||
/** | /** | ||||
* @ORM\Column(type="integer") | |||||
* @ORM\Column(type="float") | |||||
*/ | */ | ||||
protected $quantityOrder; | protected $quantityOrder; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getQuantityOrder(): ?int | |||||
public function getQuantityOrder(): ?float | |||||
{ | { | ||||
return $this->quantityOrder; | return $this->quantityOrder; | ||||
} | } | ||||
public function setQuantityOrder(int $quantityOrder): self | |||||
public function setQuantityOrder(float $quantityOrder): self | |||||
{ | { | ||||
$this->quantityOrder = $quantityOrder; | $this->quantityOrder = $quantityOrder; | ||||
interface OrderProductRefundInterface | interface OrderProductRefundInterface | ||||
{ | { | ||||
public function getQuantityRefund(): ?int; | |||||
public function getQuantityRefund(): ?float; | |||||
public function setQuantityOrder(int $quantityRefund): OrderProductRefundInterface; | |||||
public function setQuantityOrder(float $quantityRefund): OrderProductRefundInterface; | |||||
public function getPrice(): ?float; | public function getPrice(): ?float; | ||||
abstract class OrderProductRefundModel implements EntityInterface, OrderProductRefundInterface | abstract class OrderProductRefundModel implements EntityInterface, OrderProductRefundInterface | ||||
{ | { | ||||
/** | /** | ||||
* @ORM\Column(type="integer") | |||||
* @ORM\Column(type="float") | |||||
*/ | */ | ||||
protected $quantityRefund; | protected $quantityRefund; | ||||
*/ | */ | ||||
protected $orderProduct; | protected $orderProduct; | ||||
public function getQuantityRefund(): ?int | |||||
public function getQuantityRefund(): ?float | |||||
{ | { | ||||
return $this->quantityRefund; | return $this->quantityRefund; | ||||
} | } | ||||
public function setQuantityOrder(int $quantityRefund): self | |||||
public function setQuantityOrder(float $quantityRefund): self | |||||
{ | { | ||||
$this->quantityRefund = $quantityRefund; | $this->quantityRefund = $quantityRefund; | ||||
SectionInterface $section, | SectionInterface $section, | ||||
?OrderShopInterface $orderShop, | ?OrderShopInterface $orderShop, | ||||
ProductInterface $product, | ProductInterface $product, | ||||
int $quantityOrder = 0, | |||||
float $quantityOrder = 0, | |||||
bool $checkCart = false | bool $checkCart = false | ||||
) { | ) { | ||||
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus( | if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus( |