|
|
|
|
|
|
|
|
return $this->isStatus($document, Document::STATUS_VALID); |
|
|
return $this->isStatus($document, Document::STATUS_VALID); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function getProductsOrders(DocumentInterface $document): array |
|
|
|
|
|
|
|
|
public function getProductsOrders(DocumentInterface $document, bool $groupByInvoicePrice = false): array |
|
|
{ |
|
|
{ |
|
|
$productsOrdersArray = []; |
|
|
$productsOrdersArray = []; |
|
|
$ordersArray = $document->orders; |
|
|
$ordersArray = $document->orders; |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
$productOrderMatch = false; |
|
|
$productOrderMatch = false; |
|
|
foreach ($productsOrdersArray[$indexProductOrder] as &$theProductOrder) { |
|
|
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) { |
|
|
if (!$productOrderMatch) { |