|
|
@@ -189,7 +189,7 @@ class DocumentSolver extends AbstractService implements SolverInterface |
|
|
|
return $this->isStatus($document, Document::STATUS_VALID); |
|
|
|
} |
|
|
|
|
|
|
|
public function getProductsOrders(DocumentInterface $document): array |
|
|
|
public function getProductsOrders(DocumentInterface $document, bool $groupByInvoicePrice = false): array |
|
|
|
{ |
|
|
|
$productsOrdersArray = []; |
|
|
|
$ordersArray = $document->orders; |
|
|
@@ -205,12 +205,16 @@ class DocumentSolver extends AbstractService implements SolverInterface |
|
|
|
} else { |
|
|
|
$productOrderMatch = false; |
|
|
|
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { |
|
|
|
if ($theProductOrder->unit == $productOrder->unit |
|
|
|
&& $theProductOrder->price == $productOrder->price |
|
|
|
&& $theProductOrder->invoice_price == $productOrder->invoice_price) { |
|
|
|
|
|
|
|
$theProductOrder->quantity += $productOrder->quantity; |
|
|
|
$productOrderMatch = true; |
|
|
|
if ($theProductOrder->unit == $productOrder->unit) { |
|
|
|
if($groupByInvoicePrice && $theProductOrder->invoice_price == $productOrder->invoice_price) { |
|
|
|
$theProductOrder->quantity += $productOrder->quantity; |
|
|
|
$productOrderMatch = true; |
|
|
|
} |
|
|
|
elseif($theProductOrder->price == $productOrder->price |
|
|
|
&& $theProductOrder->invoice_price == $productOrder->invoice_price) { |
|
|
|
$theProductOrder->quantity += $productOrder->quantity; |
|
|
|
$productOrderMatch = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!$productOrderMatch) { |