|
|
@@ -70,20 +70,35 @@ class ProductOrderSolver extends AbstractService implements SolverInterface |
|
|
|
return $productOrder->price; |
|
|
|
} |
|
|
|
|
|
|
|
public function getPriceUnitReference(ProductOrder $productOrder): ?float |
|
|
|
public function getPriceUnitReference(ProductOrder $productOrder, bool $isInvoicePrice = false): ?float |
|
|
|
{ |
|
|
|
$productOrderPrice = $productOrder->price; |
|
|
|
if($isInvoicePrice) { |
|
|
|
$productOrderPrice = $this->getInvoicePrice($productOrder); |
|
|
|
} |
|
|
|
|
|
|
|
if($productOrder->unit == 'piece') { |
|
|
|
if($productOrder->product->weight) { |
|
|
|
$price = (1000 * $productOrder->price) / $productOrder->product->weight; |
|
|
|
$price = (1000 * $productOrderPrice) / $productOrder->product->weight; |
|
|
|
} |
|
|
|
else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
$price = $productOrder->price; |
|
|
|
$price = $productOrderPrice; |
|
|
|
} |
|
|
|
|
|
|
|
return $price; |
|
|
|
} |
|
|
|
|
|
|
|
public function getInvoicePrice(ProductOrder $productOrder) |
|
|
|
{ |
|
|
|
if($productOrder->invoice_price) { |
|
|
|
return $productOrder->invoice_price; |
|
|
|
} |
|
|
|
else { |
|
|
|
return $productOrder->price; |
|
|
|
} |
|
|
|
} |
|
|
|
} |